1
BITS Pilani, Hyderabad Campus
CONTENTS
Slide 2
Algorithm
Flow and Cut
Max Flow and Min Cut
Theorem
Running Time
Proof
3
Network reliability.
Security of statistical data.
Distributed computing.
Egalitarian stable matching.
Distributed computing.
Many many more . . .
Maximum Flow and Minimum Cut
Max flow and min cut.
Two very rich algorithmic problems.
Cornerstone problem in combinatorial optimization.
Beautiful mathematical duality.
Nontrivial applications / reductions.
Network connectivity.
Bipartite matching.
Data mining.
Open-pit mining.
Airline scheduling.
Image processing.
Project selection.
Baseball elimination.
4
Max flow network: G = (V, E, s, t, u) .
(V, E) = directed graph, no parallel arcs.
Two distinguished nodes: s = source, t = sink.
u(e) = capacity of arc e.
Max Flow Network
Capacity
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
5
An s-t flow is a function f: E → ℜ that satisfies:
For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity)
For each v ∈ V – {s, t}: (conservation)
Flows
∑∑ =
veve
efef
ofouttoin
)()(
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
4
0
0
0
0
0 0
0 4 4
0
4 0
00
Capacity
Flow
∑=∑
∈ Ewvwve
wvfef
),(:ofout
),(:)(∑=∑
∈ Evwwve
vwfef
),(:toin
),(:)(
6
An s-t flow is a function f: E → ℜ that satisfies:
For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity)
For each v ∈ V – {s, t}: (conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
4
0
0
0
0
0 0
0 4 4
0
4 0
Value = 4
∑=
se
eff
ofout
)(
00
Capacity
Flow
∑∑ =
veve
efef
ofouttoin
)()(
7
An s-t flow is a function f: E → ℜ that satisfies:
For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity)
For each v ∈ V – {s, t}: (conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
6
6
11
11
1 10
3 8 8
0
4 0
Value = 24
00
Capacity
Flow
∑∑ =
veve
efef
ofouttoin
)()(
8
An s-t flow is a function f: E → ℜ that satisfies:
For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity)
For each v ∈ V – {s, t}: (conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
Flows
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
9
9
14
14
4 10
4 8 9
1
0 0
Value = 28
00
Capacity
Flow
∑∑ =
veve
efef
ofouttoin
)()(
9
Networks
communication
Network
telephone exchanges,
computers, satellites
Nodes Arcs
cables, fiber optics,
microwave relays
Flow
voice, video,
packets
circuits
gates, registers,
processors
wires current
mechanical joints rods, beams, springs heat, energy
hydraulic
reservoirs, pumping
stations, lakes
pipelines fluid, oil
financial stocks, currency transactions money
transportation
airports, rail yards,
street intersections
highways, railbeds,
airway routes
freight,
vehicles,
passengers
chemical sites bonds energy
10
Cuts
∑∑
∈∈
∈
=
TwSv
EwvSe
wvueu
,
),(ofout
).,(:)(
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
Capacity = 30
11
An s-t cut is a node partition (S, T) such that s ∈ S, t ∈ T.
The capacity of an s-t cut (S, T) is:
Min s-t cut: find an s-t cut of minimum capacity.
Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
Capacity = 62
∑∑
∈∈
∈
=
TwSv
EwvSe
wvueu
,
),(ofout
).,(:)(
12
An s-t cut is a node partition (S, T) such that s ∈ S, t ∈ T.
The capacity of an s-t cut (S, T) is:
Min s-t cut: find an s-t cut of minimum capacity.
Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
Capacity = 28
∑∑
∈∈
∈
=
TwSv
EwvSe
wvueu
,
),(ofout
).,(:)(
13
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent
across the cut is equal to the amount reaching t.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
fefefef
seSeSe
==− ∑∑∑
ofouttoinofout
)()()(
Value = 24
10
6
6
10
10
0 10
4 8 8
0
4 0
00
14
10
6
6
10
10
0 10
4 8 8
0
4 0
00
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent
across the cut is equal to the amount reaching t.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
fefefef
seSeSe
==− ∑∑∑
ofouttoinofout
)()()(
Value = 24
15
10
6
6
10
10
0 10
4 8 8
0
4 0
0
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent
across the cut is equal to the amount reaching t.
Flows and Cuts
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
fefefef
seSeSe
==− ∑∑∑
ofouttoinofout
)()()(
Value = 24
0
16
Let f be a flow, and let (S, T) be a cut. Then,
Proof by induction on |S|.
Base case: S = { s }.
Inductive hypothesis: assume true for |S| < k.
– consider cut (S, T) with |S| = k
– S = S' ∪ { v } for some v ≠ s, t, |S' | = k-1 ⇒ cap(S', T') = | f |.
– adding v to S' increase cut capacity by
Flows and Cuts
.)()(
toinofout
∑∑ =−
SeSe
fefef
0)()(
toinofout
=− ∑∑
veve
efef
s
v
t
After
s
v
t
S' Before S
17
L2. Let f be a flow, and let (S, T) be a cut. Then, | f | ≤ cap(S, T).
Proof.
Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), then
f is a max flow and (S, T) is a min cut.
Flows and Cuts
T)cap(S,
)(
)(
)()(
ofout
ofout
toinofout
=
≤
≤
−=
∑
∑
∑∑
Se
Se
SeSe
eu
ef
efeff
s
t
S T
7
6
8
4
18
Max Flow and Min Cut
Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), then
f is a max flow and (S, T) is a min cut.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
9
9
15
15
4 10
4 8 9
1
0 0
Flow value = 28
00
Cut capacity = 28
19
Max-Flow Min-Cut Theorem
MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): In any
network, the value of the max flow is equal to the value of the min cut.
"Good characterization."
Proof IOU.
s
2
3
4
5
6
7
t
15
5
30
15
10
8
15
9
6 10
10
10154
4
10
9
9
15
15
4 10
4 8 9
1
0 0
Flow value = 28
00
Cut capacity = 28
20
Towards an Algorithm
Find an s-t path where each arc has u(e) > f(e) and "augment" flow
along the path.
s
4
2
5
3 t
4
0 0
0 0 0
0
4
0
4
4
Flow value = 0
10 13 10
21
Towards an Algorithm
Find an s-t path where each arc has u(e) > f(e) and "augment" flow
along the path.
Repeat until you get stuck.
s
4
2
5
3 t
4
0 0
0 0 0
0
4
0
4
4
Flow value = 10
10 13 10
10 10 10X X X
22
Max-Flow Min-Cut Theorem
Augmenting path theorem (Ford-Fulkerson, 1956): A flow f is a max
flow if and only if there are no augmenting paths.
MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): the value of
the max flow is equal to the value of the min cut.
We prove both simultaneously by showing the TFAE:
(i) f is a max flow.
(ii) There is no augmenting path relative to f.
(iii) There exists a cut (S, T) such that |f| = cap(S, T).
23
Proof of Max-Flow Min-Cut Theorem
We prove both simultaneously by showing the TFAE:
(i) f is a max flow.
(ii) There is no augmenting path relative to f.
(iii) There exists a cut (S, T) such that |f| = cap(S, T).
(i) ⇒ (ii)
We show contrapositive.
Let f be a flow. If there exists an augmenting path, then we can
improve f by sending flow along path.
(ii) ⇒ (iii)
Next slide.
(iii) ⇒ (i)
This was the Corollary to Lemma 2.
24
Proof of Max-Flow Min-Cut Theorem
We prove both simultaneously by showing the TFAE:
(i) f is a max flow.
(ii) There is no augmenting path relative to f.
(iii) There exists a cut (S, T) such that |f| = cap(S, T).
(ii) ⇒ (iii)
Let f be a flow with no augmenting paths.
Let S be set of vertices reachable from s in residual graph.
– clearly s ∈ S, and t ∉ S by definition of f
T)(S,
)(
)()(
ofout
toinofout
cap
eu
efeff
Se
SeSe
=
=
−=
∑
∑∑
s
t
Original Network
S T
25
Running Time
Assumption: all capacities are integers between 0 and U.
Invariant: every flow value f(e) and every residual capacities uf (e)
remains an integer throughout the algorithm.
Theorem: the algorithm terminates in at most | f * | ≤ nU iterations.
Corollary: if U = 1, then algorithm runs in O(mn) time.
Integrality theorem: if all arc capacities are integers, then there exists
a max flow f for which every flow value f(e) is an integer.
Note: algorithm may not terminate on some pathological instances
(with irrational capacities). Moreover, flow value may not even
converge to correct answer.
BITS Pilani, Hyderabad Campus
Thanks
Copyright © Mayank Garg. All Rights Reserved
Slide 26
Link to connect with author:
http://www.slideshare.net/MayankGarg25
https://www.linkedin.com/in/gargmayank
http://www.researchgate.net/profile/Mayank_Garg6/
https://www.facebook.com/mayank17692?ref=hl

Max flow min cut

  • 1.
  • 2.
    BITS Pilani, HyderabadCampus CONTENTS Slide 2 Algorithm Flow and Cut Max Flow and Min Cut Theorem Running Time Proof
  • 3.
    3 Network reliability. Security ofstatistical data. Distributed computing. Egalitarian stable matching. Distributed computing. Many many more . . . Maximum Flow and Minimum Cut Max flow and min cut. Two very rich algorithmic problems. Cornerstone problem in combinatorial optimization. Beautiful mathematical duality. Nontrivial applications / reductions. Network connectivity. Bipartite matching. Data mining. Open-pit mining. Airline scheduling. Image processing. Project selection. Baseball elimination.
  • 4.
    4 Max flow network:G = (V, E, s, t, u) . (V, E) = directed graph, no parallel arcs. Two distinguished nodes: s = source, t = sink. u(e) = capacity of arc e. Max Flow Network Capacity s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4
  • 5.
    5 An s-t flowis a function f: E → ℜ that satisfies: For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity) For each v ∈ V – {s, t}: (conservation) Flows ∑∑ = veve efef ofouttoin )()( s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 4 0 0 0 0 0 0 0 4 4 0 4 0 00 Capacity Flow ∑=∑ ∈ Ewvwve wvfef ),(:ofout ),(:)(∑=∑ ∈ Evwwve vwfef ),(:toin ),(:)(
  • 6.
    6 An s-t flowis a function f: E → ℜ that satisfies: For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity) For each v ∈ V – {s, t}: (conservation) MAX FLOW: find s-t flow that maximizes net flow out of the source. Flows s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 4 0 0 0 0 0 0 0 4 4 0 4 0 Value = 4 ∑= se eff ofout )( 00 Capacity Flow ∑∑ = veve efef ofouttoin )()(
  • 7.
    7 An s-t flowis a function f: E → ℜ that satisfies: For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity) For each v ∈ V – {s, t}: (conservation) MAX FLOW: find s-t flow that maximizes net flow out of the source. Flows s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 10 6 6 11 11 1 10 3 8 8 0 4 0 Value = 24 00 Capacity Flow ∑∑ = veve efef ofouttoin )()(
  • 8.
    8 An s-t flowis a function f: E → ℜ that satisfies: For each e ∈ E: 0 ≤ f(e) ≤ u(e) (capacity) For each v ∈ V – {s, t}: (conservation) MAX FLOW: find s-t flow that maximizes net flow out of the source. Flows s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 10 9 9 14 14 4 10 4 8 9 1 0 0 Value = 28 00 Capacity Flow ∑∑ = veve efef ofouttoin )()(
  • 9.
    9 Networks communication Network telephone exchanges, computers, satellites NodesArcs cables, fiber optics, microwave relays Flow voice, video, packets circuits gates, registers, processors wires current mechanical joints rods, beams, springs heat, energy hydraulic reservoirs, pumping stations, lakes pipelines fluid, oil financial stocks, currency transactions money transportation airports, rail yards, street intersections highways, railbeds, airway routes freight, vehicles, passengers chemical sites bonds energy
  • 10.
  • 11.
    11 An s-t cutis a node partition (S, T) such that s ∈ S, t ∈ T. The capacity of an s-t cut (S, T) is: Min s-t cut: find an s-t cut of minimum capacity. Cuts s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 Capacity = 62 ∑∑ ∈∈ ∈ = TwSv EwvSe wvueu , ),(ofout ).,(:)(
  • 12.
    12 An s-t cutis a node partition (S, T) such that s ∈ S, t ∈ T. The capacity of an s-t cut (S, T) is: Min s-t cut: find an s-t cut of minimum capacity. Cuts s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 Capacity = 28 ∑∑ ∈∈ ∈ = TwSv EwvSe wvueu , ),(ofout ).,(:)(
  • 13.
    13 L1. Let fbe a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t. Flows and Cuts s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 fefefef seSeSe ==− ∑∑∑ ofouttoinofout )()()( Value = 24 10 6 6 10 10 0 10 4 8 8 0 4 0 00
  • 14.
    14 10 6 6 10 10 0 10 4 88 0 4 0 00 L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t. Flows and Cuts s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 fefefef seSeSe ==− ∑∑∑ ofouttoinofout )()()( Value = 24
  • 15.
    15 10 6 6 10 10 0 10 4 88 0 4 0 0 L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sent across the cut is equal to the amount reaching t. Flows and Cuts s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 fefefef seSeSe ==− ∑∑∑ ofouttoinofout )()()( Value = 24 0
  • 16.
    16 Let f bea flow, and let (S, T) be a cut. Then, Proof by induction on |S|. Base case: S = { s }. Inductive hypothesis: assume true for |S| < k. – consider cut (S, T) with |S| = k – S = S' ∪ { v } for some v ≠ s, t, |S' | = k-1 ⇒ cap(S', T') = | f |. – adding v to S' increase cut capacity by Flows and Cuts .)()( toinofout ∑∑ =− SeSe fefef 0)()( toinofout =− ∑∑ veve efef s v t After s v t S' Before S
  • 17.
    17 L2. Let fbe a flow, and let (S, T) be a cut. Then, | f | ≤ cap(S, T). Proof. Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), then f is a max flow and (S, T) is a min cut. Flows and Cuts T)cap(S, )( )( )()( ofout ofout toinofout = ≤ ≤ −= ∑ ∑ ∑∑ Se Se SeSe eu ef efeff s t S T 7 6 8 4
  • 18.
    18 Max Flow andMin Cut Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), then f is a max flow and (S, T) is a min cut. s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 10 9 9 15 15 4 10 4 8 9 1 0 0 Flow value = 28 00 Cut capacity = 28
  • 19.
    19 Max-Flow Min-Cut Theorem MAX-FLOWMIN-CUT THEOREM (Ford-Fulkerson, 1956): In any network, the value of the max flow is equal to the value of the min cut. "Good characterization." Proof IOU. s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 10 10154 4 10 9 9 15 15 4 10 4 8 9 1 0 0 Flow value = 28 00 Cut capacity = 28
  • 20.
    20 Towards an Algorithm Findan s-t path where each arc has u(e) > f(e) and "augment" flow along the path. s 4 2 5 3 t 4 0 0 0 0 0 0 4 0 4 4 Flow value = 0 10 13 10
  • 21.
    21 Towards an Algorithm Findan s-t path where each arc has u(e) > f(e) and "augment" flow along the path. Repeat until you get stuck. s 4 2 5 3 t 4 0 0 0 0 0 0 4 0 4 4 Flow value = 10 10 13 10 10 10 10X X X
  • 22.
    22 Max-Flow Min-Cut Theorem Augmentingpath theorem (Ford-Fulkerson, 1956): A flow f is a max flow if and only if there are no augmenting paths. MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): the value of the max flow is equal to the value of the min cut. We prove both simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = cap(S, T).
  • 23.
    23 Proof of Max-FlowMin-Cut Theorem We prove both simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = cap(S, T). (i) ⇒ (ii) We show contrapositive. Let f be a flow. If there exists an augmenting path, then we can improve f by sending flow along path. (ii) ⇒ (iii) Next slide. (iii) ⇒ (i) This was the Corollary to Lemma 2.
  • 24.
    24 Proof of Max-FlowMin-Cut Theorem We prove both simultaneously by showing the TFAE: (i) f is a max flow. (ii) There is no augmenting path relative to f. (iii) There exists a cut (S, T) such that |f| = cap(S, T). (ii) ⇒ (iii) Let f be a flow with no augmenting paths. Let S be set of vertices reachable from s in residual graph. – clearly s ∈ S, and t ∉ S by definition of f T)(S, )( )()( ofout toinofout cap eu efeff Se SeSe = = −= ∑ ∑∑ s t Original Network S T
  • 25.
    25 Running Time Assumption: allcapacities are integers between 0 and U. Invariant: every flow value f(e) and every residual capacities uf (e) remains an integer throughout the algorithm. Theorem: the algorithm terminates in at most | f * | ≤ nU iterations. Corollary: if U = 1, then algorithm runs in O(mn) time. Integrality theorem: if all arc capacities are integers, then there exists a max flow f for which every flow value f(e) is an integer. Note: algorithm may not terminate on some pathological instances (with irrational capacities). Moreover, flow value may not even converge to correct answer.
  • 26.
    BITS Pilani, HyderabadCampus Thanks Copyright © Mayank Garg. All Rights Reserved Slide 26 Link to connect with author: http://www.slideshare.net/MayankGarg25 https://www.linkedin.com/in/gargmayank http://www.researchgate.net/profile/Mayank_Garg6/ https://www.facebook.com/mayank17692?ref=hl

Editor's Notes

  • #6 * flow: abstract entity generated at source, transmitted across edges, absorbed at sink * flow conservation is analogous to Kirchoff&amp;apos;s law
  • #7 * a more natural quantity to maximize is net flow into t * intuitively net flow into t equal net flow out of s, we&amp;apos;ll show this formally later * assume no arcs enter s or leave t (makes a little cleaner, no loss of generality)
  • #13 Caveat: from now on, we&amp;apos;ll use terms &amp;quot;flow&amp;quot; and &amp;quot;cut&amp;quot; to mean s-t flow and s-t cut.
  • #14 total amount of flow that leaves S minus amount flow that &amp;quot;swirls&amp;quot; back