

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object structure.AbstractStructure structure.GraphMatrix
public abstract class GraphMatrix
Implementation of graph using adjacency matrices. User must commit to maximum size of graph (in vertices); it may be smaller. Edges are stored in matrix. Not suitable for large graphs. Class is abstract: you must use GraphMatrixDirected or GraphMatrixUndirected to construct particular instances of graphs. Typical usage:
Graph g = new GraphMatrixUndirected(); g.add("harry"); g.add("sally"); g.addEdge("harry","sally","unfriendly"); ...
GraphMatrixDirected
,
GraphMatrixUndirected
,
GraphList
Method Summary  

void 
add(Object label)
Add a vertex to the graph. 
abstract void 
addEdge(Object v1,
Object v2,
Object label)
Add an edge between two vertices within the graph. 
void 
clear()
Remove all vertices (and thus, edges) of the graph. 
boolean 
contains(Object label)
Test for vertex membership. 
boolean 
containsEdge(Object vLabel1,
Object vLabel2)
Test for edge membership. 
int 
degree(Object label)
Determine out degree of vertex. 
abstract int 
edgeCount()
Determine the number of edges in graph. 
abstract Iterator 
edges()
Construct an traversal over all edges. 
Object 
get(Object label)
Get reference to actual label of vertex. 
Edge 
getEdge(Object label1,
Object label2)
Get reference to actual edge. 
boolean 
isDirected()
Determine if graph is directed. 
boolean 
isEmpty()
Determine if graph is empty. 
boolean 
isVisited(Object label)
Return visited flag of vertex. 
boolean 
isVisitedEdge(Edge e)
Return visited flag of edge. 
Iterator 
iterator()
Construct vertex traversal. 
Iterator 
neighbors(Object label)
Construct an adjacent vertex traversal. 
Object 
remove(Object label)
Remove a vertex from the graph. 
abstract Object 
removeEdge(Object vLabel1,
Object vLabel2)
Remove possible edge between vertices labeled vLabel1 and vLabel2. 
void 
reset()
Clear visited flags of edges and vertices. 
int 
size()
Determine number of vertices within graph. 
boolean 
visit(Object label)
Test and set visited flag of vertex. 
boolean 
visitEdge(Edge e)
Test and set visited flag of edge. 
Methods inherited from class structure.AbstractStructure 

elements, hashCode, values 
Methods inherited from class java.lang.Object 

equals, getClass, notify, notifyAll, toString, wait, wait, wait 
Methods inherited from interface structure.Structure 

elements, values 
Method Detail 

public void add(Object label)
add
in interface Graph
add
in interface Structure
label
 Label of the vertex; should be nonnull.public abstract void addEdge(Object v1, Object v2, Object label)
addEdge
in interface Graph
vtx1
 First (or source, if directed) vertex.vtx2
 Second (or destination, if directed) vertex.label
 Label associated with the edge.public Object remove(Object label)
remove
in interface Graph
remove
in interface Structure
label
 The label of the vertex within the graph.
public abstract Object removeEdge(Object vLabel1, Object vLabel2)
removeEdge
in interface Graph
vLabel1
 First (or source, if directed) vertex.vLabel2
 Second (or destination, if directed) vertex.
public Object get(Object label)
get
in interface Graph
label
 The label of the vertex sought.
public Edge getEdge(Object label1, Object label2)
getEdge
in interface Graph
label1
 The first (or source, if directed) vertex.label2
 The second (or destination, if directed) vertex.
public boolean contains(Object label)
contains
in interface Graph
contains
in interface Structure
contains
in class AbstractStructure
label
 The label of the vertex sought.
public boolean containsEdge(Object vLabel1, Object vLabel2)
containsEdge
in interface Graph
vLabel1
 First (or source, if directed) vertex.vLabel2
 Second (or destination, if directed) vertex.
public boolean visit(Object label)
visit
in interface Graph
label
 Label of vertex to be visited.
public boolean visitEdge(Edge e)
visitEdge
in interface Graph
e
 Edge object that is part of graph.
public boolean isVisited(Object label)
isVisited
in interface Graph
label
 Label of vertex.
public boolean isVisitedEdge(Edge e)
isVisitedEdge
in interface Graph
e
 Edge of graph to be considered.
public void reset()
reset
in interface Graph
public int size()
size
in interface Graph
size
in interface Structure
public int degree(Object label)
degree
in interface Graph
label
 Label associated with vertex.
public abstract int edgeCount()
edgeCount
in interface Graph
public Iterator iterator()
iterator
in interface Graph
iterator
in interface Structure
AbstractIterator
,
Iterator
,
Enumeration
,
Structure.elements()
public Iterator neighbors(Object label)
neighbors
in interface Graph
label
 Label of the vertex.
public abstract Iterator edges()
edges
in interface Graph
public void clear()
clear
in interface Graph
clear
in interface Structure
public boolean isEmpty()
isEmpty
in interface Graph
isEmpty
in interface Structure
isEmpty
in class AbstractStructure
public boolean isDirected()
isDirected
in interface Graph


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 