Class SearchNode

java.lang.Object
org.graph4j.traversal.SearchNode

public class SearchNode extends Object
A node of the BFS or DFS tree created while traversing a graph. It contains a vertex of the graph and additional information about its location in the exploration tree.
Author:
Cristian Frăsinaru
  • Constructor Details

    • SearchNode

      public SearchNode(int vertex)
      Parameters:
      vertex - the vertex number.
  • Method Details

    • component

      public int component()
      Returns:
      the connected component number of this node, starting with 0.
    • vertex

      public int vertex()
      Returns:
      the vertex corresponding to this node.
    • level

      public int level()
      Returns:
      the level of this node in the tree.
    • order

      public int order()
      Returns:
      the visiting time, starting with 0.
    • parent

      public SearchNode parent()
      Returns:
      the parent of this node, or null if it is root.
    • isAncestorOf

      public boolean isAncestorOf(SearchNode other)
      Parameters:
      other - another node of the tree.
      Returns:
      true, if this node is an ancestor of other.
    • nearestAncestor

      public static SearchNode nearestAncestor(SearchNode a, SearchNode b)
      Parameters:
      a - a node of the tree.
      b - a node of the tree
      Returns:
      the neareast ancestor of a and b.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object