structure
Class GraphMatrixDirected

java.lang.Object
  extended by structure.AbstractStructure
      extended by structure.GraphMatrix
          extended by structure.GraphMatrixDirected
All Implemented Interfaces:
Graph, Structure

public class GraphMatrixDirected
extends GraphMatrix

A class implementing a directed, adjacency-matrix based graph. User must commit to upper-bound on number of vertices.

See Also:
GraphMatrix, GraphMatrixUndirected, GraphListDirected

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

Constructor Detail

GraphMatrixDirected

public GraphMatrixDirected(int size)
Construct a directed, adjacency-matrix based graph.

Parameters:
size - The maximum number of vertices allowed in graph.
Method Detail

addEdge

public void addEdge(Object vLabel1,
                    Object vLabel2,
                    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 GraphMatrix
Parameters:
vLabel1 - Source vertex.
vLabel2 - Destination vertex.
label - Label associated with the edge.

removeEdge

public Object removeEdge(Object vLabel1,
                         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 GraphMatrix
Parameters:
vLabel1 - Source vertex.
vLabel2 - Destination vertex.
Returns:
The label associated with the edge removed.

edgeCount

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

Specified by:
edgeCount in interface Graph
Specified by:
edgeCount in class GraphMatrix
Returns:
Number of edges in graph.

edges

public Iterator edges()
Construct an traversal over all edges. edge is considered exactly once. Order is not guaranteed.

Specified by:
edges in interface Graph
Specified by:
edges in class GraphMatrix
Returns:
AbstractIterator over edges.

toString

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

Overrides:
toString in class Object
Returns:
String representing graph.