Download presentation
Presentation is loading. Please wait.
Published byLewis Williams Modified over 8 years ago
1
11/21/02CSE 202 - Max Flow CSE 202 - Algorithms Max Flow Problems
2
CSE 202 - Max Flow2 Max Flow problem Input: a directed graph with a non-negative weight (capacity) on each edge, and a designated source node s and sink node t. A flow assigns to each edge a number (from 0 to its capacity) such that for each node except s and t, the sum of the flow into the node equals sum of the flow out. [The fine print: this is slightly different from the book’s definition.] The value of a flow is the sum of the flow out of the source (which equals total flow into the sink). Maximum-Flow problem: find a flow with the maximum possible value. Note: A max flow can assign 0 to each edge going into the source, and to each edge going out of the sink.
3
CSE 202 - Max Flow3 Example b a d s 13 16 4 10 12 t c 7 20 14 9 4 source sink b a d s 8 10 4 2 12 t c 2 14 6 0 4 A flow of value 18 This is wasteful! The text’s formulation doesn’t even let it happen.
4
CSE 202 - Max Flow4 Leftover capacity b a d s 13-8 16-10 4-4 10-2 12-12 t c 7-2 20-14 14-6 9-0 4-4 source sink b a d s 5 6 2 8 12 t c 5 6 8 0 Residual network 10 8 6 9 2 0 14 4 New backedge showing we can reduce forward flow by 10
5
CSE 202 - Max Flow5 Augmenting Path b a d s 0 6 2 8 12 t c 0 1 3 0 New residual network 10 13 11 9 7 0 19 4 We can push 5 more through network on indicated path (New flow has value 23.) b a d s 5 6 2 8 12 t c 5 6 8 0 10 8 6 9 2 0 14 4 Now we’re stuck! We can’t get any more across cut.
6
CSE 202 - Max Flow6 Duality: Max Flow = Min Cut Original problem had a cut of value 23. We can’t possibly get more from source to sink. Theorem: Max flow = min cut Proof: Obviously, any flow min cut. But if max flow < min cut, there would be an augmenting path from source to sink, leading to a higher-valued flow. This is a contradiction. Thus, max flow = min cut. QED. b a d s 13 16 4 10 12 t c 7 20 14 9 4
7
CSE 202 - Max Flow7 Ford-Fulkerson Methods initialize flow to 0; while (there’s an augmenting path){ update flow; compute new residual graph; } If there are several augmenting paths, does it matter which we pick?? b a s 100 1 1 t
8
CSE 202 - Max Flow8 Edmonds-Karp Algorithm Always choose an augmenting path with as few edges as possible (say it has L edges). –This might create a new backedge, e.g (v,u). –This new edge can’t be in a new path of L edges.. (Handle multiple new backedges by induction proof.) –Meanwhile, at least one original edge has been eliminated. –Thus, there are at most E iterations using L long paths. u v s j long path t k long path u v s m long t n long j+1+k is a minimal length path (L) m j+1 and n k+1 so m+n > j+k+1 = L
9
CSE 202 - Max Flow9 Edmonds-Karp Algorithm Always choose an augmenting path with as few edges as possible. –At most E iterations use L-edge augmenting path –Longest augmenting path has V-1 edges. –Thus, there are at most O(VE) augmentations. –How long does it take to find and process a shortest augmenting path??
10
CSE 202 - Max Flow10 Max Flow Algorithms Edmonds-Karp is O(VE 2 ) Some faster algorithms based on “Push-Relabel”. –E.g. Goldberg’s algorithm is O(V 2 E) Start source at height V, all others at 0 Add in flow from higher nodes to lower ones. If a non-sink node can’t push all its incoming flow out, increase it’s height. When done, return excess back to source. –Carefully choosing order gives O(V 3 ) algorithm. Fastest known algorithm is O( min(V 2/3, E 1/2 ) E lg(1+V 2 /E) lg(max capacity) ).
11
CSE 202 - Max Flow11 An Application Maximum matching problem: –Given an (undirected) graph (V,E) find a maximum-sized set of disjoint edges. Not the same as a maximal set of disjoint edges. –Amazingly, not NP-complete (but it’s not easy) Bipartite graph: Graph such that you can partition the nodes V = V 1 U V 2, and every edge goes between a node of V 1 and one of V 2. Maximum matching for a bipartite graph can be reduced to a max flow problem.
12
CSE 202 - Max Flow12 Glossary (in case symbols are weird) subset element of infinity empty set for all there exists intersection union big theta big omega summation >= <= about equal not equal natural numbers(N) reals(R) rationals(Q) integers(Z)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.