Best graph algorithm/implementation for dynamic max-flow computation
I have to write a program which requires to maintain some data in a directed flow graph. I need to compute the maximum-flow at runtime.
I know that there exist several libraries for handling graphs, implementing almost every classical algorithm, but my problem is that my graph is dynamic, meaning it evolves at runtime. After every evolution, I need to recompute the new maximum-flow.
An evolution is, either:
- adding an edge
- increasing the capacity of an edge
and what I need to re-compute is the maximum-flow from the source S to the destination node of the edge that has been modified at that step. For example:
S S
| |
5 5
| |
V V
A---3--->B A---5--->B
adding edge | | increasing | |
B-->D 2 1 A-->B of 2 1
| | two units | |
V V V V
C---3--->D C---3--->D
OUTPUT: 3 OUTPUT: 5
(maxflow S-D) (maxflow S-B)
Considering the very specific nature of the evolution in my graph, which algorithm/library would be more time-performant? I mean, considering the fact that at each step the graph is almost identical to the previous step (except for one edge), is there an algorithm that can efficiently re-use intermediate results of its previous computations?
I know that the fact that the destination is different every time makes the problem a bit hard.... any idea on how I can be better than O(VE^2) at each step?
And what if I also consider this possible evolution?
- deleting a node (and all the incoming/outgoing edges to/from that node)
I tried to understand all the standard algorithms and think how I could modify them, but being graph theory not exactly my field, I miserably failed...
Any help will be appre开发者_如何学Pythonciated. Thanks.
The only article I can find on the general case of this problem is An Incremental Algorithm for the Maximum Flow Problem, by Kumar and Gupta. It's behind a paywall, but the main idea is pretty simple. When we increase the capacity of arc uv, traverse the graph twice to find all vertices w that lie on a path from s to t in the graph with arcs with positive residual capacity and uv. (Traverse backward from u and forward from v.) Starting with the previously computed flow, run Goldberg–Tarjan on these vertices.
To add an arc, first add it with capacity zero and then increase its capacity. Kumar–Gupta also considered decreasing capacity/removing arcs. This is more complicated; they push flow from t back to v, then delete v, then push flow forward again.
Do you have any libraries you are already working with? If I were you I'd at least search for one implementing the network simplex.
精彩评论