Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount.

Similar presentations


Presentation on theme: "1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount."— Presentation transcript:

1 1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount of flow between two specified vertices s and t. The capacity v of a path P is the sum of its constituent edge flows: v = Σx ij where x ij is the flow from vertex i to vertex j. Applications to design: supply networks oil pipelines road traffic

2 2 Background Assumptions: Integer data Directed network Nonnegative capacities on each arc Vertex s is the source Vertex t is the sink Definitions: Residual network Cut Techniques: 1.Augmenting Paths – Examine residual network for s-t paths. 2.Preflow-Push – Flow moved according to individual edge not path.

3 3 Maximum Flow as Linear Programming Problem subject to

4 4 Example t s 2 3 4 3,9 1,2 2,4 8,8 7,9 4,7 2,6 Each edge is labeled as (x ij, u ij ) = (flow, capacity). However, this flow value, v(x) = 11, is not a maximum.

5 5 Residual Network Given a current flow x, keep track of how much further the flow can be increased in each direction of the edge. For any edge in G: ij x ij, u ij The corresponding edge (with capacities) in residual network of G: ij u ij - x ij x ij The residual network of G, G(x), has edges with positive residual capacity, r ij = u ij – x ij + x ji. In general, it is the amount by which we can further increase flow from i to j in the current network.

6 6 Example – Re-examined t s 2 3 4 3,9 1,2 2,4 8,8 7,9 4,7 2,6 Network with flows and capacities. t s 2 3 4 3 1 2 8 2 3 2 Residual network with capacities. 7 4 2 6 1 6 We know this network flow is not a maximum. How can we get a better one? What do we do in general?

7 7 A cut is defined by a partition of the vertex set E into subsets S and S* = E – S. The cut [S,S*] consists of all edges with one endpoint in S and the other in S*. The forward edges of [S,S*] are denoted (S, S*). The backward edges are denoted as (S*,S). An s-t cut [S,S*] has s in S and t in S*. The removal of the forward edges in an s-t cut will separate vertices s and t. That is, there is no longer a directed s to t path. The capacity of any cut [S,S*], u[S,S*], is the sum of the capacities of the forward edges of the cut. u[S,S*] is an upper bound on the amount of flow sent from S to S*. A minimum s-t cut has the smallest capacity among all s-t cuts. Cuts

8 8 61 2 3 5 4 10 5 8 8 8 5 61 2 3 5 4 5 8 8 8 5 Examples of 1-6 cuts S = { } S* = { } Forward edges of [S,S*]= { } u[S, S*] = = 44 S = { } S* = { } Forward edges of [S,S*]= { } u[S, S*] = =

9 9 Theorem If x is any feasible flow and if [S,S*] is any s-t cut, then the flow value, v(x), from s to t is at most u[S,S*]. Corollary the max flow value ≤ the minimum cut capacity Max-Flow Min-Cut Theorem For any capacitated network, the value of the maximum s-t flow, x’, equals the capacity of a minimum s-t cut, [S,S*]. v(x’) = u [S,S*] Theorems

10 10 Given the flow x, look for a path P from s to t in the residual network G(x) along which flow can be sent. Then send as much flow along P as possible. We call any directed path P from s to t in the residual network an augmenting path. The residual capacity of such a path is δ(P) = min{r ij :(i, j)  P). To augment along P is to send δ(P) units of flow along each edge of the path. We then modify x and the residual capacities r ij appropriately. r ij := r ij – δ(P) for each edge (i,j)  P r ji := r ji + δ(P) for each edge (i, j)  P Result: flow value, v, increases by δ(P). Improving a Flow

11 11 Example t s 2 3 4 3,9 1,2 2,4 8,8 7,9 4,7 2,6 Network with flows and capacities. v =11 t s 2 3 4 3 1 2 8 2 3 2 Residual network with capacities. 7 4 2 6 1 6 Augment along path P = s-2-4-t. δ(P) = min{6, 2, 3} = 2. new flow value =13 t s 2 3 4 5,9 1,2 4,4 8,8 7,9 6,7 2,6 t s 2 3 4 5 1 8 2 1 2 7 6 4 6 1 4

12 12 Example – Augmenting Paths 61 2 35 4 6 2 4 85 8 3 2 6 61 2 35 4 2 2 4 85 4 3 2 6 Step 1: Push 4 units along path 1-2-4-6 44 Step 2: Push 5 units along path 1-3-5-6 61 2 35 4 2 2 4 35 4 3 2 1 44 5 5 Step 3: Push 2 units along path 1-2-5-4-6 61 2 35 4 6 2 4 35 2 1 2 1 6 5 5 Step 4: Push 1 units along path 1-3-5-4-6 2 Step 0: initial residual graph is original

13 13 Example – continued 61 2 35 4 6 2 4 25 1 3 2 6 7 6 No more augmenting paths Maximum Flow in G is 12 61 2 35 4 6,6 0,2 4,4 6,85,5 7,8 3,3 2,2 6,6 61 2 35 4 6 2 4 85 8 3 2 6

14 14 THEOREM The following are equivalent statements 1.The s-t flow x’ with value v(x’) is maximum 2.G(x’) contains no augmenting path. 3.There is an s-t cut [S,S*] with u[S,S*] = v(x’)

15 15 Generic Augmenting Path Algorithm In this algorithm, we keep sending flow along augmenting paths until no s-t path exists in the residual network. Can carry out calculations entirely on G(x). Flows in G are found at the very end. algorithm augmenting_path; begin x := 0 while G(x) contains a directed path from s to t do begin P = Find_Path(s, t, G(x)); δ (P) := min{r ij : (i,j)  P}; augment δ (P) units of flow along P; update G(x); end;

16 16 Find_Path Options More than one way to pick an augmenting path “Poor” choices can lead to many augmentations. Info lost when successive paths are found. Balance effort to find a “good” path with the reduction in # of augmentations. Maximum capacity – select path P such that δ(P) is as large as possible. Shortest path – use the path with the minimum number of edges. Scaling – successively solve subproblems with a certain capacity. 1 3 2 4 50 1

17 17 Distance Labels For the “shortest path” version of the augmenting path algorithm and for another max flow algorithm, the pre-flow push, the notion of distance labels is needed. The distance label d(j) is a nonnegative integer assigned to each j in G(x). The distance labels are valid if d(t) = 0 d(i) ≤ d(j)+1 for each (i,j)  G(x) If d(j) are valid, then d(j) is a lower bound on the shortest distance from j to t. If d(s) ≥ n then there is no s-t path in G(x). (n = number of vertices in G) An admissible edge in G(x) is one where d(i) = d(j) + 1. An admissible path is a path from s to t consisting of admissible edges and is a shortest augmenting path from s to t. 1 3 2 4 5

18 18 Shortest Distance Algorithm Admissible paths are successively built by advancing until vertex t is reached. If no admissible edge is available at some point, then retreat and relabel will be a way of updating distances in the new residual graph. In this way, we maintain valid distance labels without starting from scratch. algorithm shortest augmenting path; begin x:= 0; calculate exact distance labels, d(j) to vertex t; j := s; while d(s) <n do begin if j has an admissible edge then begin advance(j); if j = t then augment and set j := s; end; else retreat(j); end;

19 19 algorithm retreat(j); begin d(j) := min{d(k)+1: (j,k) in E(j) with r jk > 0}; if E(j) with r jk > 0 empty then d(j) = n; if j ≠ s then j := pred(k); end; algorithm advance(j); begin let (j,k) be an admissible edge from j; pred(k)=j; j := k; end; algorithm augment; begin derive path P from pred; δ(P) := min{r ij : (i,j)  P}; augment δ(P) units of flow along P; end;

20 20 Example 1 3 2 4 4 3 5 2 1 1. Calculate d(j) d(3)=1 d(2)=1 1 3 2 4 4 3 5 2 1 d(4)=0 d(1)=2 2. Advance 1-2-4, δ(P) =1, augment d(3)=1 d(2)=1 1 3 2 4 4 3 5 11 d(4)=0 d(1)=2 1 4. Advance 1-3-4, δ(P) =4, augment d(3)=1 3. Advance 1-2, retreat, relabel vertex 2 d(2)=2 1 3 2 4 4 3 5 11 d(4)=0 d(1)=2 1

21 21 Example 5. Advance 1, retreat relabel 1 6. Advance 1-2-3-4, δ(P) =1, augment d(3)=1 d(2)=2 1 3 2 4 4 2 5 21 d(4)=0 d(1)=3 7. Advance 1, retreat, relabel 1 8. Maximum Flow achieved d(2)=2 1 3 2 4 4 3 4 11 d(4)=0 d(1)=3 1 1 d(3)=1 1 d(2)=2 1 3 2 4 4 2 5 21 d(4)=0 d(1)=4 1 d(3)=1 d(2)=2 1 3 2 4 4 3 4 11 d(4)=0 d(1)=2 1 1 d(3)=1

22 22 Example - Results 1 3 2 4 4,4 1,3 5,5 2,2 1,1 Note monotonicity of path lengths 1-2-4 1-3-4 1-2-3-4 Note monotonicity of distance labels 1234567 d(1)2222334 d(2)1122222 d(3)1111111 d(4)0000000

23 23 Additional Exercises 1 3 2 4 22 11 25 13 17 5 6 7 8 21 30 24 26 18 19 22 1 3 2 4 8 10 11 95 6 5 7 6 9 6 7 7 8 1 3 2 4 3 2 1 3 1 5 6 1 1 2 7 4 2 source sink

24 24 Preflow-push Algorithm Distance labels – d(t) = 0; d(i) ≤d(j) + 1 for each (i,j) in G(x) Excess flow – e(i) = excess at each vertex for a given preflow Active vertices – vertices with positive excess Admissible edges – edges that satisfy the condition that d(i) = d(j) + 1 Preflow – infeasible solution; Algorithm strives for feasibility/optimality when all excess at sink and source algorithm preflow-push; begin preprocess; while network contains an active vertex do begin select an active node i; push/relabel(i); end;

25 25 algorithm push/relabel(i); begin if the networks contains an admissible edge (i,j) then push δ = min{e(i), r ij } units of flow from vertex i to vertex j; else replace d(i) by min{d(j)+1: (i,j) in E(i) and r ij > 0}; end; algorithm preprocess; begin x := 0; compute the exact distance labels d(i) from s; x sj := u sj for each edge (s,j) in E(s); d(s) := n end;

26 26 Example 1 3 2 4 4 3 5 21 e(4)=0 d(4)=0 e(3)=0 d(3)=1 e(2)=0 d(2)=1 e(1)=0 d(1)=2 1 3 2 4 4 3 5 21 e(4)=0 d(4)=0 e(3)=4 d(3)=1 e(2)=2 d(2)=1 e(1)=0 d(1)=4 1. Network G Active nodes: 2. preprocess: first residual graph Active nodes: 2, 3

27 27 Example 1 3 2 4 4 3 1 21 e(4)=5 d(4)=0 e(3)=0 d(3)=1 e(2)=1 d(2)=2 e(1)=0 d(1)=4 1 3 2 4 4 3 5 21 e(4)=1 d(4)=0 e(3)=4 d(3)=1 e(2)=1 d(2)=2 e(1)=0 d(1)=4 4 3. Saturating push of 1 unit along 2-4; Relabel distance node 2 Selected node: 2 Active nodes: 3 Active nodes: 3, 2 4. Push of 4 units along 3-4 Selected node: 3 Active nodes: 2

28 28 Example 1 3 2 4 4 21 e(4)=6 d(4)=0 e(3)=0 d(3)=1 e(2)=0 d(2)=2 e(1)=0 d(1)=4 5 5. Push of 1 unit along 2-3 Selected node: 2 Active nodes: Active nodes: 3 6. Saturating Push of 1 units along 3-4 Selected node: 3 Active nodes: 1 3 2 4 4 2 1 21 e(4)=5 d(4)=0 e(3)=1 d(3)=1 e(2)=0 d(2)=2 e(1)=0 d(1)=4 4 121

29 29 6 1 2 3 5 4 10 5 8 8 8 5 Preflow-Push: Example 2

30 30 Let G = (V,E) be a network with supplies and demands at each vertex b(j) > 0 indicates supply at vertex j b(j)<0 indicates demand at vertex j Assumption: Σb(j) = 0 Does a flow, x, exist? Transform into a maximum flow network, G’ Add a source vertex, s, and a sink vertex, t. Add edge (s, j) with capacity, r sj =b(j), if b(j)>0 Add edge (j, t) with capacity, r jt =b(j), if b(j)<0 Solve max flow from s to t Result: If the max flow in G’ saturates all the source and sink edges, then the original problem has a feasible solution. Otherwise, infeasible. Checking if feasible flow exists

31 31 1 2 3 4 6 4 2 4 8 b(1) = 4 Example 1-Feasible Flow? b(2) = 5 b(3) = -2 b(4) = -7

32 32 1 2 3 4 6 4 3 1 8 b(1) = 4 Example 2-Feasible flow? b(2) = 5 b(3) = -2 b(4) = -7


Download ppt "1 Maximum Flow Networks Suppose G = (V, E) is a directed network. Each edge (i,j) in E has an associated ‘capacity’ u ij. Goal: Determine the maximum amount."

Similar presentations


Ads by Google