Conen Maximum Flow Conen. Maximum low problem. Minimum cu problem. Max-low min-cu heorem. Augmening pah algorihm. Capaciy-caling. Shore augmening pah. Princeon Univeriy COS Theory o Algorihm Spring Kevin Wayne Maximum Flow and Minimum Cu Max Flow Nework Max low and min cu. Two very rich algorihmic problem. Cornerone problem in combinaorial opimizaion. Beauiul mahemaical dualiy. Max low nework: G (V, E,,, u). (V, E) direced graph, no parallel arc. Two diinguihed node: ource, ink. u( capaciy o arc e. Nonrivial applicaion / reducion. Nework conneciviy. Biparie maching. Daa mining. Open-pi mining. Airline cheduling. Image proceing. Projec elecion. Nework reliabiliy. Securiy o aiical daa. Diribued compuing. Egaliarian able maching. Diribued compuing. Many many more... Baeball eliminaion. Capaciy
Flow An - low i a uncion : E R ha aiie: For each e E: ( u( (capaciy) For each v V {, }: (conervaion) e in o v e ou o v Flow An - low i a uncion : E R ha aiie: For each e E: ( u( (capaciy) For each v V {, }: (conervaion) e in o v e ou o v e in o v : w :( w, v) E ( w, v) e ou o v : w :( v, w) E ( v, w) MAX FLOW: ind - low ha maximize ne low ou o he ource. e ou o Capaciy Flow Capaciy Flow Value Flow Flow An - low i a uncion : E R ha aiie: For each e E: ( u( (capaciy) For each v V {, }: (conervaion) e in o v e ou o v MAX FLOW: ind - low ha maximize ne low ou o he ource. An - low i a uncion : E R ha aiie: For each e E: ( u( (capaciy) For each v V {, }: (conervaion) e in o v e ou o v MAX FLOW: ind - low ha maximize ne low ou o he ource. Capaciy Flow Value Capaciy Flow Value
Nework communicaion circui Node Nework elephone exchange, compuer, aellie gae, regier, proceor Arc cable, iber opic, microwave relay wire Flow voice, video, packe curren mechanical join rod, beam, pring hea, energy hydraulic reervoir, pumping aion, lake pipeline luid, oil inancial ock, currency ranacion money ranporaion airpor, rail yard, ree inerecion highway, railbed, airway roue reigh, vehicle, paenger chemical ie bond energy Cu An - cu i a node pariion (S, T) uch ha S, T. The capaciy o an - cu (S, T) i: u( : u( v, w). e ou o S ( v, w ) E v S, w T Min - cu: ind an - cu o minimum capaciy. Capaciy Cu An - cu i a node pariion (S, T) uch ha S, T. The capaciy o an - cu (S, T) i: u( : u( v, w). e ou o S ( v, w ) v S E, w T Min - cu: ind an - cu o minimum capaciy. Cu An - cu i a node pariion (S, T) uch ha S, T. The capaciy o an - cu (S, T) i: u( : u( v, w). e ou o S ( v, w ) v S E, w T Min - cu: ind an - cu o minimum capaciy. Capaciy Capaciy
Flow and Cu L. Le be a low, and le (S, T) be a cu. Then, he ne low en acro he cu i equal o he amoun reaching. Flow and Cu L. Le be a low, and le (S, T) be a cu. Then, he ne low en acro he cu i equal o he amoun reaching. e ou o S e in o S e ou o e ou o S e in o S e ou o Value Value L. Le be a low, and le (S, T) be a cu. Then, he ne low en acro he cu i equal o he amoun reaching. e ou o S Flow and Cu e in o S e ou o Flow and Cu Le be a low, and le (S, T) be a cu. Then, S e in o S e ou o Proo by inducion on S. Bae cae: S { }. Inducive hypohei: aume rue or S < k. conider cu (S, T) wih S k S S { v } or ome v,, S k- cap(s, T ). adding v o S increae cu capaciy by e ou o v e in o v. v v Value S Beore S Aer
Flow and Cu Max Flow and Min Cu L. Le be a low, and le (S, T) be a cu. Then, cap(s, T). Proo. e ou o S e ou o S u( e ou o S cap(s, T) e in o S S T Corollary. Le be a low, and le (S, T) be a cu. I cap(s, T), hen i a max low and (S, T) i a min cu. Corollary. Le be a low, and le (S, T) be a cu. I cap(s, T), hen i a max low and (S, T) i a min cu. Cu capaciy Flow value Max-Flow Min-Cu Theorem MAX-FLOW MIN-CUT THEOREM (Ford-Fulkeron, ): In any nework, he value o he max low i equal o he value o he min cu. "Good characerizaion." Proo IOU. Toward an Algorihm Find an - pah where each arc ha u( > ( and "augmen" low along he pah. Cu capaciy Flow value Flow value
Toward an Algorihm Toward an Algorihm Find an - pah where each arc ha u( > ( and "augmen" low along he pah. Repea unil you ge uck. Find an - pah where each arc ha u( > ( and "augmen" low along he pah. Repea unil you ge uck. Greedy algorihm ail. X X X Flow value Flow value Flow value Reidual Arc Reidual Graph and Augmening Pah Original graph G (V, E). Flow (. Arc e (v, w) E. Capaciy Reidual graph: G (V, E ). E {e : ( < u(} {e R : ( > }. u ( u( ( i i e E R e E v w Reidual graph: G (V, E ). Reidual arc e (v, w) and e R (w, v). "Undo" low en. Flow G Reidual capaciy v w G Reidual capaciy
Augmening Pah Augmening pah pah in reidual graph. Augmening Pah Augmening pah pah in reidual graph. Max low no augmening pah??? G X X X X X G Flow value G G Max-Flow Min-Cu Theorem Proo o Max-Flow Min-Cu Theorem Augmening pah heorem (Ford-Fulkeron, ): A low i a max low i and only i here are no augmening pah. MAX-FLOW MIN-CUT THEOREM (Ford-Fulkeron, ): he value o he max low i equal o he value o he min cu. We prove boh imulaneouly by howing he TFAE: (i) i a max low. (ii) There i no augmening pah relaive o. (iii) There exi a cu (S, T) uch ha cap(s, T). We prove boh imulaneouly by howing he TFAE: (i) i a max low. (ii) There i no augmening pah relaive o. (iii) There exi a cu (S, T) uch ha cap(s, T). (i) (ii) We how conrapoiive. Le be a low. I here exi an augmening pah, hen we can improve by ending low along pah. (iii) (i) Nex lide. (iii) (i) Thi wa he Corollary o Lemma.
Proo o Max-Flow Min-Cu Theorem Augmening Pah Algorihm We prove boh imulaneouly by howing he TFAE: (i) i a max low. (ii) There i no augmening pah relaive o. (iii) There exi a cu (S, T) uch ha cap(s, T). (ii) (iii) Le be a low wih no augmening pah. Le S be e o verice reachable rom in reidual graph. clearly S, and S by deiniion o Augmen (, P) b boleneck(p) FOREACH e P IF (e E) // orward arc ( ( + b ELSE // backward arc (e R ) ( - b RETURN FordFulkeron (V, E,, ) e ou o e ou o u( S cap(s, T) S e in o S S Original Nework T FOREACH e E ( reidual graph G WHILE (here exi augmening pah P) augmen(, P) updae G RETURN Running Time Chooing Good Augmening Pah Aumpion: all capaciie are ineger beween and U. Ue care when elecing augmening pah. Invarian: every low value ( and every reidual capaciie u ( remain an ineger hroughou he algorihm. Theorem: he algorihm erminae in a mo * nu ieraion. Corollary: i U, hen algorihm run in O(mn) ime. Inegraliy heorem: i all arc capaciie are ineger, hen here exi a max low or which every low value ( i an ineger. Noe: algorihm may no erminae on ome pahological inance (wih irraional capacii. Moreover, low value may no even converge o correc anwer.
Chooing Good Augmening Pah Ue care when elecing augmening pah. Chooing Good Augmening Pah Ue care when elecing augmening pah. X X X Chooing Good Augmening Pah Ue care when elecing augmening pah. Chooing Good Augmening Pah Ue care when elecing augmening pah. X X X ieraion poible.
Chooing Good Augmening Pah Capaciy Scaling Ue care when elecing augmening pah. Some choice lead o exponenial algorihm. Clever choice lead o polynomial algorihm. Goal: chooe augmening pah o ha: Can ind augmening pah eicienly. Few ieraion. Inuiion: chooing pah wih highe boleneck capaciy increae low by max poible amoun. Don worry abou inding exac highe boleneck pah. Mainain caling parameer. Le G ( ) be he ubgraph o he reidual graph coniing o only arc wih capaciy a lea. Edmond-Karp (): chooe augmening pah wih Max boleneck capaciy. (a pah) Suicienly large capaciy. (capaciy-caling) Fewe number o arc. (hore pah) G G () Capaciy Scaling Capaciy Scaling: Analyi Inuiion: chooing pah wih highe boleneck capaciy increae low by max poible amoun. Don worry abou inding exac highe boleneck pah. Mainain caling parameer. Le G ( ) be he ubgraph o he reidual graph coniing o only arc wih capaciy a lea. ScalingMaxFlow(V, E,, ) FOREACH e E, ( malle power o greaer han or equal o U WHILE ( ) G ( ) -reidual graph WHILE (here exi augmening pah P in G ( )) augmen(, P) updae G ( ) / RETURN L. I all arc capaciie are ineger, hen hroughou he algorihm, all low and reidual capaciy value remain ineger. Thu, G ( ) G, o upon erminaion i a max low. L. The ouer while loop repea + log U ime. Iniially U <U, and decreae by a acor o each ieraion. L. Le be he low a he end o a -caling phae. Then value o he maximum low i a mo + m. L. There are a mo m augmenaion per caling phae. Le be he low a he end o he previou caling phae. L * + m ( ). Each augmenaion in a -phae increae by a lea. Theorem. The algorihm run in O(m log (U) ) ime.
Capaciy Scaling: Analyi L. Le be he low a he end o a -caling phae. Then value o he maximum low i a mo + m. We how ha a he end o a -phae, here exi a cu (S, T) uch ha cap(s, T) + m. Chooe S o be he e o node reachable rom in G ( ). clearly S, and S by deiniion o S e ou o S e ou o S e ou o S cap(s, T) ( u( ) u( - e in o S m e in o S e ou o S e in o S S Original Nework T Chooing Good Augmening Pah Ue care when elecing augmening pah. Some choice lead o exponenial algorihm. Clever choice lead o polynomial algorihm. Goal: chooe augmening pah o ha: Can ind augmening pah eicienly. Few ieraion. Edmond-Karp (): chooe augmening pah wih Max boleneck capaciy. (a pah) Suicienly large capaciy. (capaciy-caling) Fewe number o arc. (hore pah) Shore Augmening Pah Inuiion: chooing pah via breadh ir earch. Eay o implemen. may implemen by coincidence! Find augmening pah wih ewe number o arc. FOREACH e E ( reidual graph G ShoreAugmeningPah(V, E,, ) WHILE (here exi augmening pah) ind uch a pah P by BFS augmen(, P) updae G RETURN Shore Augmening Pah: Overview o Analyi L. Throughou he algorihm, he lengh o he hore pah never decreae. Proo ahead. L. Aer a mo m hore pah augmenaion, he lengh o he hore augmening pah ricly increae. Proo ahead. Theorem. The hore augmening pah algorihm run in O(m n) ime. O(m+n) ime o ind hore augmening pah via BFS. O(m) augmenaion or pah o exacly k arc. I here i an augmening pah, here i a imple one. k < n O(mn) augmenaion.
Shore Augmening Pah: Analyi Shore Augmening Pah: Analyi Level graph o (V, E, ). For each verex v, deine l(v) o be he lengh (number o arc) o hore pah rom o v. L G (V, E G ) i ubgraph o G ha conain only hoe arc (v,w) E wih l(w) l(v) +. G: Level graph o (V, E, ). For each verex v, deine l(v) o be he lengh (number o arc) o hore pah rom o v. L (V, F) i ubgraph o G ha conain only hoe arc (v,w) E wih l(w) l(v) +. Compue in O(m+n) ime uing BFS, deleing back and ide arc. P i a hore -v pah in G i and only i i i an -v pah L. L: L G : l l l l l l l l Shore Augmening Pah: Analyi Shore Augmening Pah: Analyi L. Throughou he algorihm, he lengh o he hore pah never decreae. L. Aer a mo m hore pah augmenaion, he lengh o he hore augmening pah ricly increae. Le and be low beore and aer a hore pah augmenaion. Le L and L be level graph o G and G Only back arc added o G pah wih back arc ha lengh greaer han previou lengh A lea one arc (he boleneck arc) i deleed rom L aer each augmenaion. No new arc added o L unil lengh o hore pah ricly increae. L L l l l l l l l l L L
Shore Augmening Pah: Review o Analyi Shore Augmening Pah: Improved Verion L. Throughou he algorihm, he lengh o he hore pah never decreae. L. Aer a mo m hore pah augmenaion, he lengh o he hore augmening pah ricly increae. Theorem. The hore augmening pah algorihm run in O(m n) ime. O(m+n) ime o ind hore augmening pah via BFS. O(m) augmenaion or pah o exacly k arc. O(mn) augmenaion. Two ype o augmenaion. Normal augmenaion: lengh o hore pah doen change. Special augmenaion: lengh o hore pah ricly increae. L. Group o normal augmenaion ake O(mn) ime. Explicily mainain level graph - i change by a mo n arc aer each normal augmenaion. Sar a, advance along an arc in L G unil reach or ge uck. i reach, augmen and delee a lea one arc i ge uck, delee node Noe: Θ(mn) augmenaion neceary on ome nework. Try o decreae ime per augmenaion inead. L G Dynamic ree O(mn log n) Sleaor-Tarjan, Simple idea O(mn ) l l l l Shore Augmening Pah: Improved Verion Shore Augmening Pah: Improved Verion L G augmen L G augmen L G delee L G L G augmen STOP: lengh o hore pah mu have ricly increaed
Shore Augmening Pah: Improved Verion Shore Augmening Pah: Improved Verion ARRAY pred[v V] L G level graph o G v, pred[v] nil REPEAT WHILE (here exi (v,w) L G ) pred[w] v, v w IF (v ) P pah deined by pred[] augmen(, P) updae L G v, pred[v] nil delee v rom L G UNTIL (v ) RETURN AdvanceRerea(V, E,,, ) advance augmen rerea Two ype o augmenaion. Normal augmenaion: lengh o hore pah doen change. Special augmenaion: lengh o hore pah ricly increae. L. Group o normal augmenaion ake O(mn) ime. Explicily mainain level graph - i change by a mo n arc aer each normal augmenaion. Sar a, advance along an arc in L G unil reach or ge uck. i reach, augmen and delee a lea one arc i ge uck, delee node a mo n advance ep beore one o above even Theorem. Algorihm run in O(mn ) ime. O(mn) ime beween pecial augmenaion. A mo n pecial augmenaion. Chooing Good Augmening Pah: Summary Hiory Mehod Augmenaion Running ime Augmening pah nu mnu Max capaciy m log U m log U (m + n log n) Capaciy caling m log U m log U Improved capaciy caling m log U mn log U Shore pah mn m n Improved hore pah mn mn Fir rule aume arc capaciie are beween and U. Year... Dicoverer Mehod Big-Oh Danzig Simplex mn U Ford, Fulkeron Augmening pah mnu Edmond-Karp Shore pah m n Diniz Shore pah mn Edmond-Karp, Diniz Capaciy caling m log U Diniz-Gabow Capaciy caling mn log U Karzanov Prelow-puh n Sleaor-Tarjan Dynamic ree mn log n Goldberg-Tarjan FIFO prelow-puh mn log (n / m)......... Goldberg-Rao Lengh uncion m / log (n / m) log U mn / log (n / m) log U