Class CycleDetector.ProbeIterator<V,​E>

  • All Implemented Interfaces:
    java.util.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 Detail

      • path

        private java.util.List<V> path
      • cycleSet

        private java.util.Set<V> cycleSet
      • root

        private V root
    • Constructor Detail

      • ProbeIterator

        ProbeIterator​(Graph<V,​E> graph,
                      java.util.Set<V> cycleSet,
                      V startVertex)
    • Method Detail

      • 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.