Package org.graph4j.traversal
Interface DFSVisitor
public interface DFSVisitor
A depth first search (DFS) visitor of a graph. An implementation of this
interface is provided to a
DFSTraverser.- 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) Invoked when leaving the subtree rooted in the current node, on the way up in the DFS tree, before upward.default voidforwardEdge(SearchNode from, SearchNode to) A forward edge vu is such that u is a descendant of v, but vu is not a tree edge.default voidInterrupts the traversal.default booleanisRoot(SearchNode node) 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 DFS tree obtained after the DFS traversal.default voidupward(SearchNode from, SearchNode to) Invoked when the traversal algorithm moves up in the DFS tree.
-
Method Details
-
startVertex
Invoked whenever a vertex is reached for the first time as root or after a tree edge.- Parameters:
node- the visited node.
-
finishVertex
Invoked when leaving the subtree rooted in the current node, on the way up in the DFS tree, before upward.- Parameters:
node- the current node.
-
treeEdge
A tree edge is part of the DFS tree obtained after the DFS traversal.- Parameters:
from- a node in the DFS tree.to- a node in the DFS tree.
-
backEdge
A back edge vu is such that u is the ancestor of v, but vu is not a tree edge.- Parameters:
from- a node in the DFS tree.to- a node in the DFS tree.
-
forwardEdge
A forward edge vu is such that u is a descendant of v, but vu is not a tree edge. Forward edges can appear only in directed graph traversals.- Parameters:
from- a node in the DFS tree.to- a node in the DFS tree.
-
crossEdge
A cross edge connects two nodes such that they do not have any relationship between them (ancestor or descendant). Cross edges can appear only in directed graph traversals.- Parameters:
from- a node in the DFS tree.to- a node in the DFS tree.
-
upward
Invoked when the traversal algorithm moves up in the DFS tree.- Parameters:
from- a node in the DFS tree.to- a node in the DFS tree.
-
interrupt
default void interrupt()Interrupts the traversal. -
isRoot
- Parameters:
node- a node in the DFS tree.- Returns:
trueif the given node is on first level of the tree.
-