Class CycleDetector.ProbeIterator<V,E>

All Implemented Interfaces:
Iterator<V>, GraphIterator<V,E>
Enclosing class:
CycleDetector<V,E>

private static class CycleDetector.ProbeIterator<V,E> extends DepthFirstIterator<V,E>
Version of DFS which maintains a backtracking path used to probe for cycles.
  • Field Details

    • path

      private List<V> path
    • cycleSet

      private Set<V> cycleSet
    • root

      private V root
  • Constructor Details

    • ProbeIterator

      ProbeIterator(Graph<V,E> graph, Set<V> cycleSet, V startVertex)
  • Method Details

    • encounterVertexAgain

      protected void encounterVertexAgain(V vertex, E edge)
      Called whenever we re-encounter a vertex. The default implementation does nothing.
      Overrides:
      encounterVertexAgain in class DepthFirstIterator<V,E>
      Parameters:
      vertex - the vertex re-encountered
      edge - the edge via which the vertex was re-encountered
    • provideNextVertex

      protected V provideNextVertex()
      Returns the vertex to be returned in the following call to the iterator next method.
      Overrides:
      provideNextVertex in class DepthFirstIterator<V,E>
      Returns:
      the next vertex to be returned by this iterator.