DFS always not gives shortest paths in an undirected graph. BFS should be the correct choice here.

for example, consider a graph formed by taking the corners of a triangle and connecting them. If you try to find the shortest path from one node to another using DFS, then you will get the wrong answer unless you follow the edge directly connecting the start and destination nodes.