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
adjacencies
protected Structure adjacencies
GraphListVertex
public GraphListVertex(Object key)
- Parameters:
key
-
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