Algorihm and Daa Srucure 2011/ Week Soluion (Tue 15h - Fri 18h No) 1. Queion: e are gien 11/16 / 15/20 8/13 0/ 1/ / 11/1 / / To queion: (a) Find a pair of ube X, Y V uch ha f(x, Y) = f(v X, Y). (b) Find a differen pair of ube X, Y V uch ha f(x, Y) f(v X, Y). Aner: The poin of hi queion i o ge hinking abou flo beeen e of erice, b appling Lemma 3 of Lecure lide 13-1. Hoeer, i migh be good o hink abou pecific eample of (a), (b) fir, before looking a he deail of ha he paern i. Wha e are aking i: hen i i he cae ha f(x, Y) + f(v X, Y) = 0? Remember from Lemma 3 (par 3) of lide 13-1 ha for an o dijoin e X, Y V, and an oher e Z, and an flo f, e hae f(x, Z ) + f(y, Z ) = f(x Y, Z ). Obere ha for our queion, cerainl X and V X are dijoin e. Hence b Lemma 3 (3), e kno f(x, Y) + f(v X, Y) = f(x (V X), Y) = f(v, Y). So e are eing heher f(v, Y) = 0 for (a), and heher f(v, Y) 0 for (b) - once hi i aified, X can be anhing... To make f(v, Y) = 0, e hould eiher ake Y uch ha Y {, } =, or Y {, } = {, }. Thi can be een b repeaed applicaion of par (3) of Lemma 3 from lide 13-1. To make f(v, Y) 0, e hould ake Y uch ha Y {, } = 1. Here are ome concree eample of hi behaiour: (a) A a concree eample, le Y = {, }. X can be *an* e, ake X = {} a an eample. Then f(x, Y) = + = 8. Then f(v X, Y) = 11 + 8 11 = 8. 1
(b) A a concree eample, ake Y = {}. Take X = {} again. Then e hae f(x, Y) = 0. We hae f(v X, Y) = 11 8 = 1. 2. Queion: eecue he Ford-Fulkeron algorihm (uing he Edmond-Karp heuriic) on he Neork belo: 16 20 13 1 Aner: If e are uing he Edmond-Karp heuriic, hen eer ime e earch for an augmening pah, e mu chooe a hore augmening pah. For our gien neork, e can ee ha on he fir ieraion, he pah p1 = i a hore pah. We hae c(p1) =. Hence e define he flo f1 = f p1 b for e = (, ), (, ), (, ) f1(e) = f p1 (e) = for e = (, ), (, ), (, ) 0 oherie Picoriall, e hae /16 / /20 13 1 The reidual neork N f1 i a follo: 13 1 8 We no eamine N f1 o find a hore augmening pah. We find ha p2 = i a hore augmening pah in N f1, min capaci, ee aboe... We herefore define a ne flo f p2 uch ha uni are hipped along he edge of he 2
pah p2, and - hipped in he backard direcion of p2. Then e define he flo f2 = f1 + f p2. Remember o poin ou hi i poible *onl* becaue f1 i a flo in N and f2 i a flo in he *reidual* neork N f1. Belo i he flo f2 = f1 + f p2 in N. /16 / /20 /13 /1 / Belo i he reidual neork N f2. If e again r he Edmond-Karp rule for finding an augmening pah of hore poible lengh, e find he pah p3 = (hi i of lengh, bu here are no pah of lengh 3 or le in N f2 ). The min capaci along he pah i. 8 We define a ne flo f p3 in N f2 b hipping uni along p3. Then e define he flo f3 in N a f3 = f2 + f p3. The flo look a follo: /16 / 1/20 11/13 11/1 / / We compue he reidual neork N f3, ee belo for a picure. 2 11 3 1 1 11 3
B Ford-Fulkeron algorihm, e no r for a (hore) augmening pah in he N f3. Hoeer, if e eamine N f3, e ee ha here i *no* augmening pah from o - he e of erice acceible from i no {,,, }. Hence e erminae, reurning he flo f3, of alue 23. 3. Queion: Thi queion conider he cenario of dnamicall-eoling capaciie in a neork. We ar ih a fied neork N = (G = (V, E), c,, ), and compue a maimum flo f for N. Hoeer a an ime in he fuure e ma receie noificaion ha he capaci of a paricular arc in he neork i being increaed b 1 (or decreaed b 1). To queion: (a) Suppoe ha he capaci of a ingle edge (u, ) E i increaed b 1. Gie a O( V + E )-ime algorihm hich updae f o obain a ma flo f for he updaed neork. (b) Suppoe ha he capaci of a ingle edge (u, ) E i decreaed b 1. Gie a O( V + E )-ime algorihm hich updae f o obain a ma flo f for he updaed neork. Aner: (fairl hard) (a) Suppoe ha e hae a ma flo f for he neork N, and ha e are old ha a paricular edge (u, ) i haing i capaci increaed b 1. Fir obere ha hi increae canno *decreae* he ma flo of he neork - clearl eer flo in he original neork i a flo in he modified neork. The increae in (u, ) capaci ma or ma no *increae* he ma flo. Le N be he modified neork (ame a N ecep (u, ) ha capaci c(u, ) + 1). Conider he flo f in he neork N, and le N f be he reidual neork. I claim ha f i a ma flo in N if and onl if here i *no* augmening pah in N f. Hence e hae he folloing algorihm o updae he ma flo hen he capaci of an edge i increaed b 1: 1. Take he original ma flo f and compue N f. 2. Search for an augmening pah in N f. 3. If e find an augmening pah p, reurn f + f p a he ma flo for he updae neork. OTHERWISE if e find no augmening pah, reurn f. The algorihm i correc for he folloing reaon. Fir if here i no augmening pah in N f, hen b Corollar 1 of lecure lide 13-1, f i a ma flo. Second, if here i an augmening pah p in N f, hen (i) The capaci c(p) of p in N f i 1 (if i a greaer han hi, f could no hae been a ma flo for N). (ii) Define f = f + f p. Then N f ha no augmening pah (ame reaon a for (i)). Hence in he cae here N f doe hae an augmening pah p, e kno ha f = f+f p i a ma flo of N.
Thi algorihm can be eecued in he ime i ake o conruc he reidual neork O( V + E ), and he ime i ake o find one augmening pah (O( V + E ) b breadh-fir earch). Hence i i O( V + E ) in oal. (b) If e decreae he alue of (u, ) b 1 from i original alue in N, hen he ma flo of he updaed neork N can be no greaer han he ma flo of N (and poibl le). If i i he cae ha he ma flo f of N aifie f(u, ) < c(u, ), hen f ill alo be a flo (and hence he ma flo) in N (here (u, ) ha capaci c(u, ) 1). Hoeer, if e had f(u, ) = c(u, ) in N, hen he ma flo of N migh hae alue ricl le han f. Here i our algorihm. 1. If e had f(u, ) < c(u, ) in N, hen f i a (ma) flo in N. Reurn f. 2. OTHERWISE (if e had f(u, ) = c(u, )). (i). Find a imple pah p1 in N f from u o. (ii). Find a imple pah p2 in N f from o. (iii). Take he pah p2, (, u), p1 in N f, and roue 1 uni of flo from o along hi pah. Adding hi o f, e ge a ne flo f of alue f 1 in N, ih f (u, ) < c(u, ). Hence f i a flo in N alo. (i) Finall perform a earch in N f for an augmening pah. () If e find an augmening pah p in N f, reurn he flo f + f p (of alue f ). (i) Oherie, reurn f. Noe ha a reidual neork onl keep edge ih ricl +e alue (nb for (iii)). The running ime of he algorihm i O( V + E ) (ame reaon a for (a) ecep e ma do 3 breadh-fir earche, in (i), (ii), (i), here).. Queion: A ell-knon problem in graph heor i he problem of compuing a maimum maching in a biparie graph G. Gie an algorihm hich ho ho o ole hi problem in erm of he neork flo problem. Definiion: A (undireced) graph G = (V, E) i biparie if e hae V = L R for o dijoin e L, R, uch ha for eer edge e = (u, ) eacl one of he erice u, lie in L, and he oher in R. A maching in an (undireced) graph G i a collecion M of edge, M E, uch ha for eer ere V, belong o a mo one edge of M. A maimum maching i a maching of maimum cardinali (for a pecific graph). Aner: To ole hi queion, e ill deign a neork, baed on he biparie graph G, here a maimum flo in he neork correpond o a maimum maching in G. Define he ere e V for our neork N o be V = L R {, }, here, are o ne diinguihed erice. 5
Define he (direced) edge e E a follo: E = {(, u) : u L} {(u, ) : u L, R, (u, ) E} {(, ) : R}. noice ha he middle e in he union aboe i ju he edge e E of he original graph, ih all of hee edge no direced from L o R. Define he capaciie of he neork a follo: c(, u) = 1 c(u, ) = 1 c(, ) = 1 for eer u L for eer u L, R, (u, ) E for eer R I no claim ha eer flo of alue k in N correpond o a maching of cardinali k in G. The ma flo = maimum maching follo direcl from hi. Suppoe f i a flo of alue k in N. We aume ihou an lo of generali ha f i an inegral flo (becaue all capaciie are ineger). Recall ha in N, he ere ha L neighboring edge (, u). B definiion of he alue of a flo, k = u V f(, u) = u L f(, u). Therefore eacl k of he (, u) edge carr 1 uni of flo each (ince no (, u) edge can carr more han 1). Moreoer b Lemma 11 in Lecure lide 13-1, eer (S, T) cu in he neork mu be carring flo of alue k. Hence if e ake S = {} L, hen e ee here are eacl k (u, ) edge in he neork hich carr eacl 1 uni of flo from lef o righ (ince no (u, ) edge can carr more han hi). Define M = {(u, ) E : f(u, ) = 1 in N}. Cerainl M = k. I no ho ha M i a maching. For eer u L, he flo coneraion proper mu hold. For hi neork, hi mean ha for eer u L, e require ( R f(u, )) + f(u, ) = 0. Therefore if f(, u) = 0, e require f(u, ) = 0 for eer (u, ) E. If f(, u) = 1 (o f(u, ) = 1), e require f(u, ) = 1 for eacl one (u, ) E (uing our ineger aumpion). Hence eer u L ill appear a mo once in M. We can ue a imilar argumen o ho ha eer R can appear a mo once in M. Hence M i a maching. Thi i eaier. Ju eplain ho he maching of G ge mapped o N and check flo coneraion. Mar Cran 6