Ford-Fulkerson Algorihm for Maximum Flow 1. Assign an iniial flow f ij (for insance, f ij =0) for all edges.label s by Ø. Mark he oher verices "unlabeled.". Find a labeled verex i ha has no ye been scanned. Scan i as follows For every unlabeled adjacen verex j, (a or b or c) a) if C ij > f ij and f ij 0 compue Δ ij = C ij f ij and Δ j where Δij if i = 1 Δ j = min( Δi, Δij) if i > 1 Label j wih a forward label (i +, f ij ) b) if C ij > f ij and f ij <0 (opposie direcion) Δ j =min (Δ j, f ij ) Label j wih a backward label (i, Δ j ) c) if C ij = f ij No operaion. If no unlabeled j exiss STOP. ) Repea sep unil is reached. [This gives a flow augmening pah P: s > ] If i is impossible o reach hen STOP. ). Backrack he pah P, using he labels. )Using P, augmen he exising flow by Δ, Se f = f + Δ,. 7) Remove all labels from verices,, n. Go o Sep. Example: Find he maximum flow from s o in he following graph. 0,0 10,0 11,0,0 7,0 Soluion 1) C 1 =0, C =11, C =1, C =, C 1 =10, C =7, C =, C =, f 1 =f =f =f =f 1 =f =f =f =0,,0 1,0,0 ) verex 1 (s) is labeled Ø,,,,, are unlabeled ) Scan 1. i=1,adjacen labels and. [ j= and j=] C 1 =0. f 1 =0. (perform a) For verex j= Δ 1 = C 1 f 1 = 0 0=0 Δ = Δ 1 =0. L = {1 +, 0} For verex j= C 1 =0. f 1 =0. (perform a) Δ 1 = C 1 f 1 = 10 0=10 Δ = Δ 1 =10. L = {1 +, 10} Scan. i=,adjacen label, and. [ j= and j=] For verex j= C =11. f =0. Δ = C f = 11 0 = 11 Δ = min (Δ, Δ ) = min(0, 11) =11 L = { +, 11} For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(0,0) =0 L = {, 0} Scan. i=,adjacen labels, and. [ j= ] (j= and j= are already labelled) C =1. f =0. Δ = C f = 1 0 = 1 Δ = min (Δ, Δ ) = min(11, 1) =11 L = { +, 11} Since verex is Δ =11 ---------------------------------- Now all verices are all labeled Find he pah L = { +, 11} L = { +, 11} L = {1 +, 0} L1 Thus one augmening pah i--- Add Δ =11 o his pah f 1(new) = f 1(old) + Δ f 1 = 0 + 11 f =0 +11=11 f =0 +11=11 Remove all he labels. Sar scanning
1) C 1 =0, C =11, C =1, C =, C 1 =10, C =7, C =, C =, f 1 =f =f =11, f =f 1 =f =f =f =0, ) verex 1 (s) is labeled Ø,,,,, are unlabeled ) Scan 1. i=1,adjacen labels and. [ j= and j=] C 1 =0. f 1 =11. (perform a) For verex j= Δ 1 = C 1 f 1 = 0 11=9 Δ = Δ 1 =9. L = {1 +, 9} For verex j= C 1 =10. f 1 =0. Δ 1 = C 1 f 1 = 10 0=10 Δ = Δ 1 =10. L = {1 +, 10} Scan. i=, Adjacen label, and. [ j= and j=] For verex j=, C =11. f =11. C = f No acion. For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(9,0) =0 L = {, 0} Scan. 0,11 10,0,0 7,0 i= no labeled no acion. Scan. i= Adjacen label,. [ j=] C =7. f =0. Δ = C f = 7 0 = 7 Δ = min (Δ, Δ ) = min(10, 7) =10 L = { +, 10} Scan. i= Adjacen labels,,, [ j=, j=] (j= j= are already labelled) C =. f =0. Δ = C f = 0 = Δ = min (Δ, Δ ) = min(10, ) = L = { +, },0 1,11,0 Since verex is Δ = ---------------------------------- Now all verices are all labeled Find he pah L = { +, } L = { +, 10} L = {1 +, 0} L1 Thus one augmening pah i--- Add Δ = o his pah f 1(new) = f 1(old) + Δ f 1 = 0 + f =0 += f =0 += Remove all he labels. Sar scanning ) verex 1 (s) is labeled Ø,,,,, are unlabeled ) Scan 1. i=1,adjacen labels and. [ j= and j=] C 1 =0. f 1 =11. (perform a) For verex j= Δ 1 = C 1 f 1 = 0 11=9 Δ = Δ 1 =9. L = {1 +, 9} For verex j= C 1 =10. f 1 =. Δ 1 = C 1 f 1 = 10 =7 Δ = Δ 1 =7. L = {1 +, 7} Scan. i=, Adjacen label, and. [ j= and j=] For verex j=, C =11. f =11. C = f No acion. For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(9,0) =0 L = {, 0} Scan. 0,11 10,,0 7, i= no labeled no acion. Scan. i= Adjacen label,. [ j=] C =7. f =0. Δ = C f = 7 0 = 7,0 1,11,
Δ = min (Δ, Δ ) = min(10, 7) =10 L = { +, 10} Scan. i= Adjacen labels,,, [ j=, j=] (j= j= are already labelled) C =. f =0. Δ = C f = 0 = Δ = min (Δ, Δ ) = min(10, ) = L = { +, } Soluion 1) C 1 =0, C =11, C =1, C =, C 1 =10, C Scan. i=,adjacen label, and. [ j= ] (j= and j= are already scanned) C =1. f =0. Δ = C f = 1 0 = 1 Δ = min (Δ, Δ ) = min(11, 1) =11 L = { +, 11} Since L is For verex j=, f <0 (perform b) Δ = min( Δ f ) = min(0,0) =0 L = {, 0} vv Δ = Δ 1 =10. L = {1 +, 10} Scan and. Second Number: given flow (f i,j ) S: source : arge Pah: sequence of edges in a diagraph Flow augmening pah: Pahs from S o. Examples: Pah 1=(1---) Pah =(1--- ) Pah =(1----) Forward edge:if he direcion of pah is he same as he direcion of edge i is called forward edge. Backward edge:if he direcion of pah is he opposie of he direcion of edge i is called forward edge. Pah 1: 1-, -, - all forward edges Pah : 1-, -, - forward edges, backward edge C ij =he capaciy of edge from i o j f ij =The value of curren flow from i o j. ij =possible addiional flow from edge i o j. ij = C ij - f ij 1 =0-=1, =11-8=, =1-=7, 1 =10-=, =7-=, =-=0, =- =. Maximum Flow: Maximum possible flow from s o Kirchof s rule: Incoming flow=ougoing flow Example: for verex,, incoming flow. 8:ougoing flow.. +=8 Possible addiional flow in pah 1 We can increase maximum flow by because he edge, allows only. No addiional flow is possible in pah, because =0, addiional flow is possible in pah. 0,8 10, Δ =11,,0 7, Ford-Fulkerson Algorihm for Maximum Flow ALGORفTHM FORD-FULKERSON [G = (V, E), verices l (= s),, n (= ), edges (;', j), Cy] This algorihm compues he maximum flow in a nework G wih source s, sink (, aý capaciies Cy > O of he edges (;', j). INPUT: n, s = l, = n, edges (;', j) of G, Cy OUTPUT: Maximum flow f in G 1. Assign an iniial flow f y (for insance, f y = O for ali edges), compue f.. Label s by 0. Mark he oher verices "unlabeled." J. l'lllu a laü^l^u v^/ha/a. ilul lýuo llü J^l Uüülý a^^mý^u. 0^0.11 For every unlabeled adjacen verex j, if Cy > f\p compue 1,11,
Ay = Cy - fy and A, and label7 wih a "fonvard label" (i" 1 ', A,); or if f^ > O, compue A, == min(a,, f,,) and label j by a "backward label" (;~, Aj). If no such j exiss hen OUTPUT f. Sop [^" ; r/îe ma xim um flo w.} Els e con in ue (h a is, go o Se p ).. Repea Sep unil is reached. A if ( = l ' ü im in (A,, A y) if ; > l [This gives a flow augmening pah P: s >.} If i is impossible o reach hen OUTPUT f. Sop [f is he ma xim um flo w.} Els e con in ue (h a is, go o Se p ).. Backrack he pah P, using he labels.. Using P, augmen he exising flow by a(. Se f = f + a(. 7. Remove ali labels from verices,, n. Go o Sep. End FORD-FULKERSON A Nework is a diagraph in which each edge has assigned o i a capaciy (maximum flow) 0, 10, 11,8, 7, Graphs and Combinaorial Opimizaion 1.7 Ford-Fulkerson Algorihm for Maximum Flow, 1,,
Flow augmening pahs, as discussed in he las secion, are used as he basic ool ini Ford-Fulkerson algorihm in Table 1.8 in which a given flow (for insance, zero flofl ali edges) is increased unil i is maximum. The algorihm accomplishes he increase a sepwise consrucion of flow augmening pahs, one a a ime, unil no furher sý pahs can be consruced, which happens precisely when he flow is maximum. Table 1.8 Ford-Fulkerson Algorihm for Maximum Flow ALGORفTHM FORD-FULKERSON [G = (V, E), verices l (= s),, n (= ), edges (;', j), Cy] This algorihm compues he maximum flow in a nework G wih source s, sink (, aý capaciies Cy > O of he edges (;', j). INPUT: n, s = l, = n, edges (;', j) of G, Cy OUTPUT: Maximum flow f in G 1. Assign an iniial flow f y (for insance, f y = O for ali edges), compue f.. Label s by 0. Mark he oher verices "unlabeled." J. l'lllu a laü^l^u v^/ha/a. ilul lýuo llü J^l Uüülý a^^mý^u. 0^0.11 For every unlabeled adjacen verex j, if Cy > f\p compue A if ( = l 'ü Ay = Cy - fy and A, imin (A,, Ay) if ; > l and label7 wih a "fonvard label" (i" 1 ', A,); or if f^ > O, compue A, == min(a,, f,,) and label j by a "backward label" (;~, Aj). If no such j exiss hen OUTPUT f. Sop [^" ; r/îe maximum flow.} Else coninue (ha is, go o Sep ).. Repea Sep unil is reached. [This gives a flow augmening pah P: s >.} If i is impossible o reach hen OUTPUT f. Sop [f is he maximum flow.} Else coninue (ha is, go o Sep ).. Backrack he pah P, using he labels.. Using P, augmen he exising flow by a(. Se f = f + a(. 7. Remove ali labels from verices,, n. Go o Sep. End FORD-FULKERSON Graphs and Combinaorial Opimizaion Chap. Table1.9