Mximum Flow Chper 26 Flow Grph A ommon enrio i o ue grph o repreen flow nework nd ue i o nwer queion ou meril flow Flow i he re h meril move hrough he nework Eh direed edge i ondui for he meril wih ome ed piy Verie re onneion poin u do no olle meril Flow ino verex mu equl he flow leving he verex, flow onervion 1
Smple Nework Nework Node Ar Flow ommuniion elephone exhnge, ompuer, ellie le, fier opi, mirowve rely voie, video, pke irui ge, regier, proeor wire urren mehnil join rod, em, pring he, energy hydruli reervoir, pumping ion, lke pipeline fluid, oil finnil ok, ompnie rnion money rnporion irpor, ril yrd, ree inereion highwy, riled, irwy roue freigh, vehile, penger hemil ie ond energy Flow Conep Soure verex where meril i produed Sink verex where meril i onumed For ll oher verie wh goe in mu go ou Flow onervion Gol: deermine mximum re of meril flow from oure o ink 2
Forml Mx Flow Prolem Grph G=(V,E) flow nework Direed, eh edge h piy (u,v) 0 Two peil verie: oure, nd ink For ny oher verex v, here i ph v Flow funion f : V V R Cpiy onrin: For ll u, v V: f(u,v) (u,v) Skew ymmery: For ll u, v V: f(u,v) = f(v,u) Flow onervion: For ll u V {, }: 2/15 5/1 0/9 2/5 /19 3/3 v V v V f ( u, v) f ( u, V ) 0, or f ( v, u) f ( V, u) 0 Cnellion of flow We would like o void wo poiive flow in oppoie direion eween he me pir of verie Suh flow nel (mye prilly) eh oher due o kew ymmery 2/15 5/19 2/15 5/19 2/9 5/5 0/9 3/5 5/1 2/3 5/1 2/3 3
Mx Flow We wn o find flow of mximum vlue from he oure o he ink Denoed y f Luky Puk Diriuion Nework Mx Flow, f = 19 Or i i? Be we n do? Ford-Fulkeron mehod Conin everl lgorihm: Reidue nework Augmening ph Find ph p from o (ugmening ph), uh h here i ome vlue x > 0, nd for eh edge (u,v) in p we n dd x uni of flow f(u,v) + x (u,v) Augmening Ph? /15 8/ /19 2/ 9 5/5 6/1 8/11 d 3/3
Reidul Nework To find ugmening ph we n find ny ph in he reidul nework: Reidul piie: f (u,v) = (u,v) f(u,v) i.e. he ul piy minu he ne flow from u o v Ne flow my e negive Reidul nework: G f =(V,E f ), where E f = {(u,v) V V : f (u,v) > 0} Oervion edge in E f re eiher edge in E or heir reverl: E f 2 E Su-grph Wih (u,v) nd f(u,v) 5/15 0/1 5/6 Reidul Su-Grph 19 5 1 Reidul Grph Compue he reidul grph of he grph wih he following flow: /15 2/ 8/ 9 5/5 /19 6/1 8/11 d 3/3 5
Reidul Cpiy nd Augmening Ph Finding n Augmening Ph Find ph from o in he reidul grph The reidul piy of ph p in G f : f (p) = min{ f (u,v): (u,v) i in p} i.e. find he minimum piy long p Doing ugmenion: for ll (u,v) in p, we ju dd hi f (p) o f(u,v) (nd ur i from f(v,u)) Reuling flow i vlid flow wih lrger vlue. Reidul nework nd ugmening ph 6
The Ford-Fulkeron mehod Ford-Fulkeron(G,,) 1 for eh edge (u,v) in G.E do 2 f(u,v) f(v,u) 0 3 while here exi ph p from o in reidul nework G f do f = min{ f (u,v): (u,v) i in p} 5 for eh edge (u,v) in p do 6 f(u,v) f(u,v) + f 7 f(v,u) -f(u,v) 8 reurn f The lgorihm ed on hi mehod differ in how hey hooe p in ep 3. If hoen poorly he lgorihm migh no ermine. Exeuion of Ford-Fulkeron (1) Lef Side = Reidul Grph Righ Side = Augmened Flow 7
Exeuion of Ford-Fulkeron (2) Lef Side = Reidul Grph Righ Side = Augmened Flow Cu Doe he mehod find he minimum flow? Ye, if we ge o he poin where he reidul grph h no ph from o A u i priion of V ino S nd T = V S, uh h S nd T The ne flow (f(s,t)) hrough he u i he um of flow f(u,v), where S nd T Inlude negive flow k from T o S The piy ((S,T)) of he u i he um of piie (u,v), where S nd T The um of poiive piie Minimum u u wih he mlle piy of ll u. f = f(s,t) i.e. he vlue of mx flow i equl o he piy of min u. /15 6/1 2/ 8/ 8/11 9 5/5 /19 3/3 Cu piy = 2 Min Cu piy = 21 d 8
Mx Flow / Min Cu Theorem 1. Sine f (S,T) for ll u of (S,T) hen if f = (S,T) hen (S,T) mu e he min u of G 2. Thi implie h f i mximum flow of G 3. Thi implie h he reidul nework G f onin no ugmening ph. If here were ugmening ph hi would onrdi h we found he mximum flow of G 1 2 3 1 nd from 2 3 we hve h he Ford Fulkeron mehod find he mximum flow if he reidul grph h no ugmening ph. Wor Ce Running Time Auming ineger flow Eh ugmenion inree he vlue of he flow y ome poiive moun. Augmenion n e done in O(E). Tol wor-e running ime O(E f* ), where f* i he mx-flow found y he lgorihm. Exmple of wor e: Augmening ph of 1 Reuling Reidul Nework Reuling Reidul Nework 9
Edmond Krp Tke hore ph (in erm of numer of edge) n ugmening ph Edmond-Krp lgorihm How do we find uh hore ph? Running ime O(VE 2 ), eue he numer of ugmenion i O(VE) Skipping he proof here Even eer mehod: puh-relel, O(V 2 E) runime Muliple Soure or Sink Wh if you hve prolem wih more hn one oure nd more hn one ink? Modify he grph o ree ingle uperoure nd uperink x 15 1 15 1 e g 11 11 9 5 d f 9 5 h 3 3 y i j 15 1 15 1 e g 11 11 9 5 d f 9 5 h 3 3 k l
Appliion Biprie Mhing Exmple given ommuniy wih n men nd m women Aume we hve wy o deermine whih ouple (mn/womn) re ompile for mrrige E.g. (Joe, Sun) or (Fred, Sun) u no (Frnk, Sun) Prolem: Mximize he numer of mrrige No polygmy llowed Cn olve hi prolem y reing flow nework ou of iprie grph Biprie Grph A iprie grph i n undireed grph G=(V,E) in whih V n e priioned ino wo e V 1 nd V 2 uh h (u,v) E implie eiher u V 1 nd v V 12 or vie ver. Th i, ll edge go eween he wo e V 1 nd V 2 nd no wihin V 1 nd V 2. 11
Model for Mhing Prolem Men on lefmo e, women on righmo e, edge if hey re ompile A B C D Men X Y Z Women A B C D A mhing X Y Z A X B Y C Z D Opiml mhing Soluion Uing Mx Flow Add uperoue, uperink, mke eh undireed edge direed wih flow of 1 A X A X B C D Y Z B C D Y Z Sine he inpu i 1, flow onervion preven muliple mhing 12