Package org.graph4j.traversal
Class LexBFSIterator
java.lang.Object
org.graph4j.traversal.LexBFSIterator
- All Implemented Interfaces:
Iterator<SearchNode>
A Lexicographic Breadth-First Search (Lex-BFS) is an algorithm for ordering
the vertices of a graph.
This algorithm is a variant of Breadth-First Search (BFS) and offers a linear
time complexity (O(|V| + |E|)). Lex-BFS produces an ordering consistent with
BFS, but utilizes an ordered sequence of vertex sets instead of a standard
vertex queue.
For further details on the Lex-BFS algorithm, refer to the following paper:
D. G. Corneil. Lexicographic Breadth First Search – A Survey. In: Graph-Theoretic Concepts in Computer Science. WG 2004. Lecture Notes in Comput. Sci., vol 3353 (Eds. J. Hromkovič, M. Nagl, B. Westfechtel) (pp. 1–19). Springer, Berlin, Heidelberg, 2004.
- Author:
- Cristian Frăsinaru
-
Constructor Summary
ConstructorsConstructorDescriptionLexBFSIterator(Graph graph) Creates an iterator starting with the first vertex of the graph (the one at index 0)LexBFSIterator(Graph graph, int start) Creates an iterator starting with the specified vertex. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Constructor Details
-
LexBFSIterator
Creates an iterator starting with the first vertex of the graph (the one at index 0)- Parameters:
graph- the input graph.
-
LexBFSIterator
Creates an iterator starting with the specified vertex.- Parameters:
graph- the input graph.start- the start vertex number.- Throws:
InvalidVertexException- if the graph does not contain the start vertex.
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<SearchNode>
-
next
- Specified by:
nextin interfaceIterator<SearchNode>
-