Class BreadthFirstIterator<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - the graph edge type
    All Implemented Interfaces:
    java.util.Iterator<V>, GraphIterator<V,​E>

    public class BreadthFirstIterator<V,​E>
    extends CrossComponentIterator<V,​E,​java.lang.Object>
    A breadth-first iterator for a directed and an undirected graph. For this iterator to work correctly the graph must not be modified during iteration. Currently there are no means to ensure that, nor to fail-fast. The results of such modifications are undefined.
    Since:
    Jul 19, 2003
    • Field Detail

      • queue

        private java.util.Deque<V> queue
    • Constructor Detail

      • BreadthFirstIterator

        public BreadthFirstIterator​(Graph<V,​E> g)
        Creates a new breadth-first iterator for the specified graph.
        Parameters:
        g - the graph to be iterated.
      • BreadthFirstIterator

        public BreadthFirstIterator​(Graph<V,​E> g,
                                    V startVertex)
        Creates a new breadth-first iterator for the specified graph. Iteration will start at the specified start vertex and will be limited to the connected component that includes that vertex. If the specified start vertex is null, iteration will start at an arbitrary vertex and will not be limited, that is, will be able to traverse all the graph.
        Parameters:
        g - the graph to be iterated.
        startVertex - the vertex iteration to be started.