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 appreciated. Thanks.