src/main/java/org/jboss/util/graph/Graph.java
public <E extends Exception> void breadthFirstSearch(Vertex<T> v, VisitorEX<T, E> visitor)
      throws E
   {
      LinkedList<Vertex<T>> q = new LinkedList<Vertex<T>>();

      q.add(v);
      if( visitor != null )
         visitor.visit(this, v);
      v.visit();
      while (q.isEmpty() == false)
      {
         v = q.removeFirst();
         for (int i = 0; i < v.getOutgoingEdgeCount(); i++)
         {
            Edge<T> e = v.getOutgoingEdge(i);
            Vertex<T> to = e.getTo();
            if (!to.visited())
            {
               q.add(to);
               if( visitor != null )
                  visitor.visit(this, to);
               to.visit();
            }
         }
      }
   }
public <E extends Exception> void breadthFirstSearch(Vertex<T> v, VisitorEX<T, E> visitor)
      throws E
   {
      LinkedList<Vertex<T>> q = new LinkedList<Vertex<T>>();

      q.add(v);
      if( visitor != null )
         visitor.visit(this, v);
      v.visit();
      while (q.isEmpty() == false)
      {
         v = q.removeFirst();
         for (int i = 0; i < v.getOutgoingEdgeCount(); i++)
         {
            Edge<T> e = v.getOutgoingEdge(i);
            Vertex<T> to = e.getTo();
            if (!to.visited())
            {
               q.add(to);
               if( visitor != null )
                  visitor.visit(this, to);
               to.visit();
            }
         }
      }
   }
public < E extends Exception > void breadthFirstSearch ( Vertex < T > v , VisitorEX < T , E > visitor ) throws E { LinkedList < Vertex < T >> q = new LinkedList < Vertex < T > > ( ) ; q . add ( v ) ; if ( visitor != null ) visitor . visit ( this , v ) ; v . visit ( ) ; while ( q . isEmpty ( ) == false ) { v = q . removeFirst ( ) ; for ( int i = 0 ; i < v . getOutgoingEdgeCount ( ) ; i ++ ) { Edge < T > e = v . getOutgoingEdge ( i ) ; Vertex < T > to = e . getTo ( ) ; if ( ! to . visited ( ) ) { q . add ( to ) ; if ( visitor != null ) visitor . visit ( this , to ) ; to . visit ( ) ; } } } }
Perform a breadth first search of this graph, starting at v. The
vist may be cut short if visitor throws an exception during
a vist callback.
@param <E> exception type

@param v - the search starting point
@param visitor - the vistor whose vist method is called prior
to visting a vertex.
@throws E if vistor.visit throws an exception
Perform a breadth first search of this graph starting at v . The vist may be cut short if visitor throws an exception during a vist callback . @param <E > exception type