Package org._3pq.jgrapht.traverse
Class CrossComponentIterator
- java.lang.Object
-
- org._3pq.jgrapht.traverse.AbstractGraphIterator
-
- org._3pq.jgrapht.traverse.CrossComponentIterator
-
- All Implemented Interfaces:
java.util.Iterator,GraphIterator
- Direct Known Subclasses:
BreadthFirstIterator,ClosestFirstIterator,DepthFirstIterator,TopologicalOrderIterator
public abstract class CrossComponentIterator extends AbstractGraphIterator
Provides a cross-connected-component traversal functionality for iterator subclasses.- Since:
- Jan 31, 2004
- Author:
- Barak Naveh
-
-
Constructor Summary
Constructors Constructor Description CrossComponentIterator(Graph g, java.lang.Object startVertex)Creates a new iterator for the specified graph.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidencounterVertex(java.lang.Object vertex, Edge edge)Update data structures the first time we see a vertex.protected abstract voidencounterVertexAgain(java.lang.Object vertex, Edge edge)Called whenever we re-encounter a vertex.protected java.lang.ObjectgetSeenData(java.lang.Object vertex)Access the data stored for a seen vertex.booleanhasNext()protected abstract booleanisConnectedComponentExhausted()Returns true if there are no more uniterated vertices in the currently iterated connected component; false otherwise.protected booleanisSeenVertex(java.lang.Object vertex)Determines whether a vertex has been seen yet by this traversal.java.lang.Objectnext()protected abstract java.lang.ObjectprovideNextVertex()Returns the vertex to be returned in the following call to the iteratornextmethod.protected java.lang.ObjectputSeenData(java.lang.Object vertex, java.lang.Object data)Stores iterator-dependent data for a vertex that has been seen.-
Methods inherited from class org._3pq.jgrapht.traverse.AbstractGraphIterator
addTraversalListener, fireConnectedComponentFinished, fireConnectedComponentStarted, fireEdgeTraversed, fireVertexTraversed, isCrossComponentTraversal, isReuseEvents, remove, removeTraversalListener, setCrossComponentTraversal, setReuseEvents
-
-
-
-
Constructor Detail
-
CrossComponentIterator
public CrossComponentIterator(Graph g, java.lang.Object startVertex)
Creates a new iterator for the specified graph. Iteration will start at the specified start vertex. If the specified start vertex isnull, Iteration will start at an arbitrary graph vertex.- Parameters:
g- the graph to be iterated.startVertex- the vertex iteration to be started.- Throws:
java.lang.NullPointerExceptionjava.lang.IllegalArgumentException
-
-
Method Detail
-
hasNext
public boolean hasNext()
- See Also:
Iterator.hasNext()
-
next
public java.lang.Object next()
- See Also:
Iterator.next()
-
isConnectedComponentExhausted
protected abstract boolean isConnectedComponentExhausted()
Returns true if there are no more uniterated vertices in the currently iterated connected component; false otherwise.- Returns:
- true if there are no more uniterated vertices in the currently iterated connected component; false otherwise.
-
encounterVertex
protected abstract void encounterVertex(java.lang.Object vertex, Edge edge)Update data structures the first time we see a vertex.- Parameters:
vertex- the vertex encounterededge- the edge via which the vertex was encountered, or null if the vertex is a starting point
-
provideNextVertex
protected abstract java.lang.Object provideNextVertex()
Returns the vertex to be returned in the following call to the iteratornextmethod.- Returns:
- the next vertex to be returned by this iterator.
-
getSeenData
protected java.lang.Object getSeenData(java.lang.Object vertex)
Access the data stored for a seen vertex.- Parameters:
vertex- a vertex which has already been seen.- Returns:
- data associated with the seen vertex or
nullif no data was associated with the vertex. Anullreturn can also indicate that the vertex was explicitly associated withnull.
-
isSeenVertex
protected boolean isSeenVertex(java.lang.Object vertex)
Determines whether a vertex has been seen yet by this traversal.- Parameters:
vertex- vertex in question- Returns:
- true if vertex has already been seen
-
encounterVertexAgain
protected abstract void encounterVertexAgain(java.lang.Object vertex, Edge edge)Called whenever we re-encounter a vertex. The default implementation does nothing.- Parameters:
vertex- the vertex re-encounterededge- the edge via which the vertex was re-encountered
-
putSeenData
protected java.lang.Object putSeenData(java.lang.Object vertex, java.lang.Object data)Stores iterator-dependent data for a vertex that has been seen.- Parameters:
vertex- a vertex which has been seen.data- data to be associated with the seen vertex.- Returns:
- previous value associated with specified vertex or
nullif no data was associated with the vertex. Anullreturn can also indicate that the vertex was explicitly associated withnull.
-
-