Download presentation
Presentation is loading. Please wait.
Published byHubert Marsh Modified over 9 years ago
1
9/23/2015ACM-ICPC1 Maximum Flow Problem Source t fg e 42 Target (sink) 1 322 32 flow capacity b s c a de 2/3/ actual flow 1/2/ 1/ 2/ 1.Actual flow capacity 2.The source node can produce flow as much as possible 3.For every node other than s and t, flow out flow in The target node’s flow-in is called the flow of the graph A node may have different ways to dispatch its flow-out. What is the maximum flow of the graph?
2
9/23/2015ACM-ICPC2 What makes the maximum flow problem more difficult than the shortest path problem? Source t fg e 42 Target 1 322 32 b s c a de 2/3/ 1/2/ 1/ 2/ The shortest path of t is based on the shortest path of g. once a node’s shortest path from s is determined, we will never have to revise the decision The maximum flow to t is not based on the maximum flows to f and g.
3
9/23/2015ACM-ICPC3 local optimum does not imply global optimum Source Target s a b c d t 4/52/2 3/3 0/1 2/31/4 3/3 Target Source s a b c d 5/52/2 0/3 1/1 3/34/4 0/3 s c max flow = 6 s d max flow = 7 Source s a b c d 5/52/2 1/3 1/1 3/33/4 1/3 2/25/5 s t max flow = 7
4
9/23/2015ACM-ICPC4 A naïve approach: adding all possible paths together t Target Source b d 32 3 1 2 4 23 2/ s a c t Target Source 12 1 1 2 4 3 a c 2/ b d s Residual Graph t Target Source 1 1 1 4 1 c b Residual Graph 1/ a d s
5
9/23/2015ACM-ICPC5 Not always work. t Target Source 1 1 3 a c b d s Residual Graph t Target Source b d 2/2 3 1 23/3 2/ s c a 1/4 We are just lucky
6
9/23/2015ACM-ICPC6 We may have a wrong choice: t Target Source b 3 2 3 1 2 4 23 3/ s c t Target Source b d 2 3 1 2 1 2 s a c d a So, we keep a path for changing decision:
7
9/23/2015ACM-ICPC7 Keep a path for changing decision: t Target Source b 3 2 3 1 2 4 23 3/ s c Target Source b 2 3 1 2 1 2 s c d a 3 d t 3 3 Augmented Graph a
8
9/23/2015ACM-ICPC8 Find another path in the augmented graph Target Source 2 3 1 2 1 2 3 3 3 Augmented Graph 2/ b s c a t d new Augmented Graph 2 1 1 2 1 2 3 1 3 2 2 b s t c a d 2 1 1 2 3 2 3 1 3 2 b s t c a d No more path from s to t
9
9/23/2015ACM-ICPC9 Add flows together Target Maximum Flow 2 2 2 2 2 b s c a t d + t Target Source b 3 s c 3 3 d a = Target 2 2 2 2 b c t 3 d s 3 a 1
10
9/23/2015ACM-ICPC10 An algorithm for finding the maximum flow of graphs Input: G = (V, E), and s,t V Let G max = ( , ), G aug = G 1.Find a path p from s to t in G aug 2.If no such p exists, output G max and stop the program 3.Add p into G max and update G aug 4.Repeat 1, 2, and, if possible, 3 Complexity: O(f |E|)
11
9/23/2015ACM-ICPC11 Claim: This algorithm always terminates with a maximum flow of the input graph Input: G = (V, E), and s,t V Let G max = ( , ), G aug = G 1.Find a path p from s to t in G aug 2.If no such p exists, output G max and stop the program 3.Add p into G max and update G aug 4.Repeat 1, 2, and 3 if possible The proof is somewhat difficult and beyond the scope of 279. I say: No, it is not difficult and every one here should know. Since any given graph has a finite maximum flow, and every path from s to t, if any, provides a positive flow, the program therefore cannot run forever. By contradiction, suppose the algorithm terminates with a flow in G max. that is not maximum. Then, there must be a flow not included in G max. But, if this is the case, there must be a path from s to t to carries this flow, and hence the program should not terminate at this moment. A contradiction.
12
9/23/2015ACM-ICPC12 An inefficient situation Target Source 1000 1 1 1/ a s t b
13
9/23/2015ACM-ICPC13 An inefficient situation Target Source 1000 1 1/ a s t b 2/
14
9/23/2015ACM-ICPC14 Solution Target Source 1000 1/ s b 1000/ t a Always chose the maximum next edge
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.