A Breadth-First Search Method

Once the Search algorithm is coded, we can easily implement BFS:

    /**
     * Performs a breadth-first search of this graph from a given starting
     * vertex.  For each vertex that is reachable from the start, this 
     * operation computes its distance from the start and its predecessor 
     * on the search path.
     * @param start The start vertex
     */
    public void breadthFirstSearch(Vertex start) {

        DequeAdder tailAdder = new DequeAdder() {
            public void add(Vertex vertex, Deque<Vertex> deque) {
                deque.addLast(vertex);
            }
        };

        search(start, tailAdder);
    }