Constructor Detail

BreadthFirstSearch

Method Detail

search

Executes the search on the input graph. Sets the parent of the source
vertex to null and sets parents for all vertices reachable from source
according to a shortest path from source to the given vertex. Unreachable
vertices will have parent set to null after this method call. Reachable
vertices will further have distances entered according to the minimum number of
steps (edges) required to reach them from source. The source vertex will
show a distance of 0, and unreachable vertices will have distances set to -1

path

Shows a shortest path from the source vertex passed in the search() method
to any given vertex in the graph.
For actually getting the list rather than just printing, a loop seems easier
than the recursion used by CLRS (p. 601)

Parameters:

target - the vertex to which the path is returned

Returns:

the shortest path from the source vertex passed in a prior call of search()
to the target vertex. Returns null if the target is not reachable from the
source vertex.