max-flow and min-cut - indiana state universitycs.indstate.edu › ~arash › adslec15.pdf · arash...
TRANSCRIPT
Max-Flow and Min-Cut
Arash Rafiey
1 December 2015
Arash Rafiey Max-Flow and Min-Cut
Max-Flow and Min-Cut
We say a directed loop-less graph D is a network or transportnetwork if :
D has a source vertex, a vertex without in-neighbor
D has a sink vertex, a vertex without out-neighbor
D is weighted (non-negative integer values), every arc e has aweight (capacity), c(e).
a
b d
g h
z5
75
56
45
6
2
Function F : E (D) → N+ is a flow if :
f (e) ≤ c(e) for every e ∈ E .
for each v ∈ V other than source and sink,∑w∈V f (wv) =
∑u∈V f (vu). (if wv is not an arc f (wv) = 0)
Arash Rafiey Max-Flow and Min-Cut
Max-Flow and Min-Cut
We say a directed loop-less graph D is a network or transportnetwork if :
D has a source vertex, a vertex without in-neighbor
D has a sink vertex, a vertex without out-neighbor
D is weighted (non-negative integer values), every arc e has aweight (capacity), c(e).
a
b d
g h
z5
75
56
45
6
2
Function F : E (D) → N+ is a flow if :
f (e) ≤ c(e) for every e ∈ E .
for each v ∈ V other than source and sink,∑w∈V f (wv) =
∑u∈V f (vu). (if wv is not an arc f (wv) = 0)
Arash Rafiey Max-Flow and Min-Cut
a a
b d
g h
z5,3
7,5
5,2
b d
g h
z5,3
7,5
5,2
5,26,5
5,24,1
6,42,1
4,2
5,36,4
5,4
6,32,2
A B
A is not a flow and B is a flow.
Definition
Let f be a flow for network D = (V ,E ).
An edge e is called saturated if f (e) = c(e) and unsaturatedotherwise.
If a is a source of D then val(f ) =∑
v∈V f (av) is called thevalue of f .
Arash Rafiey Max-Flow and Min-Cut
a a
b d
g h
z5,3
7,5
5,2
b d
g h
z5,3
7,5
5,2
5,26,5
5,24,1
6,42,1
4,2
5,36,4
5,4
6,32,2
A B
A is not a flow and B is a flow.
Definition
Let f be a flow for network D = (V ,E ).
An edge e is called saturated if f (e) = c(e) and unsaturatedotherwise.
If a is a source of D then val(f ) =∑
v∈V f (av) is called thevalue of f .
Arash Rafiey Max-Flow and Min-Cut
a a
b d
g h
z5,3
7,5
5,2
b d
g h
z5,3
7,5
5,2
5,26,5
5,24,1
6,42,1
4,2
5,36,4
5,4
6,32,2
A B
A is not a flow and B is a flow.
Definition
Let f be a flow for network D = (V ,E ).
An edge e is called saturated if f (e) = c(e) and unsaturatedotherwise.
If a is a source of D then val(f ) =∑
v∈V f (av) is called thevalue of f .
Arash Rafiey Max-Flow and Min-Cut
Definition
Let D = (V ,E ) be a network. A set of arcs C is a cut (cut-set) ifE \ C separates source a from sink z (a− z-cut). (There is nodirected path from a to z after removing the edges in C from E .
C1 C2
a
b d
g h
z5
75
5
45
6
26
We usually denote a cut-set C by (P,P). P is a set of vertices inV containing source a and P = V \ P.The cost of cut-set C = (P,P) is denoted by
c(P,P) =∑
v∈P,w∈P
c(v ,w).
Arash Rafiey Max-Flow and Min-Cut
Definition
Let D = (V ,E ) be a network. A set of arcs C is a cut (cut-set) ifE \ C separates source a from sink z (a− z-cut). (There is nodirected path from a to z after removing the edges in C from E .
C1 C2
a
b d
g h
z5
75
5
45
6
26
We usually denote a cut-set C by (P,P). P is a set of vertices inV containing source a and P = V \ P.The cost of cut-set C = (P,P) is denoted by
c(P,P) =∑
v∈P,w∈P
c(v ,w).
Arash Rafiey Max-Flow and Min-Cut
Theorem
Let f be a flow in a network D = (V ,E ). If C = (P,P) is any cutin D, then val(f ) ≤ c(P,P).
Proof.
Let a be the source. Since id(a) = 0, we can say for all w ∈ V ,f (wa) = 0. Thus val(f ) =
∑v∈V f (av)−
∑w∈V f (wa). We also
know for every x ∈ P, x 6= a,∑
v∈V f (xv)−∑
w∈V f (wx) = 0.Therefore :
val(f ) = [∑v∈v
f (av)−∑w∈V
f (wa)] +∑
a 6=x∈P
[∑v∈V
f (xv)−∑w∈V
f (wx)]
=∑
x∈P,v∈V
f (xv)−∑
x∈P,w∈V
f (wx)
Arash Rafiey Max-Flow and Min-Cut
Proof. ∑x∈P,v∈V
f (xv)−∑
x∈P,w∈V
f (wx)
= [∑
x ,v∈P
f (xv) +∑
x∈P,v∈P
f (xv)]− [∑
a,w∈P
f (wx) +∑
x∈P,w∈P
f (wx)].
Since∑
x ,v∈P f (xv),∑
x ,w∈P f (wx) are summed over the same setof arcs, they are equal. Consequently,
val(f ) =∑
x∈P,v∈P
f (xv)−∑
x∈P,w∈P
f (wx).
Therefore :val(f ) ≤
∑x∈P,v∈P f (xv) ≤
∑x∈P,v∈P c(xv) = c(P,P)
Arash Rafiey Max-Flow and Min-Cut
Corollary
If f is a flow in a network D = (V ,E ), then value of the flow fromsource a is equal to the value of the flow in sink z.
Proof.
This follows from the definition because the flow is not going to belost. Whatever we send out from a will be received in z .
Corollary
Let f be a flow in a network D = (V ,E ) and let C = (P,P) be acut where val(f ) = c(P,P). Then f is a maximum flow for D andC is a minimum cut.
Proof.
By previous theorem for any flow f1 for D we haveval(f1) ≤ c(P,P) = val(f ). Therefore f is a maximum flow.Similarly for any cut (P ′,P ′) we have c(P,P) = val(f ) ≤ c(P ′,P ′)and hence C is a minimum cut.
Arash Rafiey Max-Flow and Min-Cut
Corollary
If f is a flow in a network D = (V ,E ), then value of the flow fromsource a is equal to the value of the flow in sink z.
Proof.
This follows from the definition because the flow is not going to belost. Whatever we send out from a will be received in z .
Corollary
Let f be a flow in a network D = (V ,E ) and let C = (P,P) be acut where val(f ) = c(P,P). Then f is a maximum flow for D andC is a minimum cut.
Proof.
By previous theorem for any flow f1 for D we haveval(f1) ≤ c(P,P) = val(f ). Therefore f is a maximum flow.Similarly for any cut (P ′,P ′) we have c(P,P) = val(f ) ≤ c(P ′,P ′)and hence C is a minimum cut.
Arash Rafiey Max-Flow and Min-Cut
Corollary
If f is a flow in a network D = (V ,E ), then value of the flow fromsource a is equal to the value of the flow in sink z.
Proof.
This follows from the definition because the flow is not going to belost. Whatever we send out from a will be received in z .
Corollary
Let f be a flow in a network D = (V ,E ) and let C = (P,P) be acut where val(f ) = c(P,P). Then f is a maximum flow for D andC is a minimum cut.
Proof.
By previous theorem for any flow f1 for D we haveval(f1) ≤ c(P,P) = val(f ). Therefore f is a maximum flow.Similarly for any cut (P ′,P ′) we have c(P,P) = val(f ) ≤ c(P ′,P ′)and hence C is a minimum cut.
Arash Rafiey Max-Flow and Min-Cut
Corollary
If f is a flow in a network D = (V ,E ), then value of the flow fromsource a is equal to the value of the flow in sink z.
Proof.
This follows from the definition because the flow is not going to belost. Whatever we send out from a will be received in z .
Corollary
Let f be a flow in a network D = (V ,E ) and let C = (P,P) be acut where val(f ) = c(P,P). Then f is a maximum flow for D andC is a minimum cut.
Proof.
By previous theorem for any flow f1 for D we haveval(f1) ≤ c(P,P) = val(f ). Therefore f is a maximum flow.Similarly for any cut (P ′,P ′) we have c(P,P) = val(f ) ≤ c(P ′,P ′)and hence C is a minimum cut.
Arash Rafiey Max-Flow and Min-Cut
Corollary
Let f be a flow in a network D = (V ,E ) and let C = (P,P) be acut. Then val(f ) = c(P,P) if and only if
(a) f (e) = c(e) for every arc xy, where x ∈ P and y ∈ P.
(b) f (e) = 0 for every arc vw, where v ∈ P and w ∈ P.
Furthermore, f is a maximum flow and C is a minimum cut.
Arash Rafiey Max-Flow and Min-Cut
Definition
Let D be a network. We say a sequencea = v0, e1, v1, e2, v2, . . . , en, vn = z (a is source and z is a sink) isan oriented path, where each ei is either in a forward direction orbackward direction.
Definition
Let f be a flow in network D = (V ,E ). An f -augmenting pathp is an oriented path (from a to z) where for each edge e of p wehavef (e) < c(e) for e forward edgef (e) > 0 for e backward edge.
Arash Rafiey Max-Flow and Min-Cut
Definition
Let D be a network. We say a sequencea = v0, e1, v1, e2, v2, . . . , en, vn = z (a is source and z is a sink) isan oriented path, where each ei is either in a forward direction orbackward direction.
Definition
Let f be a flow in network D = (V ,E ). An f -augmenting pathp is an oriented path (from a to z) where for each edge e of p wehavef (e) < c(e) for e forward edgef (e) > 0 for e backward edge.
Arash Rafiey Max-Flow and Min-Cut
Definition
Let p be an f -augmenting path in network D = (V ,E ). For eachedge e on p
∆e =
{c(e)− f (e) for e a forward edgef (e) for e a backward edge
∆e is called the tolerance of e.
Theorem
Let f be a flow in network D = (V ,E ) and let p be anf -augmenting path in D with ∆p = mine∈p ∆e .Define f1 : E → N by
f1(e) =
f (e) + ∆p e ∈ p, e a forward edgef (e)−∆p e ∈ p, e a backward edgef (e) e ∈ E, e 6∈ p
Then f1 is a flow in D with val(f1) = val(f ) + ∆p.
Arash Rafiey Max-Flow and Min-Cut
Definition
Let p be an f -augmenting path in network D = (V ,E ). For eachedge e on p
∆e =
{c(e)− f (e) for e a forward edgef (e) for e a backward edge
∆e is called the tolerance of e.
Theorem
Let f be a flow in network D = (V ,E ) and let p be anf -augmenting path in D with ∆p = mine∈p ∆e .Define f1 : E → N by
f1(e) =
f (e) + ∆p e ∈ p, e a forward edgef (e)−∆p e ∈ p, e a backward edgef (e) e ∈ E, e 6∈ p
Then f1 is a flow in D with val(f1) = val(f ) + ∆p.
Arash Rafiey Max-Flow and Min-Cut
Max-Flow Algorithm
We need to find an f -augmenting path first. We can do it using amodified version of BFS so called BFS-f-augmenting algorithmstarting from source a.
At each step we create a new level by adding vertex w to a vertexv from the previous level if vw is a forward edge andf (vw) < e(vw) or v ,w is a backward edge (wv is an arc of thenetwork) and f (wv) > 0. Once we reach z we stop.
Arash Rafiey Max-Flow and Min-Cut
Ford-Fulkerson Max-Flow Algorithm
Max-Flow( (D = (V ,E ) )
1. Define flow f for every edge e by setting f (e) = 0.
2. Repeat :
3. Apply BFS-f-augmenting to find an f -augmenting path p
4. Let ∆p = mine∈p ∆e
5. for each edge e ∈ p
6. if e is a forward edge
7. f (e) := f (e) + ∆p.
8. else (e is a backward edge)
9. f (e) := f (e)−∆p.
10. Until no f -augmenting path p can be found.
11. Return f .
Arash Rafiey Max-Flow and Min-Cut