CSE 202 Algorithms Max Flow Problems 112102 CSE
CSE 202 - Algorithms Max Flow Problems 11/21/02 CSE 202 - Max Flow
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. 2 CSE 202 - Max Flow
Example 16 source 13 b 10 s This is wasteful! 8 The text’s formulation doesn’t even let it happen. 4 2 b d c 0 6 20 t 7 14 12 a c 9 4 10 s 12 a sink 4 14 t 2 d 4 A flow of value 18 3 CSE 202 - Max Flow
Leftover capacity 16 -10 13 -8 New backedge showing we can reduce forward flow by 10 12 -12 c 9 -0 10 -2 4 -4 s source a 6 b a 10 8 2 8 s 5 b 14 -6 0 12 9 6 8 20 -14 t 7 -2 d 4 -4 c 6 14 5 2 4 d sink t 0 Residual network 4 CSE 202 - Max Flow
Augmenting Path We can push 5 more through network on indicated path (New flow has s value 23. ) 6 a 10 8 2 8 5 b 6 a 10 8 2 13 s 0 b 0 12 9 6 8 0 12 9 11 3 c 6 14 5 2 4 t d 0 c 1 19 0 7 4 d t 0 New residual network 5 Now we’re stuck! We can’t get any more across cut. CSE 202 - Max Flow
Duality: Max Flow = Min Cut Original problem had a cut of value 23. We can’t possibly get more from source to sink. 16 13 b c 9 4 10 s 12 a 14 20 t 7 d 4 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. 6 CSE 202 - Max Flow
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? ? a 100 7 1 1 s 100 b t 100 CSE 202 - Max Flow
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 at most E iterations using L long paths. v k long path t s j long path 8 u j+1+k is a minimal length path (L) m long v t s u n long m j+1 and n k+1 so m+n > j+k+1 = L CSE 202 - Max Flow
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 at most O(VE) augmentations. – How long does it take to find and process a shortest augmenting path? ? 9 CSE 202 - Max Flow
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) ). 10 CSE 202 - Max Flow
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. 11 CSE 202 - Max Flow
Glossary (in case symbols are weird) subset element of set infinity empty for all there exists intersection union big theta big omega summation >= <= about equal not equal natural numbers(N) 12 CSE 202 - Max Flow
- Slides: 12