Class BreadthFirstIterator<V,​E extends DefaultEdge>

  • Type Parameters:
    V - Vertex type
    E - Edge type
    All Implemented Interfaces:

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

      • deque

        private final java.util.Deque<V> deque
      • set

        private final java.util.Set<V> set
    • Constructor Detail

      • BreadthFirstIterator

        public BreadthFirstIterator​(DirectedGraph<V,​E> graph,
                                    V root)
    • Method Detail

      • reachable

        public static <V,​E extends DefaultEdge> void reachable​(java.util.Set<V> set,
                                                                     DirectedGraph<V,​E> graph,
                                                                     V root)
        Populates a set with the nodes reachable from a given node.
      • 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>