V
 the graph vertex typeE
 the graph edge typepublic class TopologicalOrderIterator<V,E> extends AbstractGraphIterator<V,E>
A topological order is a permutation p of the vertices of a graph such that an edge (i,j) implies that i appears before j in p. For more information see wikipedia or wolfram.
The iterator crosses components but does not track them, it only tracks visited vertices. The
iterator will detect (at some point) if the graph is not a directed acyclic graph and throw a
IllegalArgumentException
.
For this iterator to work correctly the graph must not be modified during iteration. Currently there are no means to ensure that, nor to failfast. The results of such modifications are undefined.
crossComponentTraversal, graph, nListeners, reusableEdgeEvent, reusableVertexEvent, reuseEvents
Constructor and Description 

TopologicalOrderIterator(Graph<V,E> graph)
Construct a topological order iterator.

TopologicalOrderIterator(Graph<V,E> graph,
Comparator<V> comparator)
Construct a topological order iterator.

TopologicalOrderIterator(Graph<V,E> graph,
Queue<V> queue)
Deprecated.
in favor of
TopologicalOrderIterator(Graph, Comparator) 
Modifier and Type  Method and Description 

boolean 
hasNext() 
boolean 
isCrossComponentTraversal()
Test whether this iterator is set to traverse the graph across connected components.

V 
next() 
void 
setCrossComponentTraversal(boolean crossComponentTraversal)
Sets the cross component traversal flag  indicates whether to traverse the graph across
connected components.

addTraversalListener, createEdgeTraversalEvent, createVertexTraversalEvent, fireConnectedComponentFinished, fireConnectedComponentStarted, fireEdgeTraversed, fireVertexFinished, fireVertexTraversed, getGraph, isReuseEvents, remove, removeTraversalListener, setReuseEvents
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public TopologicalOrderIterator(Graph<V,E> graph)
Traversal will start at one of the graph's sources. See the definition of source at http://mathworld.wolfram.com/Source.html. In case of partial order, tiebreaking is arbitrary.
graph
 the directed graph to be iterated@Deprecated public TopologicalOrderIterator(Graph<V,E> graph, Queue<V> queue)
TopologicalOrderIterator(Graph, Comparator)
graph
 the directed graph to be iterated.queue
 queue to use for tiebreak in case of partial order (e.g. a PriorityQueue can be
used to break ties according to vertex priority); must be initially emptypublic TopologicalOrderIterator(Graph<V,E> graph, Comparator<V> comparator)
Traversal will start at one of the graph's sources. See the definition of source at http://mathworld.wolfram.com/Source.html. In case of partial order, a comparator is used to break ties.
graph
 the directed graph to be iteratedcomparator
 comparator in order to break ties in case of partial orderpublic boolean isCrossComponentTraversal()
isCrossComponentTraversal
in interface GraphIterator<V,E>
isCrossComponentTraversal
in class AbstractGraphIterator<V,E>
true
if traverses across connected components, otherwise
false
.public void setCrossComponentTraversal(boolean crossComponentTraversal)
IllegalArgumentException
.setCrossComponentTraversal
in class AbstractGraphIterator<V,E>
crossComponentTraversal
 if true
traverses across connected components.public boolean hasNext()
public V next()
Copyright © 2017. All rights reserved.