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 Type
    Method
    Description
    default void
    A back edge vu is such that u is the ancestor of v, but vu is not a tree edge.
    default void
    A cross edge connects two nodes such that they do not have any relationship between them (ancestor or descendant).
    default void
    Invoked when leaving the subtree rooted in the current node, on the way up in the DFS tree, before upward.
    default void
    A forward edge vu is such that u is a descendant of v, but vu is not a tree edge.
    default void
    Interrupts the traversal.
    default boolean
     
    default void
    Invoked whenever a vertex is reached for the first time as root or after a tree edge.
    default void
    A tree edge is part of the DFS tree obtained after the DFS traversal.
    default void
    Invoked when the traversal algorithm moves up in the DFS tree.
  • Method Details

    • startVertex

      default void startVertex(SearchNode node)
      Invoked whenever a vertex is reached for the first time as root or after a tree edge.
      Parameters:
      node - the visited node.
    • finishVertex

      default void finishVertex(SearchNode node)
      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

      default void treeEdge(SearchNode from, SearchNode to)
      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

      default void backEdge(SearchNode from, SearchNode to)
      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

      default void forwardEdge(SearchNode from, SearchNode to)
      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

      default void crossEdge(SearchNode from, SearchNode to)
      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

      default void upward(SearchNode from, SearchNode to)
      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

      default boolean isRoot(SearchNode node)
      Parameters:
      node - a node in the DFS tree.
      Returns:
      true if the given node is on first level of the tree.