Ford-Fulkerson算法

2025 年 3 月 17 日 | 阅读 1 分钟

最初,流的值为0。 找到一些增广路径p,并增加路径p中每条边的流量f,增加值为残余容量cf (p)。 当不存在增广路径时,流量f是最大流量。

FORD-FULKERSON METHOD (G, s, t)
 1. Initialize flow f to 0
 2. while there exists an augmenting path p
 3. do argument flow f along p
 4. Return f
 
FORD-FULKERSON (G, s, t)
 1. for each edge (u, v) ∈ E [G]
 2. do f [u, v] ← 0
 3. f [u, v] ← 0
 4. while there exists a path p from s to t in the residual network Gf.
 5. do cf (p)←min?{ Cf (u,v):(u,v)is on p}
 6. for each edge (u, v) in p
 7. do f [u, v] ← f [u, v] + cf  (p)
 8. f [u, v] ←-f[u,v]

示例: 每条有向边都标有容量。 使用Ford-Fulkerson算法找到最大流量。

Ford-Fulkerson Algorithm

解决方案: 每部分的左侧显示带有阴影增广路径p的残余网络Gf,每部分的右侧显示净流量f。

Ford-Fulkerson Algorithm
Ford-Fulkerson Algorithm
下一主题最大二分匹配