480 likes | 627 Views
Flow Networks. zichun@comp.nus.edu.sg. Formalization. Basic Results. Min-cut. Ford-Fulkerson. Edmunds-Karp. Bipartite Matching. Flow Network. Directed Graph G = (V, E) Each edge has a capacity. Properties of Flow. Capacity Constraint Skew Symmetry Flow Conservation. Maximum Flow.
E N D
Flow Networks zichun@comp.nus.edu.sg
Formalization Basic Results Min-cut Ford-Fulkerson Edmunds-Karp Bipartite Matching
Flow Network • Directed Graph G = (V, E) • Each edge has a capacity
Properties of Flow Capacity Constraint Skew Symmetry Flow Conservation
Maximum Flow • Returns Maximum Flow of G Value of Flow
Motivating Problem 12 v1 v3 20 16 Factory Warehouse s t 10 4 7 9 13 4 v2 v4 14
Motivating Problem 12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14
12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14
Multiple Sources / Sinks 12 v1 v3 20 16 t1 s1 10 4 7 9 13 4 4 s2 t2 v2 v4 4 14
Multiple Sources / Sinks 12 v1 v3 20 16 t1 s1 10 4 7 9 13 t S 4 4 s2 t2 v2 v4 4 14
Key Equalities Let G = (V, E) be a flow network, and let f be a flow in G. Then
Capacity Constraint Skew Symmetry Flow Conservation Homomorphism
Flow Value Prove Definition Homomorphism Flow Conservation Skew Symmetry Homomorphism Flow Conservation
Ford-Fulkerson flow=0while(augmenting path p)) { augment flow f along p } return flow
Residual network Induced network from G=(V, E) and flow f
12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3
Augmenting Path A pathof non-zeroweight from s to t in Gf
12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3
12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3
12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3
12/12 v1 v3 11/16 20/20 Factory Warehouse s t 10 1/4 7/7 0/9 13/13 4/4 v2 v4 11/14 v1 0 v3 0 11 12 Factory Warehouse 5 20 9 s t 3 11 7 0 0 13 0 0 11 v2 v4 4 3
S-T Cut • A cut C=(S, T) of a flow network G=(V, E) is a partition of V into S and T = V – S • Net flow across • Capacity of cut:
12/12 v1 v3 11/16 15/20 Factory Warehouse s t 10 1/4 7/7 4/9 8/13 4/4 v2 v4 11/14 f(S, T) = 12 – 4 + 11 = 19c(S, T) = 12 + 14 = 26
Let f be a flow in a flow network G with source s and sink t, and let (S, T) be a cut of G. Then the net flow across (S, T) is f(S, T) = |f| Homomorphism Flow Conservation Homomorphism Flow Conservation Definition
The value of any flow f in a flow network G is bounded by the capacity of any cut of G
Min-Cut Max-Flow • f is a maximum flow in G • The residual network Gf contains no augmenting path • |f|= c(S, T) for some cut (S, T) of G
Premise: f is a max-flow in G • Assume Gf has augmenting path p • We can augment Gf with p to get a flow f’ > f • Contradicts [1] • Hence Gf has no augmenting paths
Premise: Gf has no augmenting paths • Let • T = V-S • (S, T) is a cut • Otherwise
The value of any flow f in a flow network G is bounded by the capacity of any cut of G • , |f| is maximum
Ford-Fulkerson flow=0while(augmenting path p)) { augment flow f along p } return flow Termination: Gf has no augmenting path iff flow is maximum
Run-time flow=0while(augmenting path p)) { augment flow f along p } return flow O(E|f*|) where |f*| is the maximum flow
v1 1,000,000 1,000,000 s 1 t 1,000,000 1,000,000 v2
v1 1,000,000 1,000,000 s 1 t 1,000,000 1,000,000 v2
v1 999,999 1,000,000 1 s 1 t 1 1,000,000 1,000,000 v2
v1 999,999 1,000,000 1 s 1 t 1 1,000,000 1,000,000 v2
v1 999,999 999,999 1 1 s 1 t 1 1 999,999 1,000,000 v2
v1 999,999 999,999 1 1 s 1 t 1 1 999,999 1,000,000 v2
Edmunds Karp flow=0while(augmenting path p)) { find augmenting path by BFS augment flow f along p } return flow Run-time: O(VE2)
v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3 Critical Edge
Lemma: Edges can be critical at most times v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3 Critical Edge
v1 0 v3 5 11 12 Factory Warehouse 5 15 5 s t 3 11 7 0 4 8 0 5 11 v2 v4 4 3
Assume (u, v) is a critical edge • Augmenting-paths are shortest path [by EK] • [from 1] • After flow-augmentation, cf(u,v) = 0 • (u, v) cannot be critical path until another augmenting path containing (v, u). • Let the flow at this point be f’ • i.e, each time (u, v) is augmenting-path, path length increases by 2 • (u, v) can be critical edge at most times
Lemma: Edges can be critical at most times Since there are O(E) edges, the number of augmenting path is bounded by O(VE) [by Lemma]. Run-time: O(VE2)