Package org.jgrapht.traverse
Class CrossComponentIterator<V,E,D>
- java.lang.Object
- 
- org.jgrapht.traverse.AbstractGraphIterator<V,E>
- 
- org.jgrapht.traverse.CrossComponentIterator<V,E,D>
 
 
- 
- Type Parameters:
- V- vertex type
- E- edge type
- D- type of data associated to seen vertices
 - All Implemented Interfaces:
- Iterator<V>,- GraphIterator<V,E>
 - Direct Known Subclasses:
- BreadthFirstIterator,- ClosestFirstIterator,- DepthFirstIterator
 
 public abstract class CrossComponentIterator<V,E,D> extends AbstractGraphIterator<V,E> Provides a cross-connected-component traversal functionality for iterator subclasses.- Author:
- Barak Naveh
 
- 
- 
Field Summary- 
Fields inherited from class org.jgrapht.traverse.AbstractGraphIteratorcrossComponentTraversal, graph, nListeners, reusableEdgeEvent, reusableVertexEvent, reuseEvents
 
- 
 - 
Constructor SummaryConstructors Constructor Description CrossComponentIterator(Graph<V,E> g)Creates a new iterator for the specified graph.CrossComponentIterator(Graph<V,E> g, Iterable<V> startVertices)Creates a new iterator for the specified graph.CrossComponentIterator(Graph<V,E> g, V startVertex)Creates a new iterator for the specified graph.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidencounterVertex(V vertex, E edge)Update data structures the first time we see a vertex.protected abstract voidencounterVertexAgain(V vertex, E edge)Called whenever we re-encounter a vertex.protected voidfinishVertex(V vertex)Called when a vertex has been finished (meaning is dependent on traversal represented by subclass).protected Iterator<V>getEntireGraphVertexIterator()Lazily instantiatesentireGraphVertexIterator.protected DgetSeenData(V vertex)Access the data stored for a seen vertex.booleanhasNext()protected abstract booleanisConnectedComponentExhausted()Returnstrueif there are no more uniterated vertices in the currently iterated connected component;falseotherwise.protected booleanisSeenVertex(V vertex)Determines whether a vertex has been seen yet by this traversal.Vnext()protected abstract VprovideNextVertex()Returns the vertex to be returned in the following call to the iteratornextmethod.protected DputSeenData(V vertex, D data)Stores iterator-dependent data for a vertex that has been seen.protected Set<E>selectOutgoingEdges(V vertex)Selects the outgoing edges for a given vertex based on the source vertex and other traversal state.- 
Methods inherited from class org.jgrapht.traverse.AbstractGraphIteratoraddTraversalListener, createEdgeTraversalEvent, createVertexTraversalEvent, fireConnectedComponentFinished, fireConnectedComponentStarted, fireEdgeTraversed, fireVertexFinished, fireVertexTraversed, getGraph, isCrossComponentTraversal, isReuseEvents, remove, removeTraversalListener, setCrossComponentTraversal, setReuseEvents
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface java.util.IteratorforEachRemaining
 
- 
 
- 
- 
- 
Constructor Detail- 
CrossComponentIteratorpublic CrossComponentIterator(Graph<V,E> g) Creates a new iterator for the specified graph.- Parameters:
- g- the graph to be iterated
 
 - 
CrossComponentIteratorpublic CrossComponentIterator(Graph<V,E> g, V 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:
- IllegalArgumentException- if- g==nullor does not contain- startVertex
 
 - 
CrossComponentIteratorpublic CrossComponentIterator(Graph<V,E> g, Iterable<V> startVertices) Creates a new iterator for the specified graph. Iteration will start at the specified start vertices. If the specified start vertices isnull, Iteration will start at an arbitrary graph vertex.- Parameters:
- g- the graph to be iterated.
- startVertices- the vertices iteration to be started.
- Throws:
- IllegalArgumentException- if- g==nullor does not contain- startVertex
 
 
- 
 - 
Method Detail- 
hasNextpublic boolean hasNext() 
 - 
nextpublic V next() 
 - 
getEntireGraphVertexIteratorprotected Iterator<V> getEntireGraphVertexIterator() Lazily instantiatesentireGraphVertexIterator.- Returns:
- iterator which provides start vertices for cross-component iteration
 
 - 
isConnectedComponentExhaustedprotected abstract boolean isConnectedComponentExhausted() Returnstrueif there are no more uniterated vertices in the currently iterated connected component;falseotherwise.- Returns:
- trueif there are no more uniterated vertices in the currently iterated connected component;- falseotherwise.
 
 - 
encounterVertexprotected abstract void encounterVertex(V vertex, E edge) Update data structures the first time we see a vertex.- Parameters:
- vertex- the vertex encountered
- edge- the edge via which the vertex was encountered, or null if the vertex is a starting point
 
 - 
provideNextVertexprotected abstract V provideNextVertex() Returns the vertex to be returned in the following call to the iteratornextmethod.- Returns:
- the next vertex to be returned by this iterator.
 
 - 
getSeenDataprotected D getSeenData(V 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.
 
 - 
isSeenVertexprotected boolean isSeenVertex(V vertex) Determines whether a vertex has been seen yet by this traversal.- Parameters:
- vertex- vertex in question
- Returns:
- trueif vertex has already been seen
 
 - 
encounterVertexAgainprotected abstract void encounterVertexAgain(V vertex, E edge) Called whenever we re-encounter a vertex. The default implementation does nothing.- Parameters:
- vertex- the vertex re-encountered
- edge- the edge via which the vertex was re-encountered
 
 - 
putSeenDataprotected D putSeenData(V vertex, D 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.
 
 - 
finishVertexprotected void finishVertex(V vertex) Called when a vertex has been finished (meaning is dependent on traversal represented by subclass).- Parameters:
- vertex- vertex which has been finished
 
 - 
selectOutgoingEdgesprotected Set<E> selectOutgoingEdges(V vertex) Selects the outgoing edges for a given vertex based on the source vertex and other traversal state. The default implementation returns all outgoing edges.- Parameters:
- vertex- vertex in question
- Returns:
- set of outgoing edges connected to the vertex
 
 
- 
 
-