Download presentation
Presentation is loading. Please wait.
1
Network flow problem [Adapted from M.Chandy]
2
Maximum Flow - Example 12 a b 16 20 10 s 4 t 9 7 13 4 c d 14
3
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
4
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
5
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.
6
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
7
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 |.
8
Maximum Flow - Flow Properties
X,Y - sets of vertices f(X,Y) = xX yY f(x,y)
9
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)
10
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
11
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)
12
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}
13
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
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
15
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
16
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
17
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
18
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 ’ |
19
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}
20
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.
21
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 |.
22
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).
23
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
24
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.
25
Maximum Flow - Cuts - Lemmas
[Adapted from R.Solis-Oba]
26
Maximum Flow - Cuts - Lemmas
[Adapted from R.Solis-Oba]
27
Maximum Flow - Cuts - Lemmas
[Adapted from R.Solis-Oba]
28
Maximum Flow - Cuts - Lemmas
[Adapted from R.Solis-Oba]
29
Maximum Flow - Cuts - Lemmas
[Adapted from R.Solis-Oba]
30
Maximum Flow - Cuts - Lemmas
[Adapted from R.Solis-Oba]
31
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]
32
Maximum Flow - Max-Flow Theorem
[Adapted from R.Solis-Oba]
33
Maximum Flow - Max-Flow Theorem
[Adapted from R.Solis-Oba]
34
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]
35
Maximum Flow - Ford-Fulkerson - Example
12 a b 16 20 10 s 4 t 9 7 13 4 c d 14
36
Maximum Flow - Ford-Fulkerson - Example
12 a b 16 20 10 s 4 t 9 7 13 4 c d 14
37
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
38
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
39
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
40
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
41
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
42
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
43
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
44
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
45
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
46
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
47
Maximum Flow - Ford-Fulkerson - Example
b 12 19 11 5 1 s 11 3 t 7 9 1 4 12 3 c d 11
48
Maximum Flow - Ford-Fulkerson - Bad Example
s 1 t b
49
Maximum Flow - Ford-Fulkerson - Bad Example
s 1 t b
50
Maximum Flow - Ford-Fulkerson - Bad Example
999999 1 s 1 t 1 999999 b
51
Maximum Flow - Ford-Fulkerson - Bad Example
999999 1 s 1 t 1 999999 b
52
Maximum Flow - Ford-Fulkerson - Bad Example
999999 999999 1 1 s 1 t 1 1 999999 999999 b
53
Maximum Flow - Ford-Fulkerson - Bad Example
999999 999999 1 1 s 1 t 1 1 999999 999999 b
54
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* |)
55
Maximum Flow - Ford-Fulkerson - Complexity
[Adapted from Z.Hu]
56
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]
57
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).
58
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
59
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
60
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
61
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
62
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
63
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
64
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
65
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
66
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
67
Maximum Flow - Edmonds-Karp Algorithm - complexity
[Adapted from Z.Hu]
68
Maximum Flow - Edmonds-Karp Algorithm - complexity
T(V,E) = O(V E2)
69
Maximum Flow - Best algorithms
[Adapted from R.Solis-Oba]
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.