Download presentation
Presentation is loading. Please wait.
1
Max Flow / Min Cut
2
Max Flow Given a directed graph G with a special source node s, a special sink node t s has no inbound edges, and t has no outbound edges For each edge e in the graph, c(e) is the given “capacity” of the edge The capacity must be greater than 0 For simplicity, assume the capacity is an integer or ∞ Define f(e) to be the “flow” along an edge The flow must be non-negative The flow must also no greater than the capacity for a given edge For any given node, the sum of flows of inbound edges must equal the sum of flows of outbound edges (“conservation of flow”) Exceptions: s may have any amount of outbound flow, and t may have any amount of inbound flow Question: what is the maximum amount of flow that can be sent from s to t?
3
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15
4
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15
5
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 15/15
6
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 15/15
7
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 2/2 0/2 3/3 6/15
1/1 h
8
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 2/2 0/2 3/3 6/15
1/1 h
9
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15
10
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15
11
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 0/2 0/3 0/15
12
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 2/2 2/3 2/15
13
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 2/2 2/3 2/15
14
Max Flow d a e s t g b h 0/10 0/∞ 0/4 0/3 0/∞ 0/10 0/2 2/2 2/3 2/15
15
Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15
16
Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15
17
Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15
18
Max Flow d a e s t g b h 0/10 3/∞ 3/4 3/3 0/∞ 3/10 0/2 2/2 2/3 2/15
19
Max Flow d a e s t g b h 0/10 4/∞ 4/4 3/3 0/∞ 4/10 1/2 2/2 2/3 3/15
20
Max Flow d a e s t g b h 0/10 4/∞ 4/4 3/3 0/∞ 4/10 1/2 2/2 2/3 3/15
21
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 4/15
0/1 0/1 h
22
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 4/15
0/1 0/1 h
23
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15
24
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15
25
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15
26
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15
27
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15
28
Max Flow d a e s t g b h 1/10 5/∞ 4/4 3/3 0/∞ 4/10 2/2 2/2 2/3 5/15
29
Max Flow / Min Cut Define a “cut” to be a partition of the nodes into two sets. An s-t cut is one where one set contains s and the other contains t Define the capacity of an s-t cut to be the sum of the capacities of the edges that “cross the partition boundary” from the s set to the t set In other words, if the nodes are partitioned into sets A and B with s ∈ A and t ∈ B, the edges from u to v where u ∈ A and v ∈ B The Min Cut problem is to find the s-t cut with the minimum capacity The Max Flow / Min Cut Theorem says the answers are the same! Essentially formalizes the notion of “bottlenecks” ...but does our bottleneck finding/saturating algorithm always work?
30
Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w
31
Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w
32
Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w
33
Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?
34
Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?
35
Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?
36
Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?
37
Max Flow v 3/3 0/2 s t 3/5 0/2 3/3 w Max flow = 3 ?
38
Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w
39
Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w
40
Max Flow v 2/3 2/2 s t 0/5 0/2 0/3 w
41
Max Flow v 2/3 2/2 s t 0/5 0/2 0/3 w
42
Max Flow v 2/3 2/2 s t 0/5 0/2 0/3 w
43
Max Flow v 2/3 2/2 s t 0/5 2/2 2/3 w
44
Max Flow v 2/3 2/2 s t 0/5 2/2 2/3 w
45
Max Flow v 2/3 2/2 s t 0/5 2/2 2/3 w
46
Max Flow v 3/3 2/2 s t 1/5 2/2 3/3 w
47
Max Flow v 3/3 2/2 s t 1/5 2/2 3/3 w Max flow = 5 !
48
Max Flow Being greedy isn’t quite good enough
At least, the order you pick the paths seems to matter Key idea: just because we *can* saturate a path doesn’t necessarily mean we *should* We want to be able to “undo” choices if it turns out they boxed us in a corner Solution: “residual graphs” Augment the graph with information that allows algorithm to “undo” or “push flow back”
49
Max Flow v 0/3 0/2 s t 0/5 0/2 0/3 w
50
Max Flow v v s t s t w w Original Graph Residual Graph 3 2 0/3 0/2 5
0/5 2 3 0/2 0/3 w w
51
Max Flow v v s t s t w w Original Graph Residual Graph 3 2 0/3 0/2 5
0/5 2 3 0/2 0/3 w w
52
Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 0/2 2 3
3/5 2 3 0/2 3/3 w w
53
Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 0/2 2 3
3/5 2 3 0/2 3/3 w w
54
Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 0/2 2 3
3/5 2 3 0/2 3/3 w w
55
Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 2/2 4 1
1/5 2 3 2/2 3/3 w w
56
Max Flow v v s t s t w w Original Graph Residual Graph 3 2 3/3 2/2 4 1
1/5 2 3 2/2 3/3 w w
57
Max Flow: Ford-Fulkerson Method
Given graph G, define GR (the residual graph) to be the same graph but with only capacity (no flow) and capacities denoted by cR(e). Maintain that for any edge (u, v) in G that cR(u, v) + cR(v, u) = c(u, v) Called “skew symmetry” While there’s a path P from s to t in GR: Find the minimum capacity cR among all edges in P, call it m For each edge (u, v) in P: If (u, v) in G, update f(u, v) += m Otherwise, (v, u) is in G so update f(v, u) -= m Update cR(u, v) and cR(v, u) accordingly to match remaining capacity in G and maintain skew symmetry Called a “method” because the path finding mechanism is not explicitly defined If you use Breadth-First search, it’s called the Edmonds-Karp algorithm
58
Max Flow: Applications
Many seemingly unrelated problems map nicely into a network flow equivalent Useful fact: If all edge capacities are integers, the max flow will also be an integer (and the flow along any given edge will also be an integer) Known as the Integral Flow Theorem
59
Max Flow: Network Connectivity
You have two computers that are indirectly connected through a network of other computer systems. How many internal network disconnections is your connection resilient to? s t 0/1
60
Max Flow: Network Connectivity
You have two computers that are indirectly connected through a network of other computer systems. How many internal network disconnections is your connection resilient to? 1/1 1/1 1/1 0/1 1/1 1/1 s t 0/1 0/1 0/1 0/1
61
Max Flow: School Dance Boys and girls need to be paired up for the school dance, but the kids only want to be paired with someone that they know. Is such a pairing possible? And if so, what’s the pairing? s b1 b2 b3 b4 g1 g2 g3 g4 t (all capacities = 1)
62
Min Cut: Project Selection
You have a set of projects pi which will each net a revenue of r(pi). Each project will require purchasing one or more machines qj each of which costs c(qj). Machines can be shared by multiple projects. The goal is to maximize profit. Let P̄ be the set of projects NOT taken, and Q be the set of machines purchased. Then we want: max [ ∑i r(pi) - ∑pi∈ P̄ r(pi) - ∑pj∈ Q c(qj) ] Which can be reformulated as: ∑i r(pi) - min [ ∑pi∈ P̄ r(pi) + ∑pj∈ Q c(qj) ] OPTIONAL MATERIAL
63
Min Cut: Project Selection
∑i r(pi) - min [ ∑pi∈ P̄ r(pi) + ∑pj∈ Q c(qj) ] s p1 p2 p3 q1 q2 q3 t ∞ r(p1) r(p2) r(p3) c(q1) c(q2) c(q3) OPTIONAL MATERIAL
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.