IE172 – Algorithms in Systems EngineeringLecture 28Pietro BelottiDepartment of Industrial & Systems EngineeringLehigh UniversityMarch 27, 2009The Maximum Flow ProblemThe Maximum Flow ProblemInput: G = (V, A), source s ∈ V and sink t ∈ V, arc capacity c.Output: a flow whose value is maximum.stab2/26/435/24/4Here, |f | = f(s, a) + f (s, b) + . . . = 6. Is it maximum?Avoiding Σ’s: a shorthand notation◮Given X ⊆ V, Y ⊆ Vf (X, Y) =Xx∈XXy∈Yf (x, y).◮Therefore flow conservation isf ({u}, V) = 0 ∀u ∈ V \ {s, t}◮The value is |f| = f ({s}, V) or |f | = f(V, {t})◮With this shorthand notation, writing down us eful flowproperties is easy. Can you prove the following?a. f (X, X) = 0 ∀X ⊆ Vb. f(X, Y) = −f(Y, X) ∀X, Y ⊆ Vc. Let X, Y, Z ⊂ V be such that X ∩ Y = ∅. Thenf (X ∪ Y, Z) = f (X, Z) + f (Y, Z)f (Z, X ∪ Y) = f (Z, X) + f(Z, Y)Cuts◮A cut of a (flow) netw ork G = (V, A) is a partition of V intoS and T = V \ S such thats ∈ S and t ∈ T◮For flo w f , n et flow across a cut is f (S, T)◮The cut’s capacity is c(S, T) =Pu∈SPv∈Tc(u, v)S T(u1, v1)(u2, v2)(u3, v3)(uk, vk)stab2/26/435/24/4e.g. f(S, T) = 2 + 4 = 6; c(S, T) = 2 + 3 + 4 = 9◮A minimum cut of G is a cut whose capacity is minimumA S imple Upper BoundLemmaFor any cut (S, T), f (S, T) = |f |Proof:f (S, T) = f (S, V) − f(S, S) Since S ∪ T = V, S ∩ T = ∅= f (S, V)= f ({s}, V) + f (S \ {s}, V) flow conservation= f ({s}, V) = |f |CorollaryThe value of a flow is no more than the capacity of any cut|f| = f(S, T) =Xu∈SXv∈Tf (u, v) ≤Xu∈SXv∈Tc(u, v) = c(S, T).Residual Network◮Given a flow f in a net work G = (V, A), how much moreflow can be pushed from u ∈ V t o v ∈ V?◮Easy: the residual capacity of the arc (u, v),cf(u, v)def= c(u, v) − f (u, v) ≥ 0.◮Given flow f , create a residual netwo r k Gf= (V, Af), withAfdef= {(u, v) ∈ V × V | cf(u, v) > 0}◮Each arc in Gfcan admit a positive flow.stab2/26/435/24/4stab2423324Augmenting Flow Lemm a◮We define the flow sum of tw o flows f1, f2as the sum of theindividual flows(f1+ f2)(u, v) = f1(u, v) + f2(u, v).◮Note t h at f1+ f2is also a flow functionAugmenting Flow LemmaGiven a flow network G, a flow f in G. Let f′be any flow inthe residual network Gf. Then the flow sum f + f′is a flow inG with value |f | + |f′|Augmenting Paths◮Consider a path Pstfrom s to t in Gf.◮According to the lemma, we can increase the flow in G byincreasing the flow along in arc in Pst≈ a seq uence of pipes s → t with a extra capacity◮How much more?cf(Pst) = min{cf(u, v) | (u, v) is on path Pst}.Augmenting Paths◮Augmenting flow: Let P be an augmenting path in Gf,define fP: V × V → R :fP(u, v) =cf(p) (u, v) on P−cf(p) (v, u) on P0 otherwisethen fPis a flow in Gfwith value |fP| = cf(P) > 0◮corollary: f′= f + fPis a flow in G with value|f′| = |f| + cf(P) > |f|The Max-Flow Min-Cut TheoremThe following statemen ts are equivalent◮f is a maximum flow◮f admits no augmenting patha◮|f| = c(S, T) for some cut (S, T)ai.e. No (s, t) path in resi dual networkMotivation11From A. Schrijver, “On the histor y of the transportation and maximumflow problems.”Proof of MFMC◮(1) ⇒ (2). By contradiction. If f has an augmenting path,then the flow can’t be maximum (by previous corollary)◮(2) ⇒ (3). LetS = {v ∈ V | ∃ path from s to v in Gf}.T = V \ S.Note t h at t ∈ T or else there was an augmenting path, so(S, T) is a cut. For each u ∈ S, v ∈ T, f(u, v) = c(u, v) orotherwise (u, v) ∈ Afand we should have put v ∈ S.Therefore |f | = f (S, T) = c(S, T) for t h e chosen cut (S, T)◮(3) ⇒ (1). Since |f| ≤ c(S, T) (always), the fact that|f| = c(S, T) for the chosen cut implies that f must be amaximum flow.Ford-Fulkerson AlgorithmThis gave Lester Ford and Del Fulkerson an idea to find hemaximum flow in a network:FORD-FULKERSON(V, E, c, s, t)1 for i ← 1 to n2 do f [u, v] ← f [v, u] ← 03 while ∃ augmenting path P in Gf4 do augment f by cf(P)Assume all capacities are integ ers. If the y are rational numbers,scale t h em to be integers.Analysis◮If the maximum flow is |f|∗, then (since the augmentingpath must raise the flow by at least 1 on each iter ation), wewill require ≤ |f |∗iterations.◮Augmenting t h e flow t akes O(|A|)◮FORD-FULKERSON runs in O(|f|∗|A|)◮This is not polynomial in the size of the inputCan We Do Better?Jack Edmonds and Richard Karp had the following idea:◮Instead of using an arbitrary aug menting path, augmentflow along theshortest2augmenting path◮With some heavy machinery (see book), one can show thatif you only augme n t on shortest paths, then you have to doat mo st O(|V||A|) augmentations of the flow⇒ Edmonds-Karp algorithm runs in O(|V||A|2) t ime.◮There are even faster algorithms, such as push-relabel, butwe won’t cover those .2According to number of arcs taken, so all arcs have weight 1⇒ use BFS.Maximum Bipartite Matching◮A graph G = (V, E) is bipartite if V can be partitioned intoV = L ∪ R such that all edge s in E go between L and R◮A matching is a subset of edges M ⊆ E such that for allv ∈ V, ≤ 1 edge of M is incident upon it.Maximum Bipartite MatchingGiven (undirected) bipartite graph G = (L ∪ R, E), find amatching M of G that contains the most edgesApplications: e.g. airlines.◮L set of planes, R set of routes◮(u, v) ∈ E if plane u can fly route v◮Maximize the number of routes served by planesSolving It◮Bipartite matching is one of many problems that can beequivalently fo r mulated (and solved) via maximum flows.◮Given G = (L ∪ R, E), create flow network G′= (V′, E′)◮V′= V ∪ {s, t}◮E′= {(s, u) | u ∈ L} ∪ E ∪ {(v, t) | v ∈ R}◮c(u, v) = 1 ∀(u, v) ∈ E′Observations (see the book for more formal p roofs):◮There is a matching M in G of size |M| if and only if there isan (integer-valued) flow f in G′of value |f | = |M|.◮Thus a maximum-matching in a bipartite graph G is thevalue of the maximum flow in the flow network G′A not-so-practically-important ap p lication◮There are r residents in the city of Springfield: R1, R2. . . , Rr◮There are q clubs: C1, C2. . . Cq◮There are p political parties: P1, P2. . . , Pp◮Each resident belongs t o at least …
View Full Document