V
 the graph vertex type.E
 the graph edge type.public class LexBreadthFirstIterator<V,E> extends AbstractGraphIterator<V,E>
Every vertex has an implicit label (they aren't used explicitly in order to reduce time and memory complexity). When some vertex is returned by this iterator, its index is the number of vertices in this graph minus number of already returned vertices. For a given vertex v its label is a concatenation of indices of already returned vertices, that were also its neighbours, with some separator between them. For example, 7#4#3 is a valid vertex label.
Iterator chooses vertex with lexicographically largest label and returns it. It breaks ties arbitrarily. For more information on lexicographical BFS see the following article: Corneil D.G. (2004) Lexicographic Breadth First Search – A Survey. In: Hromkovič J., Nagl M., Westfechtel B. (eds) GraphTheoretic Concepts in Computer Science. WG 2004. Lecture Notes in Computer Science, vol 3353. Springer, Berlin, Heidelberg; and the following paper:CS 762: Graphtheoretic algorithms. Lecture notes of a graduate course. University of Waterloo.
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.
Note: only vertex events are fired by this iterator.
crossComponentTraversal, graph, nListeners, reusableEdgeEvent, reusableVertexEvent, reuseEvents
Constructor and Description 

LexBreadthFirstIterator(Graph<V,E> graph)
Creates new lexicographical breadthfirst iterator for
graph . 
Modifier and Type  Method and Description 

boolean 
hasNext()
Checks whether there exist unvisited vertices.

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

V 
next()
Returns the next vertex in the ordering.

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 boolean hasNext()
public V next()
public boolean isCrossComponentTraversal()
Always returns true since this iterator doesn't care about connected components.
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)
Trying to disable the cross components nature of this iterator will result into throwing a
IllegalArgumentException
.
setCrossComponentTraversal
in class AbstractGraphIterator<V,E>
crossComponentTraversal
 if true
traverses across connected components.Copyright © 2018. All rights reserved.