in Dijkstra's Algorithm (to find the shortest path), when you have analyzed all the paths going from the current node that were not visited, and found their tentative distance. You have to select the next node to go to and this is done by selecting the one with the shortest tentative distance. This is pretty easy, except when there are more than one paths with the same length. For example in this graph :
If we try to go from node 0 to node 5, there are two paths, first we go to node 4 and then we have to choose between 6 and 8. This is complicated and the algorithm would choose between the two paths of length 10.
I see 3 options :
- Choose the first one the minimum function returns, which would in this case depend on the way you represent you graph.
- Choose one randomly, but that doesn't really help either
- Enter the next nodes recursively, but wouldn't that become DFS (depth first search)
I really don't know how to proceed, thank you for reading.
(Cross posted on theoretical computer science stack exchange)