Maximum Flow and Minimum u Max Flow, Min u Max flow and min cu. Two very rich algorihmic problem. ornerone problem in combinaorial opimizaion. eauiful mahemaical dualiy. Minimum cu Maximum flow Max-flow min-cu heorem Ford-Fulkeron augmening pah algorihm dmond-karp heuriic iparie maching Nonrivial applicaion / reducion. Nework conneciviy. iparie maching. aa mining. Open-pi mining. irline cheduling. Image proceing. Projec elecion. aeball eliminaion. Nework reliabiliy. ecuriy of aiical daa. iribued compuing. galiarian able maching. iribued compuing. Many many more... Princeon Univeriy O lgorihm and aa rucure pring Kevin Wayne hp://www.princeon.u/~co ovie Rail Nework, Minimum u Problem Nework: abracion for maerial FLOWING hrough he edge. ireced graph. apaciie on edge. ource node, ink node. Min cu problem. elee "be" e of edge o diconnec from. ource ink capaciy ource: On he hiory of he ranporaion and maximum flow problem. lexander chrijver in Mah Programming, :,.
u u cu i a node pariion (, T) uch ha i in and i in T. capaciy(, T) = um of weigh of edge leaving. cu i a node pariion (, T) uch ha i in and i in T. capaciy(, T) = um of weigh of edge leaving. apaciy = apaciy = Minimum u Problem Maximum Flow Problem cu i a node pariion (, T) uch ha i in and i in T. capaciy(, T) = um of weigh of edge leaving. Min cu problem. Find an - cu of minimum capaciy. Nework: abracion for maerial FLOWING hrough he edge. ireced graph. ame inpu a min cu problem apaciie on edge. ource node, ink node. Max flow problem. ign flow o edge o a o: qualize inflow and ouflow a every inermediae verex. Maximize flow en from o. ource capaciy ink apaciy =
Flow Flow flow f i an aignmen of weigh o edge o ha: apaciy: f(e) u(e). Flow conervaion: flow leaving v = flow enering v. excep a or flow f i an aignmen of weigh o edge o ha: apaciy: f(e) u(e). Flow conervaion: flow leaving v = flow enering v. excep a or capaciy flow Value = capaciy flow Value = Maximum Flow Problem Flow and u Max flow problem: find flow ha maximize ne flow ino ink. Obervaion. Le f be a flow, and le (, T) be any - cu. Then, he ne flow en acro he cu i equal o he amoun reaching. capaciy flow Value = Value =
Flow and u Flow and u Obervaion. Le f be a flow, and le (, T) be any - cu. Then, he ne flow en acro he cu i equal o he amoun reaching. Obervaion. Le f be a flow, and le (, T) be any - cu. Then, he ne flow en acro he cu i equal o he amoun reaching. Value = Value = Flow and u Max Flow and Min u Obervaion. Le f be a flow, and le (, T) be any - cu. Then he value of he flow i a mo he capaciy of he cu. Obervaion. Le f be a flow, and le (, T) be an - cu whoe capaciy equal he value of f. Then f i a max flow and (, T) i a min cu. u capaciy = Flow value u capaciy = Flow value Flow value =
Max-Flow Min-u Theorem Toward an lgorihm Max-flow min-cu heorem. (Ford-Fulkeron, ): In any nework, he value of max flow equal capaciy of min cu. Proof IOU: we find flow and cu uch ha Obervaion applie. Find - pah where each arc ha f(e) < u(e) and "augmen" flow along i. Min cu capaciy = Max flow value = flow Flow value = capaciy Toward an lgorihm Toward an lgorihm Find - pah where each arc ha f(e) < u(e) and "augmen" flow along i. Greedy algorihm: repea unil you ge uck. Find - pah where each arc ha f(e) < u(e) and "augmen" flow along i. Greedy algorihm: repea unil you ge uck. Fail: need o be able o "backrack." flow Flow value = flow Flow value = capaciy X X X capaciy X X X oleneck capaciy of pah = Flow value =
Reidual Graph ugmening Pah Original graph. Flow f(e). dge e = v-w v flow = f(e) capaciy = u(e) w ugmening pah = pah in reidual graph. Increae flow along forward edge. ecreae flow along backward edge. Reidual edge. dge e = v-w or w-v. "Undo" flow en. Reidual graph. ll he edge ha have ricly poiive reidual capaciy. v reidual capaciy = u(e) f(e) w reidual capaciy = f(e) reidual original X X X X X ugmening Pah Ford-Fulkeron ugmening Pah lgorihm Obervaion. If augmening pah, hen no ye a max flow. Q. If no augmening pah, i i a max flow? Ford-Fulkeron algorihm. Generic mehod for olving max flow. reidual while (here exi an augmening pah) { Find augmening pah P ompue boleneck capaciy of P ugmen flow along P original Flow value = X X X X X Queion. oe hi lead o a maximum flow? ye How do we find an augmening pah? - pah in reidual graph How many augmening pah doe i ake? How much effor do we pending finding a pah?
Max-Flow Min-u Theorem Proof of Max-Flow Min-u Theorem ugmening pah heorem. flow f i a max flow if and only if here are no augmening pah. Max-flow min-cu heorem. The value of he max flow i equal o he capaciy of he min cu. We prove boh imulaneouly by howing he following are equivalen: (i) f i a max flow. (ii) There i no augmening pah relaive o f. (iii) There exi a cu whoe capaciy equal he value of f. (i) (ii) equivalen o no (ii) no (i), which wa Obervaion (ii) (iii) nex lide (iii) (i) hi wa Obervaion (ii) (iii). If here i no augmening pah relaive o f, hen here exi a cu whoe capaciy equal he value of f. Proof. Le f be a flow wih no augmening pah. Le be e of verice reachable from in reidual graph. conain ; ince no augmening pah, doe no conain all edge e leaving in original nework have f(e) = u(e) all edge e enering in original nework have f(e) = f e ou of e ou of f ( e) u( e) capaciy (, T) e in o f ( e) T reidual nework Max Flow Nework Implemenaion Ford-Fulkeron lgorihm: Implemenaion dge in original graph may correpond o or reidual edge. May need o ravere edge e = v-w in forward or revere direcion. Flow = f(e), capaciy = u(e). Iner wo copie of each edge, one in adjacency li of v and one in w. Ford-Fulkeron main loop. // while here exi an augmening pah, ue i while (augpah()) { public cla dge { privae in v, w; privae in cap; privae in flow; // from, o // capaciy from v o w // flow from v o w public dge(in v, in w, in cap) {... public in cap() { reurn cap; public in flow() { reurn flow; public boolean from(in v) { reurn hi.v == v; public in oher(in v) { reurn from(v)? hi.w : hi.v; public in capro(in v) { reurn from(v)? flow : cap - flow; public void addflowro(in v, in d) { flow += from(v)? -d : d; // compue boleneck capaciy in bole = INFINITY; for (in v = ; v!= ; v = T(v)) bole = Mah.min(bole, pred[v].capro(v)); // augmen flow for (in v = ; v!= ; v = T(v)) pred[v].addflowro(v, bole); // keep rack of oal flow en from o value += bole;
Ford-Fulkeron lgorihm: nalyi hooing Good ugmening Pah umpion: all capaciie are ineger beween and U. Ue care when elecing augmening pah. Invarian: every flow value and every reidual capaciie remain an ineger hroughou he algorihm. Theorem: he algorihm erminae in a mo f * V U ieraion. orollary: if U =, hen algorihm run in V ieraion. no polynomial in inpu ize! Inegraliy heorem: if all arc capaciie are ineger, hen here exi a max flow f for which every flow value i an ineger. Original Nework hooing Good ugmening Pah hooing Good ugmening Pah Ue care when elecing augmening pah. Ue care when elecing augmening pah. X X X Original Nework Original Nework
hooing Good ugmening Pah hooing Good ugmening Pah Ue care when elecing augmening pah. Ue care when elecing augmening pah. X X X Original Nework Original Nework ieraion poible! hooing Good ugmening Pah hore ugmening Pah Ue care when elecing augmening pah. ome choice lead o exponenial algorihm. lever choice lead o polynomial algorihm. Opimal choice for real world problem??? eign goal i o chooe augmening pah o ha: an find augmening pah efficienly. Few ieraion. hooe augmening pah wih: dmond-karp () Fewe number of arc. (hore pah) Max boleneck capaciy. (fae pah) hore augmening pah. ay o implemen wih F. Find augmening pah wih fewe number of arc. while (!q.impy()) { in v = q.dequeue(); InIeraor i = G.neighbor(v); while(i.hanex()) { dge e = i.nex(); in w = e.oher(v); if (e.capro(w) > ) { // i v-w a reidual edge? if (w[w] > w[v] + ) { w[w] = w[v] + ; pred[w] = e; // keep rack of hore pah q.enqueue(w); reurn (w[] < INFINITY); // i here an augmening pah?
hore ugmening Pah nalyi Fae ugmening Pah Lengh of hore augmening pah increae monoonically. ricly increae afer a mo augmenaion. mo V oal augmening pah. O( V) running ime. Fae augmening pah. Find augmening pah whoe boleneck capaciy i maximum. eliver mo amoun of flow o ink. olve uing ijkra-yle (PF) algorihm. X v reidual capaciy w if (w[w] < Mah.min(w[v], e.capro(w)) { w[w] = Mah.min(w[v], e.capro(w)); pred[w] = v; Finding a fae pah. O( log V) per augmenaion wih binary heap. Fac. O( log U) augmenaion if capaciie are beween and U. hooing an ugmening Pah Hiory of Wor-ae Running Time hooing an augmening pah. ny pah will do wide laiude in implemening Ford-Fulkeron. Generic prioriy fir earch. ome choice lead o good wor-cae performance. hore augmening pah fae augmening pah variaion on a heme: PF verage cae no well underood. Reearch challenge. Pracice: olve max flow problem on real nework in linear ime. Theory: prove i for wor-cae nework. Year... icoverer Mehod ympoic Time anzig implex V U Ford, Fulkeron ugmening pah V U dmond-karp hore pah V dmond-karp Max capaciy log U ( + V log V) iniz Improved hore pah V dmond-karp, iniz apaciy caling log U iniz-gabow Improved capaciy caling V log U Karzanov Preflow-puh V leaor-tarjan ynamic ree V log V Goldberg-Tarjan FIFO preflow-puh V log (V / )......... Goldberg-Rao Lengh funcion / log (V / ) log U V / log (V / ) log U rc capaciie are beween and U.
n pplicaion iparie Maching Jon placemen. ompanie make job offer. uden have job choice. an we fill every job? iparie maching. Inpu: undireced and biparie graph G. e of edge M i a maching if each verex appear a mo once. Max maching: find a max cardinaliy maching. an we employ every uden? lice-dobe ob-yahoo arol-hp ave-pple liza-im Frank-un Maching M -, -, - L R iparie Maching iparie Maching iparie maching. Inpu: undireced and biparie graph G. e of edge M i a maching if each verex appear a mo once. Max maching: find a max cardinaliy maching. Reduce o max flow. reae a direced graph G'. irec all arc from L o R, and give infinie (or uni) capaciy. dd ource, and uni capaciy arc from o each node in L. dd ink, and uni capaciy arc from each node in R o. L R Maching M -, -, -, - L R G G'
iparie Maching: Proof of orrecne iparie Maching: Proof of orrecne laim. Maching in G of cardinaliy k induce flow in G' of value k. Given maching M = { -, -, - of cardinaliy. onider flow f ha end uni along each of pah: --- --- ---. f i a flow, and ha cardinaliy. laim. Flow f of value k in G' induce maching of cardinaliy k in G. y inegraliy heorem, here exi / valued flow f of value k. onider M = e of edge from L o R wih f(e) =. each node in L and R inciden o a mo one edge in M M = k L R L R G G' G G' Reducion Reducion. Given an inance of biparie maching. Tranform i o a max flow problem. olve max flow problem. Tranform max flow oluion o biparie maching oluion. Iue. How expenive i ranformaion? O( + V) I i beer o olve problem direcly? O( V / ) biparie maching oom line: max flow i an exremely rich problem-olving model. Many imporan pracical problem reduce o max flow. We know good algorihm for olving max flow problem.