Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting.

Similar presentations


Presentation on theme: "1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting."— Presentation transcript:

1 1 Maximum flow problems

2 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting paths cuts of networks max-flow min-cut theorem example of an execution analysis, running time, variations of the max-flow problem

3 3 Introduction – flow network Practical examples of a flow network - liquids flowing through pipes - parts through assembly lines - current through electrical network - information through communication network - goods transported on the road…

4 4 Introduction – flow network Example: oil pipelineRepresentation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 S t v1 v2 v3 v4 source sink

5 5 Introduction – max-flow problem Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 S t v1 v2 v3 v4 source sink Informal definition of the max-flow problem: What is the greatest rate at which material can be shipped from the source to the sink without violating any capacity contraints? Example: oil pipeline

6 6 Introduction - capacity S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 uv 12 uv 6 c(u,v)=12 c(u,v)=6 Big pipe Small pipe 8 3 6 8 6 6 3 3 Example: oil pipeline

7 7 Introduction - capacity S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 8 6 6 3 3 Example: oil pipeline v4 v2 v3 v4 If (u,v)  E  c(u,v) = 0 0 0 0 6

8 8 Introduction – flow S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 uv 6/12 uv 6/6 f(u,v)=6 Flow below capacity Maximum flow 8 3 6 8 6 6 3 3 Example: oil pipeline

9 9 Introduction – flow S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 8 6 6 3 3 Example: oil pipeline

10 10 Introduction – flow S t v1 v2 v3 v4 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 6/8 6/6 3 3 Example: oil pipeline

11 11 Introduction – flow S t v1 v2v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 8 3 6 6/8 6/6 3 3 Example: oil pipeline

12 12 Introduction – flow S t v1 v2v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 3/8 3/3 3/6 6/8 6/6 3 3 Example: oil pipeline

13 13 Introduction – flow S t v1 v2v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 3/8 3/3 3/6 6/8 6/6 3 3 Example: oil pipeline

14 14 Introduction – flow S t v1 v2v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 5/8 3/3 3/6 8/8 6/6 2/3 3 Example: oil pipeline

15 15 Introduction – cancellation S t v1 v2v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 5/8 3/3 3/6 8/8 6/6 2/3 3 Example: oil pipeline

16 16 Introduction – cancellation S t v1 v2v4 v3 Representation Flow network: directed graph G=(V,E) S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 u v 104 u v 8/104 u v 3/4 u v 5/104 Example: oil pipeline

17 17 Flow properties

18 18 Flow properties St v1 v2 v3 v4 10 8/13 12/12 11/16 1/4 4/4 11/14 15/20 7/7 4/9 Flow network G = (V,E) Note: by skew symmetry f (v3,v1) = - 12

19 19 Net flow and value of a flow S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 u v 8/103/4 u v 5/104 f(u,v) = 5 f(v,u) = -5

20 20 The max-flow problem Informal definition of the max-flow problem: What is the greatest rate at which material can be shipped from the source to the sink without violating any capacity contraints? Formal definition of the max-flow problem: The max-flow problem is to find a valid flow for a given weighted directed graph G, that has the maximum value over all valid flows.

21 21 The Ford-Fulkerson method a way how to find the max-flow This method contains 3 important ideas: 1) residual networks 2) augmenting paths 3) cuts of flow networks

22 22 Ford-Fulkerson – pseudo code 1 initialize flow f to 0 2 while there exits an augmenting path p 3 do augment flow f along p 4 return f

23 23 Ford Fulkerson – residual networks St v1 v2 v3 v4 10 8/13 12/12 11/16 1/4 4/4 11/14 15/20 7/7 4/9 The residual network G f of a given flow network G with a valid flow f consists of the same vertices v  V as in G which are linked with residual edges (u,v)  E f that can admit more strictly positive net flow. The residual capacity c f represents the weight of each edge E f and is the amount of additional net flow f(u,v) before exceeding the capacity c(u,v) Flow network G = (V,E) c f (u,v) = c(u,v) – f(u,v) St v1 v2 v3 v4 residual network G f = (V,E f ) 5 11 8 5

24 24 Ford Fulkerson – residual networks St v1 v2 v3 v4 10 8/13 12/12 11/16 1/4 4/4 11/14 15/20 7/7 4/9 Flow network G = (V,E) c f (u,v) = c(u,v) – f(u,v) St v1 v2 v3 v4 residual network G f = (V,E f ) 11 8 12 5 3 4 3 5 7 5 11 5 15 4 The residual network G f of a given flow network G with a valid flow f consists of the same vertices v  V as in G which are linked with residual edges (u,v)  E f that can admit more strictly positive net flow. The residual capacity c f represents the weight of each edge E f and is the amount of additional net flow f(u,v) before exceeding the capacity c(u,v)

25 25 Ford Fulkerson – augmenting paths St v1 v2 v3 v4 10 8/13 12/12 11/16 1/4 4/4 11/14 15/20 7/7 4/9 c f (p) = min{c f (u,v): (u,v) is on p} Flow network G = (V,E)residual network G f = (V,E f ) Definition: An augmenting path p is a simple (free of any cycle) path from s to t in the residual network G f Residual capacity of p St v1 v2 v3 v4 11 8 12 5 3 4 3 5 7 5 11 5 15 4

26 26 Ford Fulkerson – augmenting paths St v1 v2 v3 v4 10 8/13 12/12 11/16 1/4 4/4 11/14 15/20 7/7 4/9 c f (p) = min{c f (u,v): (u,v) is on p} Flow network G = (V,E) St v1 v2 v3 v4 11 8 12 5 3 4 3 5 7 5 residual network G f = (V,E f ) 11 5 15 4 Definition: An augmenting path p is a simple (free of any cycle) path from s to t in the residual network G f Residual capacity of p Augmenting path

27 27 Ford Fulkerson – augmenting paths St v1 v2 v3 v4 10 8/13 12/12 11/16 1/4 4/4 11/14 15/20 7/7 4/9 Flow network G = (V,E) St v1 v2 v3 v4 11 8 12 5 3 4 3 5 7 5 residual network G f = (V,E f ) 11 5 15 4 We define a flow: f p : V x V  R such as: c f (p) if (u,v) is on p f p (u,v) = - c f (p) if (v,u) is on p 0 otherwise

28 28 Ford Fulkerson – augmenting paths St v1 v2 v3 v4 10 8/13 12/12 11/16 1/4 4/4 11/14 15/20 7/7 4/9 Flow network G = (V,E) St v1 v2 v3 v4 11 -4/8 12 5 3 4 3 4/5 7 -4/5 residual network G f = (V,E f ) 11 4/5 11 -4/15 4/4 Our virtual flow f p along the augmenting path p in G f c f (p) if (u,v) is on p f p (u,v) = - c f (p) if (v,u) is on p 0 otherwise We define a flow: f p : V x V  R such as:

29 29 Ford Fulkerson – augmenting the flow St v1 v2 v3 v4 10 12/13 12/12 11/16 1/4 4/4 11/14 19/20 7/7 0/9 Flow network G = (V,E) St v1 v2 v3 v4 11 8 12 5 3 4 3 4/5 7 5 residual network G f = (V,E f ) 11 4/5 11 15 4/4 Our virtual flow f p along the augmenting path p in G f New flow: f´: V x V  R : f´=f + f p c f (p) if (u,v) is on p f p (u,v) = - c f (p) if (v,u) is on p 0 otherwise We define a flow: f p : V x V  R such as:

30 30 Ford Fulkerson – new valid flow proof of capacity constraint Proof: f p (u,v) < c f (u,v) = c (u,v) – f (u,v)  (f + f p ) (u,v) = f (u,v) + f p (u,v) < c (u,v) Lemma: f´ : V x V  R : f´ = f + f p in G Capacity constraint: For all u,v  V, we require f(u,v) < c(u,v) c f (p) if (u,v) is on p f p (u,v) = - c f (p) if (v,u) is on p 0 otherwise c f (p) = min{c f (u,v): (u,v) is on p} c f (u,v) = c(u,v) – f(u,v)

31 31 Ford Fulkerson – new valid flow proof of Skew symmetry Proof: (f + f p )(u,v) = f (u,v) + f p (u,v) = - f (v,u) – f p (v,u) = - (f (v,u) + f p (v,u)) = - (f + f p ) (v,u) Skew symmetry: For all u,v  V, we require f(u,v) = - f(v,u) Lemma: f´ : V x V  R : f´ = f + f p in G

32 32 Ford Fulkerson – new valid flow proof of flow conservation Proof: u  V – {s,t}   (f + f p ) (u,v) =  (f(u,v) + f p (u,v)) =  f (u,v) +  f p (u,v) = 0 + 0 = 0 Flow conservation: For all u  V \ {s,t} :  f(u,v) = 0 v  V Lemma: f´ : V x V  R : f´ = f + f p in G

33 33 Ford Fulkerson – new valid flow Proof: | (f + f p ) | =  (f + f p ) (s,v) =  (f (s,v) + f p (s,v)) =  f (s,v) +  f p (s,v) = | f | + | f p | Lemma: | (f + f p ) | = | f | + | f p | v  V Value of a Flow f: Def: |f| =  f(s,v) v  V

34 34 Ford Fulkerson – new valid flow Lemma: | (f + f p ) | = | f | + | f p | > | f | f´ : V x V  R : f´ = f + f p in G Lemma shows: if an augmenting path can be found then the above flow augmentation will result in a flow improvement. Question: If we cannot find any more an augmenting path is our flow then maximum? Idea: The flow in G is maximum  the residual G f contains no augmenting path.

35 35 Ford Fulkerson – cuts of flow networks New notion: cut (S,T) of a flow network A cut (S,T) of a flow network G=(V,E) is a partiton of V into S and T = V \ S such that s  S and t  T. Implicit summation notation: f (S, T) =   f (u, v) St v1 v2 v3 v4 10 12/13 12/12 11/16 1/4 4/4 19/20 7/7 0/9 11/14 TS In the example: S = {s,v1,v2), T = {v3,v4,t} Net flow f(S,T) = f(v1,v3) + f(v2,v4) + f(v2,v3) = 12 + 11 + (-0) = 23 Capacity c(S,T) = c(v1,v3) + c(v2,v4) = 12 + 14 = 26 Practical example u  S v  T

36 36 Ford Fulkerson – cuts of flow networks Lemma: the value of a flow in a network is the net flow across any cut of the network f (S,T) = | f | St v1 v2 v3 v4 10 12/13 12/12 11/16 1/4 4/4 19/20 7/7 0/9 11/14 proof

37 37 Ford Fulkerson – cuts of flow networks Assumption: The value of any flow f in a flow network G is bounded from above by the capacity of any cut of G Lemma: | f | < c (S, T) | f | = f (S, T) =   f (u, v) <   c (u, v) = c (S, T) v  T u  S v  T u  S St v1 v2 v3 v4 10 12/13 12/12 11/16 1/4 4/4 19/20 7/77/7 0/9 11/14

38 38 F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1.f is a maximum flow in G. 2.The residual network G f contains no augmenting paths. 3.| f | = c (S, T) for some cut (S, T) of G. proof: (1)  (2): We assume for the sake of contradiction that f is a maximum flow in G but that there still exists an augmenting path p in G f. Then as we know from above, we can augment the flow in G according to the formula: f´= f + f p. That would create a flow f´that is strictly greater than the former flow f which is in contradiction to our assumption that f is a maximum flow.

39 39 F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1.f is a maximum flow in G. 2.The residual network G f contains no augmenting paths. 3.| f | = c (S, T) for some cut (S, T) of G. proof: (2)  (3): S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 S t v1 v2 v3 v4 2 3 2 8 1 6 3 2 5 6 1 4 residual network G f original flow network G

40 40 F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1.f is a maximum flow in G. 2.The residual network G f contains no augmenting paths. 3.| f | = c (S, T) for some cut (S, T) of G. proof: (2)  (3): Define S = {v  V |  path p from s to v in G f } T = V \ S (note t  S according to (2)) S t v1 v2 v3 v4 2 3 2 8 1 6 3 2 5 6 1 4 residual network G f

41 41 F. Fulkerson: Max-flow min-cut theorem If f is a flow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1.f is a maximum flow in G. 2.The residual network G f contains no augmenting paths. 3.| f | = c (S, T) for some cut (S, T) of G. proof: (2)  (3): Define S = {v  V |  path p from s to v in G f } T = V \ S (note t  S according to (2))  for  u  S, v  T: f (u, v) = c (u, v) (otherwise (u, v)  E f and v  S)  | f | = f (S, T) = c (S, T) 1 S t v1 v2 v3 v4 6/8 3/3 4/6 8/8 5/6 6/6 3/3 1/3 original network G

42 42 F. Fulkerson: Max-flow min-cut theorem If f is a fow in a flow network G = (V,E) with source s and sink t, then the following conditions are equivalent: 1.f is a maximum flow in G. 2.The residual network G f contains no augmenting paths. 3.| f | = c (S, T) for some cut (S, T) of G. proof: (3)  (1): as proofed before | f | = f (S, T) < c (S, T) the statement of (3) : | f | = c (S, T) implies that f is a maximum flow

43 43 The basic Ford Fulkerson algorithm

44 44 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 16 4 4 14 20 7 9 (residual) network G f

45 45 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 0/10 0/13 0/12 0/16 0/4 0/14 0/20 7 0/9 (residual) network G f

46 46 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 16 4 4 14 20 7 9 (residual) network G f

47 47 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 16 4 4 14 20 7 9 (residual) network G f temporary variable: c f (p) = 12

48 48 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 16 4 4 14 20 7 9 (residual) network G f temporary variable: c f (p) = 12 St v1 v2 v3 v4 10 13 12/12 12/16 4 4 14 12/20 7 9 new flow network G

49 49 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 4 4 4 14 8 7 9 (residual) network G f St v1 v2 v3 v4 10 13 12/12 12/16 4 4 14 12/20 7 9 new flow network G 12

50 50 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 4 4 4 14 8 7 9 (residual) network G f St v1 v2 v3 v4 10 13 12/12 12/16 4 4 14 12/20 7 9 new flow network G 12

51 51 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 4 4 4 14 8 7 9 (residual) network G f St v1 v2 v3 v4 10 13 12/12 12/16 4 4 14 12/20 7 9 new flow network G 12

52 52 The basic Ford Fulkerson algorithm example of an execution (residual) network G f St v1 v2 v3 v4 10 13 12/12 12/16 4 4 14 12/20 7 9 new flow network G temporary variable: c f (p) = 4 St v1 v2 v3 v4 10 13 12 4 4 4 14 8 7 9 12

53 53 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 13 12 4 4 4 14 8 7 9 (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/20 7 9 new flow network G 12 temporary variable: c f (p) = 4

54 54 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 9 12 4 4 4 10 8 7 9 (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/20 7 9 new flow network G 12 4 4

55 55 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 9 12 4 4 4 10 8 7 9 (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/20 7 9 new flow network G 12 4 4

56 56 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 9 12 4 4 4 10 8 7 9 (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/20 7 9 new flow network G 12 4 4

57 57 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 9 12 4 4 4 10 8 7 9 (residual) network G f St v1 v2 v3 v4 10 4/13 12/12 12/16 4 4/4 4/14 12/20 7 9 new flow network G 12 4 4 temporary variable: c f (p) = 7

58 58 The basic Ford Fulkerson algorithm example of an execution St v1 v2 v3 v4 10 9 12 4 4 4 10 8 7 9 (residual) network G f St v1 v2 v3 v4 10 11/13 12/12 12/16 4 4/4 11/14 19/20 7/7 9 new flow network G 12 4 4 temporary variable: c f (p) = 7

59 59 The basic Ford Fulkerson algorithm example of an execution (residual) network G f St v1 v2 v3 v4 10 11/13 12/12 12/16 4 4/4 11/14 19/20 7/7 9 new flow network G St v1 v2 v3 v4 10 2 12 4 4 4 3 1 7 9 19 11

60 60 The basic Ford Fulkerson algorithm example of an execution (residual) network G f St v1 v2 v3 v4 10 11/13 12/12 12/16 4 4/4 11/14 19/20 7/7 9 new flow network G St v1 v2 v3 v4 10 2 12 4 4 4 3 1 7 9 19 11 Finally we have: | f | = f (s, V) = 23

61 61 Analysis of the Ford Fulkerson algorithm Running time The running time depends on how the augmenting path p in line 4 is determined.

62 62 Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) O(|E|) O(|E| |f max |) running time: O ( |E| |f max | ) with f max as maximum flow (1) The augmenting path is chosen arbitrarily and all capacities are integers O(|E|)

63 63 Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1,000,000 1 running time: O ( |E| |f max | ) with f max as maximum flow

64 64 Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1 / 1,000,000 1,000,000 1 / 1,000,000 1 / 1 t v2 v1 s 999,999 1,000,000 999,999 1 residual network G f 1 1 running time: O ( |E| |f max | ) with f max as maximum flow

65 65 Analysis of the Ford Fulkerson algorithm Running time (arbitrary choice of p) (1) The augmenting path is chosen arbitrarily and all capacities are integers Consequencies of an arbitrarily choice: Example if |f*| is large: t v2 v1 s 1 / 1,000,000 1 t v2 v1 s 999,999 1 residual network G f 1 1 1 1 running time: O ( |E| |f max | ) with f max as maximum flow

66 66 Analysis of the Ford Fulkerson algorithm Running time with Edmonds-Karp algorithm running time: O ( |V| |E|² ) St u1 u2 v3 v4 4 4 6 4 4 6 2 2 Informal idea of the proof: (1)for all vertices v  V\{s,t}: the shortest path distance  f (s,v) in G f increases monotonically with each flow augmentation.  f (s,v) <  f´ (s,v)  f (s,u2) = 1 (2) Edmonds-Karp algorithm augmenting path is found by breath-first search and has to be a shortest path from p to t


Download ppt "1 Maximum flow problems. 2 - Introduction of: network, max-flow problem capacity, flow - Ford-Fulkerson method pseudo code, residual networks, augmenting."

Similar presentations


Ads by Google