CSE 202: Deign and Analyi of Algorihm Winer 2013 Problem Se 3 Inrucor: Kamalika Chaudhuri Due on: Tue. Feb 26, 2013 Inrucion For your proof, you may ue any lower bound, algorihm or daa rucure from he ex or in cla, and heir correcne and analyi, bu pleae cie he reul ha you ue. Problem 1 i worh 18 poin. Problem 2 i worh 12 poin. If you do no prove ha your algorihm i correc, we will aume ha i i incorrec. If you do no provide an analyi of he running ime, we will aume you do no know wha he running ime i. Problem 1 The following aemen may or may no be correc. For each aemen, if i i correc, provide a hor proof of correcne. If i i incorrec, provide a couner-example o how ha i i incorrec. 1. In he capaciy-caling algorihm, an edge e can be preen in he reidual graph G f (D) in a mo one D-caling phae. 2. The max-flow problem wih node capaciie i defined a follow. We are given a direced graph G = (V, E) wih ource, ink and capaciie c v 0 for all node v V (bu no edge capaciie c e ). A flow f i feaible in G if for all v oher han and, he oal flow ino node v i a mo c v, and he ize of a feaible flow f i he oal flow ou of. Given hi inpu, he max-flow problem wih node capaciie i o compue a feaible flow of maximum ize. Compuing a max-flow wih node capaciie can be reduced o he regular max-flow problem. 3. Le f and h be a preflow and a labeling compaible wih he preflow. Le (u, v) be an edge in he original graph G, and le h(v) = 4 and h(u) = 2. Then, f(u, v) = 0. 4. Suppoe you have already compued a maximum (, )-flow f in a flow nework G wih ineger capaciie. Le k be an arbirary poiive ineger, and le e be an arbirary edge in G whoe capaciy i a lea k. Now uppoe we increae he capaciy of e by k uni. Then, he maximum flow in he updaed graph can be compued in O( E k) ime. 5. If all direced edge in a nework have diinc capaciie, hen here i a unique maximum flow. 6. If we replace each direced edge in a nework wih wo direced edge in oppoie direcion wih he ame capaciy and connecing he ame verice, hen he value of he maximum flow remain unchanged. Soluion 1. Fale. In he following graph G, he (, a) edge i preen in wo D-caling phae D = 2 5 and D = 1.
2 5 + 1 2 5 a 2. True. The reducion i a follow. We build a graph G, which, for each node v in G wih node capaciy c v, ha wo node wo node v 1 and v 2. All incoming edge o v connec o v 1, and all ougoing edge from v connec from v 2. Finally, add he edge (v 1, v 2 ) wih edge capaciy c v. Now any flow f in G which repec he node capaciy conrain can be convered o a flow f in G which alo repec he edge capaciy conrain. To conver f o f, e f (u 2, v 1 ) = f(u, v) for any edge (u, v) G, and f (v 1, v 2 ) o be he oal incoming flow a node v. A he node capaciy conrain on v i aified in G, f (v 1, v 2 ) c v, and hence f aifie he edge capaciy conrain in G. f alo aifie conervaion conrain becaue f aifie conervaion conrain and becaue of he way we e f (v 1, v 2 ). Moreover, any flow f in G can be convered o a flow f in G ha aifie he node capaciy conrain. To conver f o f, e f(u, v) = f (u 2, v 1 ) for any edge (u, v) G. f aifie node capaciy conrain becaue f aifie capaciy and conervaion conrain; hi enure ha he oal flow hrough any node v i a mo c v. Finally f aifie conervaion conrain becaue f aifie conervaion conrain oo. Thu he max flow in G correpond o a flow in G of maximum ize ha repec he node capaciy conrain. 3. True. Proof i by conradicion. If f(u, v) 0, hen (v, u) i in he reidual graph G f. Noe ha h(v) > h(u) + 1; hi violae he compaibiliy propery for he edge (v, u) G f. 4. True. Simply compue he reidual graph and run he hill-climbing Ford-Fulkeron algorihm from ha poin. The min cu capaciy increae by a mo k. Thu he max flow ize will increae by a mo k. A each ieraion of Ford Fulkeron ake O( E ) ime, and each ieraion improve he max flow by a lea 1, he oal running ime will be O(k E ). 5. Fale. In he following graph G, all he edge capaciie are unique; ye here are a lea wo max-flow f 1 and f 2 of ize 1. Here f 1 (, a) = f 1 (a, v) = f 1 (v, ) = 1, and f 1 (e) = 0 for all oher edge e; f 2 (, b) = f 2 (b, v) = f 2 (v, ) = 1, and f 2 (e) = 0 for all oher edge e.
2 a 3 v 1 4 5 b 6. Fale. Aume ha edge capaciie are 1. In G 1, he max-flow ha ize 0, wherea in G 2, he ize of he max-flow i 1. G1 G2 Problem 2 In a public building uch a a movie heaer, i i imporan o have a plan of exi in he even of a fire. We will deign uch an emergency exi plan in hi queion uing max-flow. Suppoe a movie heaer i repreened by a graph G = (V, E), where each room, landing, or oher locaion i repreened by a verex and each corridor or airway i repreened by an edge. Each corridor ha an aociaed capaciy c, meaning ha a mo c people can pa hrough he corridor a once. Travering a corridor from one end o he oher ake one imeep. (Travering a room ake zero ime.) 1. Suppoe all people are iniially in a ingle room, and here i a ingle exi. Show how o ue maximum flow o find a fae way o ge everyone ou of he building. (Hin: creae anoher graph G ha ha verice o repreen each room a each ime ep.) 2. Show how he ame idea can be ued when people are iniially in muliple locaion and here are muliple exi. 3. Finally, uppoe ha i ake differen (bu ineger) amoun of ime o cro differen corridor or airway, and ha for each uch corridor or airway e, you are alo given an ineger (e) which i he number of econd required o cro e. Now how how o ranform your algorihm in Par (1) o find a fae way o ge everyone ou of he building.
Soluion 1. Suppoe ha here are M people ha need o be moved ou. Fir, we provide an algorihm o decide if all people can be moved ou in T ep. Given hi algorihm, we can do a binary earch on T beween 1 o V M/c o find he hore ime in which all he people can move ou. Our algorihm i a follow: given he graph G, we conruc G T a follow. For each v V, we make T copie of v: v 1,..., v T, where copy v i correpond o ime ep i. For each i, we conruc an edge from v i o v i+1 a ime wih infinie capaciy (people can ju ay in room a a ime ep). We hen conruc an edge from v i o w i+1 wih capaciy c if here exi an edge from v o w wih capaciy c in G. Suppoe everyone i in room a iniially, and he exi i room b. Then we e he ource = a 1, and he ink = b T. To e if all he people can ge from he ource o he ink in T imeep, we check if he max flow in G T i greaer han or equal o he number of people iniially a he ource. If o, we can move all he people acro hi graph in T imeep. 2. We can ue he ame overall idea: conruc a graph G T, and compue i max flow. If i max flow i greaer han or equal o he oal number of people we are rying o move, hen T ime uni uffice o move all he people acro he graph. The conrucion of G T i he ame, excep for he following. We creae a ink and ource. Le S be he ar verice correponding o he room ha iniially conain all he people, and le U be he ink verice ha correpond o all he exi. We creae a link from o each x 1, for each x S wih capaciy equal o he number of people aring a x. Similarly, we creae a link from each x T (for each x U) o T wih infinie capaciie. 3. Again, he overall idea i he ame. Bu when we conruc G T now, we creae edge beween he layer in a differen way: conruc he edge linking v i o w i + (v, w) wih capaciy c if here i an edge beween v and w in G wih rani ime (v, w). Correcne. Suppoe he number of ep oupu by he algorihm i T, and iniially here are M people. To how he correcne, we need o how he following wo aemen. Fir, if here i a way o ge everyone ou of he building in T ep, hen, here exi a flow of ize M in G T. Second, if here exi a flow of ize M in G T, hen, here i a way o ge everyone ou of he building in T ep. We prove hee aemen for par (a) of he queion below; he proof for par (b) and (c) are analogou. For he fir par, conider a chedule for geing everyone ou of he building in ime T. We how ha hi chedule can be convered o a valid flow f of ize M in G T. Given he chedule, we build f a follow: if m people are en hrough he corridor (v, w) a ime i, e f((v i, w i+1 )) = m. If m people linger a room v a ime i, e f((v i, v i+1 )) = m. Se f((u, v)) = 0 for any oher edge (u, v) G T. Since no more han c people can go hrough a corridor a any ime, f aifie all capaciy conrain. Moreover, becaue he chedule enure ha anyone who ener an inermediae room v oher han and ulimaely leave i, and becaue of he way we e f((v i, v i+1 )), f alo aifie conervaion conrain. Finally, he ize of f i he number of people ulimaely moving ou of room a, which i M. Thu if a valid chedule exi, hen, G T ha a max flow of ize M. For he econd par, conider a flow of ize M in G T, and conver i o a chedule a follow: end f((v i, w i+1 )) people from room v o room w hrough he corridor connecing hee room a ime i. Thi i a valid chedule by conrucion of G : all people ar from he ource, and end up a he exi, and people who ener corridor (v, w) a ime i leave a ime i + 1. Moreover, becaue f aifie capaciy conrain, no corridor ha more han c people a any ime; becaue f aifie conervaion conrain, people who ener a room mu ulimaely leave he room. Finally, hi chedule ge everyone ou of he building in ime T, becaue everyone i a he exi a ime T. Thu, if here i a flow of ize M in G T, hen here i a chedule o ge everyone ou of he building in ime T. The correcne proof for par (b) and (c) i analogou.
Running Time. Suppoe he movie heaer ha n room and m corridor. Then for a given T, he conruced G T ha O(T n) node and O(T (m + n)) edge, regardle of which verion of he problem i being olved. The maximum flow value i M and he reducion will work wih a maximum edge capaciy of O(M). The running ime for he max flow problem in ieraion T i hu O(min((m + n)t M, (m + n) 2 T 2 log M, (m + n)n 2 T 3 )), depending on he relaive value of M, T, m and n. We can find he opimal value of T by doing a binary earch fir we double unil we can ge everyone ou of he building in ep; if he fir uch value of we encouner i, hen we can do a binary earch on he inerval [ /2, ] o ge o he correc value of T. Thi procedure will involve O(log T ) invocaion of max flow, each invoked for a 2T. Thu he oal running ime i: O ( log T min((m + n)t M, (m + n) 2 T 2 log M, (m + n)n 2 T 3 ) )