CS 401
Max Flow / Bipartite Matching
Xiaorui Sun
1
CS 401 Max Flow / Bipartite Matching Xiaorui Sun 1 Flow network - - PowerPoint PPT Presentation
CS 401 Max Flow / Bipartite Matching Xiaorui Sun 1 Flow network Flow network. G = (V, E) = directed graph, no parallel edges. Two distinguished nodes: s = source, t = sink. c(e) = capacity of edge e. 9 2 5 10 15 15 10 4 source 5
Xiaorui Sun
1
G = (V, E) = directed graph, no parallel edges. Two distinguished nodes: s = source, t = sink. c(e) = capacity of edge e.
s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10 15 4 4
capacity source sink
3
s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10 15 4 4 A Capacity = 10 + 8 + 10 = 28
4
10 9 9 14 4 10 4 8 9 1 14
capacity flow
s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10 15 4 4
Value = 28
Ford-Fulkerson(G, s, t, c) { foreach e Î E f(e) ¬ 0 Gf ¬ residual graph while (there exists augmenting path P) { f ¬ Augment(f, c, P) update Gf } return f }
s 1 2 t
C C C C 1
s 1 2 t
C C 1
X 1
C C
X X X
1 1 1
X X
1 1
X X X
1 1
m, n, and log C
Some choices lead to exponential algorithms. Clever choices lead to polynomial algorithms. If capacities are irrational, algorithm not guaranteed to terminate!
Can find augmenting paths efficiently. Few iterations.
Sufficiently large bottleneck capacity. Fewest number of edges.
How to find exact highest bottleneck path? Homework 4 Maintain scaling parameter D. Let Gf (D) be the subgraph of the residual graph consisting of only arcs with capacity at least D.
110
s 4 2 t
1 170 102 122 Gf 110
s 4 2 t
170 102 122 Gf (100)
Scaling-Max-Flow(G, s, t, c) { foreach e Î E f(e) ¬ 0 D ¬ smallest power of 2 greater than or equal to C Gf ¬ residual graph while (D ³ 1) { Gf(D) ¬ D-residual graph while (there exists augmenting path P in Gf(D)) { f ¬ augment(f, c, P) update Gf(D) } D ¬ D / 2 } return f }
By integrality invariant, when D = 1 Þ Gf(D) = Gf. Upon termination of D = 1 phase, there are no augmenting paths. ▪
Lemma 1. The outer while loop repeats 1 + élog2 Cù times.
Lemma 2. Let f be the flow at the end of a D-scaling phase. Then the value of the maximum flow is at most v(f) + m D. Lemma 3. There are at most 2m augmentations per scaling phase. Let f be the flow at the end of the previous scaling phase. L2 Þ v(f*) £ v(f) + m (2D). Each augmentation in a D-phase increases v(f) by at least D. ▪
log C) augmentations. It can be implemented to run in O(m2 log C)
proof on next slide
We show that at the end of a D-phase, there exists a cut (A, B) such that cap(A, B) £ v(f) + m D. Choose A to be the set of nodes reachable from s in Gf(D). By definition of A, s Î A. By definition of f, t Ï A.
s t
A B
15
17
18
1 3 5 1' 3' 5' 2 4 2' 4'
Create digraph ! as follows:
19
s 1 3 5 1' 3' 5' t 2 4 2' 4' 1 1
∞
20
1 3 5 1' 3' 5' 2 4 2' 4'
4 4' s 1 3 5 1' 3' 5' t 2 2' 1 1
Integrality theorem Þ $ is integral and we can assume " is 0-1. Consider % = set of edges from & to ' with " ( = 1.
21
s 1 3 5 1' 3' 5' t 2 4 2' 4' 1 1
1 3 5 1' 3' 5' 2 4 2' 4'