Presentation is loading. Please wait.

Presentation is loading. Please wait.

Max-flow, Min-cut Network flow.

Similar presentations


Presentation on theme: "Max-flow, Min-cut Network flow."— Presentation transcript:

1 Max-flow, Min-cut Network flow

2 Max-flow Maximize the total amount of flow from s to t subject to two constraints Flow on edge e doesn’t exceed c(e) For every node v ≠ {s, t}, incoming flow is equal to outgoing flow

3 Max-flow: Ford-Fulkerson
Find paths from s to t using depth first search Find paths using the residual graph G’

4 Ford-Fulkerson: example
4 10 0|4 2 2 0|10 0|2 0|2 7 10 7 s t 0|7 0|10 0|7 s t 2 2 0|2 0|2 6 10 0|10 0|6 G G Depth first search f = min(4,10)=4 0|4 0|10 4|4 4|10 0|2 0|2 0|2 0|2 0|7 0|10 0|7 0|7 0|10 0|7 s t s t 0|2 0|2 0|2 0|2 0|6 0|6 0|10 0|10 G G

5 Ford-Fulkerson: DFS s t s t s t s t G G G G f = min(7,10,7)=7
4|4 4|10 4|4 4|10 0|2 0|2 0|2 0|2 0|7 0|10 0|7 7|7 7|10 7|7 s t s t 0|2 0|2 0|2 0|2 0|6 0|10 0|6 0|10 G G f = min(10,6)=6 4|4 4|10 4|4 4|10 0|2 0|2 0|2 0|2 7|7 7|10 7|7 7|7 7|10 7|7 s t s t 0|2 0|2 0|2 0|2 0|10 0|6 6|6 6|10 G G

6 Ford-Fulkerson: Residual graph
4|4 4|10 ? ? 0|2 0|2 ? ? 7|7 7|10 7|7 ? ? ? s t s t 0|2 0|2 ? ? 6|6 ? 6|10 ? G G’ G G’ 4|4 4|10 4 ? 0|2 0|2 ? 7|7 7|10 7|7 s t ? ? ? s t 0|2 0|2 ? ? 6|6 6|10 ? ?

7 Ford-Fulkerson: Residual graph
4|4 4|10 4 4 0|2 0|2 ? 6 7|7 7|10 7|7 s t ? ? ? s t 0|2 0|2 ? ? 6|6 6|10 ? ? G G’ 4|4 4|10 4 4 0|2 0|2 ? 6 7|7 7|10 7|7 s t ? ? s t 7 0|2 0|2 ? ? 6|6 6|10 ? ? G G’

8 Ford-Fulkerson: Residual graph
4|4 4|10 4 4 0|2 0|2 2 6 7|7 7|10 7|7 s t ? ? s t 7 0|2 0|2 ? ? 6|6 6|10 ? ? G G’ 4|4 4|10 4 4 0|2 0|2 2 6 7|7 7|10 7|7 s t ? ? s t 7 0|2 0|2 ? 6 ? 6|10 6|6 4 ? G G’

9 Ford-Fulkerson: Residual graph
Keep work on for the rest of edges 4|4 4|10 4 4 0|2 0|2 2 2 6 7|7 7|10 7|7 s t 3 7 s t 7 7 0|2 0|2 2 6 2 6|6 6|10 4 6 G G’ 4 4 2 2 6 3 7 s t Remove “0” edge (optional) 7 7 4 2 6 2 6 G’

10 Ford-Fulkerson: Residual graph
Any more paths? 4 4 2 2 6 3 7 s t 7 7 2 4 2 6 6 G’ f = min(6,2,3,2,4)=2 4 4 4|4 2 6|10 2 6 2|2 0|2 3 7 s t 7|7 5|10 7|7 s t 7 7 2 4 2 6 0|2 2|2 6 6|6 8|10 G’ G

11 Max flow = 6 + 7 +6 = 19 s t G 4|4 6|10 2|2 0|2 7|7 5|10 7|7 0|2 2|2
8|10 6|6 G

12 Edmonds-Karp Edmonds-Karp = Ford-Fulkerson + “Choose the augmenting path with the smallest number of edges” or “Choose the augmenting path with the largest bottle neck value”

13 Edmonds-Karp vs Ford-Fulkerson
0|4 0|10 0|2 0|2 0|7 0|10 0|7 s t 0|2 0|2 0|6 Edmonds-Karp Ford-Fulkerson G Ford-Fulkerson 0|4 0|10 0|2 0|2 0|4 0|10 0|2 0|2 0|7 0|10 0|7 s t 0|7 0|10 0|7 s t 0|2 0|2 0|10 0|6 0|2 0|2 0|10 0|6 G G Which one is the valid first choice of Edmonds-Karp? Which one is the valid first choice of Ford-Fulkerson?

14 Min cut We want to remove some edges from the graph such that after removing the edges, there is no path from s to t The cost of removing e is equal to its capacity c(e) The minimum cut problem is to find a cut with minimum total cost

15 Min cut: approach “Subtract” the max-flow from the original graph
Mark all nodes reachable from s. Call the set of reachable nodes A Now separate these nodes from the others Cut edges going from A to V − A

16 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

17 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

18 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

19 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

20 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

21 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

22 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

23 Min cut: example s t s t s t G G max flow
4 10 4 6 2 2 2 7 10 7 7 s t 5 7 s t 2 2 2 6 8 10 6 G G max flow s t G – G max flow = residual graph

24 Nodes reachable from s (A)
t

25 Cut edges come from V - A s t s t G G – G max flow = residual graph
4 10 2 2 7 10 7 s t s t 2 2 6 10 G G – G max flow = residual graph Cost of min cut = = 19 = max flow value


Download ppt "Max-flow, Min-cut Network flow."

Similar presentations


Ads by Google