Flows s source t sink Flows edgeweights capacities

  • Slides: 61
Download presentation

Flows s source t sink

Flows s source t sink

Flows edge-weights = capacities 2 5 7 4 2 3 4 2 source sink

Flows edge-weights = capacities 2 5 7 4 2 3 4 2 source sink

Flows 2 2 2 5 7 2 2 source edge-weights = capacities 4 2

Flows 2 2 2 5 7 2 2 source edge-weights = capacities 4 2 2 3 2 4 units of flow sink

Flows 2 4 5 2 7 2 2 2 source edge-weights = capacities 4

Flows 2 4 5 2 7 2 2 2 source edge-weights = capacities 4 2 2 3 4 4 2 6 units of flow sink

Flows 2 edge-weights = capacities 2 5 5 3 7 2 1 4 2

Flows 2 edge-weights = capacities 2 5 5 3 7 2 1 4 2 source 1 3 3 4 4 2 7 units of flow sink

Optimal? 2 2 55 3 3 3 7 2 2 1 4 12 a

Optimal? 2 2 55 3 3 3 7 2 2 1 4 12 a larger flow? 4 4

Cuts capacity of a cut C s u C v V-C for any cut

Cuts capacity of a cut C s u C v V-C for any cut and any flow cut C V s C t V-C cap(C)= c(u, v) max-flow min-cut

Flows 5 5 2 edge-weights = capacities 2 3 4 FLOW CONSERVATION

Flows 5 5 2 edge-weights = capacities 2 3 4 FLOW CONSERVATION

Skew symmetry 2 5 5 x edge-weights = capacities 2 3 4 -x FLOW

Skew symmetry 2 5 5 x edge-weights = capacities 2 3 4 -x FLOW CONSERVATION

Flows 2 -5 5 x 3 edge-weights = capacities 2 f(u, v) = 0

Flows 2 -5 5 x 3 edge-weights = capacities 2 f(u, v) = 0 v V 4 -x FLOW CONSERVATION

Flow – formal definition FLOW CONSERVATION f(u, v) = 0 v V CAPACITY CONSTRAINTS

Flow – formal definition FLOW CONSERVATION f(u, v) = 0 v V CAPACITY CONSTRAINTS 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

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

Max-flow problem F zero-flow while can improve F

Max-flow problem 2 2 54 2 2 2 7 4 22 2 3 2

Max-flow problem 2 2 54 2 2 2 7 4 22 2 3 2 2 4 4 improving can decrease flow on some edges 55 3 3 3 7 2 2 1 4 12 4 4

Augmenting path +1 +1 -1 +1 +1

Augmenting path +1 +1 -1 +1 +1

Augmenting path +1 +1 +1

Augmenting path +1 +1 +1

Augmenting path can improve the flow +1 +1 +1 Ford-Fulkerson algorithm F zero-flow while

Augmenting path can improve the flow +1 +1 +1 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)

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 5 4 2 2 7 2 2 2 4 2 2 2

Residual network 5 4 2 2 7 2 2 2 4 2 2 2 3 4 4

Residual network 2 9 1 2 7 2 2 2 4 2 2 2

Residual network 2 9 1 2 7 2 2 2 4 2 2 2 3 4 4

Residual network 2 9 1 2 7 2 2 2 4 2 2 2

Residual network 2 9 1 2 7 2 2 2 4 2 2 2 3 4 4

Residual network 4 9 1 7 2 2 2 4 2 2 2 3

Residual network 4 9 1 7 2 2 2 4 2 2 2 3 4 4

Residual network 4 9 1 7 2 2 2 4 2 2 2 3

Residual network 4 9 1 7 2 2 2 4 2 2 2 3 4 4

Residual network 4 9 1 7 2 2 2 4 2 2 1 4

Residual network 4 9 1 7 2 2 2 4 2 2 1 4 5 4

Residual network 4 9 4 6 1 7 7 2 5 1 8 4

Residual network 4 9 4 6 1 7 7 2 5 1 8 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

Correct ? F zero-flow while augmenting path p improve F along p YES Theorem:

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

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

Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to t in the residual network s vertices to which we can get from s t

Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to

Theorem: no augmenting path max-flow Proof: no augmenting path no path from s to t in the residual network C s vertices to which we can get from s all edges from C to V-C saturated t

Theorem: no augmenting path max-flow Theorem 2: max-flow = min-cut

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

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 0 0 100

F zero-flow while augmenting path p improve F along p 100 0 0 100 1 0 0 0 100

F zero-flow while augmenting path p improve F along p 100 0 0 100

F zero-flow while augmenting path p improve F along p 100 0 0 100 1 0 0 0 100

F zero-flow while augmenting path p improve F along p 100 1 0 100

F zero-flow while augmenting path p improve F along p 100 1 0 100 1 1 100

F zero-flow while augmenting path p improve F along p 100 1 0 100

F zero-flow while augmenting path p improve F along p 100 1 0 100 1 1 100

F zero-flow while augmenting path p improve F along p 100 1 0 100

F zero-flow while augmenting path p improve F along p 100 1 0 100 1 1 100

F zero-flow while augmenting path p improve F along p 100 1 2 -1

F zero-flow while augmenting path p improve F along p 100 1 2 -1 1 100

F zero-flow while augmenting path p improve F along p 100 1 2 -1

F zero-flow while augmenting path p improve F along p 100 1 2 -1 1 100

F zero-flow while augmenting path p improve F along p 100 3 2 100

F zero-flow while augmenting path p improve F along p 100 3 2 100 1 2 1 3 100

F zero-flow while augmenting path p improve F along p Assume that the capacities

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* running time O(E F*) (=max-flow)

F zero-flow while augmenting path p improve F along p can a good choice

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

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

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’

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’

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

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

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;

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)

1. choose path p which increases the flow the most (i. e. , 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 Residual network Gf f’=f*-f flow f in G max-flow f* in G path with bottleneck capacity f’/|E|

1. choose path p which increases the flow the most (i. e. , 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*) max-flow in the residual graph decreases by a factor of at least (1 -1/|E|) Graph G Residual network Gf f’=f*-f flow f in G max-flow f* in G path with bottleneck capacity f’/|E|

2. choose path p which has the fewest number of edges THEOREM: number of

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 =

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 =

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 count edges in

2. choose path p which has the fewest number of edges count edges in the residual graph which are on a path of length d from s to t 1) one such edge saturated 2) no new introduced

Plain Ford-Fulkerson O(E F*) Maximum bottleneck capacity O( (E+V log V) E log F*

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

Max-matching in bipartite graphs

Max-matching in bipartite graphs

Max-matching in bipartite graphs

Max-matching in bipartite graphs solution using max-flow all edge weights =1 s t

Max-matching in bipartite graphs solution using max-flow all edge weights =1 s t

Max-matching in bipartite graphs solution using max-flow all edge weights =1 s t Plain

Max-matching in bipartite graphs solution using max-flow all edge weights =1 s t Plain Ford-Fulkerson O(E F*) which one to use? Maximum bottleneck capacity O( (E+V log V) E log F* ) Fewest edges O(E 2 V)