Do we need to use BFS or DFS algorithm to find the k shortest loopless paths in a graph between any two nodes? If so where can it be useful?
Tell me more
×
Computer Science Stack Exchange is a question and answer site for
students, researchers and practitioners of computer science. It's 100% free, no registration required.
|
|
Consider the case $k=1$ first. Can you use BFS or DFS? Now try to generalize. |
|||||||||||||||||||
|
|
For k=1. I would like to draw your attention to the Theorem 22.5:
Cormen ð(s,v) ... the minimum number of edges from s to v |
|||||
|
|
Whenever they ask for shortest paths in a graph, it is a safe bet that some form of BFS is called for (you need to first check the neighbors of the starting point, if none qualifies you need to check all their neighbors, and so on. I.e., BFS). |
|||
|
|
