Answer
justifying that For Which graphs do depth-first search, and breadth-first
search produce identical spanning trees no matter which
vertex is selected as the root of the tree
Work Step by Step
--Certainly these two procedures produce the identical spanning trees if the graph
-we are working with is a tree itself, because in this case there is only one spanning tree (the whole graph).
-This is the only case in which that happens,
-however.
-If the original graph has any other edges, they must be back edges
and hence, join a vertex to an ancestor or descendant, they must connect vertices at the same level or at levels that differ by 1.
- Clearly these two possibilities are mutually exclusive.
-Therefore there can be no edges other than tree edges if the two spanning trees are to be the same.