Grue Algorihm CS673-2016F-18 Flow Nework Dvi Glle Deprmen of Compuer Siene Univeriy of Sn Frnio
18-0: Flow Nework Diree Grph G Eh ege weigh i piy Amoun of wer/eon h n flow hrough pipe, for inne Single oure S, ingle ink Clule mximum flow hrough grph
18-1: Flow Nework Flow: Funion: V V R Flow from eh verex o every oher verex f(u,v) i he ire flow from u o v Properie: u,v V,f(u,v) (u,v) u,v V,f(u,v) = f(v,u) u V {,}, v V f(u,v) = 0 Tol flow, f = v V f(,v) = v V f(v,)
18-2: Flow Nework Single Soure / Single Sink Aume h here i lwy ingle oure n ingle ink Don lo ny expreive power lwy rnform prolem wih muliple oure n muliple ink o n equivlen prolem wih ingle oure n ingle ink How?
18-3: Flow Nework Exmple: Shipping prou o wrehoue Prou proue fory, pu in re Cre re hippe o wrehoue To u own o, ue exr pe in oher people ruk How muh prou n e proue per y?
18-4: Flow Nework 16 Chigo 12 New York 20 L.A. 4 10 9 7 New Jerey 13 Dll 14 Piurgh 4
18-5: Flow Nework I woul e lile illy o hip 4 re from Dll o Chigo, n 7 re from Chigo o Dll Coul ju hip 3 re from Chigo o Dll ine We will ume h here i only every flow in one ireion Flow in he oppoie ireion nel ou
18-6: Flow Nework 11/16 Chigo 12/12 New York 15/20 L.A. 1/4 0/10 4/9 7/7 New Jerey 8/13 Dll I hi flow opiml? Piurgh 11/14 4/4
18-7: Flow Nework 11/16 Chigo 12/12 New York 19/20 L.A. 1/4 0/10 0/9 7/7 New Jerey 12/13 Dll Piurgh 11/14 4/4
18-8: Flow Nework Negive flow I i perfely legl for here o e negive flow from v o u Negive flow from v o u ju men h here i poiive flow from u o v Rell h he ol flow over ll ege inien o verex mu e zero, exep for oure & ink
18-9: Flow Nework Reiul piy f (u,v) i he reiul piy of ege (u,v) f (u,v) = (u,v) f(u,v) Noe h i i poile for he reiul piy of n ege o e greer hn he ol piy Cnelling flow in he oppoie ireion
18-10: Flow Nework Reiul Nework Given e of piie, n e of urren flow, we n ree reiul nework Reiul nework n hve ifferen ege hn he piy nework
18-11: Flow Nework 5 6 8 3 3 2 6 4 1 5
18-12: Flow Nework 3/5 0/3 3/6 2/8 1/3 2/2 0/6 1/4 0/1 2/5
18-13: Flow Nework 3/5 0/3 3/6 2/8 1/3 2/2 0/6 1/4 0/1 2/5 3 3 3 2 2 6 1 3 2 1 1 8 3 2
18-14: Flow Nework Given flow nework, wih ome flow lule Inue reiul nework There i ph from oure o ink in he reiul nework uh h: All reiul piie long he ph re > 0 How n we inree he ol flow?
18-15: Augmening Ph An Augmening ph in flow nework i ph hrough he nework uh h ll reiul piie long he ph > 0 Given flow nework n n ugmening ph, we n inree he ol flow y he mlle reiul piy long he ph Inree flow long ph y mlle reiul piy long he ph My involve ome flow nelling
18-16: Augmening Ph 3/5 0/3 3/6 2/8 1/3 2/2 0/6 1/4 0/1 2/5 3 3 3 2 2 3 6 1 3 2 1 1 8 3 2
18-17: Augmening Ph 3/5 0/3 3/6 2/8 1/3 2/2 0/6 1/4 0/1 2/5 3 3 3 2 2 3 6 1 3 2 1 1 8 3 2
18-18: Augmening Ph 4/5 0/3 4/6 2/8 0/3 2/2 0/6 1/4 1/1 3/5 4 4 2 2 1 6 1 3 3 0 0 1 8 2 3
18-19: Augmening Ph 4/5 0/3 4/6 2/8 0/3 2/2 0/6 1/4 1/1 3/5 4 4 2 2 1 1 3 3 3 1 8 6 2 3
18-20: For-Fulkeron Meho For-Fulkeron(G,, ) iniilize flow f o 0 while here i n ugmening ph p ugmen flow f long p reurn f
18-21: For-Fulkeron Meho Wh i he running ime of For-Fulkeron Meho? Fin n ugmening ph Upe flow / reiul Repe unil here re no more ugmening ph
18-22: For-Fulkeron Meho Wh i he running ime of For-Fulkeron Meho? Fin n ugmening ph Uing DFS, O( E ) Upe flow / reiul O( E ) Repe unil here re no more ugmening ph Eh ierion oul inree he flow y 1, oul hve f ierion! Tol: O( f E )
18-23: For-Fulkeron Meho Coul ke mny f ierion: 1000000 1000000 1 1000000 1000000
18-24: For-Fulkeron Meho Coul ke mny f ierion: Flow Nework Reiul Nework 0/1000000 0/1000000 1000000 1000000 0/1 1 0/1000000 0/1000000 1000000 1000000
18-25: For-Fulkeron Meho Coul ke mny f ierion: Flow Nework Reiul Nework 1/1000000 0/1000000 999999 1000000 1/1 1 0/1000000 1/1000000 1000000 999999
18-26: For-Fulkeron Meho Coul ke mny f ierion: Flow Nework Reiul Nework 1/1000000 0/1000000 999999 1000000 1/1 1 0/1000000 1/1000000 1000000 999999
18-27: For-Fulkeron Meho Coul ke mny f ierion: Flow Nework Reiul Nework 1/1000000 1/1000000 999999 999999 0/1 1 1/1000000 1/1000000 999999 999999
18-28: For-Fulkeron Meho How n we e mr ou hooing he ugmening ph, o voi he previou e?
18-29: Emon-Krp Algorihm How n we e mr ou hooing he ugmening ph, o voi he previou e? We n ge eer performne y lwy piking he hore ph (ph wih he fewe ege) We n quikly fin he hore ph y oing BFS from he oure in he reiul nework, o fin he hore ugmening ph If we lwy hooe he hore ugmening ph (i.e., mlle numer of ege), ol numer of ierion i O( V E ), for ol running ime of O( V E 2 )
18-30: Emon-Krp Algorihm If we lwy pik he hore ugmening ph, no more hn V E ierion: Lemm #1: Shore ph from oure o ny oher verex in reiul grph n only inree, no eree. Reiul grph hnge over ime ege re e n remove However, hore ph from oure o ny verex in he reiul grph will only inree over ime, never eree
18-31: Emon-Krp Algorihm Lemm #1: Shore ph from oure o ny oher verex in reiul grph n only inree, no eree. Proof y onriion Aume hore ph from oure o ome oher verex hnge fer n ugmenion Le f e he flow righ efore he hore ph eree, n f e he flow righ fer Le v e verex uh h δ f (,v) < δ f (,v). If here i more hn one uh v, pik he one wih he mlle δ f (,v) vlue Le p =... u v e he hore ph from o v in f
18-32: Emon-Krp Algorihm Lemm #1: Shore ph from oure o ny oher verex in reiul grph n only inree, no eree. Proof y onriion Ege (u,v) (l ege on ph from o v in G f ) mu no e in G f δ f (,u) δ f (,u) Beue δ f (,u) < δ f (,v), n we pike v o e he verex wih he mlle δ f (,v) vlue h hnge If (u,v) G f δ f (,v) δ f (,u)+1 δ f (,u)+1 δ f (,v)
18-33: Emon-Krp Algorihm Lemm #1: Shore ph from oure o ny oher verex in reiul grph n only inree, no eree. Proof y onriion Ege (u,v) mu e in G f u no in G f o he ugmening ph mu inlue (v,u) We lwy hooe hore ph our ugmening ph Shore ph from o u mu inlue (v,u) δ f (,v) = δ f (,u) 1 δ f (,u) 1 δ f (,v) 2
18-34: Emon-Krp Algorihm If we lwy pik he hore ugmening ph, no more hn V E ierion: An ege on n ugmening ph i riil if i i remove when he flow i ugmene (why mu here lwy e le one riil ege)? Eh ege n only e riil mo V /2 ime
18-35: Emon-Krp Algorihm Eh ege n only e riil mo V /2 ime When ege (u,v) i riil: δ f (,v) = δ f (,u)+1 Criil ege i remove efore i n eome riil gin, i mu e e k y ome ugmening ph h ph mu onin ege (u,v) Le f e he flow when he ege i e k. δ f (,u) = δ f (,v)+1 δ f (,v)+1 = δ f (,u)+1+1
18-36: Emon-Krp Algorihm Eh ege n only e riil mo V /2 ime Le f e he flow when he ege i e k. δ f (,u) = δ f (,v)+1 δ f (,v)+1 = δ f (,u)+1+1 If n ege (u,v) eome riil wie, he hore ph from o u mu inree y 2 Eh ege n only e riil V /2 ime
18-37: Emon-Krp Algorihm If we lwy pik he hore ugmening ph, no more hn V E ierion: An ege on n ugmening ph i riil if i i remove when he flow i ugmene (why mu here lwy e le one riil ege)? Eh ege n only e riil mo V /2 ime E ol ege no more hn E V /2 ierion
18-38: Mhing Prolem Given n uniree grph G = (V,E) mhing M i Sue of ege E For ny verex v V, mo one ege in M i inien o v Mximum mhing i mhing wih lrge poile numer of ege
18-39: Mhing Prolem Biprie grph Verie n e ivie ino wo group, S 1 n S 2 Eh ege onne verex in S 1 wih verex in S 2
18-40: Mhing Prolem
18-41: Mhing Prolem
18-42: Mhing Prolem
18-43: Mhing Prolem
18-44: Mhing Prolem Fining mhing in iprie grph n e oniere mximum flow prolem. How?
18-45: Mhing Prolem Fining mhing in iprie grph n e oniere mximum flow prolem. How?
18-46: Puh-Relel Algorihm New lgorihm for luling mximum flow Bi ie: Allow verie o e overfull (hve more inflow hn ouflow) Puh full piy ou of ege from oure Puh overflow eh verex forwr o he ink Puh exe flow k o oure
18-47: Puh-Relel Algorihm Think of grph unh of wer oniner onnee y pipe. We will rie n lower he verie, n llow wer o flow eween hem Wer n only flow from higher verex o lower verex Iniilly, oure i heigh V, ll oher verie re heigh 1 Full piy of eh pipe ou of he oure flow o eh verex jen o he oure
18-48: Puh-Relel Algorihm Full piy of eh pipe ou of he oure flow k o eh verex jen o he oure Thi ue ome verie o e overfull inflow greer hn ouflow Rie ome verex whoe inflow i greer hn ouflow, o llow wer o flow o ifferen verie Repe unil ll verie (oher hn he ink, whih y level 0) re he me level he oure If here re ill overfull verie, oninue o rie hem o h he exr flow pill k ino he oure
18-49: Puh-Relel Algorihm Heigh 4 3 5 3 2 6 6 5 1 2
18-50: Puh-Relel Algorihm Heigh 4/4 4 0 0/5 0/3 0/6 0/3 0/2 0/6 5 0/1 0 0/2
18-51: Puh-Relel Algorihm Heigh 4/4 4 0 0/5 0/3 0/6 0/3 0/2 0/6 5 0/1 0 0/2
18-52: Puh-Relel Algorihm Heigh 4/4 0 4 4/5 0/3 0/6 0/3 0/2 0/6 5 0/1 0 0/2
18-53: Puh-Relel Algorihm Heigh 4/4 0 4 4/5 0/3 0/6 0/3 0/2 0/6 5 0/1 0 0/2
18-54: Puh-Relel Algorihm Heigh 4/4 0 0 4/5 0/3 4/6 0/3 0/2 0/6 5 0/1 0 0/2
18-55: Puh-Relel Algorihm Heigh 4/4 0 0 4/5 0/3 4/6 0/3 0/2 0/6 5 0/1 0 0/2
18-56: Puh-Relel Algorihm Heigh 4/4 0 0 4/5 0/3 4/6 0/3 0/2 0/6 4 1/1 1 0/2
18-57: Puh-Relel Algorihm Heigh 4/4 0 0 4/5 0/3 4/6 0/3 0/2 0/6 4 1/1 1 0/2
18-58: Puh-Relel Algorihm Heigh 4/4 0 3 4/5 3/3 4/6 0/3 0/2 0/6 1 1/1 1 0/2
18-59: Puh-Relel Algorihm Heigh 4/4 1 3 4/5 3/3 4/6 1/3 0/2 0/6 0 1/1 1 0/2
18-60: Puh-Relel Algorihm Heigh 4/4 1 3 4/5 3/3 4/6 1/3 0/2 0/6 0 1/1 1 0/2
18-61: Puh-Relel Algorihm Heigh 4/4 1 3 4/5 3/3 4/6 1/3 0/2 0/6 0 1/1 0 1/2
18-62: Puh-Relel Algorihm Heigh 4/4 1 3 4/5 3/3 4/6 1/3 0/2 0/6 0 1/1 0 1/2
18-63: Puh-Relel Algorihm Heigh 4/4 0 4 3/3 4/6 1/3 0/2 0/6 0 1/1 0 1/2
18-64: Puh-Relel Algorihm Heigh 4/4 0 2 3/3 6/6 1/3 0/2 0/6 0 1/1 0 1/2
18-65: Puh-Relel Algorihm Heigh 4/4 0 2 3/3 6/6 1/3 0/2 0/6 0 1/1 0 1/2
18-66: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 0 1/1 2 1/2
18-67: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 0 1/1 1 2/2
18-68: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 0 1/1 1 2/2
18-69: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 1 0/1 0 2/2
18-70: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 1 0/1 0 2/2
18-71: Puh-Relel Algorihm Heigh 4/4 1 0 3/3 6/6 2/3 2/2 0/6 0 0/1 0 2/2
18-72: Puh-Relel Algorihm Heigh 4/4 1 0 3/3 6/6 2/3 2/2 0/6 0 0/1 0 2/2
18-73: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 1 0/1 0 2/2
18-74: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 1 0/1 0 2/2
18-75: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 0 1/1 1 2/2
18-76: Puh-Relel Algorihm Heigh 4/4 0 1 3/3 6/6 1/3 1/2 0/6 0 1/1 0 2/2
18-77: Puh-Relel Algorihm Heigh 4/4 0 1 3/3 6/6 1/3 1/2 0/6 0 1/1 0 2/2
18-78: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 0 1/1 1 2/2
18-79: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 0 1/1 1 2/2
18-80: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 1 0/1 0 2/2
18-81: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 1 0/1 0 2/2
18-82: Puh-Relel Algorihm Heigh 4/4 0 0 3/3 6/6 1/3 2/2 0/6 4/5 0 0/1 0 2/2
18-83: Puh-Relel Algorihm Puh(u, v) Applie when: u i overflowing f (u,v) > 0 h[u] = h[v]+1 Aion: Puh min(overflow[u], f (u,v)) o v
18-84: Puh-Relel Algorihm Relel(u) Applie when: u i overflowing For ll v uh h f (u,v) > 0 h[v] h[u] Aion: h[u] h[u]+1
18-85: Puh-Relel Algorihm Puh-Relel(G) Iniilize-Preflow(G, ) while here exi n pplile puh/relel implemen puh/relel
18-86: Puh-Relel Algorihm Puh-Relel(G) Iniilize-Preflow(G, ) while here exi n pplile puh/relel implemen puh/relel Pik he operion (puh/relel) rirrily, ime i O( V 2 E) (We won prove hi reul, hough he proof i in he ook) Cn o eer wih relel-o-fron Speifi orering for oing puh-relel Time O( V 3 ), lo no proven here, proof in ex