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
           
protected  java.lang.Object label
          A label associated with vertex.
protected  boolean visited
          Whether or not a vertex has been visited.
 
Constructor Summary
GraphListVertex(java.lang.Object key)
           
 
Method Summary
 void addEdge(Edge e)
           
 java.util.Iterator adjacentEdges()
           
 java.util.Iterator adjacentVertices()
           
 boolean containsEdge(Edge e)
           
 int degree()
           
 boolean equals(java.lang.Object o)
          Returns true iff the labels of two vertices are equal.
 Edge getEdge(Edge e)
           
 int hashCode()
          Return a hashcode associated with the vertex.
 boolean isVisited()
          Determine if the vertex has been visited.
 java.lang.Object label()
          Fetch the label associated with vertex.
 Edge removeEdge(Edge e)
           
 void reset()
          Clears the visited flag.
 java.lang.String toString()
          Construct a string representing vertex.
 boolean visit()
          Test and set the visited flag.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

adjacencies

protected Structure adjacencies

label

protected java.lang.Object label
A label associated with vertex.


visited

protected boolean visited
Whether or not a vertex has been visited.

Constructor Detail

GraphListVertex

public GraphListVertex(java.lang.Object key)
Parameters:
key -
Method Detail

addEdge

public void addEdge(Edge e)
Parameters:
e -

containsEdge

public boolean containsEdge(Edge e)
Parameters:
e -
Returns:

removeEdge

public Edge removeEdge(Edge e)
Parameters:
e -
Returns:

getEdge

public Edge getEdge(Edge e)
Parameters:
e -
Returns:

degree

public int degree()
Returns:

adjacentVertices

public java.util.Iterator adjacentVertices()
Returns:

adjacentEdges

public java.util.Iterator adjacentEdges()
Returns:

toString

public java.lang.String toString()
Description copied from class: Vertex
Construct a string representing vertex.

Overrides:
toString in class Vertex
Returns:
String representation of vertex

label

public java.lang.Object label()
Fetch the label associated with vertex.

Returns:
The label associated with vertex.

visit

public boolean visit()
Test and set the visited flag.

Returns:
The value of the flag before marking

isVisited

public boolean isVisited()
Determine if the vertex has been visited.

Returns:
True iff the vertex has been visited.

reset

public void reset()
Clears the visited flag.


equals

public boolean equals(java.lang.Object o)
Returns true iff the labels of two vertices are equal.

Overrides:
equals in class java.lang.Object
Parameters:
o - Another vertex.
Returns:
True iff the vertex labels are equal.

hashCode

public int hashCode()
Return a hashcode associated with the vertex.

Overrides:
hashCode in class java.lang.Object
Returns:
An integer for use in hashing values into tables.