Download presentation
Presentation is loading. Please wait.
Published byCuthbert McDaniel Modified over 9 years ago
1
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 23
2
Network Flow Soviet Rail Network, 1955 Reference: On the history of the transportation and maximum flow problems. Alexander Schrijver in Math Programming, 91: 3, 2002.
3
Maximum Flow and Minimum Cut Max flow and min cut –Two very rich algorithmic problems –Cornerstone problems in combinatorial optimization –Beautiful mathematical duality Nontrivial applications / reductions –Data mining –Project selection –Airline scheduling –Bipartite matching –Baseball elimination –Image segmentation –Network connectivity –Network reliability –Distributed computing –Security of statistical data –Network intrusion detection –Multi-camera scene reconstruction –Many many more...
4
Flow Network Flow network –Abstraction for material flowing through the edges –G = (V, E) = directed graph, no parallel edges –Two distinguished nodes: s = source, t = sink –c(e) = capacity of edge e s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 capacity source sink
5
Flows Def: An s-t flow is a function that satisfies –For each e E: (capacity) –For each v V – {s, t}: (conservation) Def: The value of a flow f is: The maximum-flow problem –Given a flow network, a natural goal is to arrange the traffic so as to make as efficient use as possible of the available capacity –Thus basic algorithmic problem is: given a flow network, find a flow of maximum possible value
6
Flow Example u st v 20 30 10
7
Flow Example a s d b cf e g h i t 20 5 55 5 5 10 20 5 5 5 5 10 30
8
Towards a Max Flow Algorithm Greedy algorithm –Start with f(e) = 0 for all edge e E –Find an s-t path P where each edge has f(e) < c(e) –Augment flow along path P –Repeat until you get stuck s 1 2 t 10 00 00 0 20 30 Flow value = 0
9
Towards a Max Flow Algorithm Greedy algorithm –Start with f(e) = 0 for all edge e E –Find an s-t path P where each edge has f(e) < c(e) –Augment flow along path P –Repeat until you get stuck s 1 2 t 20 Flow value = 20 10 20 30 00 00 0 X X X 20
10
Towards a Max Flow Algorithm Greedy algorithm –Start with f(e) = 0 for all edge e E –Find an s-t path P where each edge has f(e) < c(e) –Augment flow along path P –Repeat until you get stuck local optimality global optimality greedy = 20 s 1 2 t 2010 20 30 200 0 opt = 30 s 1 2 t 2010 20 30 2010 20
11
Towards a Max Flow Algorithm The way we are going to increase the flow is by finding augmenting paths (i.e., s-t paths that increase the flow) The other way that we can increase the flow is by reversing the direction of flow
12
Residual Graph Original edge: e = (u, v) E –Flow f(e), capacity c(e) Residual edge –"Undo" flow sent –e = (u, v) and e R = (v, u) –Residual capacity: Residual graph: G f = (V, E f ) –Residual edges with positive residual capacity –E f = {e : f(e) 0} uv 17 6 capacity flow uv 11 residual capacity 6
13
Build Residual Graph s 1 2 t 2010 20 30 200 0
14
Augmenting Path Lemma Let P be a path from s to t with minimum capacity b in the residual graph b units of flow can be added along the path P in the flow graph
15
Augmenting Path Algorithm Augment(f, c, P) { b bottleneck(P) foreach e P { if (e E) f(e) f(e) + b else f(e R ) f(e) - b } return f } forward edge backward edge
16
Ford-Fulkerson Max-Flow Algorithm Ford-Fulkerson(G, s, t, c) { foreach e E f(e) 0 G f residual graph while (there exists augmenting path P) { f Augment(f, c, P) update G f } return f }
17
Ford-Fulkerson Example s 2 3 4 5t 10 9 8 4 6 2 0 0 0 0 0 0 0 0 G: Flow value = 0 0 flow capacity
18
Ford-Fulkerson Example s 2 3 4 5t 10 9 8 4 6 2 0 0 0 0 0 0 0 0 G: s 2 3 4 5t 10 9 4 6 2 G f : 10 8 8 8 8 X X X 0 Flow value = 0 capacity residual capacity flow
19
Ford-Fulkerson Example s 2 3 4 5t 10 9 8 4 6 2 8 0 0 0 0 8 8 0 0 G: s 2 3 4 5t 10 4 6 G f : 8 8 8 9 2 2 2 10 2 X X X 2 X Flow value = 8
20
0 Ford-Fulkerson Example s 2 3 4 5t 10 9 8 4 6 2 0 0 0 2 8 2 G: s 2 3 4 5t 4 2 G f : 10 8 2 7 6 X 6 6 6 X X 8 X Flow value = 10
21
Ford-Fulkerson Example s 2 3 4 5t 10 9 8 4 6 2 0 6 6 8 8 2 G: s 2 3 4 5t 1 6 G f : 10 8 8 6 6 6 4 4 4 2 X 8 2 8 X X 0 X Flow value = 16
22
Ford-Fulkerson Example s 2 3 4 5t 10 9 8 4 6 2 2 8 8 8 8 0 G: s 2 3 4 5t 6 2 G f : 10 8 6 8 8 2 2 1 2 8 2 X 9 7 9 X X 9 X X 3 Flow value = 18
23
Ford-Fulkerson Example s 2 3 4 5t 10 9 8 4 6 2 3 9 9 9 7 0 G: s 2 3 4 5t 1 9 1 1 6 2 G f : 10 7 6 9 9 3 1 Flow value = 19
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.