graph
Class AdjListDigraph

java.lang.Object
  |
  +--graph.AdjListDigraph
All Implemented Interfaces:
Digraph

public class AdjListDigraph
extends java.lang.Object
implements Digraph

A directed graph in which each vertex stores its outgoing edges.


Constructor Summary
AdjListDigraph()
           
 
Method Summary
 graph.DirectedEdge insertDirectedEdge(graph.Vertex from, graph.Vertex to, java.lang.Object element)
          Adds a new directed edge from one vertex to another.
 void insertReverseOf(graph.DirectedEdge e)
          Convenience method: Add the reverse of the given edge, with the same element.
 graph.Vertex insertVertex(java.lang.Object element)
          Insert and return a new vertex.
 int numEdges()
          Return the size of the graph (number of edges, m).
 int numVertices()
          Return the order of the graph (number of vertices, n).
 java.util.Iterator outIncidentEdges(graph.Vertex v)
          Return an iterator over all the directed edges from a vertex.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdjListDigraph

public AdjListDigraph()
Method Detail

numVertices

public int numVertices()
Description copied from interface: Digraph
Return the order of the graph (number of vertices, n).

Specified by:
numVertices in interface Digraph

numEdges

public int numEdges()
Description copied from interface: Digraph
Return the size of the graph (number of edges, m).

Specified by:
numEdges in interface Digraph

outIncidentEdges

public java.util.Iterator outIncidentEdges(graph.Vertex v)
Description copied from interface: Digraph
Return an iterator over all the directed edges from a vertex.

Specified by:
outIncidentEdges in interface Digraph

insertVertex

public graph.Vertex insertVertex(java.lang.Object element)
Description copied from interface: Digraph
Insert and return a new vertex. The vertex has no incident edges yet.

Specified by:
insertVertex in interface Digraph
Parameters:
element - the element stored at the vertex.

insertDirectedEdge

public graph.DirectedEdge insertDirectedEdge(graph.Vertex from,
                                             graph.Vertex to,
                                             java.lang.Object element)
Description copied from interface: Digraph
Adds a new directed edge from one vertex to another.

Specified by:
insertDirectedEdge in interface Digraph
Parameters:
element - the element stored on the edge.

insertReverseOf

public void insertReverseOf(graph.DirectedEdge e)
Description copied from interface: Digraph
Convenience method: Add the reverse of the given edge, with the same element. Thus, to add a pair of opposing edges, you can do something like
    insertReverseOf(insertDirectedEdge(from, to, element));
 
This is convenient if from, to, or element is a complicated expression.

Specified by:
insertReverseOf in interface Digraph