Usually when I\'ve had to walk a graph, I\'ve always used depth-first search because of the lower space complexity. I\'ve honestly never seen a situation that calls for a b
When does it make sense to use a breadth-first search?
For example, when you need to find the shortest path in a graph - DFS just can't do that. There are some other applications, but, in general, DFS and BFS are the same algorithm working on different data structures (BFS uses queue and DFS works with stack).
In depth first search you may find "local" solutions - to truly find a global solution you need to traverse the entire graph (or use a heuristic).
When you want to reach a node by traversing as few edges as possible, i.e. when you want to find the shortest path in an unweighted graph.
Also the space complexity of a depth first search can be higher than that of a breadth first search when e.g. each node has only one child node, i.e. when the graph is deep but not very broad.
One example is traversing the filesystem (with limited recursive depth).
According to wikipedia, it's also useful for certain graph algorithms (bipartiteness, connected components).
BFS is sometimes really useful. Suppose you have a tree that represents let's say WBS. You may want to present to your user only 1 level of it.
Could be used for solving a search problem with minimum number of steps. Going in depth first could lead (if not limited somehow) to infinite depth.
Ex: finding the closest node to the root that satisfies a condition.