What are the methods to deal with variations in cost in a dynamic graph when applying Dijkstra? For instance, I select the shortest path in a graph, however, the weight of this path changed after I selected (I made the selection using an estimate). How do I deal with this variation?
So if I get this right, you computed Dijkstra for your whole graph (that has no negative cycles) and then you are interested in the shortest path between two specific points. You used estimates, and after choosing the shortest (estimated) path, you compute the real path length (you don't do this before for performance reasons I guess).
Now here are my thoughts on this:
- The real path length will very likely vary from the one you computed using estimates. That's why it is called estimates. So you first have to decide whether you are interested in the definitely shortest path or if it is sufficient to find a most likely or approximately shortest path.
- For most applications the latter case is sufficient and hence your solution works.
- If not, you have some possibilities. You could ignore the decreasing performance and just compute Dijkstra with the real values. This would be the easiest solution.
- The best solution that comes to my mind is:
- Estimate the length of all edges
- Compute Dijkstra
- Find shortest path between the desired nodes
- If the shortest path contains one or more estimates: Compute the distances between all nodes along the shortest path and replace the corresponding estimates with your results. Go to 2.
- Break; the computed path is indeed the shortest path