structure
Class GraphListDirected

java.lang.Object
  extended by structure.AbstractStructure
      extended by structure.GraphList
          extended by structure.GraphListDirected
All Implemented Interfaces:
Graph, Structure

public class GraphListDirected
extends GraphList

A class implementing a directed, adjacency-list based graph.

See Also:
GraphList, GraphListUndirected, GraphMatrixDirected

Field Summary
 
Fields inherited from class structure.GraphList
dict, directed
 
Constructor Summary
GraphListDirected()
          Construct a directed, adjacency-list based graph.
 
Method Summary
 void addEdge(java.lang.Object vLabel1, java.lang.Object vLabel2, java.lang.Object label)
          Add an edge between two vertices within the graph.
 int edgeCount()
          Determine the number of edges in graph.
 java.lang.Object remove(java.lang.Object label)
          Remove a vertex from the graph.
 java.lang.Object removeEdge(java.lang.Object vLabel1, java.lang.Object vLabel2)
          Remove possible edge between vertices labeled vLabel1 and vLabel2.
 java.lang.String toString()
          Construct a string representation of graph.
 
Methods inherited from class structure.GraphList
add, clear, contains, containsEdge, degree, edges, get, getEdge, isDirected, isEmpty, isVisited, isVisitedEdge, iterator, neighbors, reset, size, visit, visitEdge
 
Methods inherited from class structure.AbstractStructure
elements, hashCode, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface structure.Structure
elements, values
 

Constructor Detail

GraphListDirected

public GraphListDirected()
Construct a directed, adjacency-list based graph.

Postcondition:
constructs an directed graph
Method Detail

addEdge

public void addEdge(java.lang.Object vLabel1,
                    java.lang.Object vLabel2,
                    java.lang.Object label)
Add an edge between two vertices within the graph. Edge is directed. Duplicate edges are silently replaced. Labels on edges may be null.

Specified by:
addEdge in interface Graph
Specified by:
addEdge in class GraphList
Parameters:
vLabel1 - Source vertex.
vLabel2 - Destination vertex.
label - Label associated with the edge.
Precondition:
vLabel1 and vLabel2 are labels of existing vertices, v1 & v2
Postcondition:
an edge is inserted between v1 and v2; if edge is new, it is labeled with label (can be null)

remove

public java.lang.Object remove(java.lang.Object label)
Remove a vertex from the graph. Associated edges are also removed. Non-vertices are silently ignored.

Specified by:
remove in interface Graph
Specified by:
remove in interface Structure
Specified by:
remove in class GraphList
Parameters:
label - The label of the vertex within the graph.
Returns:
The label associated with the vertex.
Precondition:
label is non-null vertex label
Postcondition:
vertex with "equals" label is removed, if found

removeEdge

public java.lang.Object removeEdge(java.lang.Object vLabel1,
                                   java.lang.Object vLabel2)
Remove possible edge between vertices labeled vLabel1 and vLabel2. vLabel1 is the source.

Specified by:
removeEdge in interface Graph
Specified by:
removeEdge in class GraphList
Parameters:
vLabel1 - Source vertex.
vLabel2 - Destination vertex.
Returns:
The label associated with the edge removed.
Precondition:
vLabel1 and vLabel2 are labels of existing vertices
Postcondition:
edge is removed, its label is returned

edgeCount

public int edgeCount()
Determine the number of edges in graph.

Specified by:
edgeCount in interface Graph
Specified by:
edgeCount in class GraphList
Returns:
Number of edges in graph.
Postcondition:
returns the number of edges in graph

toString

public java.lang.String toString()
Construct a string representation of graph.

Overrides:
toString in class java.lang.Object
Returns:
String representing graph.
Postcondition:
returns string representation of graph