Conen Conen. Maximum flow problem. Minimum cu problem. Max-flow min-cu heorem. Augmening pah algorihm. Capaciy-caling. Shore augmening pah. Chaper Maximum How do we ranpor he maximum amoun daa from ource o ink? Some of hee lide are adaped from Lecure Noe of Kevin Wayne. Conen Conen. Maximum flow problem. Minimum cu problem. Max-flow min-cu heorem. Augmening pah algorihm. Capaciy-caling. Shore augmening pah. Nework communicaion Nework Node elephone exchange, compuer, aellie Arc cable, fiber opic, microwave relay voice, video, packe circui gae, regier, proceor wire curren mechanical join rod, beam, pring hea, energy hydraulic reervoir, pumping aion, lake pipeline fluid, oil financial ock, currency ranacion money ranporaion airpor, rail yard, ree inerecion highway, railbed, airway roue freigh, vehicle, paenger chemical ie bond energy biological gene pahway ineracion Maximum & Minimum Cu Max flow and min cu. Two very rich algorihmic problem. Cornerone problem in combinaorial opimizaion. Beauiful mahemaical dualiy. Nonrivial applicaion / reducion. Nework conneciviy. Securiy of aiical daa. Biparie maching. Diribued compuing. Daa mining. Egaliarian able maching. Image proceing. Diribued compuing. Airline cheduling. Compuaional biology. Projec elecion. Nework reliabiliy. Many many more... Nework nework: G = (V, E,,, c). (V, E) = weighed direced graph. Two diinguihed verice (node): =ource, =ink. c( = capaciy of edge (arc) e=(. Capaciy
A poiive - flow i a func. p: V V R ha aifie: For all v V: p( c( (capaciy conrain) For all u V {, }: Capaciy Poiive p ( = p( (flow conervaion) (flow o (flow in) Poiive A poiive - flow i a func. p: V V R ha aifie: For all v V: p( c( (capaciy conrain) For all u V {, }: (flow o (flow in) (flow conervaion) MAX FLOW: poiive - flow ha maximize ne flow ou of he ource. Capaciy p ( = p( Value = Poiive A poiive - flow i a func. p: V V R ha aifie: For all v V: p( c( (capaciy conrain) For all u V {, }: (flow o (flow in) (flow conervaion) MAX FLOW: find poiive - flow ha maximize ne flow ou of he ource. Capaciy p ( = p( Value = Poiive A poiive - flow i a func. p: V V R ha aifie: For all v V: p( c( (capaciy conrain) For all u V {, }: (flow o (flow in) (flow conervaion) MAX FLOW: poiive - flow ha maximize ne flow ou of he ource. Capaciy p ( = p( Value = Maximum flow problem Maximize he flow over a flow nework. Capaciy Value = Formalizaion How do we formalize flow? Graph G=(V,E) a flow nework Direced, each edge ha capaciy c( Two pecial verice: ource, and ink For any oher verex here i a pah v A (ne)) - flow i a func. f : V V R ha aifie Capaciy conrain: : For all v V: f( c( Skew ymmery: : For all v V: f( ) = f( conervaion: For all u V {, }: f( uv, ) = f( uv, ) =, or f(, v = f( Vu, ) =
Cancellaion of flow Do we wan o have flow going in boh direcion beween wo verice? No! uch flow cancel (maybe parially) each oher Skew ymmery noaional convenience a c b d a c b d Equivalence of Definiion Define ne flow in erm of poiive flow f( ) = p( - p( How do we know f defined hi way i a ne flow? Capaciy conrain conervaion Skew ymmery Equivalence of Definiion Define poiive flow in erm of ne flow p( ) = f( ) if f( ) > = o.w. How do we know p defined hi way i a poiive flow? Capaciy conrain conervaion In lieraure, view of flow are ued. The curren verion ( rd ediion) of our book ue poiive flow. conervaion Define poiive flow in erm of ne flow p( ) = f( ) if f( ) > = o.w. Need o how Given p( = f ( = p( v f ( V > = = f ( + v f ( V > p( p( v f ( V < f ( v f ( V < p( p( = Implici Summaion Noaion Funcion over e ummaion: x X f ( X, Y ) = f ( x, y) y Y conervaion for poiive flow: p( V ) = p( V,, u V {, } conervaion for ne flow: f ( V ) =, u V {, } Capaciy Conervaion Theorem f = f(,) v = f(, V) = f( V,) proof:? Value =
Lemma G = (V,E) i a flow nework. f i a ne flow in G. f (X,X) =, X, Y V f (X,Y) = f (Y,X), X, Y V f (X Y, Z) = f (X,Z)+ f (Y,Z), X,Y,Z V & X Y= Y= f (Z, X Y) = f (Z,X)+ f (Z,Y), X,Y,Z V & X Y= Y= Conervaion Theorem f = f(,) v = f(, V) = f( V,) proof: Proof: f = f (, V ) = f ( V, V ) f ( V, V ) = f ( V, V ) = f ( V, ) + f ( V, V {, }) = f ( V, ) + f ( V, u V {, } = f ( V, ). conervaion Cu An - cu i a node pariion (S, T).. S, T. The capaciy of an - cu (S, T) i: c(. u S, v T u, v V Min - cu: find an - cu of minimum capaciy. Capaciy = Cu An - cu i a node pariion (S, T).. S, T. The capaciy of an - cu (S, T) i: c(. Min - cu: find an - cu of minimum capaciy. u S, v T Capaciy = Cu An - cu i a node pariion (S, T).. S, T. The capaciy of an - cu (S, T) i: c(. u S, v T Min - cu: find an - cu of minimum capaciy. Capaciy Recall he example Value = Capaciy =
and Cu Lemma. Le f be a ne flow, and le (S, T) be a cu. Then, he ne flow en acro he cu i equal o he amoun reaching. and Cu Lemma. Le f be a flow, and le (S, T) be a cu. Then, he ne flow en acro he cu i equal o he amoun reaching. Value = Value = and Cu Lemma. Le f be a flow, and le (S, T) be a cu. Then, he ne flow en acro he cu i equal o he amoun reaching. Value = Proof of he Lemma For any flow f, he flow acro any cu (S, T) i he flow value f, i.e. f (S, T) = f = f (, V). Proof: f (S, T) = f (S, V S) = f (S, V) f (S, S) = f (, V) + f (S-, V) = f. (lemma ) (flow conervaion) Proof by Mah Inducion For any flow f, he flow acro any cu (S, T) i he flow value f, i.e. f (S, T) = f = f (,V). Proof: by inducion on S. Bae cae: S = { }. Inducive hypohei: aume rue for S < k. conider cu (S, T) wih S = k S = S' { v } for ome v,, S' = k- f(s', T') = f. adding v o S', change o he f? and Cu Lemma. f i a flow & (S, T) i a cu. Then f c(s, T). Proof. f = f ( S, T ) = u S v T u S v T f ( c( = c( S, T ) S T v v Corollary. Le f be a flow, and le (S, T) be a cu. If f = c(s, T), hen f i a max flow and (S, T) i a min cu. S' Before S Afer
Max and Min Cu Corollary. Le f be a flow, and le (S, T) be a cu. If f = c(s, T), hen f i a max flow and (S, T) i a min cu. Max and Min Cu Corollary. Le f be a flow, and le (S, T) be a cu. If f = c(s, T), hen f i a max flow and (S, T) i a min cu. Cu capaciy = value = Cu capaciy = value = Summary Lemma. Le f be a flow, and le (S, T) be a cu. Then, he ne flow en acro he cu i equal o he amoun reaching. Lemma. f i a flow & (S, T) i a cu. Then f c(s, T). Corollary. Le f be a flow, and le (S, T) be a cu. If f = c(s, T), hen f i a max flow and (S, T) i a min cu. Conen Maximum flow problem. Minimum cu problem. Max-flow min-cu heorem. Augmening pah algorihm. Capaciy-caling. Shore augmening pah. Max- Min-Cu Theorem MAX-FLOW MIN-CUT THEOREM (Ford-Fulkeron, Fulkeron, ): In any nework, he value of he max flow i equal o he value of he min cu. Proof:? Cu capaciy = value = Toward an Algorihm Find an - pah where each edge e=( ha c(e) > f(e) and "augmen" flow along he pah. value =
Toward an Algorihm Find an - pah where each arc e=( ha c(e) > f(e) and "augmen" flow along he pah. Repea unil you ge uck. The A Greedy deign Algorihm of hi algorihm? value = Toward an Algorihm Find an - pah where each arc ha u(e) > f(e) and "augmen" flow along he pah. Repea unil you ge uck. The raigh forward greedy algorihm fail. value = value = Reidual Nework Le f be a flow on G = (V, E). The reidual nework G f = (V, E f ) i he graph wih ricly poiive reidual capaciie: c f ( = c( f ( >, (where f ( >) E f = {( V V V c f (>}. G f conain edge of G ha can admi more ne flow. (G f G G T, where G T ha G edge in revere.) Original graph G = (V, E). f(. u Arc e = ( E. Reidual Arc Capaciy v flow nework and flow f reidual nework Reidual graph: G = (V, E f f ). Reidual arc e = ( and e R = (. "Undo" flow en. u Reidual capaciy v Reidual capaciy Reidual Graph & Augmening Pah Reidual graph: G = (V, E f f ). Augmening Pah Augmening pah = pah in reidual graph. G G G f G f
Relaion beween flow on G & G f Lemma: Le f be a flow on G=(V,E), f be a flow on he reidual nework G f of G. Then he flow um (f +f )( f (+f ( i a flow on G and f +f = f + f. Proof: f +f i a flow on G (flow conervaion, capaciy conrain, kew ymmery) f +f = f + f f + f ' = = ( f + f ')(, f (, + = f + f '. f '(, Augmening Pah Augmening pah = pah in reidual graph. Max flow no augmening pah??? G G f value = Max- Min-Cu Theorem Augmening pah heorem (Ford-Fulkeron, Fulkeron, ): A flow f i a max flow if and only if here are no augmening pah. MAX-FLOW MIN-CUT THEOREM (Ford-Fulkeron, Fulkeron, ): he value of he max flow i equal o he value of he min cu. We prove boh heorem imulaneouly by howing he TFAE: (i) f i a max flow. (ii) There i no augmening pah relaive o f. (iii) There exi a cu (S, T) uch ha f = c(s, T). Proof We prove boh imulaneouly by howing he TFAE: (i) f i a max flow. (ii) There i no augmening pah relaive o f. (iii) There exi a cu (S, T) uch ha f = c(s, T). (i) (ii) Le f be a flow. If here exi an augmening pah, hen we can improve f by ending flow along pah. (proof by conradicion) (iii) (i) Thi wa he Corollary o Lemma. Proof (ii) (iii) Le f be a flow wih no augmening pah. Le S be e of verice reachable from in reidual graph. Le T=V S. I T.? (clearly S, and S by definiion of f, o.w. augmening pah) For each u S, v T, f ( = c(.? (o.w. c f (=c( f (>, hen v S). Therefore:? f = f (S,T) = c(s,t). S T Reidual Nework Ford-Fulkeron Fulkeron algorihm Le G=(V, E) be a flow nework. Ford-Fulkeron(G,,,c) for each edge ( in E do Θ(E) f( f( while here exi a pah p from o in reidual do nework G f c f = min{c f (: ( i in p} for each edge ( in p do f( f( + c f f( -f( reurn f Θ(E) Co? Θ(? ) Θ(V+E) deph fir earch or breadh fir earch
Performance If capaciie are ineger, O( E f * ), f * i max flow found by he algorihm (no a polynomial algorihm). Performance Example: Original nework and flow Reidual nework Maximum flow: Performance Ne flow:. ieraion poible. Performance For nonineger capaciie, migh never erminae. Need more efficien algorihm (Edmond-Karp, ): Augmen along breadh-fir augmening pah in G f (hore pah) Augmen along max-capaciy augmening pah in G f (capaciy-caling) BFS for Shore Pah Edmond-Karp Algorihm S S Finihed Dicovered Undicovered Daa rucure for BFS? S Take only wo ieraion.
Shore Augmening Pah Inuiion: chooing pah via breadh fir earch. Eay o implemen. may implemen by coincidence! Find augmening pah wih fewe number of arc. ShoreAugmeningPah(V, E,, ) FOREACH e E f(e) G f reidual graph WHILE (here exi augmening pah) //find uch a pah P by BFS f augmen(f, P) updae G f RETURN f Co? Shore Augmening Pah: Overview of Analyi Lemma.. Throughou he algorihm, he lengh of he hore pah increae. Proof ahead. Lemma.. Afer a mo E hore pah augmenaion, he lengh of he hore augmening pah increae monaonically. Proof ahead. Theorem.. The hore augmening pah algorihm run in O( V E ) ime. O( V + E ) ime o find a hore augmening pah via BFS. O( E ) augmening pah of le han V edge. (If here i an augmening pah, i mu be a imple one.) O( V E ) augmenaion. O(( V + E )*( V E )) = O( V E ) running ime. Shore Augmening Pah: Analyi Level graph of (V, E, ). For each verex define ( o be he lengh (number of edge) of hore pah from o v. L G = (V, E G ) i ubgraph of G ha conain only hoe edge ( w) E wih (w) = ( +. Shore Augmening Pah: Analyi Level graph of (V, E, ). For each verex define ( o be he lengh of hore pah from o v. L = L G = (V, F) i ubgraph of G ha conain only hoe edge (w) E wih (w) = ( +. Compue in O( V + E ) ime uing BFS, deleing back and ide edge. P i a hore -v pah in G if and only if i i an -v pah in L. G: L: L G : = = = = = = = = Shore Augmening Pah: Analyi Lemma. he lengh of he hore pah increae. Le f and f' be flow before and afer a hore pah augmenaion. Le L and L' be level graph of reidual nework G f and G f ' Only back edge added o G f ' pah wih back edge ha lengh greaer han previou lengh L = = = = L' Shore Augmening Pah: Analyi Lemma. Afer a mo E hore pah augmenaion, he lengh of he hore augmening pah ricly increae. A lea one edge (he boleneck edge) i deleed from L afer each augmenaion. No new edge added o L unil lengh of hore pah o ricly increae. L L' = = = = Lengh= Lengh=
Shore Augmening Pah: Review of Analyi Theorem.. The hore augmening pah algorihm run in O( V E ) ime. O( V + E ) ime o find a hore augmening pah via BFS. O( E ) augmening pah of le han V edge. (If here i an augmening pah, i mu be a imple one.) O( V E ) augmenaion. O(( V + E )*( V E )) = O( V E ) running ime. More rigorou proof i given in our exbook. Oher approache: Augmen along max-capaciy augmening pah in G f (capaciy-caling) Capaciy Scaling Inuiion: chooing pah wih highe boleneck capaciy increae flow by max poible amoun. In pracice, don' worry abou finding exac highe boleneck pah. Mainain caling parameer. Le G f ( ) be he ubgraph of he reidual graph coniing of only arc wih capaciy a lea. G f G f () Capaciy Scaling Aumpion: all capaciie are ineger beween & U. Chooing Good Augmening Pah: Summary ScalingMax(V, E,, ) FOREACH e E, f(e) (malle power of greaer han or equal o U)/ WHILE ( ) G f ( ) -reidual graph WHILE (here exi augmening pah P in G f ( )) f augmen(f, P) updae G f ( ) / RETURN f Theorem. The algorihm run in O( E log (U) ) ime. Mehod Augmenaion Running ime Augmening pah V U E V U Max capaciy E log U E log U ( E + V log V ) Capaciy caling E log U E log U Improved capaciy caling E log U E V log U Shore pah E V E V Improved hore pah E V E V Fir rule aume edge capaciie are beween and U. Year... Dicoverer Danzig Hiory Mehod Simplex Big-Oh E V U Ford, Fulkeron Augmening pah E V U Edmond-Karp Shore pah E V Diniz Shore pah E V Edmond-Karp, Diniz Capaciy caling E log U Diniz-Gabow Capaciy caling E V log U Karzanov Preflow-puh V Sleaor-Tarjan Dynamic ree E V log V Goldberg-Tarjan FIFO preflow-puh E V log ( V / E )......... Goldberg-Rao Lengh funcion E / log ( V / E ) log U E V / log ( V / E ) log U
Nework wih muliple ource and ink a c e k f g h Can be reduced o a ingle ource & ingle ink max problem b d b d b d Maximum biparie maching Biparie graph G=(V,E): Undireced V = V V, V V =. e=( E, u V and Complee biparie: u V, u i joined wih every v V Maching: e of edge wih no verex included wice Maximum maching: a maching of maximum cardinaliy i.e. no maching conain more edge Applicaion Daing aignmen L women,, R men. An edge beween verice: hey have a chance o be compaible (can be mached) Job placemen Companie make job offer Suden have job choice An edge beween verice: he uden can fi he job Example Problem: Given N men and M women, find a maching beween men and women. Paricipan li member of oppoie ex hey like o dae. Men Preference Li Man nd rd Vicor Diana Amy Wya Diane Berha Amy Xavier Amy Erika Clare Yancey Amy Diane Clare Zeu Amy Diane Can we find a perfec mach? Wha i he max mach? Problem: Job placemen Example Suden Preference Li Suden nd rd Alice Apple Dell HP Bob Apple Dell Google Carol HP IBM Sun Dave Apple Dell Eliza IBM Sun Google Frank HP Sun Google Maximum biparie maching How can we reformulae hi problem o become a max-flow problem? Can we find a perfec mach? Wha i he max mach?
Maximum biparie maching How can we reformulae hi problem o become a max-flow problem? Keep all edge & verice Add ource conneced o all verice in one e Add ink conneced o all verice in anoher e Se all capaciie o A B C D E Maching A D H I S Soluion Suden nd rd Theorem: : The e of edge in he maxflow oluion give he oluion o he maximum maching problem. Proof homework F G Alice Bob Carol Dave Eliza Apple Dell IBM Sun HP Frank Google Lemma Lemma : Le G=(V,E), V = V V, V V =. Le G =(V,E ), V = V {,}, E =. flow nework Then: If M i a maching, hen here i an ineger valued flow f on G wih f = M. If f i an ineger valued flow on G, hen here i a maching M on G wih cardinaliy M = f Proof: M f,.. f = M If ( M, define: f(,=f(=f()=; f()=f(=f(,=-; ( ( M, f(=, hen f i a flow and f = M? (kew ymmery, capaciy conrain, flow conervaion) f M,.. M = f ince f i an ineger valued flow, f(= or. M =f(v, V ) = f Inegraliy Theorem Inegraliy Theorem: : If he capaciy of a flow nework i an ineger funcion, maximum flow f produced by Ford-Fulkeron Fulkeron mehod i an ineger-valued flow. Proof: homework Corollary: : If M i he cardinaliy of a maximum maching M, hen he value of a maximum flow f = M. Proof:? Show conrapoiive. uppoe M i a max maching and f i no a max flow, i.e. f,.. f > f Then M,.. M = f > f = M = M Conradicing our aumpion ha M i a maximum maching.