Max-flow, Min-cut Network flow
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
Max-flow: Ford-Fulkerson Find paths from s to t using depth first search Find paths using the residual graph G’
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
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
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 ? ?
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’
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’
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’
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
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
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”
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?
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
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
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
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
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
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
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
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
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
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
Nodes reachable from s (A) t
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 = 4 + 7 + 2 + 6 = 19 = max flow value