动态最大流计算的最佳图算法/实现
我必须编写一个程序,需要在有向流程图中维护一些数据。我需要计算运行时的最大流量。
我知道有几个用于处理图的库,实现了几乎所有经典算法,但我的问题是我的图是动态的,这意味着它在运行时演变。每次进化之后,我都需要重新计算新的最大流量。
进化是:
- 添加一条边,
- 增加一条边的容量
,而我需要重新计算的是在该步骤中修改的边从源 S 到目标节点的最大流量。例如:
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)
考虑到我的图中演化的非常具体的性质,哪种算法/库的时间性能更好?我的意思是,考虑到每一步的图几乎与上一步相同(除了一条边),是否有一种算法可以有效地重用之前计算的中间结果?
我知道每次目的地都不同这一事实使问题有点困难......知道我如何在每一步都比 O(VE^2) 更好吗?
如果我也考虑这种可能的演变呢?
- 删除一个节点(以及该节点的所有传入/传出边缘)
我试图理解所有标准算法并思考如何修改它们,但是图论不完全是我的领域,我惨败了......
任何帮助将不胜感激。 谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能找到的关于此问题一般情况的唯一文章是最大流问题的增量算法,作者:Kumar 和 Gupta。它位于付费墙后面,但主要思想非常简单。当我们增加弧uv的容量时,遍历图形两次以找到位于从s到的路径上的所有顶点w图中的 t 具有正剩余容量和 uv 的弧。 (从 u 向后遍历,从 v 向前遍历。)从之前计算的流开始,在这些顶点上运行 Goldberg-Tarjan。
要添加弧线,首先添加其容量为零,然后增加其容量。库马尔-古普塔还考虑了减少容量/移除电弧。这个比较复杂;他们将流从t推回到v,然后删除v,然后再次将流向前推。
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.