Chptr 6 Pth, yl n flow in grph Suppo you wnt to fin hortt pth from givn trting point to givn tintion. Thi i ommon nrio in rivr itn ytm (GPS) n n mol on of th mot i omintoril optimiztion prolm, th hortt pth prolm. In thi hptr, w introu irt grph, hortt pth n flow in ntwork. W fou in prtiulr on th mximum-flow prolm, whih i linr progrm tht w olv with irt mtho, vru th implx mtho, n nlyz th running tim of th irt mtho. 6.1 Growth of funtion In th nlyi of lgorithm, it i mor pproprit to invtigt th ymptoti running tim of n lgorithm pning on th input n not th pri running tim itlf. W rviw th O,Ω n Θ-nottion. Dfinition 6.1 (O, Ω, Θ-nottion). Lt T, f : N N two funtion T (n) i in O(f (n)), if thr xit poitiv ontnt n o N n R >0 with T (n) f(n) for ll n n 0. T (n) i in Ω(f (n)), if thr xit ontnt n o N n R >0 with T (n) f(n) for ll n n 0. T (n) i in Θ(f (n)) if T (n) i oth in O(f (n)) n in Ω(f (n)). Exmpl 6.1. Th funtion T (n)=n + n+ 1 i in O(n ), in for ll x 1 on h n + n+ 1 6n. Hr n 0 = 1 n = 6. Similrly T (n) = Ω(n ), in for h n 1 on h n + n+ 1 n. Thu T (n) i in Θ(n ). 55
56 6. Grph Dfinition 6.. A irt grph i tupl G = (V, A), whr V i finit t, ll th vrti of G n A (V V ) i th t of r of G. W not n r y it two fining no (u, v) A. Th no u n v r ll til n h of th r (u, v) rptivly. u v z x y Fig. 6.1: Exmpl of irt grph with 5 no n 7 r. Dfinition 6. (Wlk, pth, itn). A wlk i qun of th form P = (v 0, 1, v 1,..., v m 1, m, v m ), whr i = (v i 1, v i ) A for i = 1,...,m. If th no v 0,..., v m r ll iffrnt, thn P i pth. Th lngth of P i m. Th itn of two no u n v i th lngth of hortt pth from u to v. It i not y (u, v). Exmpl 6.. Th following i wlk n pth of th grph in Figur 6.1. u,(u, z), z,(z, x), x,(x,u),u,(u, z), z,(z, y), y u,(u, z), z,(z, y), y 6. Rprnting grph n omputing th itn of two no W rprnt grph with n vrti n rry A[v 1,..., v n ], whr th ntry A[v i ] i pointr to link lit of vrti, th nighor of v i. N (v i ) = {u V : (v i,u) A}. W nxt ri vry i lgorithm, whih omput th itn from V to ll othr no. W lt V i V th t of vrti whih hv itn i from. Lmm 6.1. For i = 0,...,n 1, th t V i+1 i qul to th t of vrti v V \(V 0 V i ) uh tht thr xit n r (u, v) A with u V i.
57 u v x y z z u u x x y y Fig. 6.: Ajny lit rprnttion of th grph in Figur 6.1. Proof. Suppo tht v V 0 V i n thr xit n r uv A with u V i. Sin u V i, thr xit pth, 1, v 1,, v,..., i,u of lngth i from to u. Th qun, 1, v 1,, v,..., i,u,uv, v i pth of lngth i+1 from to v n thu v V i+1. If, on th othr hn, v V i+1, thn thr xit pth, 1, v 1,..., i, v i, i+1, v of lngth i+ 1 from to v. W n to how tht v i V i hol. Clrly, in thr xit pth of lngth i from to v i, on h v i V j with j i. If j < i, thn thr xit pth, 1, v 1,..., j, v i of lngth j whih n xtn to pth of lngth j + 1<i+ 1 from to v, 1, v 1,..., j, v i, i+1, v whih ontrit v V i+1. W now ri th rth-firt rh lgorithm, tht omput th itn from trting vrtx to ll othr vrti v V. Th lgorithm mintin rry D[v 1 =, v,..., v n ] π[v 1 =, v,..., v n ] n quu Q whih ontin only in th ginning. Th rry D ontin t trmintion of th lgorithm th itn from to ll othr no n i initiliz with [0,,..., ]. Th rry π ontin pror informtion for hortt pth, in othr wor, whn th lgorithm trmint, π[v]=u, whr uv i n r n D[u]+1= D[v]. Th rry π i initiliz with [0,...,0]. Aftr thi initiliztion, th lgorithm pro follow. whil Q u := h(q) for h v N (u) if (D[v]= ) π[v] := u
58 D[v] := D[u]+1 nquu(q, v) quu(q) Hr th funtion h(q) rturn th nxt lmnt in th quu n quu(q) rmov th firt lmnt of Q, whil nquu(q, v) v to th quu lt lmnt. Lmm 6.. Th rth-firt rh lgorithm ign itn ll D orrtly. Proof. Lt v V. W how y inution on (, v) tht th ll r orrtly ign. If (, v) = 0, thn = v n D[v] = 0. If (, v) = 1, thn v i nighor of n D[v]=1 i t orrtly in th firt itrtion of th whil loop. Lt (, v)> 1. Thn thr xit u, v with (,u)=(, v) 1 n uv A. By inution, th ll D[u] = (, u) i t orrtly y th rth-firt-rh lgorithm. Alo, in th rth-firt-rh lgorithm omput for v pth of lngth D[v] from to v, th no v riv ll whih i grtr thn or qul to (, v). If w onir th qun (ovr tim) of ign ll, tht rthfirt-rh i igning, thn it i y to tht thi qun i monotonouly inring, xri 6. Th no v i thu xplor t th ltt, whn u i quu. Thi how tht th ll of v, D[v] i ign orrtly. Dfinition 6.4 (Tr). A irt tr i irt grph T = (V, A) with A = V 1 n thr xit no r T uh tht thr xit pth from r to ll othr no of T. Lmm 6.. Conir th rry D n π ftr th trmintion of th rth-firtrh lgorithm. Th grph T = (V, A ) with V = {v V : D[v] < } n A = {π(v)v : 1 D[v]< } i tr. Dfinition 6.5. Th tr T from ov i th hortt-pth-tr of th (unwight) irt grph G = (V, A). Thorm 6.1. Th rth-firt-rh lgorithm run in tim O( V + A ). Proof. Eh vrtx i quu n quu t mot on. Th quuing oprtion tk ontnt tim h. Thu quuing n quuing ot O( V ) in totl. Whn vrtx u i quu, it nighor r inpt n th oprtion in th if ttmnt ot ontnt tim h. Thu on h n itionl ot of O( A ), in th ontnt-tim oprtion r rri out for h r A. 6.4 Shortt Pth Dfinition 6.6 (Cyl). A wlk in whih trting no n n-no gr i ll yl.
59 () Th rth-firt rh lgorithm trt with th quu Q = []. Th itn ll for [,,,,,] r [0,,,,, ] rptivly. () Aftr th firt itrtion of th whil loop th quu i Q = [,] n th itn ll r [0,1,,1,, ] rptivly. () Aftr th on itrtion of th whil loop th quu i Q = [,] n th itn ll r [0,1,,1,, ] rptivly. () Aftr th thir itrtion of th whil loop th quu i Q = [] n th itn ll r unhng, in o not hv ny nighor. () Aftr th fourth itrtion of th whil loop th quu i Q = [,] n th itn ll r [0,1,,1,,] rptivly. (f) Aftr th ixth itrtion of th whil loop th quu i mpty Q = [] n th itn ll rmin unhng. Th lu g not th hortt pth tr. Fig. 6.: An xmpl-run of rth-firt rh Suppo w r givn irt grph D = (V, A) n lngth funtion : A R. Th lngth of wlk W i fin (W )= (). A W W now tuy how to trmin hortt pth in th wight grph D ffiintly, in of th n of yl of ngtiv lngth.
60 Thorm 6.. Suppo tht h yl in D h non-ngtiv lngth n uppo thr xit n t-wlk in D. Thn thr xit pth onnting with t whih h minimum lngth mong ll wlk onnting n t. Proof. If thr xit n t-wlk, thn thr xit n t-pth. Sin th numr of r in pth i t mot A, thr mut xit hortt pth P onnting n t. W lim tht (P) (W ) for ll t-wlk W. Suppo tht thr xit n t-wlk W with (W ) < (P). Thn lt W uh wlk with minimum numr of r. Clrly W ontin yl C. If th yl h nonngtiv lngth, thn it n rmov from W to otin wlk who lngth i t mot (W ) n who numr of r i tritly l thn C. W u th nottion W, C, P to not th numr of r in wlk W yl C or pth P. A onluion w n not hr: If thr o not xit ngtiv yl in D, n n t r onnt, thn thr xit hortt wlk trvring t mot V 1 r. Th Bllmn-For lgorithm Lt n= V. W lult funtion f 0, f 1,..., f n : V R { } uivly y th following rul. i) f 0 ()=0, f 0 (v)= for ll v ii) For k < n if f k h n foun, omput for ll v V. f k+1 (v)=min{f k (v), min (u,v) A {f k (u)+(u, v)}} Thorm 6.. For h k = 0,...,n n for h v V f k (v)=min{(p): P i n v-wlk trvring t mot k r}. Corollry 6.1. If D = (V, A) o not ontin ngtiv yl w.r.t., thn f n (v) i qul to th lngth of hortt v-pth. Th numr f n (v) n omput in tim O( V A ). Corollry 6.. In tim O( V A ) on n tt whthr D = (V, A) h ngtiv yl w.r.t. n vntully rturn on.
61 4 1 4 1 () Th lgorithm i initiliz with itn ll for,,,,, ing [0,,,,, ] rptivly () Aftr th firt itrtion th ll r [0,,,4,, ] 4 1 1 4 () Aftr th on itrtion th ll r [0,,4,4,, ] () Aftr th thir itrtion th ll r [0,,4,,7,6] 4 1 4 1 () Aftr th fourth itrtion th ll r [0,,4,,7,4] (f) Aftr th fifth itrtion th ll r unhng. Th hortt pth itn hv n omput. Fig. 6.4: An xmpl-run of th Bllmn-For lgorithm. Th lu g rprnt th tr who pth hv th orrponing lngth. 6.5 Mximum t -flow W now turn our ttntion to linr progrmming prolm whih w will olv y irt mtho, motivt y th ntur of th prolm. W oftn u th following nottion. If f : A B not funtion n if U A, thn f (U ) i fin f (U )= U f (). Dfinition 6.7 (Ntwork, t-flow). A ntwork with piti onit of irt impl grph D = (V, A) n pity funtion u : A R 0. A funtion f : A R 0 i ll n t-flow, if δ out (v) f ()= δ i n (v) f (), for ll v V {, t}, (6.1)
6 whr, t V. Th flow i fil, if f () u() for ll A. Th vlu of f i fin v lu(f )= δ out () f () δ i n () f (). Th mximum t-flow prolm i th prolm of trmining mximum fil t-flow. Hr, for U V, δ in (U ) not th r whih r ntring U n δ out (U ) not th r whih r lving U. Ar t of th form δ out (U ) r ll ut of D. Th pity of ut u(δ out (U )) i th um of th piti of it r. Thu th mximum flow prolm i linr progrm of th form mx δ out () δ out (v) x() δ i n () x() = δ i n (v) x() (6.) x(), for ll v V {, t} (6.) x() u(), for ll A (6.4) x() 0, for ll A (6.5) Dfinition 6.8 (x funtion). For ny f : A R, th x funtion i th funtion x f : V R fin y x f (U )= δ i n (U ) f () δ out (U ) f (). Thorm 6.4. Lt D = (V, A) igrph, lt f : A R n lt U V, thn x f (U )= x f (v). (6.6) v U Proof. An r whih h oth npoint in U i ount twi with iffrnt priti on th right, n thu nl out. An r whih h it til in U i utrt on on th right n on on th lft. An r whih h it h in U i on on th right n on on th lft. A ut δ out (U ) with U n t U i ll n t-ut. Thorm 6.5 (Wk ulity). Lt f fil t-flow n lt δ out (U ) n t-ut, thn v lu(f ) u(δ out (U )). Proof. v lu(f )= x f ()= x f (U )= f (δ out (U )) f (δ in (U )) f (δ out (U )) u(δ out (U )). For n r = (u, v) A th r 1 not th r (v,u). Dfinition 6.9 (Riul grph). Lt f : A R, n u : A R whr 0 f u. Conir th t of r A f = { A, f ()<u()} { 1 A, f ()>0}. (6.7) Th igrph D(f )=(V, A f ) i ll th riul grph of f (for piti u). Corollry 6.. Lt f fil t-flow n uppo tht D(f ) h no pth from to t, thn f h mximum vlu.
Proof. Lt U th t of no whih r rhl in D(f ) from. Clrly δ out (U ) i n t-ut. Now v lu(f )= f (δ out (U )) f (δ in (U ). Eh r lving U i not n r of D(f ) n thu f (δ out (U ))=u(δ out (U )). Eh r ntring U o not rry ny flow n thu f (δ in (U )=0. It follow tht v lu(f ) = u(δ out (U )) n f i optiml y Thorm 6.5. Dfinition 6.10 (unirt wlk). An unirt wlk i qun of th form P = (v 0, 1, v 1,..., v m 1, m, v m ), whr i A for i = 1,...,m n i = (v i 1, v i ) or i = (v i, v i 1 ). If th no v 0,..., v m r ll iffrnt, thn P i n unirt pth. Any irt pth P in D(f ) yil n unirt pth in D. Dfin for uh pth P th vtor χ P {0,±1} A 1 if P trvr, χ P ()= 1 if P trvr 1, 0 if P trvr nithr or 1. 6 (6.8) Thorm 6.6 (mx-flow min-ut thorm, trong ulity). Th mximum vlu of fil t-flow i qul to th minimum pity of n t ut. Proof. Lt f mximum t-flow. Conir th riul grph D(f ). If thi riul grph ontin n t-pth P, thn w n rout flow long thi pth. Mor prily, thr xit n ǫ>0 uh tht f +ǫχ P i fil. W hv v lu(f + ǫχ P )= v lu(f )+ǫ. Thi ontri th mximlity of f thu thr xit no tpth in D(f ). Lt U th no rhl from in D(f ). Thn v lu(f )=u(δ out (U )) n δ out (U ) i n t-ut of minimum pity y th wk ulity thorm. Thi uggt th lgorithm of For n Fulkron to fin mximum flow. Strt with f = 0. Nxt itrtivly pply th following flow ugmnttion lgorithm. Lt P irt t-pth in D(f ). St f f + ǫχ P, whr ǫ i lrg poil to mintin 0 f u. Exri 6.1. Dfin riul pity for D( f ). Thn trmin th mximum ǫ uh tht 0 f u. Thorm 6.7. If ll piti r rtionl, thi lgorithm trmint.
64 u M M 1 t M M v Th xmpl ov how tht, if th ugmnting pth r hon in ivntgou wy, thn th For-Fulkron lgorithm my tk Ω(M) itrtion, whr M i th lrgt pity in th ntwork. Thi hppn if ll ugmnting pth u th r uv or vu rptivly in th riul ntwork. Corollry 6.4 (intgrity thorm). If u() N for h A, thn thr xit n intgr mximum flow (f () N for ll A). Proof. Thi follow from th ft tht th riul piti rmin intgrl n thu th ugmnt flow i lwy intgrl. Thorm 6.8. If w hoo in h itrtion hortt t-pth in D(f ) flowugmnting pth, th numr of itrtion i t mot V A. Dfinition 6.11. Lt D = (V, A) igrph,, t V n lt µ(d) not th lngth of hortt pth from to t. Lt α(d) not th t of r ontin in t lt on hortt t pth. Thorm 6.9. Lt D = (V, A) igrph n, t V. Dfin D = (V, A α(d) 1 ). Thn µ(d)=µ(d ) n α(d)=α(d ). Proof. It uffi to how tht µ(d) n α(d) r invrint if w 1 to D for on r α(d). Suppo not, thn thr i irt t-pth P 1 trvring 1 of lngth t mot µ(d). A α(d) thr i pth P trvring of lngth µ(d). If w follow P until th til of i rh n from thron follow P 1, w otin nothr t pth P in D. Similrly if w follow P 1 until th h of i rh n thn follow P, w otin fourth t pth P 4 in D. Howvr P or P 4 h lngth l thn µ(d). Thi i ontrition. Proof (of Thorm 6.8). Lt u ugmnt flow f long hortt t-pth P in D(f ) otining flow f. Th riul grph D f i ugrph of D = (V, A f α(d(f )) 1 ). Hn µ(d f ) µ(d )=µ(d(f )). If µ(d f )=µ(d(f )), thn α(d f ) α(d )=α(d(f )). At lt on r of P o not long to D f, (th r of minimum riul pity!) thu th inluion i trit. Sin µ(d( f )) inr t mot V tim n, long µ(d(f )) o not hng, α(d(f )) r t mot A tim, w hv th thorm.
65 In th following lt m= A n n= V. Corollry 6.5. A mximum flow n foun in tim O(n m ). 6.6 Minimum ot ntwork flow, MCNFP In ontrt to th mximum t-flow prolm, th gol hr i to rout flow, whih om from vrl our n ink through ntwork with piti n ot in uh wy, tht th totl ot i minimiz. Exmpl 6.. Suppo you r givn irt grph with r wight D = (V, A), : A R 0 n your tk i to omput hortt pth from prtiulr no to ll othr no in th grph n um tht uh pth xit. Thn on n mol thi MCNFP y ning flow of vlu V 1 into th our no n y ltting flow of vlu 1 lv h no. Th ot on th r r fin y. Th r hv infinit piti. W will ltr, tht thi minimum ot ntwork flow prolm h n intgrl olution whih orrpon to th hortt pth from to ll othr no. 1/ /4 1/ / / 7/ 1 0 1 0 1 Fig. 6.5: A Ntwork with in/out-flow, ot n piti n fil flow of ot 1.
66 Hr i forml finition of minimum ot ntwork flow prolm. In thi nottion, vrti r inx with th lttr i, j,k n r r not y thir til n h rptivly, for xmpl (i, j ) not th r from i to j. A ntwork i now irt grph D = (V, A) togthr with pity funtion u : A Q 0, ot funtion : A Q n n xtrnl flow : V Q. Th vlu of (i ) not th mount of flow whih om from th xtrior. If (i )>0, thn thr i flow from th outi, ntring th ntwork through no i. If (i )<0, thr i flow whih lv th ntwork through i. In th following w oftn u th nottion f (i, j ) for th flow-vlu on th r (i, j ) (int of f ((i, j ))). Similrly w writ (i, j ) n u(i, j ). A fil flow i funtion f : A Q 0 whih tifi th following ontrint. δ out (i) f () j δ i n (i) f ()= i for ll i V, 0 f () u() for ll A. Th gol i to fin fil flow with minimum ot: minimiz A ()f () ujt to δ out (i) f () δ i n (i) f ()= (i ) for ll i V, 0 f () u() for ll () A Exmpl 6.4. Imgin you r pilot n fly pngr irpln in hop from irport 1 to irport to irport n o on, until irport n. At irport i thr r i j pngr tht wnt to trvl to irport j, whr j > i. You my i how mny of th i j pngr you will tk on or. Eh of th pngr will py i j ollr for th trip. Th irpln n ommot p popl. You r gry pilot n think of pln to pik up n livr pngr on your hop from 1 to n whih mximiz your rvnu. Fining thi pln n mol minimum ot ntwork flow prolm. Your ntwork h no 1,...,n n r (i,i + 1),i = 1,...,n 1 with piti p n without ot. Th no o not hv in/out-flow from th outi. You furthrmor hv no i j for i < j n i, j {1,...,n} whih r x no with in-flow i j from th outi. Eh no i j i onnt to i n to j with irt r. Th piti on th r r infinit. Th ot of th r (i j,i ) i i j. Th ot of th r (i j, j ) i zro. Th outflow on th no j i th totl numr of pngr tht wnt to fly to no j. An intgrl optiml flow to thi prolm i n optiml pln for you. Throughout thi hptr w mk th following umption. 1. All t (ot, upply, mn n pity) r intgrl.. Th ntwork ontin n inpitt irt pth twn vry pir of no.. Th uppli/mn t th no tify th onition i V (i ) = 0 n th MCNFP h fil olution. 4. All r ot r nonngtiv. 5. Th grph o not ontin pir of rvr r.
Exri 6.. Show how to trnform MCNFP on igrph with pir of rvr r into MCNFP on igrph with no pir of rvr r. Th numr of r n no houl ymptotilly rmin th m. An r-flow of D i flow vtor, tht tifi th nonngtivity n pity ontrint. δ i n (i) f () δ out (i) f ()= (i ) for ll i V, 0 f () u() for ll A. If (i )>0, thn i i n x no (mor inflow thn outflow). If (i )<0, thn i i fiit no (mor outflow thn inflow). If (i )=0 thn i i ll ln. Exri 6.. Prov tht i V (i )=0 hol n thu tht fil flow only xit if th um of th (i ) i qul to zro. Lt P th olltion of irt pth of D n lt C th olltion of irt yl of D. A pth-flow i funtion β : P C R 0 whih ign flow vlu to pth n yl. For (i, j ) A n P P lt δ (i,j ) (P) 1 if (i, j ) P n 0 othrwi. For C C lt δ (i,j ) (C) 1 if (i, j ) C n 0 othrwi. A pth-flow β trmin uniqu r-flow f (i, j )= P P δ (i,j ) (P)β(P)+ δ (i,j ) (C)β(C). Thorm 6.10. Evry pth n yl flow h uniqu rprnttion nonngtiv r-flow. Convrly, vry nonngtiv r flow f n rprnt pth n yl flow with th following proprti: 1. Evry irt pth with poitiv flow onnt fiit no with n x no.. At mot n+ m pth n yl hv nonzro flow n t mot m yl hv nonzro flow. If th r flow f i intgrl, thn o r th pth n yl flow into whih it ompo. Proof. S iuion ov. Lt f n r flow. Suppo i 0 i fiit no. Thn thr xit n inint r (i 0,i 1 ) whih rri poitiv flow. If i 1 i n x no, w hv foun pth from fiit to x no. Othrwi, th flow ln ontrint t i 1 impli tht thr xit n r (i 1,i ) with poitiv flow. Rpting thi prour, w finlly mut rriv t n x no or rviit no. Thi mn tht w C C 67
68 ithr hv ontrut irt pth P from fiit no to x no or irt yl C, oth involving only r with tritly poitiv flow. In th firt, lt P = i 0,...,i k th irt pth from fiit no i 0 to x no i k. W t β(p) = min{ i0, ik,min{f (i, j ) (i, j ) P}} n f (i, j )= f (i, j ) β(p), (i, j ) P. In th on, t β(c)=min{f (i, j ) (i, j ) C n f (i, j )= f (i, j ) β(c), (i, j ) C. Rpt thi prour until ll no imln r zro. Now fin n r with poitiv flow n ontrut yl C y following only poitiv r from thr. St β(c) = min{f (i, j ) (i, j ) C} n f (i, j )= f (i, j ) β(c), (i, j ) C}. Rpt thi pro until thr r no poitiv flow-r lft. Eh tim pth or yl i intifi, th x/fiit of om no i t to zro or om r i t to zro. Thi impli tht w ompo into t mot n + m pth n yl. Sin yl ttion t n r to zro w hv t mot m yl. An r flow f with (i ) = 0 for h i V i ll irultion. Corollry 6.6. A irultion n ompo into t mot m yl flow. Lt D = (V, A) ntwork with piti u(i, j ), (i, j ) A n ot (i, j ), (i, j ) A n lt f fil flow of th ntwork. Th riul ntwork D(f ) i fin follow. W rpl h r (i, j ) A with two r (i, j ) n (j,i ). Th r (i, j ) h ot (i, j ) n riul pity r (i, j )= u(i, j ) f (i, j ). Th r (j,i ) h ot (i, j ) n riul pity r (j,i )= f (i, j ). Dlt ll r whih o not hv tritly poitiv riul pity. A irt yl in D(f ) i ll n ugmnting yl of f. Lmm 6.4. Suppo tht f n f r fil flow, thn f f i irultion in D(f ). Hr f f i th flow mx{0, f () f ()}, if A(D) (f f )()= mx{0, f () f ()}, if 1 A(D) 0, othrwi. Proof. It i vry y to tht th flow f f tifi th pity ontrint. On lo h for h v V δ out (v)(f () f ()) (f () f ())=0. δ i n (v) If trm (f () f ()) i ngtiv, it i rpl y it olut vlu n hrg flow on th r 1 in D(f ) whih lv it ontriution to th um ov invrint.
69 /4 1/1 1/ 1/ 1/1 / /1 /1 7/ Fig. 6.6: Th riul ntwork of th flow in Figur 6.5 n ngtiv yl mrk y th r g. 4//4 1 /4/4 1/1 1 1/4 1 Fig. 6.7: Two r 1, A ll with f ()/f ()/u() n th orrponing flow on th r (or thir rvr) in D(f ). Ar in D(f ) r ll with flow n pity vlu rptivly. Thorm 6.11 (Augmnting Cyl Thorm). Lt f n f ny two fil flow of ntwork flow prolm. Thn f qul f plu th flow of t mot m irt yl in D(f ). Furthrmor th ot of f qul th ot of f plu th ot of flow on th ugmnting yl. Proof. Thi n n y pplying flow ompoition on th flow f f in D(f ). Thorm 6.1 (Ngtiv Cyl Optimlity Conition). A fil flow f i n optiml olution of th minimum ot ntwork flow prolm, if n only if it tifi th ngtiv yl optimlity onition: Th riul ntwork D(f ) ontin no irt yl of ngtiv ot. Proof. Suppo tht f i fil flow n tht D(f ) ontin ngtiv irt yl. Thn f nnot optiml, in w n ugmnt poitiv flow
70 long th orrponing yl in th ntwork. Thrfor, if f i n optiml flow, thn D(f ) nnot ontin ngtiv irt yl. Suppo now tht f i fil flow n uppo tht D(f ) o not ontin ngtiv yl. Lt f n optiml flow with f f. Th vtor f f i irultion in D(f ) with non-poitiv ot T (f f ) 0. It follow from Thorm 6.11 tht th ot of f qul th ot of f plu th ot of irt yl in th riul ntwork D(f ). Th ot of th yl i nonngtiv, n thrfor (f ) (f ) whih impli tht f i optiml. 0 0 0 1 Fig. 6.8: Th rult of ugmnting flow of on long th ngtiv yl in Figur 6.6. Thi flow h ot 1 ut i not optiml, in th riul ntwork till ontin ngtiv yl. Algorithm 6.1 (Cyl Cnling Algorithm). 1. tlih fil flow f in th ntwork. WHILE D( f ) ontin ngtiv yl. tt ngtiv yl C in D( f ). δ=min{r (i, j ) (i, j ) C}. ugmnt δ unit of flow long th yl C. upt D(f ). RETURN f Thorm 6.1. Th yl nling lgorithm trmint ftr finit numr of tp if th MCNFP h n optiml olution. Proof. Th yl nling lgorithm ru th ot in h itrtion. W hv um tht th input t i intgrl. Thu th ot r y t lt on unit h itrtion. Thrfor th numr of itrtion i finit. Corollry 6.7. If th piti r intgrl n if th MCNFP h optiml flow, thn it h n optiml flow with intgr vlu only.
Lt π : V R funtion (no potntil). Th ru ot of n r (i, j ) w.r.t. π i π ((i, j )) = ((i, j ))+π(i ) π(j ). Th potntil π i ll fil if π ((i, j )) 0 for ll r (i, j ) A. Lmm 6.5. Lt D = (V, A) igrph with r wight : A R. Thn D o not hv ngtiv yl if n only if thr xit fil no potntil π of D with r wight. Proof. Conir irt pth P = i 0,i 1,...,i k. Th ot of thi pth i (P)= k ((i j 1,i j )). j=1 Th ru ot of thi pth i qul to π (P)= k ((i j 1,i j ))+π(i 0 ) π(i k ). j=1 If P i yl, thn i 0 n i k r qul, whih mn tht it ot n ru ot oini. Thu, if thr xit fil no potntil, thn thr o not xit ngtiv yl. On th othr hn, uppo tht D, o not ontin ngtiv yl. A vrtx to D n th r (,i ) for ll i V. Th wight (ot) of ll th nw r i 0. Noti tht in thi wy, no nw yl r rt, thu till thr o not xit ngtiv yl. Thi mn w n omput th hortt pth from to ll othr no i V. Lt π th funtion whih ign th hortt pth lngth. Clrly π ((i, j ))=π(i ) π(j )+((i, j )) 0, in th hortt-pth lngth to j i t mot th hortt-pth lngth to i + ((i, j )). Thi mn tht w hv gin ni wy to prov tht flow i optiml. Simply quip th riul ntwork with fil no potntil. Corollry 6.8 (Ru Cot Optimlity Conition). A fil flow f i optiml if n only if thr xit no potntil π uh tht th ru ot π (i, j ) of h rh (i, j ) of D( f ) r nonngtiv. Th yl nling lgorithm i only puopolynomil. If w oul lwy ho minimum yl (yl with t improvmnt) n ugmnting yl, w woul hv polynomil numr of itrtion. Fining minimum yl i N P-hr. Int w ugmnt long minimum mn yl. On n fin minimum mn yl in polynomil tim. Th mn ot of yl C C i th ot of C ivi y th numr of r in C: ( (i, j ))/ C. (i,j ) C Algorithm 6. (Minimum Mn Cyl Cnling, MMCC). 71
7 1. tlih fil flow f in th ntwork. WHILE D( f ) ontin ngtiv yl. tt minimum mn yl C in D( f ). δ=min{r (i, j ) (i, j ) C}. ugmnt δ unit of flow long th yl C. upt D(f ). RETURN f W now nlyz th MMCC-lgorithm. Lt µ(f ) not th minimum mnwight of yl in D(f ). Lmm 6.6 (S Kort & Vygn [8]). Lt f 1, f,... qun of fil flow uh tht f i+1 rult from f i y ugmnting flow long C i, whr C i i minimum mn yl of D(f i ), thn 1. µ(f k ) µ(f k+1 ) for ll k.. µ(f k ) n n 1 µ(f l ), whr k < l n C k C l ontin pir of rvr r. Proof. 1): Suppo f k n f k+1 r two uqunt flow in thi qun. Conir th multi-grph H whih rult from C k n C k+1 y lting pir of oppoing r. Th r of H r ut of th r of D(f k ), in n r of C k+1 whih i not in D(f k ) mut rvr r of C k. Eh no in H h vn gr. Thu H n ompo into yl, h of mn wight t lt µ(f k ). Thu w hv (A(H)) µ(f k ) A(H). Sin th totl wight of h rvr pir of r i zro w hv (A(H))=(C k )+(C k+1 )=µ(f k ) C k +µ(f k+1 ) C k+1. Sin A(H) C k + C k+1 w onlu µ(f k )( C k + C k+1 ) µ(f k ) A(H) (A(H)) = µ(f k ) C k +µ(f k+1 ) C k+1. Thu µ(f k ) µ(f k+1 ). ): By th firt prt of th thorm, it i nough to prov th ttmnt for k,l uh tht C i C l o not ontin pir of rvr r for h i, k < i < l. Agin, onir th grph H rulting from C k n C l y lting pir of oppoing r. H i ugrph of D(f k ), in ny r of C l whih o not long to D(f k ) mut rvr r of C k,c k+1,...,c l 1. But only C k ontin rvr r of C l. So ov w hv (A(H))=(C k )+(C l )=µ(f k ) C k +µ(f l ) C k+1. Sin A(H) C k + C l w hv A(H) n 1 n ( C k + C l ). Thu w gt
7 µ(f k ) n 1 n ( C k + C l ) µ(f k ) A(H) (A(H)) = µ(f k ) C k +µ(f l ) C l µ(f l )( C k + C l ) Thi impli tht µ(f k ) n n 1 µ(f l ). Corollry 6.9. During th xution of th MMCC-lgorithm, µ( f ) r y ftor of 1/ vry n m itrtion. Proof. Lt C 1,C,... th qun of ugmnting yl. Evry m-th itrtion, thr mut n r of th yl, whih i rvr to on of th uing m 1 yl, u vry itrtion, on r of th riul ntwork will lt. Thu ftr n m itrtion, th olut vlu of µ h ropp y ( ) n 1 n n 1 1/. Corollry 6.10. If ll t r intgrl, thn th MMCC-lgorithm run in polynomil tim. Proof. A lowr oun on µ i th mllt ot min µ rop y 1/ vry m n itrtion. Aftr mn logn min itrtion, olut vlu of minimum mn wight yl rop low 1/n, thu i zro. W n to prov tht minimum mn yl n foun in polynomil tim Thi i o-ll wkly polynomil oun, in th inry noing lngth of th numr in th input (hr th ot) influn th running tim. W now prov tht th MMCC-lgorithm i trongly polynomil. Thorm 6.14 (S Kort & Vygn [8]). Th MMCC-lgorithm rquir O(m n logn) itrtion (mn wight yl nlltion). Proof. On how tht vry m n( log n +1) itrtion, t lt on r i fix, whih mn tht th flow through thi r o not hng nymor. Lt f 1 om flow t om itrtion n lt f th flow m n( logn +1) itrtion ltr. It follow from Corollry 6.9 tht µ(f 1 ) n µ(f ) (6.9) hol. Dfin th ot () = () µ(f ) for th riul ntwork D(f ). Thr xit no ngtiv yl in D(f ) w.r.t. thi ot. ( A yl C h wight (C) = C () C µ(f ) n thu (C)/ C = C ()/ C µ(f ) 0). By Lmm 6.5
74 thr xit fil no potntil π for th wight. On h 0 π () = π () µ(f ) n thu π () µ(f ), for ll A(D(f )). (6.10) Lt C minimum mn yl of D(f 1 ). On h π (C)=(C)=µ(f 1 ) C n µ(f ) C. (6.11) It follow tht thr xit n r 0 of C uh tht hol. Th inquliti (6.10) imply tht 0 A(D(f )) W now mk th following lim: π ( 0 ) n µ(f ) (6.1) Lt f fil flow uh tht 0 D(f ), thn µ(f ) µ(f ). If w hv hown thi lim, thn it follow from Lmm 6.6 tht 0 nnot nymor in th riul ntwork of flow ftr f. Thu th flow long th r 0 (or 0 1 ) i fix. Lt f flow uh tht 0 A(D(f )). Rll tht f f i irultion in D(f ) whr 0 D(f ), 0 1 D(f ) n thi irultion n flow ovr 0 1. Thi irultion n ompo into yl n on of th yl C ontin 0 1. On h π(0 1)= π( 0 ) n µ(f ) (q. (6.1)). Uing (6.10) on otin (C) = C π () (6.1) n µ(f )+(n 1)µ(f ) (6.14) = (n+ 1)µ(f ) (6.15) > n µ(f ). (6.16) Th rvr of C i n ugmnting yl for f with totl wight t mot n µ(f ) n thu with mn wight t mot µ(f ). Thu µ(f ) µ(f ). 6.7 Computing minimum ot-to-profit rtio yl Givn igrph D = (V, A) with ot : A Z n profit p : A N >0, th tk i to omput yl C C with minimum rtio (C) p(c). (6.17) Noti tht thi i th lrgt numr β Q whih tifi
75 β (C), for ll C C. (6.18) p(c) By rwriting thi inqulity, w unrtn thi to th lrgt numr β Q uh tht (C) βp(c) 0 for ll C C. (6.19) In othr wor, w rh th lrgt numr β Q uh tht th igrph D = (V, A) with ot β : A Q, whr β ()=() βp(). W n routin to hk whthr D h ngtiv yl for givn wight funtion. For thi w um w.l.o.g. tht h vrtx i rhil from th vrtx, if nry y intruuing nw vrtx from whih thr i n r with ot n profit 0 to ll othr no. Th minimum ot-to-profit rtion yl w.r.t. thi nw grph i thn th minimum ot to profit rtio yl w.r.t. th originl grph, in i not vrtx of ny yl. Rll th following ingl-our hortt-pth lgorithm of Bllmn-For whih w now pply with wight β : Lt n= V. W lult funtion f 0, f 1,..., f n : V R { } uivly y th following rul. i) f 0 ()=0, f 0 (v)= for ll v ii) For k < n if f k h n foun, omput for ll v V. f k+1 (v)=min{f k (v), min (u,v) A {f k (u)+ β (u, v)} Thr xit ngtiv yl w.r.t. β if n only if f n (v)< f k (v) for om v V n 1 k < n. Thu w n tt in O(m n) tp whthr D, β ontin ngtiv yl. W now pply th following i to rh for th orrt vlu of β. W kp n intrvl I = [L,U ] with th invrint tht th vlu β tht w r rhing li in thi intrvl I. A trting vlu, w n ho L = min n U = mx, whr min n mx r th mllt n lrgt ot rptivly. In on itrtion w omput M = (L+U )/. W thn hk whthr D, togthr with M ontin ngtiv yl. If y, w know tht β i t lt M n w t L M. If not, thn β i t mot M n w upt th uppr oun U M. Whn n w top thi prour? W n top it, if w n ur tht only on vli ot-to-profit rtio yl li in [L,U ]. Suppo tht C 1 n C hv iffrnt ot-to-profit rtio. Thn (C 1 )/p(c 1 ) (C )/p(c ) = (C 1 ) p(c ) (C )p(c 1 ) (p(c 1 ) p(c )) (6.0) 1/(n pmx ). (6.1) Thu w n top our pro, if U L < 1/(n p mx ), in w know thn tht thr n only on yl C with (C)/p(C) [L,U ].
76 Suppo tht [L,U ] i th finl intrvl. W know thn tht L (C)/p(C) for ll C C n U > (C)/p(C) hol for om C C. Lt C minimum wight yl w.r.t. th r ot L. Clrly U > (C)/p(C) L hol n thu C i th minimum ot-to-profit yl w hv n looking for. Lt u nlyz th numr of rquir itrtion. W n to hlv th trting intrvl-lngth, whr i th lrgt olut vlu of ot, until th lngth i t mot 1/(n pmx ). W rh th miniml i N uh tht (1/) i 1/(n pmx ). (6.) Thi how u tht w n O(log( p mx n )) itrtion whih i O(logn log K ), whr K i th lrgt olut vlu of ot or profit. Thorm 6.15 (Lwlr [9]). Lt D igrph with ot : A Z n profit p : A N >0 n lt K N uh tht () + p() K for ll N. A minimum ot-to-profit rtio yl of G n omput in tim O(m n logn log K ). But w knw wkly polynomil lgorithm for MCNFP from th xri. So you urly k: Cn w o ttr for minimum ot-to-profit yl omputtion? Th nwr i Y! 6.7.1 Prmtri rh Lt u firt roughly ri th i on how to otin trongly polynomil lgorithm, [1]. Th Bllmn-For lgorithm tll u whthr our urrnt β i too lrg or too mll, pning on whthr D with wight β ontin ngtiv yl or not. Rll tht th B-F lgorithm omput ll f i (v) for v V n 1 i n. If th ll r omput with ot β, thn thy r piwi linr funtion in β n w not thm y f i (v)[β]. Dnot th optiml β tht w look for y β n uppo tht w know n intrvl I with uh tht β I n h funtion f i (v)[β] i linr if it i rtrit to thi omin I. Thn w n trmin β follow. Lt I = [L,U ] th intrvl n rmmr tht w r rhing for th lrgt vlu of β I uh tht f n (v)[β]= f n 1 (v)[β] hol for h v V. Clrly thi hol for β = L. Thu w only n to hk whthr β = U y omputing th vlu f n (v)[u ] n f n 1 (v)[u ] for h v V n hk whthr on of th pir onit of iffrnt numr. Th i i now to omput uh n intrvl I = [L,U ] in trongly polynomil tim. Conir th funtion f 1 (v)[β]. Clrly on h
77 f 1 (v)[β]= { (, v) β p(, v) if (, v) A, othrwi. Thi how tht f 1 (v)[β] i linr funtion in β for h v V. Now uppo tht i 1 n tht w hv omput n intrvl I = [L,U ] with β I n h funtion f i (v)[β] i linr funtion if β i rtrit to I. Now onir th funtion f i+1 (v)[β] for prtiulr v V. Rll th formul f i+1 (v)[β]=min{f i (v)[β], min (u,v) A {f i (u)[β]+(u, v) β p(u, v)}}. (6.) Eh of th funtion f i (v)[β] n f i (u)[β]+(u, v) β p(u, v) r linr on I. Th funtion f i (v)[β] n rtriv y omputing hortt pth P i (v) from to v with r wight β for om β in (L,U ) whih u t mot i r. If β i thn llow to vry, th lin whih i fin y f i (v)[β] on I i thn th lngth of thi pth P with prmtr β. Similrly w n rtriv th funtion (lin) f i (u)[β]+(u, v) β p(u, v) for h (u, v) A. With th Bllmn-For lgorithm, thi mount to running tim of O(m n). W now hv n lin n n now omput th lowr nvlop of th lin in tim O(n log n) ltrntivly w n lo omput ll intrtion point of th lin n ort thm w.r.t. inring β-oorint. Thi woul mount to O(n log n). Lt β 1,...,β k th ort lit of th β-oorint. Now β tr i l := β k/ n hk whthr β > β tr i l. If y, w n rpl L y β tr i l n w n lt th numr β 1,...,β k/ 1. Othrwi, w rpl U y β tr i l n lt β k/ +1,..., k. In ny, w hlv th numr of poil β-oorint n ontinu in thi wy. Suh hk rquir ngtiv yl tt in th grph D with r wight β tr i l n ot O(m n). In th n w hv two onutiv β-oorint n hv n intrvl [L,U ] on whih f i+1 (v)[β] i linr. To fin n intrvl I uh tht f i+1 (v)[β] i linr on I n β I ot thu O(m n log n) tp. W now ontinu to tightn thi intrvl uh tht ll funtion f i+1 (v)[β], v V r linr on [L,U ]. Thu in tp i+ 1 thi mount to running tim of Th totl running tim i thu O ( n (m n log n) ). O(n m log n). Thorm 6.16. Lt D = (V, A) irt grph n lt : A R n p : A R >0 funtion. On n omput yl C of D minimizing (C)/p(C) in tim O(n m log n).
78 6.7.1.1 Exri 1) Show tht thr r no two iffrnt pth from r to nothr no in irt tr T = (V, A). ) Prov Lmm 6.. ) Why n w um without lo of gnrlity tht minimum ot ntwork h pth from i to j for ll i j V whih i inpitt? 4) Provi n xmpl of MCNFP for whih th impl yl-nling lgorithm from ov n rquir n xponntil numr of nl, if th yl r hon in ivntgou wy. 5) Provi proof of Thorm 6.7. 6) Lt Q =< u 1,...,u k > th quu for n itrtion of th whil loop of th rth-firt-rh lgorithm. Show tht D[u i ] i monotonouly inring n tht D[u 1 ]+1 D[u k ]. Conlu tht th qun of ign ll (ovr tim) i monotonouly inring qun.
89 Rfrn 1. J. Emon. Mximum mthing n polyhron with 0,1-vrti. Journl of Rrh of th Ntionl Buru of Stnr, 69:15 10, 1965.. J. Emon. Pth, tr n flowr. Cnin Journl of Mthmti, 17:449 467, 1965.. F. Einrn, A. Krrnur, n C. Xu. Algorithm for longr ol liftim. In C. Dmtru, itor, 6th Intrntionl Workhop on Exprimntl Algorithm, WEA07, volum 455 of Ltur Not in Computr Sin, pg 8 51. Springr, 007. 4. M. Gröthl, L. Lováz, n A. Shrijvr. Gomtri Algorithm n Comintoril Optimiztion, volum of Algorithm n Comintori. Springr, 1988. 5. L. Khhiyn. A polynomil lgorithm in linr progrmming. Dokly Akmii Nuk SSSR, 44:109 1097, 1979. 6. V. Kl n G. J. Minty. How goo i th implx lgorithm? In Inquliti, III (Pro. Thir Sympo., Univ. Cliforni, Lo Angl, Clif., 1969; it to th mmory of Thoor S. Motzkin), pg 159 175. Ami Pr, Nw York, 197. 7. T. Koh. Rpi Mthmtil Progrmming. PhD thi, Thnih Univrität Brlin, 004. ZIB-Rport 04-58. 8. B. Kort n J. Vygn. Comintoril optimiztion, volum 1 of Algorithm n Comintori. Springr-Vrlg, Brlin, on ition, 00. Thory n lgorithm. 9. E. L. Lwlr. Comintoril optimiztion: ntwork n mtroi. Holt, Rinhrt n Winton, Nw York, 1976. 10. L. Lováz. Grph thory n intgr progrmming. Annl of Dirt Mthmti, 4:141 158, 1979. 11. J. E. Mrn n M. J. Hoffmn. Elmntry Clil Anlyi. Frmn, ition, 199. 1. J. Mtouk n B. Gärtnr. Unrtning n Uing Linr Progrmming (Univritxt). Springr-Vrlg Nw York, In., Suu, NJ, USA, 006. 1. N. Mgio. Comintoril optimiztion with rtionl ojtiv funtion. Mth. Opr. R., 4(4):414 44, 1979. 14. A. S. Nmirovkiy n D. B. Yuin. Informtionl omplxity of mthmtil progrmming. Izvtiy Akmii Nuk SSSR. Tkhnihky Kirntik, (1):88 117, 198. 15. A. Shrijvr. Thory of Linr n Intgr Progrmming. John Wily, 1986. 16. N. Z. Shor. Cut-off mtho with p xtnion in onvx progrmming prolm. Cyrnti n ytm nlyi, 1(1):94 96, 1977.