© 1998-2002 McGraw-Hill

structure
Class GraphListVertex

java.lang.Object
  |
  +--structure.Vertex
        |
        +--structure.GraphListVertex

class GraphListVertex
extends Vertex

A private implementation of a vertex for use in graphs that are internally represented as a list. A vertex is capable of holding a label and has a flag that can be set to mark it as visited.

Typical Usage:

     Vertex v = new Vertex(someLabel);
     //...several graph related operations occur
     if(!v.isVisited()){
         Object label = v.label();
         v.visit();
     }
 

See Also:
GraphListVertex, Vertex

Field Summary
protected  Structure adjacencies
           
 
Fields inherited from class structure.Vertex
label, visited
 
Constructor Summary
GraphListVertex(Object key)
           
 
Method Summary
 void addEdge(Edge e)
           
 Iterator adjacentEdges()
           
 Iterator adjacentVertices()
           
 boolean containsEdge(Edge e)
           
 int degree()
           
 Edge getEdge(Edge e)
           
 Edge removeEdge(Edge e)
           
 String toString()
          Construct a string representing vertex.
 
Methods inherited from class structure.Vertex
equals, hashCode, isVisited, label, reset, visit
 
Methods inherited from class java.lang.Object
, clone, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

adjacencies

protected Structure adjacencies
Constructor Detail

GraphListVertex

public GraphListVertex(Object key)
Parameters:
key -  
Method Detail

addEdge

public void addEdge(Edge e)
Parameters:
e -  
Precondition:
e is an edge that mentions this vertex
Postcondition:
adds edge to this vertex's adjacency list

containsEdge

public boolean containsEdge(Edge e)
Parameters:
e -  
Postcondition:
returns true if e appears on adjacency list
Returns:
 

removeEdge

public Edge removeEdge(Edge e)
Parameters:
e -  
Postcondition:
removes and returns adjacent edge "equal" to e
Returns:
 

getEdge

public Edge getEdge(Edge e)
Parameters:
e -  
Postcondition:
returns the edge that "equals" e, or null
Returns:
 

degree

public int degree()
Postcondition:
returns the degree of this node
Returns:
 

adjacentVertices

public Iterator adjacentVertices()
Postcondition:
returns iterator over adj. vertices
Returns:
 

adjacentEdges

public Iterator adjacentEdges()
Postcondition:
returns iterator over adj. edges
Returns:
 

toString

public String toString()
Description copied from class: Vertex
Construct a string representing vertex.
Overrides:
toString in class Vertex
Postcondition:
returns string representation of vertex
Returns:
String representation of vertex

© 1998-2002 McGraw-Hill