digraph
Class DiGraph<V,E>

java.lang.Object
  extended by digraph.DiGraph<V,E>
All Implemented Interfaces:
Graph<V,E>, Iterable<Graph.Vertex<V,E>>

public class DiGraph<V,E>
extends Object
implements Graph<V,E>

Class DiGraph represents a generic directed graph with elements of type V associated to its vertices and data of type E to its Edges.


Nested Class Summary
static class DiGraph.Edge<V,E>
          Inner class representing an edge of a directed graph.
static class DiGraph.Vertex<V,E>
          Nested class representing a vertex of a directed graph.
 
Constructor Summary
DiGraph()
          Constructs an empty directed graph
 
Method Summary
 void addEdge(E value, Graph.Vertex<V,E> source, Graph.Vertex<V,E> destination)
          Inserts a new directed edge in this graph.
 Graph.Vertex<V,E> addVertex(V value)
          Inserts a new vertex in the graph.
 Iterator<Graph.Vertex<V,E>> iterator()
          Creates an iterator for the vertices of this graph.
 String toString()
          Returns a String representation of the vertices and edges of the graph.
 void unvisit()
          Marks all vertices of this graph as not visited.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiGraph

public DiGraph()
Constructs an empty directed graph

Method Detail

iterator

public Iterator<Graph.Vertex<V,E>> iterator()
Creates an iterator for the vertices of this graph.

Specified by:
iterator in interface Iterable<Graph.Vertex<V,E>>

addVertex

public Graph.Vertex<V,E> addVertex(V value)
Inserts a new vertex in the graph.

Specified by:
addVertex in interface Graph<V,E>
Parameters:
value - The value associated with the newly inserted vertex.
Returns:
Returns the newly created vertex.

addEdge

public void addEdge(E value,
                    Graph.Vertex<V,E> source,
                    Graph.Vertex<V,E> destination)
Inserts a new directed edge in this graph.

Specified by:
addEdge in interface Graph<V,E>
Parameters:
value - The value associated with the newly created edge.
source - The source vertex of the newly created edge.
destination - The destination vertex of the newly created Edge.
Throws:
NoSuchElementException - if source or destination is not present in this graph.

unvisit

public void unvisit()
Marks all vertices of this graph as not visited.

Specified by:
unvisit in interface Graph<V,E>

toString

public String toString()
Returns a String representation of the vertices and edges of the graph.

Overrides:
toString in class Object
Returns:
A String representation of the graph.