Package org.graph4j.traversal
Interface BFSVisitor
public interface BFSVisitor
A breadth first search (BFS) visitor of a graph. An implementation of this
interface is provided to a
BFSTraverser.- Author:
- Cristian Frăsinaru
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidbackEdge(SearchNode from, SearchNode to) A back edge vu is such that u is the ancestor of v, but vu is not a tree edge.default voidcrossEdge(SearchNode from, SearchNode to) A cross edge connects two nodes such that they do not have any relationship between them (ancestor or descendant).default voidfinishVertex(SearchNode node, boolean leaf) Invoked after all the neighbors of the current vertex have been visited (added to the queue).default voidInterrupts the traversal.default voidstartVertex(SearchNode node) Invoked whenever a vertex is reached for the first time as root or after a tree edge.default voidtreeEdge(SearchNode from, SearchNode to) A tree edge is part of the BFS tree obtained after the BFS traversal.
-
Method Details
-
startVertex
Invoked whenever a vertex is reached for the first time as root or after a tree edge.- Parameters:
node- the current node.
-
finishVertex
Invoked after all the neighbors of the current vertex have been visited (added to the queue).- Parameters:
node- the current node.leaf-trueif the node is a leaf in the BFS tree.
-
treeEdge
A tree edge is part of the BFS tree obtained after the BFS traversal.- Parameters:
from- a node in the BFS tree.to- a node in the BFS tree.
-
backEdge
A back edge vu is such that u is the ancestor of v, but vu is not a tree edge. Back edges are specific to directed graphs.- Parameters:
from- a node in the BFS tree.to- a node in the BFS tree.
-
crossEdge
A cross edge connects two nodes such that they do not have any relationship between them (ancestor or descendant).- Parameters:
from- a node in the BFS tree.to- a node in the BFS tree.
-
interrupt
default void interrupt()Interrupts the traversal.
-