I have a graph on which I frequently need to know all shortest paths (or rather their lengths). Because I do not want to recalculate them I store them in a simple array and just retrieve them from there. However since the graph might also change over time I will have to recalculate them at given times.
For now the following changes might happen:
Adding a node and an edge to it to the graph
Changing the length of an edge
Adding a new edge of the graph
Deleting an edge or deleting a node
In all cases all nodes will always be connected and all edges have positive weights. Also the graph is undirected. The sequence of operations is such, that all nodes will always be from the same component of the graph. If a node or edge is deleted before this other nodes and edges will have been added so that the graph never becomes separated.
For now I am planning to just do the updates and then propagate all the changes through the graph structure. However I am not sure yet how to handle this correctly. How would you try to achieve these updates of the cached length.
EDIT:
As some of you have pointed out it might be neccessary to recalculate everything when a node is added or a link is changed. This might be for example when all distances change through the update. However if I just propagate the changes through the graph and do a relaxation similar to the way it is done dijkstras, I might have to relax the same node multiple times, because I might not choose the optimal order. The question would be how to order the relaxation steps, so I avoid multiple updates as good as possible.
Not sure this makes much sense without the actual idea I have in mind, but I hope this clarifies some more.
The D* family of search algorithms are exactly concerned with the updating of shorting paths in dynamically changing graphs. The algorithms were developed for mobile robot path planning problems. Although the algorithms only return the shortest path from the goal to the current robot location, you might be able to use their bookkeeping and updating rules for all-shortest-paths problems too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With