620 likes | 637 Views
Flows. t. s. source. sink. Flows. edge-weights = capacities. 2. 3. 5. 7. 4. 4. 2. 2. source. sink. Flows. edge-weights = capacities. 2. 2. 2. 3. 2. 5. 7. 2. 4. 4. 2. 2. 2. 2. 4 units of flow. source. sink. Flows. edge-weights = capacities. 2. 2. 2. 3. 4.
E N D
Flows t s source sink
Flows edge-weights = capacities 2 3 5 7 4 4 2 2 source sink
Flows edge-weights = capacities 2 2 2 3 2 5 7 2 4 4 2 2 2 2 4 units of flow source sink
Flows edge-weights = capacities 2 2 2 3 4 5 7 2 2 4 4 4 2 2 2 6 units of flow source sink
Flows edge-weights = capacities 2 2 3 3 5 5 7 3 2 1 4 4 4 2 1 2 7 units of flow source sink
Optimal? 2 2 3 3 5 5 7 3 2 1 4 4 4 2 1 2 a larger flow?
Cuts capacity of a cut cap(C)= c(u,v) C s uC vV-C C V s C t V-C for any cut and any flow flow cut max-flow min-cut
Flows edge-weights = capacities 2 2 5 5 3 4 FLOW CONSERVATION
Skew symmetry edge-weights = capacities 2 2 5 5 3 4 x -x FLOW CONSERVATION
Flows edge-weights = capacities 2 2 -5 5 3 f(u,v) = 0 vV 4 x -x FLOW CONSERVATION
Flow – formal definition FLOW CONSERVATION CAPACITY CONSTRAINTS f(u,v) = 0 vV f(u,v) c(u,v) SKEW SYMMETRY f(u,v) = - f(v,u)
Max-flow problem INPUT: directed graph G=(V,E), source sV, sink tV a capacity c(e) for each edge eE OUTPUT: maximum flow from s to t
Max-flow problem F zero-flow while can improve F improve F
Max-flow problem 2 2 2 2 3 2 3 3 4 5 5 5 7 7 3 2 2 2 1 4 4 4 4 4 4 2 2 2 1 2 2 improving can decrease flow on some edges
Augmenting path +1 +1 +1 +1 -1
Augmenting path +1 +1 +1 +1 +1
Augmenting path +1 +1 +1 +1 +1 can improve the flow Ford-Fulkerson algorithm F zero-flow while augmenting path p improve F along p
Residual capacity f(u,v) c(u,v) r(u,v) = c(u,v) – f(u,v) makes sense for negative f(u,v)
Residual network 2 2 5 2 3 7 2 4 2 4 4 4 2 2 2
Residual network 2 2 2 3 9 7 2 1 2 4 4 4 2 2 2
Residual network 2 2 2 3 9 7 2 1 2 4 4 4 2 2 2
Residual network 4 2 3 9 7 2 1 2 4 4 4 2 2 2
Residual network 4 2 3 9 7 2 1 2 4 4 4 2 2 2
Residual network 4 5 9 7 2 1 1 2 4 4 4 2 2 2
Residual network 4 5 6 9 7 1 1 7 2 8 4 4 Is there an augmenting path? Is there a path from s to t in the residual network?
Correct ? F zero-flow while augmenting path p improve F along p
Correct ? F zero-flow while augmenting path p improve F along p YES Theorem: no augmenting path max-flow
Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to t in the residual network s t
Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to t in the residual network s t vertices to which we can get from s
Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to t in the residual network all edges from C to V-C saturated C s t vertices to which we can get from s
Theorem: no augmenting path max-flow Theorem 2: max-flow = min-cut
Is there an augmenting path? Is there a path from s to t in the residual network? time O(E) F zero-flow while augmenting path p improve F along p time = ?
F zero-flow while augmenting path p improve F along p 100 100 0 0 1 0 0 0 100 100
F zero-flow while augmenting path p improve F along p 100 100 0 0 1 0 0 0 100 100
F zero-flow while augmenting path p improve F along p 100 100 1 0 1 1 0 1 100 100
F zero-flow while augmenting path p improve F along p 100 100 1 0 1 1 0 1 100 100
F zero-flow while augmenting path p improve F along p 100 100 1 0 1 1 0 1 100 100
F zero-flow while augmenting path p improve F along p 100 100 1 2 1 -1 2 1 100 100
F zero-flow while augmenting path p improve F along p 100 100 1 2 1 -1 2 1 100 100
F zero-flow while augmenting path p improve F along p 100 100 3 2 1 1 2 3 100 100
F zero-flow while augmenting path p improve F along p Assume that the capacities are integers. Then the number of augementations is bounded by F* (=max-flow) running time O(E F*)
F zero-flow while augmenting path p improve F along p can a good choice of p improve the algorithm? running time O(E F*)
F zero-flow while augmenting path p improve F along p 1. choose path p which increases the flow the most (i.e., p has the maximum bottleneck capacity) 2. choose path p which has the fewest number of edges
1. choose path p which increases the flow the most (i.e., p has the maximum bottleneck capacity) THEOREM: number of augmenting steps O(E log F*)
Graph G flow f in G Residual network Gf f’=flow in Gf Claim: h=f+f’ is a flow in G SKEW SYMMETRY: h(u,v)=f(u,v)+f’(u,v)=-f(v,u)-f’(v,u) = - (f(v,u) + f’(v,u)) = - h(v,u) FLOW CONSERVATION: u h(u,v) = u (f(u,v)+f’(u,v))= u f(u,v) + u f’(u,v) = 0
Graph G flow f in G Residual network Gf f’=flow in Gf Claim: h=f+f’ is a flow in G CAPACITY CONSTRAINTS: f’(u,v) c(u,v)-f(u,v) h(u,v)=f(u,v)+f’(u,v) c(u,v)
Graph G flow f in G Residual network Gf f’=flow in Gf flow h in G Claim: f’=h-g is a flow in Gf CAPACITY CONSTRAINTS: f’(u,v)= h(u,v)-f(u,v)c(u,v)-f(u,v)
Claim: any flow f in G is a sum of at most |E| path flows Induction on the number of non-zero edges in f
Claim: any flow f in G is a sum of at most |{e E;f(e)0}| path flows Induction on the number of non-zero edges in f f = flow G’ with capacities c’(u,v)=max{0,f(u,v)} p = augmenting path from zero flow in G’ p has bottleneck edge f-p has less non-zero edges than f f = p + (f-p)