Conider he following flow nework CS444/944 Analyi of Algorihm II Soluion for Aignmen (0 mark) In he following nework a minimum cu ha capaciy 0 Eiher prove ha hi aemen i rue, or how ha i i fale Uing he algorihm of Ford and Fulkeron we compue he maximum flow f hown in Figure (a) The flow i indicaed by he dahed arrow and he number below hem Since he flow ha value, he claim ha a minimum cu ha capaciy 0 i fale a by he maximum flow minimum cu heorem a minimum cu in he given nework ha capaciy a 0 7 7 a b 6 c b c d 0 d 9 G f (a) (b) ( mark) Find a minimum cu (S,T) eparaing from You need o indicae which verice are in S and which are in T Build he reidual nework G f for he maximum flow in Figure (a) and mark all he verice reachable from he ource verex (haded node in Figure (b) above) Thee verice are in he S ide of a minimum cu A minimum cu for he given flow nework i hen ({,a,b,c},{d,}) (0 mark) Le G = (V,E) be a flow nework wih ource, ink and a poiive ineger capaciy c(u,v) on every edge (u,v) E Le (S,T) be a minimum cu of G eparaing from Le k > 0 be a poiive ineger Claim If he capaciy of every edge (u,v) E i increaed by k, o he new capaciy of edge (u,v) i c (u,v) = c(u,v) +k, he cu (S,T) will ill be a minimum cu wih repec o he new capaciie Deermine wheher he above aemen i rue or fale If i i rue, give proof for i If i i fale, give an example proving he aemen wrong The claim i fale Conider he following flow nework in Figure (c) wih minimum cu ({,},{,,}) Le k = If he capaciy of every edge i increaed by, a hown in Figure (d), hen({,},{,,}) i no a minimum cu anymore a c({},{,,,}) = < c({,},{,,}) = 6
4 4 (c) (d) Le G = (V,E) be a flow nework wih ource, ink, and ineger capaciie A alway, le m be he number of edge and n be he number of verice of G Aume ha we are given a maximum flow f of G, ie we know he value of he flow f(u,v) on every edge (u,v) of G a (0 mark) Le he capaciy of a ingle edge (u,v) E be increaed by an ineger conan value k > 0 Wrie in peudocode, imilar o he one ued in cla, an O(m+n)-ime algorihm o compue a maximum flow for he modified flow nework Algorihm UpdaeFlow (G = (V,E),f,k) Inpu: Flow nework G = (V,E), flow funcion f and ineger conan value k; f i a maximum flow funcion for he nework before he capaciy of an edge wa increaed by k, G i he flow nework afer he capaciy of an edge wa increaed by k Oupu: Maximum flow funcion for G Build he reidual nework G f while G f ha a lea one augmening pah do { Find an augmening pah p in G f Compue he reidual capaciy c f (p) of p For each edge (u,v) p do f(u,v) f(u,v)+c f (p) Build he new reidual nework G f } Reurn f b (0 mark) Prove ha your algorihm compue a maximum flow To how ha he algorihm compue a maximum flow for he modified nework, we fir need o prove ha i erminae Noe ha by increaing he capaciy of a ingle edge by k he capaciy of a minimum cu, and hu he value of a maximum flow, increae by a mo k a well Hence he algorihm erminae a each ieraion of he while loop increae he value of he flow by a lea, o afer a mo k ieraion he algorihm mu erminae Noe ha building he reidual nework, compuing a reidual nework and updaing he value of he flow on he edge of an augmening pah all ake finie ime The algorihm compue a maximum flow of he modified nework becaue by he maximum flow minimum cu heorem, a flow funcion f i a maximum flow for a flow nework G = (V,E) if and only if G f ha no augmening pah The while loop of he above algorihm end only when G f ha no augmening pah and hence he flow reurned i a maximum flow c (0 mark) Show ha he ime complexiy of your algorihm i O(m+n)
Building he reidual nework require ime O(m + n) To deermine wheher G f ha augmening pah and o find an augmening pah p we can ue a deph fir earch algorihm, which run on O(m+n) ime Updaing he value of he flow on he edge of an augmening pah require O(n) ime a an augmening pah ha a mo n edge A menioned above, he while loop perform a mo k ieraion, hence he running ime of he while loop i O(k(m +n)) which i O(m +n) a k i conan Finally, o reurn he flow funcion f we need o pecify he value of he flow on every edge, which ake O(m) ime The ime complexiy of he algorihm i hen O(m+n) 4 A e P = {P,P,,P k } of k compuer program are o be execued by a group C = {C,C,,C l } of compuer The compuer program are claified inobype T,T,,T b, depending on how many compuer reource hey require Each compuer program P i ha a unique ype, T π(i) Each compuer C i can execue a e of a mo a(i) program, bu i can proce a mo a(i,j) program of ype T j, for each j =,,,b The problem i o aign all he program in P o he compuer o he he above condiion are aified, or o how ha uch an aignmen i no poible For example, aume ha here are 7 program {P,P,P,P 4,P,P 6,P 7 } of ype T, T, and T Program P and P are of ype T, program P, P 4, and P are of ype T and he oher one are of ype T There are compuer, C, C, and C : C can proce a mo program, of which could be of ype T and a mo could be of ype T, o a() =, a(,) =, a(,) =, and a(,) = 0 For C we have a() =, a(,) =, a(,) =, a(,) = For C we have a() =, a(,) =, a(,) = 0, a(,) = A oluion i o aign P and P 4 o C, P, P, and P 6 o C and P and P 7 o C i (0 mark) Wrie in peudocode an algorihm for olving hi problem If here i a way of aigning program o compuer, he algorihm mu reurn he value rue, oherwie i mu reurn he value fale Algorihm ProgramAignmen (P, T, C, a) Inpu: Se P of compuer program, e T = {T,T,,T b } of program ype, e C of compuer wih capaciie a Oupu: True, if all he program can be aigned o he compuer wihou exceeding he capaciie a(i) and a(i, j); fale oherwie Build a flow nework G = (V,E), where V = {,} P T C and E = {(,P i ) P i P,c(,P i ) = } {(P i,t π(i) ) P i P,T π(i) T,c(P i,t π(i) ) = } {(T j,c k ) T j T,C k C,c(T j,c k ) = a(k,j)} {(C k,) C k C,c(C k,) = a(k)} Compue a maximum flow f of G uing he algorihm of Ford and Fulkeron If f aurae all edge inciden on hen reurn rue ele reurn fale The following figure illurae he conrucion of he flow nework ii ( mark) Prove ha your algorihm correcly olve he above problem To prove ha he algorihm i correc, firwe need o how ha i erminae Graph G ha a finie number of verice and edge, o i can be conruced in finie ime Since G
P P P T T a(, ) a(, ) C C a() a() P k T b C l a(l) a(b, l) ha finie ize and all capaciie are ineger, he algorihm of Ford and Fulkeron finihe in finie ime Teing wheher he flow f aurae all edge inciden on he ource alo require a finie amoun of ime Hence, he algorihm alway erminae The algorihm reurn he value rue or fale, o he oluion produced by i i feaible To how ha he oupu of he algorihm i correc we need o how ha here i a flow f ha aurae all edge inciden on here i a feaible aignmen A of program o compuer ha doe no exceed he capaciie of he compuer a We how fir ha if here i a flow f ha aurae all edge inciden on here i a feaible aignmen A of program o compuer For hi we need o how how o conruc a feaible aignmen A given ha we know he value of he flow f on every edge of G A feaible aignmen A aign all program o compuer o ha he capaciie a(i) and a(i, j) of he compuer are no exceeded The aignmen A i conruced a follow For each program ype T i le P i = {P j f(p j,t i ) = }, o P i i he e of program of ype T i ha are o be aigned o compuer Program in P i are aigned o compuer a follow: The fir f(t i,c ) program of P i are aigned o C The nex f(t i,c ) program of P i are aigned o C The la f(t i,c l ) program of P i are aigned o C l Noe ha ince f aifie he flow conervaion propery, he above proce aign all program in P i o compuer Since all edge inciden on are auraed, hen f(,p i ) = f(p i,t π(i) ) = for each program P i and hu each program belong o ome e P j Therefore, by he above argumen each program i aigned o a compuer ThenumberofprogramofypeT j aignedocompuerc i if(t j,c i ) c(t j,c i ) = a(i,j) andheoalnumberofprogramaignedocompuerc i i T j T f(t j,c i ) = f(c i,) a(i), he fir equaliy hold becaue of he flow conervaion propery; hence he compuer capaciie are no exceeded and hu he above i a feaible aignmen of program o compuer b Finally, we how ha if herei a feaible aignmen A of all program o compuer here i a flow f ha aurae all edge inciden on We now how how o build he flow f from he aignmen A: 4
f(,p i ) = for each P i P f(p i,t π(i) ) = for each P i P f(t j,c i ) = number of program of ype T j ha A aign o compuer C i a(i,j), a A i a feaible aignmen of program o compuer f(c i,) = oal number of program aigned o compuer C i a(i), a A i a feaible aignmen of program o compuer The above flow funcion f aifie he capaciy conrain We how now ha i alo aifie he flow conervaion propery f(,p i ) = f(p i,t π(i) ) = for each program P i P, o flow conervaion i aified a each node P i P j P f(p j,t i ) = C j C f(t i,c j )foreachprogramypet i, a P j P f(p j,t i ) iequalohenumberofprogramofypet i andhivalueiequalo C j C f(t i,c j ) a all program of ype T i are aigned by A o compuer Hence, flow conervaion i aified on all node T i T T j T f(t j,c i ) = f(c i,) a T j T f(t j,c i ) i he oal number of program aigned o C i and hi number i equal o f(c i,) Hence flow conervaion i aified on all node C i C The above hen i a feaible flow funcion f ha aurae all edge inciden on (0 mark) Compue he ime complexiy of your algorihm The flow nework G conruced by he algorihm ha k +b+l+ node and a mo k + k + bl + l edge Hence building he flow nework require O(k + bl) ime The algorihm of Ford and Fulkeron require O(#edge f ) = O(k(k + bl)) ime a f k ince he cu ({},V \{}) ha capaciy k Finally, checking wheher all edge inciden on he ource are auraed require O(k) ime Hence, he ime complexiy of he algorihm i O(k(k +bl))