Class DepthFirstIterator<V,​E extends DefaultEdge>

  • Type Parameters:
    V - Vertex type
    E - Edge type
    All Implemented Interfaces:
    java.util.Iterator<V>

    public class DepthFirstIterator<V,​E extends DefaultEdge>
    extends java.lang.Object
    implements java.util.Iterator<V>
    Iterates over the vertices in a directed graph in depth-first order.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Iterator<V> iterator  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static <V,​E extends DefaultEdge>
      java.util.List<V>
      buildList​(DirectedGraph<V,​E> graph, V start)  
      private static <V,​E extends DefaultEdge>
      void
      buildListRecurse​(java.util.Collection<V> list, java.util.Set<V> activeVertices, DirectedGraph<V,​E> graph, V start)  
      boolean hasNext()  
      V next()  
      static <V,​E extends DefaultEdge>
      java.lang.Iterable<V>
      of​(DirectedGraph<V,​E> graph, V start)
      Creates an iterable over the vertices in the given graph in a depth-first iteration order.
      static <V,​E extends DefaultEdge>
      void
      reachable​(java.util.Collection<V> list, DirectedGraph<V,​E> graph, V start)
      Populates a collection with the nodes reachable from a given node.
      void remove()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • iterator

        private final java.util.Iterator<V> iterator
    • Constructor Detail

      • DepthFirstIterator

        public DepthFirstIterator​(DirectedGraph<V,​E> graph,
                                  V start)
    • Method Detail

      • buildList

        private static <V,​E extends DefaultEdge> java.util.List<V> buildList​(DirectedGraph<V,​E> graph,
                                                                                   V start)
      • of

        public static <V,​E extends DefaultEdge> java.lang.Iterable<V> of​(DirectedGraph<V,​E> graph,
                                                                               V start)
        Creates an iterable over the vertices in the given graph in a depth-first iteration order.
      • reachable

        public static <V,​E extends DefaultEdge> void reachable​(java.util.Collection<V> list,
                                                                     DirectedGraph<V,​E> graph,
                                                                     V start)
        Populates a collection with the nodes reachable from a given node.
      • buildListRecurse

        private static <V,​E extends DefaultEdge> void buildListRecurse​(java.util.Collection<V> list,
                                                                             java.util.Set<V> activeVertices,
                                                                             DirectedGraph<V,​E> graph,
                                                                             V start)
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<V>
      • next

        public V next()
        Specified by:
        next in interface java.util.Iterator<V>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<V>