CMPS 6610/4610 – Fall 2016 Flow Networks Carola Wenk Slides adapted from slides by Charles Leiserson
Max flow and min cut • Fundamental problems in combinatorial optimization • Duality between max flow and min cut • Many applications: • Bipartite matching • Image segmentation • Airline scheduling • Network reliability • Survey design • Baseball elimination • Gene function prediction • … 2
Flow networks Definition. A flow network is a directed graph G = ( V , E ) with two distinguished vertices: a source s and a sink t . Each edge ( u , v ) E has a nonnegative capacity c ( u , v ). If ( u , v ) E , then c ( u , v ) = 0. We require that if ( u , v ) E then ( v , u ) E . 2 Example: 3 3 1 3 s t 1 2 2 3 3
Flow networks Definition. A (positive) flow on G is a function f : V V R satisfying the following: • Capacity constraint: For all u , v V , 0 f ( u , v ) c ( u , v ). • Flow conservation: For all u V \ { s , t }, f ( u , v ) f ( v , u ) 0 v V v V The value of a flow is the net flow out of the source: | f | f ( s , v ) f ( v , s ) v V v V 4
A flow on a network flow capacity 2:2 1:3 2:3 1:3 s t 1:1 1:2 2:2 u 2:3 Flow conservation (like Kirchoff’s current law): • Flow into u is 2 + 1 = 3. • Flow out of u is 1 + 2 = 3. The value of this flow is 1 + 2 = 3. 5
The maximum-flow problem Maximum-flow problem: Given a flow network G , find a flow of maximum value on G . 2:2 2:3 2:3 0:3 s t 1:1 2:2 2:2 3:3 The value of the maximum flow is 4. 6
Cuts Definition. A cut ( S , T ) of a flow network G = ( V , E ) is a partition of V such that s S and t T . If f is a flow on G , then the net flow across the cut is f ( S , T ) f ( u , v ) f ( v , u ) u S v T u S v T The capacity of the cut is c ( S , T ) c ( u , v ) u S v T 7
T S 8 t f ( S , T ) = (2 + 2+1+2) – (2+1) = 4 2:3 2:2 1:1 c ( S , T ) = 2+3+1+3 = 9 2:2 3:3 0:3 Cuts 2:3 2:2 s
Another characterization of flow value Lemma. For any flow f and any cut ( S , T ), we have | f | = f ( S , T ). Proof: f f ( s , v ) f ( v , s ) 0 v V v V f ( s , v ) f ( v , s ) f ( u , v ) f ( v , u ) v V v V u S \{ s } v V v V f ( u , v ) f ( v , u ) v V u S v V u S f ( u , v ) f ( u , v ) f ( v , u ) f ( v , u ) v S u S v T u S v S u S v T u S f ( u , v ) f ( v , u ) f ( S , T ) v T u S v T u S 9
Upper bound on the maximum flow value Theorem. The value of any flow is bounded from above by the capacity of any cut: |f| c(S,T) . Proof. f f ( S , T ) f ( u , v ) f ( v , u ) u S v T u S v T . f ( u , v ) u S v T c ( u , v ) u S v T c ( S , T ) 10
Flow into the sink 2:2 2:3 2:3 0:3 s t 1:1 2:2 2:2 3:3 | f | = f ({ s }, V\ { s }) = f ( V\ { t }, t ) = 4 11
Residual network Definition. Let f be a flow on G = ( V , E ). The residual network G f ( V , E f ) is the graph with residual capacities c ( u , v ) – f ( u , v ), if ( u , v ) E , if ( v , u ) E c f ( u , v ) = f ( v , u ) 0 , otherwise Edges in E f admit more flow. Lemma. | E f | 2| E |. 12
Augmenting paths Definition. Let p be a path from s to t in G f . The c ( p ) min { c ( u , v )} residual capacity of p is . f f ( u , v ) p If c f ( p ) > 0 then p is called an augmenting path in G with respect to f . The flow value can be increased along an augmenting path p by c f ( p ). 3:5 2:6 2:5 Ex.: G : s t 2:3 4:5 c f ( p ) = 2 2 4 4 2 3 p G f : s t 3 2 1 1 2 13
Augmenting paths (cont.) 3:5 2:6 2:5 G : s t 2:3 4:5 2 4 4 2 3 c f ( p ) = 2 p s G f : t 3 2 1 1 2 5:5 4:6 4:5 G : s t 2:5 . 0:3 0 0 2 2 1 G f : s t 5 4 3 3 4 14
Max-flow, min-cut theorem Theorem. The following are equivalent: 1. | f | = c ( S , T ) for some cut ( S , T ). min-cut 2. f is a maximum flow. 3. f admits no augmenting paths. Proof. ( 1 ) ( 2 ): Since | f | c ( S , T ) for any cut ( S , T ), the assumption that | f | c ( S , T ) implies that f is a maximum flow. ( 2 ) ( 3 ): If there was an augmenting path, the flow value could be increased, contradicting the maximality of f . 15
Proof (continued) ( 3 ) ( 1 ): Define S = { v V : there exists an augmenting path in G f from s to v }, and let T = V \ S . Since f admits no augmenting paths, there is no path from s to t in G f . Hence, s S and t T , and thus ( S , T ) is a cut. Consider any vertices u S and v T . s u v path in G f S T We must have c f ( u , v ) = 0, since if c f ( u , v ) > 0, then v S , not v T as assumed. Thus, f ( u , v ) = c ( u , v ) if ( u , v ) E since c f ( u , v ) = c ( u , v ) – f ( u , v ). And otherwise f ( u , v )=0. Summing over all u S and v T yields f ( S , T ) = c ( S , T ), and since | f | = f ( S , T ), the theorem follows. 16
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 10 9 10 9 G : 1 s t 10 9 10 9 17
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 0:10 9 0:10 9 G : 0:1 s t 0:10 9 0:10 9 18
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 0:10 9 0:10 9 G : 0:1 s t 0:10 9 0:10 9 19
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 1:10 9 0:10 9 G : 1:1 s t 0:10 9 1:10 9 20
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 1:10 9 0:10 9 G : 1:1 s t 0:10 9 1:10 9 21
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 1:10 9 1:10 9 G : 0:1 s t 1:10 9 1:10 9 22
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 1:10 9 1:10 9 G : 0:1 s t 1:10 9 1:10 9 23
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Can be slow: 2:10 9 1:10 9 G : 1:1 s t 1:10 9 2:10 9 2 billion iterations on a graph with 4 vertices! 24
Ford-Fulkerson max-flow algorithm Algorithm: f [ u , v ] 0 for all ( u , v ) E while an augmenting path p in G wrt f exists : augment f by c f ( p ) Runtime: • Let | f*| be the value of a maximum flow, and assume it is an integral value. • The initialization takes O ( |E| ) time • There are at most | f*| iterations of the loop • Find an augmenting path with DFS in O ( |V|+|E| ) time • Each augmentation takes O ( |V| ) time O ( |E| ·|f*| ) time in total 25
Edmonds-Karp algorithm Edmonds and Karp noticed that many people’s implementations of Ford-Fulkerson augment along a breadth-first augmenting path : a shortest path in G f from s to t where each edge with positive capacity has weight 1. These implementations would always run relatively fast. Since a breadth-first augmenting path can be found in O (| V|+|E| ) time, their analysis, which provided the first polynomial-time bound on maximum flow, focuses on bounding the number of flow augmentations. (In independent work, Dinic also gave polynomial-time bounds.) 26
Running time of Edmonds- Karp • One can show that the number of flow augmentations (i.e., the number of iterations of the while loop) is O (| V| |E| ). • Breadth-first search runs in O (| V|+|E| ) time • All other bookkeeping is O (| V| ) per augmentation. The Edmonds-Karp maximum-flow algorithm runs in O (| V| | E| 2 ) time. 27
Recommend
More recommend