Download presentation
Presentation is loading. Please wait.
1
Network Flow CSE 373 Data Structures
2
Sources and Sinks S T 4/7/2019 CSE 373 AU Network Flow
3
Flow Conservation 14 + 10 = 6 + 11 + 7 6 14 11 10 7 4/7/2019
CSE 373 AU Network Flow
4
Capacities/Saturation
7/9 T 7/10 7/7 7/11 flow / capacity 4/7/2019 CSE 373 AU Network Flow
5
Flow Cancellation 8 5 = 3 4/7/2019 CSE 373 AU Network Flow
6
Max Flow? A 0/12 B 0/20 0/16 0/4 S T 0/10 0/7 0/9 0/13 0/4 C D 0/14
4/7/2019 CSE 373 AU Network Flow
7
A Flow A 12/12 B 19/20 11/16 1/4 S T 0/10 7/7 0/9 12/13 4/4 C D 11/14
4/7/2019 CSE 373 AU Network Flow
8
A Flow saturated 12 + 7 = 19 + 0 A 12/12 B 19/20 11/16 1/4 S T 0/10
7/7 0/9 saturated 12/13 4/4 saturated C D 11/14 = 4/7/2019 CSE 373 AU Network Flow
9
Cuts 23/29 A 12/12 B 19/20 11/16 1/4 S T 0/10 7/7 0/9 12/13 4/4 C D
11/14 Remove edges until S is in one connected component, and T in the other 23/29 4/7/2019 CSE 373 AU Network Flow
10
Cuts 23/26 A 12/12 B 19/20 11/16 1/4 S T 0/10 7/7 0/9 12/13 4/4 C D
11/14 23/26 Only count forward edges 4/7/2019 CSE 373 AU Network Flow
11
Cuts 23/31 A 12/12 B 19/20 11/16 1/4 S T 0/10 7/7 0/9 12/13 4/4 C D
11/14 23/31 4/7/2019 CSE 373 AU Network Flow
12
Min Cut 23/23 A 12/12 B 19/20 11/16 1/4 S T 0/10 7/7 0/9 12/13 4/4 C D
11/14 23/23 4/7/2019 CSE 373 AU Network Flow
13
Max Flow = Min Cut 23 23 A 12/12 B 19/20 11/16 1/4 S T 0/10 7/7 0/9
12/13 4/4 C D 11/14 No more capacity along cut to take more flow 4/7/2019 CSE 373 AU Network Flow
14
Ford-Fulkerson Method
Single source, single sink Several algorithms are implementations of this method Requires integer capacities for steady progress Fastest implementation computes max flow in O(V^3) time 4/7/2019 CSE 373 AU Network Flow
15
Ford-Fulkerson Method
Initialize flow f to 0 While there exists an augmenting path p Augment flow f along p Return f 4/7/2019 CSE 373 AU Network Flow
16
An Augmenting Path How much can be sent along the path? A 0/12 B 0/20
0/16 0/4 S T 0/10 0/7 0/9 0/13 0/4 C D 0/14 How much can be sent along the path? 4/7/2019 CSE 373 AU Network Flow
17
An Augmenting Path Find a path with DFS or BFS. bottleneck A 12/12 B
12/20 12/16 0/4 S T 0/10 0/7 0/9 0/13 0/4 C D 0/14 Find a path with DFS or BFS. 4/7/2019 CSE 373 AU Network Flow
18
Another Augmenting Path
12/12 B 12/20 12/16 0/4 S T 0/10 0/7 0/9 0/13 0/4 C D 0/14 How much can be sent along the path? 4/7/2019 CSE 373 AU Network Flow
19
Another Augmenting Path
12/12 B bottleneck 12+4=16/20 12+4=16/16 0/4 S T 4/10 4/7 0/9 0/13 0/4 C D 4/14 How much can be sent along the path? 4/7/2019 CSE 373 AU Network Flow
20
Residual Graphs How much more flow can be sent? 4/12 A B 4/16 0/20 0/4
0/10 0/7 4/9 0/13 4/4 C D 4/14 12-4=8 A B 4 16-4=12 20 4 4 S T 10 4 7 9-4=5 13 4 4 C D 4/7/2019 CSE 373 AU Network Flow 14-4=10 How much more flow can be sent?
21
Residual Graphs S A C B D T 4/16 0/13 0/10 0/4 4/9 4/14 4/12 0/20 0/7
4/4 8 A B 4 12 20 4 4 S T 10 4 7 5 13 4 S A C B D T 4/16 4/13 0/10 0/4 0/9 4/14 4/12 4/20 0/7 4/4 4 C D 10 8 A B 4 12 16 4 4 4 S T 10 7 9 4 9 4 Can cancel out flow (BC) 4/7/2019 CSE 373 AU Network Flow 4 C D 10
22
Residual Graphs S A C B D T 4/16 0/13 0/10 0/4 4/9 4/14 4/12 0/20 0/7
4/4 8 A B 4 12 12 4 4 4 S T 10 7 9 4 9 4 12/12 4 A B C D 12/16 12/20 10 0/4 0/10 S T 0/7 0/9 A B 4/13 12 4/4 C D 4 8 4/14 12 12 4 S T 10 7 9 4 9 4 4/7/2019 CSE 373 AU Network Flow 4 C D 10
23
Residual Graphs S A C B D T 4/16 0/13 0/10 0/4 4/9 4/14 4/12 0/20 0/7
4/4 A B 12 4 8 12 12 4 S T 10 7 9 4 9 4 12/12 4 A B C D 12/16 10 19/20 0/4 0/10 S T 7/7 0/9 A B 11/13 12 4/4 C D 4 1 11/14 19 12 4 S T 10 7 9 11 2 4 4/7/2019 CSE 373 AU Network Flow 11 C D 3
24
Residual Graphs 12/12 A B 12/16 19/20 0/4 0/10 S T 7/7 0/9 11/13 4/4 C
11/14 A B 12 4 1 19 12 4 S T 10 7 9 11 2 4 11 C D 3 No more augmenting paths: Max Flow! Reachable vertices from source form one set, other vertices the other set. Edges in the middle are the cut. 4/7/2019 CSE 373 AU Network Flow
25
Linear Programming: Max Flow
Variables: SA, SB, AB, AT, BT (amount of flow through the edge) Constraints: capacity 0 <= SA, SB, AB, AT, BT SA <= 16 SB <= 13 AB <= 10 AT <= 4 BT <= 20 flow conservation AS = AB + AT AB + SB = BT Objective: max ( SA + SB + AB + AT + BT ) A 0/4 0/16 S T 0/10 0/13 B 0/20 4/7/2019 CSE 373 AU Network Flow
26
Linear Programming: Min Cut
Variables: SA, SB, AB, AT, BT (not cut = 0, cut = 1) AinS, BinS (not in S = 0, in S = 1) Constraints: 0 <= SA, SB, AB, AT, BT 1 <= SA + AinS (A in S or SA is cut) 1 <= SB + BinS (B in S or SB is cut) 0 <= AB - AinS + BinS (A in S but not B means AB is cut) 0 <= AT - AinS (A in S means AT is cut) 0 <= BT - BinS (B in S means BT is cut) Objective: min (16 SA + 4 AT + 10 AB + 13 SB + 20 BT) A 0/4 0/16 S T 0/10 0/13 B 0/20 4/7/2019 CSE 373 AU Network Flow
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.