Given that, all edges are same weight, therefore ignore the weight of edges... just you have a connected graph, ===> distance btw vertices = no.of edges btw them
let you want to find the distance btw U and V
how bfs works ?
start with U , in BFS, we add all adjacent nodes of it in the queue at a time, therefore until V encounter in to the queue. run the BFS
if V encounter in the first pass ( it happens when U and V are neighbors ) ===> distance btw them is 1 edge ==> cost = 1 * edge weight
if V encounter in the second pass ( it happens when U ---- X ------ V, where X is a any vertex in the graph except U and V ) ===> distance btw them is 2 edges ==> cost = 2 * edge weight
..... this process continues
in last option it is already a tree then what will be the role of DFS we can also do it by bfs .
read that option clearly.... it is not saying " If tree, then DFS gives correct results ( it is true but there is no significance of DFS )"
it is saying " If DFS gives correct results then it must be a tree "
Now my question arises,
WHY DFS doesn't gives correct results when given graph is not a tree ?
if you know this, just leave it