Network flow problem [Adapted from M.Chandy]
Maximum Flow - Example 12 a b 16 20 10 s 4 t 9 7 13 4 c d 14
Maximum Flow - Example 12/12 a b 11/16 15/20 0/10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14
Maximum Flow - Example 12/12 a b 11/16 19/20 0/10 s 1/4 t 0/9 7/7 12/13 4/4 c d 11/14
Maximum Flow - Flow Network Flow network - directed graph G = (V,E) in which each edge (u,v) E has a non-negative capacity c(u,v) 0. If (u,v) E, we assume c(u,v) = 0.
Maximum Flow - Flow A Flow in G - a real valued function f : VV R: for all u,v V : f(u,v) c(u,v) for all u,v V : f(u,v) = – f(v,u) for all u V – {s,t} : vV f(u,v) = 0
Maximum Flow - Flow The value of flow : | f | = vV f(s,v) Problem Given a flow network G with source s and sink t, find a flow f with a maximum possible value | f |.
Maximum Flow - Flow Properties X,Y - sets of vertices f(X,Y) = xX yY f(x,y)
Maximum Flow - Flow Properties Lemma Let G = (V,E) be a flow network and let f be a flow in G. Then: for X V : f(X,X) = 0 for X,Y V : f(X,Y) = – f(Y,X) for X,Y,Z V, XY = : f(XY,Z) = f(X,Z) + f(Y,Z) f(Z,XY) = f(Z,X) + f(Z,Y)
Maximum Flow - Ford-Fulkerson Method procedure FordFulkerson(graph G, source s, sink t) initialize flow f to 0 while there exists an augmenting path p do augment flow f along p return f
Maximum Flow - Residual Networks G = (V,E) - flow network s - source, t - sink f - flow in G Residual capacity of u,vV: cf(u,v) = c(u,v) – f(u,v)
Maximum Flow - Residual Networks G = (V,E) - flow network f - flow in G Residual network induced by f: Gf = (V,Ef), where Ef = {(u,v) VV: cf(u,v) > 0}
Maximum Flow - Residual Networks - Example 12/12 a b 11/16 15/20 0/10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14
Maximum Flow - Residual Networks - Example 12 a b 11 15 5 4 5 s 11 3 t 7 5 5 8 4 3 c d 11
Maximum Flow - Residual Networks - Example 12 a b 11 15 5 4 5 s 11 3 t 7 5 5 8 4 3 c d 11
Maximum Flow - Residual Networks - Example 12/12 a b 11/16 19/20 0/10 s 1/4 t 0/9 7/7 12/13 4/4 c d 11/14
Maximum Flow - Residual Networks - Example 12 a b 11 19 5 1 s 11 3 t 7 9 1 12 4 3 c d 11
Maximum Flow - Residual Networks Lemma Let G = (V,E) be a flow network with source s and sink t. Let f be a flow in G. Let Gf be a residual network induced by f and let f ’ be a flow in Gf. then the flow sum f + f ’ defined by (f + f ’) (u,v) = f(u,v) + f ’(u,v) is a flow in G with value | f + f ’| = | f | + | f ’ |
Maximum Flow - Augmenting Paths G = (V,E) - a flow network with source s and sink t. f - a flow in G. An augmenting path p is a simple path from s to t in Gf. Residual capacity of p : cf(p) = min{cf(u,v) : (u,v) is on p}
Maximum Flow - Augmenting Paths Lemma Let G = (V,E) be a flow network, let f be a flow in G, and let p be an augmenting path in Gf. Define fp : VV R by cf(p), if (u,v) is on p –cf(p), if (v,u) is on p 0, otherwise fp (u,v) = Then fp is a flow in Gf with value | fp | = cf(p) > 0.
Maximum Flow - Augmenting Paths Corollary Let G = (V,E) be a flow network, let f be a flow in G, and let p be an augmenting path in Gf. Let fp be defined as above. Define f ’ : VV R by f ’ = f + fp. Then f ’ is a flow in G with value | f ’ | = | f | + | fp | > | f |.
Maximum Flow - Cuts A cut (S,T) of a flow network G = (V,E) is a partition of V into S and T = V – S such that s S and t T. The net flow across the cut (S,T) is defined to be f(S,T). The capacity of the cut (S,T) is c(S,T).
Maximum Flow - Cuts - Example f(S,T) = 19 c(S,T) = 26 12/12 a b 11/16 15/20 0/10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14 T S
Maximum Flow - Cuts - Lemmas Let f be a flow in flow network G with source s and sink t and let (S,T) be a cut of G. Then the flow across (S,T) is f(S,T) = | f |. Corollary The value of any flow f in a flow network G is bounded from above by the capacity of any cut in G.
Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]
Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]
Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]
Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]
Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]
Maximum Flow - Cuts - Lemmas [Adapted from R.Solis-Oba]
Maximum Flow - Max-Flow Theorem If f is a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: f is a maximum flow in G the residual network Gf contains no augmenting paths | f | = c(S,T) for some cut (S,T) in G [Adapted from R.Solis-Oba]
Maximum Flow - Max-Flow Theorem [Adapted from R.Solis-Oba]
Maximum Flow - Max-Flow Theorem [Adapted from R.Solis-Oba]
Maximum Flow - Ford-Fulkerson Method procedure FordFulkerson(graph G = (V,E), source s, sink t) for (u,v) E do f[u,v] 0 f[v,u] 0 while there exists a path p from s to t in Gf do cf(p) min{ cf(u,v): (u,v) p } for (u,v) p do f[u,v] f[u,v] + cf(p) f[v,u] f[u,v]
Maximum Flow - Ford-Fulkerson - Example 12 a b 16 20 10 s 4 t 9 7 13 4 c d 14
Maximum Flow - Ford-Fulkerson - Example 12 a b 16 20 10 s 4 t 9 7 13 4 c d 14
Maximum Flow - Ford-Fulkerson - Example 4/12 a b 4/16 20 10 s 4 t 4/9 7 13 4/4 c d 4/14
Maximum Flow - Ford-Fulkerson - Example 8 a b 4 4 20 12 4 s 10 4 t 7 5 13 4 10 c d 4
Maximum Flow - Ford-Fulkerson - Example 8 a b 4 4 20 12 4 s 10 4 t 7 5 13 4 10 c d 4
Maximum Flow - Ford-Fulkerson - Example 4/12 a b 11/16 7/20 7/10 s 4 t 4/9 7/7 13 4/4 c d 11/14
Maximum Flow - Ford-Fulkerson - Example 8 a b 4 7 11 5 4 13 s 3 11 t 7 5 13 4 3 c d 11
Maximum Flow - Ford-Fulkerson - Example 8 a b 4 7 11 5 4 13 s 3 11 t 7 5 13 4 3 c d 11
Maximum Flow - Ford-Fulkerson - Example 12/12 a b 11/16 15/20 10 s 1/4 t 4/9 7/7 8/13 4/4 c d 11/14
Maximum Flow - Ford-Fulkerson - Example b 12 15 11 5 4 5 s 11 3 t 7 5 5 4 8 3 c d 11
Maximum Flow - Ford-Fulkerson - Example b 12 15 11 5 4 5 s 11 3 t 7 5 5 4 8 3 c d 11
Maximum Flow - Ford-Fulkerson - Example 12/12 a b 11/16 19/20 10 s 1/4 t 9 7/7 12/13 4/4 c d 11/14
Maximum Flow - Ford-Fulkerson - Example b 12 19 11 5 1 s 11 3 t 7 9 1 4 12 3 c d 11
Maximum Flow - Ford-Fulkerson - Bad Example 1000000 1000000 s 1 t 1000000 1000000 b
Maximum Flow - Ford-Fulkerson - Bad Example 1000000 1000000 s 1 t 1000000 1000000 b
Maximum Flow - Ford-Fulkerson - Bad Example 999999 1000000 1 s 1 t 1 1000000 999999 b
Maximum Flow - Ford-Fulkerson - Bad Example 999999 1000000 1 s 1 t 1 1000000 999999 b
Maximum Flow - Ford-Fulkerson - Bad Example 999999 999999 1 1 s 1 t 1 1 999999 999999 b
Maximum Flow - Ford-Fulkerson - Bad Example 999999 999999 1 1 s 1 t 1 1 999999 999999 b
Maximum Flow - Ford-Fulkerson - Complexity procedure FordFulkerson(graph G = (V,E), source s, sink t) for (u,v) E do f[u,v] 0 f[v,u] 0 while there exists a path p from s to t in Gf do cf(p) min{ cf(u,v): (u,v) p } for (u,v) p do f[u,v] f[u,v] + cf(p) f[v,u] f[u,v] If all capacities are integers and f* is a maximum flow, then T(V,E,f*) = O(E | f* |)
Maximum Flow - Ford-Fulkerson - Complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm Apply Ford-Fulkerson method with using BFS for finding finding the shortest augmenting path in each residual network. [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity Lemma If the Edmonds-Karp algorithm is run on a flow network G = (V,E) with source s and sink t, then for all vertices v V – {s,t} the shortest path distance f(s,v) in the residual network Gf increases monotonically with each flow augmentation. Theorem If the Edmonds-Karp algorithm is run on a flow network G = (V,E) with source s and sink t, then the total number of flow augmentations performed by the algorithm is at most O(V E).
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity [Adapted from Z.Hu]
Maximum Flow - Edmonds-Karp Algorithm - complexity T(V,E) = O(V E2)
Maximum Flow - Best algorithms [Adapted from R.Solis-Oba]