Class BFSTraverser

java.lang.Object
org.graph4j.traversal.BFSTraverser

public class BFSTraverser extends Object
A breadth first search (BFS) traverser of the graph. As the graph is traversed, a visitor methods are invoked corresponding with the current operation.
Author:
Cristian Frăsinaru
See Also:
  • Constructor Details

    • BFSTraverser

      public BFSTraverser(Graph graph)
      Parameters:
      graph - the graph to be traversed.
  • Method Details

    • traverse

      public void traverse(BFSVisitor visitor)
      Parameters:
      visitor - a visitor of the traversal.
    • traverse

      public void traverse(int start)
      Parameters:
      start - the start vertex number.
    • traverse

      public void traverse(int start, BFSVisitor visitor)
      Parameters:
      start - the start vertex number.
      visitor - a visitor of the traversal.
    • numComponents

      public int numComponents()
      Returns:
      the number of connected components identified by the traversal.
    • maxLevel

      public int maxLevel()
      Returns:
      the maximum level in the search tree, root is at level 0.
    • isInterrupted

      public boolean isInterrupted()
      Returns:
      true if the traversal was interrupted before all vertices have been visited.