complexitydsagraphs
Why does BFS find the shortest unweighted path?
Anonymous
in an unweighted graph, BFS visits vertices in nondecreasing distance from the source. Mark a vertex when it first enters the queue; that prevents duplicate work and makes its first parent a shortest-path predecessor. With adjacency lists, traversal is O(V + E). For weighted edges, use an algorithm suited to the weights instead.
0