'I am confused between shortest path finding algorithm and graph traversing algorithm
My understanding is that BFS and DFS are graph traversing algorithm while other algorithms like A* and dijkstra are for finding shortest path between two nodes of a graph. But in some places, I see BFS and DFS also stated as shortest path finding algorithm. Please elaborate the difference between graph traversing algorithm and shortest path finding algorithm. Thanks!
Solution 1:[1]
"Graph traversal" is any algorithm that iterates over nodes. "Shortest path" means finding the shortest path between two nodes.
Your confusion probably comes from the fact that BFS, a graph traversal algorithm, can also be used to find the shortest path in unweighted graphs. Also, both BFS and DFS find the shortest path in trees (since there's always only one path between nodes)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | BlueRaja - Danny Pflughoeft |