Flows sourcesink s t
Flows sourcesink edge-weights = capacities
Flows sourcesink edge-weights = capacities 4 units of flow
Flows sourcesink edge-weights = capacities 6 units of flow 2
Flows sourcesink edge-weights = capacities 7 units of flow 3 1
Optimal? a larger flow?
Cuts s C C V s C t V-C capacity of a cut cap(C)= c(u,v) u C v V-C for any cut and any flow flow cut max-flow min-cut
Flows edge-weights = capacities 3 FLOW CONSERVATION
Skew symmetry edge-weights = capacities 3 FLOW CONSERVATION x -x
Flows edge-weights = capacities 3 FLOW CONSERVATION x -x f(u,v) = 0 vVvV
Flow – formal definition FLOW CONSERVATION CAPACITY CONSTRAINTS f(u,v) = 0 vVvV f(u,v) c(u,v) SKEW SYMMETRY f(u,v) = - f(v,u)
Max-flow problem INPUT: directed graph G=(V,E), source s V, sink t V a capacity c(e) for each edge e E OUTPUT: maximum flow from s to t
Max-flow problem F zero-flow while can improve F improve F
Max-flow problem improving can decrease flow on some edges
+1 +1 Augmenting path
+1 Augmenting path
+1 Augmenting path can improve the flow F zero-flow while augmenting path p improve F along p Ford-Fulkerson algorithm
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
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 Theorem: no augmenting path max-flow YES
Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to t in the residual network st
Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to t in the residual network st 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 st vertices to which we can get from s all edges from C to V-C saturated C
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
F zero-flow while augmenting path p improve F along p
F zero-flow while augmenting path p improve F along p
F zero-flow while augmenting path p improve F along p
F zero-flow while augmenting path p improve F along p
F zero-flow while augmenting path p improve F along p
F zero-flow while augmenting path p improve F along p
F zero-flow while augmenting path p improve F along p
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 running time O(E F * ) can a good choice of p improve the algorithm?
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 G f f’=flow in G f 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 G f f’=flow in G f 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 G f f’=flow in G f Claim: f’=h-g is a flow in G f CAPACITY CONSTRAINTS: f’(u,v) h(u,v)-f(u,v) c(u,v)-f(u,v) flow h in G
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 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 = flow f = p + (f-p)
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 * ) Claim: any flow f in G is a sum of at most |E| path flows Graph G flow f in G Residual network G f f’=f * -f max-flow f * in G path with bottleneck capacity f’/|E|
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 G f f’=f * -f max-flow f * in G path with bottleneck capacity f’/|E| max-flow in the residual graph decreases by a factor of at least (1-1/|E|)
2. choose path p which has the fewest number of edges THEOREM: number of augmenting steps O(E V)
2. choose path p which has the fewest number of edges level graph = BFS in the residual network
2. choose path p which has the fewest number of edges level graph = BFS in the residual network
2. choose path p which has the fewest number of edges 1) one such edge saturated 2) no new introduced count edges in the residual graph which are on a path of length d from s to t
Plain Ford-Fulkerson O(E F * ) Maximum bottleneck capacity O( (E+V log V) E log F ) Fewest edges O(E 2 V)
Max-matching in bipartite graphs
st solution using max-flow all edge weights =1
Max-matching in bipartite graphs solution using max-flow st all edge weights =1 Plain Ford-Fulkerson O(E F * ) Maximum bottleneck capacity O( (E+V log V) E log F ) Fewest edges O(E 2 V) which one to use?