Question: why bfs gives shortest path?
Answer: We say that BFS is the algorithm to use if we want to find the shortest path in an undirected, unweighted graph. The claim for BFS is that the first time a node is discovered during the traversal, that distance from the source would give us the shortest path. ... The shortest path is A --> M --> E --> B o f length 10.