Package org.apache.openjpa.lib.graph
Class BreadthFirstWalk
java.lang.Object
org.apache.openjpa.lib.graph.BreadthFirstWalk
Performs a breadth-first walk of a given Graph
,
notifying visitors as it sees each node. See the BFS algorithm
in the book 'Introduction to Algorithms' by Cormen, Leiserson, and
Rivest.
Each GraphVisitor
will be notified when a node
is colored black (nodeVisited), edge seen (edgeVisited),
and a node is seen for the first time, i.e. colored gray (nodeSeen).
- Since:
- 1.0.0
- Author:
- Steve Kim
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addGraphVisitor
(GraphVisitor visitor) add aGraphVisitor
to be notified during breadth first search.protected void
edgeVisited
(Edge edge) An edge is seen.protected void
Push the given node onto the queue to be processed.void
removeGraphVisitor
(GraphVisitor visitor) remove a givenGraphVisitor
from the listener set.protected void
Visit the node.void
walk()
Begins the breadth first traversal.
-
Constructor Details
-
BreadthFirstWalk
-
-
Method Details
-
walk
public void walk()Begins the breadth first traversal. -
enqueue
Push the given node onto the queue to be processed. Notify visitors. -
visit
Visit the node. Mark the node black and notify visitors. -
edgeVisited
An edge is seen. Notify visitors. -
addGraphVisitor
add aGraphVisitor
to be notified during breadth first search. -
removeGraphVisitor
remove a givenGraphVisitor
from the listener set.
-