








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
These are the Lecture Slides of Algorithm and Complexity Analysis which includes Approximation Algorithms, Coping with Np-Hardness, Fully Polynomial-Time, Brute-Force Algorithms, Approximation Scheme, Knapsack Problem, Profit Subset of Items, Nonnegative Values etc. Key important points are:Maximum Flow, Minimum Cut, Max Flow Network, Augmenting Path Algorithm, Capacity-Scaling, Shortest Augmenting Path, Egalitarian Stable Matching, Network Reliability, Distributed Computing
Typology: Slides
1 / 14
This page cannot be seen from the preview
Don't miss anything!









Contents.
n^
Maximum flow problem.
n^
Minimum cut problem.
n^
Max-flow min-cut theorem.
n^
Augmenting path algorithm.
n^
Capacity-scaling.
n^
Shortest augmenting path.
3
n^
Network reliability. n^
Security of statistical data. n^
Distributed computing. n^
Egalitarian stable matching. n^
Distributed computing. n^
Many many more...
Max flow and min cut.
n^
Two very rich algorithmic problems. n^
Cornerstone problem in combinatorial optimization. n^
Beautiful mathematical duality.
Nontrivial applications / reductions.
n^
Network connectivity. n^
Bipartite matching. n^
Data mining. n^
Open-pit mining. n^
Airline scheduling. n^
Image processing. n^
Project selection. n^
Baseball elimination.
Max flow network: G = (V, E, s, t, u).
n^
(V, E) = directed graph, no parallel arcs. n^
Two distinguished nodes: s = source, t = sink. n^
u(e) = capacity of arc e.
Capacity
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
5
An s-t flow is a function f: E
that satisfies:
n^
For each e
f(e)
u(e)
(capacity)
n^
For each v
V – {s, t}:
(conservation)
v
e
v
e
e f
e f
of out
to in
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
4
0
0
0
0 0
0
0
4
4
0
4
(^00)
0
Capacity
Flow
∈
E w v w v e
) , (:
of out
∈
E v w w v e
) , (:
to in
An s-t flow is a function f: E
that satisfies:
n^
For each e
f(e)
u(e)
(capacity)
n^
For each v
V – {s, t}:
(conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
4
0
0
0
0 0
0
0
4
4
0
4
0
Value = 4
s
e
e f
f
of
out
0
0
Capacity
Flow
v
e
v
e
e f
e f
of out
to in
7
An s-t flow is a function f: E
that satisfies:
n^
For each e
f(e)
u(e)
(capacity)
n^
For each v
V – {s, t}:
(conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
10
6
6
11
(^111)
10
3
8
8
0
4
0
Value = 24
0
0
Capacity
Flow
v
e
v
e
e f
e f
of out
to in
An s-t flow is a function f: E
that satisfies:
n^
For each e
f(e)
u(e)
(capacity)
n^
For each v
V – {s, t}:
(conservation)
MAX FLOW: find s-t flow that maximizes net flow out of the source.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
10
9
9
14
(^414)
10
4
8
9
1
0
0
Value = 28
0
0
Capacity
Flow
v
e
v
e
e f
e f
of out
to in
Docsity.com
13
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sentacross the cut is equal to the amount reaching t.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
f e f e f e f
s e S e S e
of out
to in
of
out
Value = 24
10
6
6
10
(^010)
10
4
8
8
0
4
(^00)
0
10
6
6
10
(^010)
10
4
8
8
0
4
(^00)
0
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sentacross the cut is equal to the amount reaching t.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
f e f e f e f
s e S e S e
of out
to in
of
out
Value = 24
15
10
6
6
10
(^010)
10
4
8
8
0
4
(^00)
L1. Let f be a flow, and let (S, T) be a cut. Then, the net flow sentacross the cut is equal to the amount reaching t.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
f e f e f e f
s e S e S e
of out
to in
of
out
Value = 24
0
Let f be a flow, and let (S, T) be a cut. Then,Proof by induction on |S|.
n^
Base case: S = { s }. n^
Inductive hypothesis: assume true for |S| < k.
consider cut (S, T) with |S| = k -
{ v } for some v
s, t, |S’ | = k-
cap(S’, T’) = | f |.
adding v to S’ increase cut capacity by
to in
of
out
S
e
S
e
f
e f
e f
to in
of
out
v
e
v
e
e f
e f
s
v
t
After
s
v
t
Before
Docsity.com
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), thenf is a max flow and (S, T) is a min cut.
cap(S,
of out
of out
to in
of out
S
e
S
e
S
e
S
e
e u
e f
e f
e f
f
s
t
(^4876)
Corollary. Let f be a flow, and let (S, T) be a cut. If |f| = cap(S, T), thenf is a max flow and (S, T) is a min cut.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
10
9
9
15
(^415)
10
4
8
9
1
0
0
Flow value = 28
0
0
Cut capacity = 28
19
MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): In anynetwork, the value of the max flow is equal to the value of the min cut.
n^
"Good characterization." n^
Proof IOU.
s
2 3 4
5 6 7
t
(^515)
30
15
10
(^91586)
10 10 10
15
4 4
10
9
9
15
(^415)
10
4
8
9
1
0
0
Flow value = 28
0
0
Cut capacity = 28
Find an s-t path where each arc has u(e) > f(e) and "augment" flowalong the path.
s
4 2
5 3
t
4
0
0
0
0
0
(^0404)
4
Flow value = 0
10
13
10
Docsity.com
25
Augmenting path = path in residual graph.
s
4 2
5 3
t
10
13
(^410)
0
0
10
10
10
(^0404)
4
s
4 2
5 3
t
10
10
(^410)
(^44)
4
3
f
4
4
6
4 4
X X
X
X
X
Augmenting path = path in residual graph.
n^
Max flow
no augmenting paths ???
s
4 2
5 3
t
10
13
(^410)
4
4
10
6
10
(^4444)
4
s
4 2
5 3
t
10
6
(^410)
(^44)
4
7
Flow value = 14
f
27
Augmenting path theorem (Ford-Fulkerson, 1956): A flow f is a maxflow if and only if there are no augmenting paths.MAX-FLOW MIN-CUT THEOREM (Ford-Fulkerson, 1956): the value ofthe 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).
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)
n^
We show contrapositive. n^
Let f be a flow. If there exists an augmenting path, then we canimprove f by sending flow along path.
(iii)
(i)
n^
Next slide.
(iii)
(i)
n^
This was the Corollary to Lemma 2.
Docsity.com
29
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)
n^
Let f be a flow with no augmenting paths. n^
Let S be set of vertices reachable from s in residual graph.
clearly s
S, and t
S by definition of f
of
out
to in
of
out cap
e u
e f
e f
f
S
e
S
e
S
e
= =
s
t
Original Network S
b
bottleneck(P)
e
IF (e
E) // forward arc
f(e)
f(e) + b
// backwards arc
f(e
R
f(e) - b
RETURN f
Augment (f, P)
e
f(e)
f
residual graph
WHILE (there exists augmenting path P)
f
augment(f, P)
update G
f
RETURN f
FordFulkerson (V, E, s, t)
31
Assumption: all capacities are integers between 0 and U.Invariant: every flow value f(e) and every residual capacities u
f^ (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 existsa 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 evenconverge to correct answer.
100
(^00)
s
4 2
t
1
100 100
0
0 0
Use care when selecting augmenting paths.
100
Docsity.com
37
Use care when selecting augmenting paths.
n^
Some choices lead to exponential algorithms. n^
Clever choices lead to polynomial algorithms.
Goal: choose augmenting paths so that:
n^
Can find augmenting paths efficiently. n^
Few iterations.
Edmonds-Karp (1972): choose augmenting path with
n^
Max bottleneck capacity.
(fat path)
n^
Sufficiently large capacity.
(capacity-scaling)
n^
Fewest number of arcs.
(shortest path)
Intuition: choosing path with highest bottleneck capacity increasesflow by max possible amount.
n^
Don’t worry about finding exact highest bottleneck path. n^
Maintain scaling parameter
n^
Let G
f^
) be the subgraph of the residual graph consisting of only
arcs with capacity at least
110
s
4 2
t
1
102 170
122
f
110
s
4 2
t
102 170
122
f^
39
Intuition: choosing path with highest bottleneck capacity increasesflow by max possible amount.
n^
Don’t worry about finding exact highest bottleneck path. n^
Maintain scaling parameter
n^
Let G
f^
) be the subgraph of the residual graph consisting of only
arcs with capacity at least
e
E, f(e)
smallest power of 2 greater than or equal to U
f
-residual graph
WHILE (there exists augmenting path P in G
f
f
augment(f, P)
update G
f
RETURN f
ScalingMaxFlow(V, E, s, t)
L1. If all arc capacities are integers, then throughout the algorithm, allflow and residual capacity values remain integers.
n^
Thus,
(f
f^ , so upon termination f is a max flow.
L2. The outer while loop repeats 1 +
log
2
times.
n^
Initially U
< 2U,and
decreases by a factor of 2 each iteration.
L3. Let f be the flow at the end of a
-scaling phase. Then value of the
maximum flow is at most | f | + m
L4. There are at most 2m augmentations per scaling phase.
n^
Let f be the flow at the end of the previous scaling phase. n^
|f*|
| f | + m (
n^
Each augmentation in a
-phase increases | f | by at least
Theorem. The algorithm runs in O(m
2 log (2U) ) time.
Docsity.com
41
L3. Let f be the flow at the end of a
-scaling phase. Then value of the
maximum flow is at most |f| + m
n^
We show that at the end of a
-phase, there exists a cut (S, T) such
that cap(S, T)
| f | + m
n^
Choose S to be the set of nodes reachable from s in G
(f
clearly s
S, and t
S by definition of S
m
T)
cap(S,
e u
e u
e f
e f
f
S e S e S e
S
e
S
e
S
e
S
e
=
to in
of
out
of out
to in
of out
to in
of out
s
t
Original Network S
Use care when selecting augmenting paths.
n^
Some choices lead to exponential algorithms. n^
Clever choices lead to polynomial algorithms.
Goal: choose augmenting paths so that:
n^
Can find augmenting paths efficiently. n^
Few iterations.
Edmonds-Karp (1972): choose augmenting path with
n^
Max bottleneck capacity.
(fat path)
n^
Sufficiently large capacity.
(capacity-scaling)
n^
Fewest number of arcs.
(shortest path)
43
Intuition: choosing path via breadth first search.
n^
Easy to implement.
may implement by coincidence!
n^
Finds augmenting path with fewest number of arcs.
e
f(e)
f
residual graph
WHILE (there exists augmenting path)
find such a path P by BFSf
augment(f, P)
update G
f
RETURN f
ShortestAugmentingPath(V, E, s, t)
n^
Proof ahead.
L2.
After at most m shortest path augmentations, the length of the
shortest augmenting path strictly increases.
n^
Proof ahead.
Theorem. The shortest augmenting path algorithm runs in O(m
2 n)
time.
n^
O(m+n) time to find shortest augmenting path via BFS. n^
O(m) augmentations for paths of exactly k arcs. n^
If there is an augmenting path, there is a simple one. ⇒
k < n
O(mn) augmentations.
Docsity.com
49
L1. Throughout the algorithm, the length of the shortest path neverdecreases.L2.
After at most m shortest path augmentations, the length of the
shortest augmenting path strictly increases.Theorem. The shortest augmenting path algorithm runs in O(m
2 n)
time.
n^
O(m+n) time to find shortest augmenting path via BFS. n^
O(m) augmentations for paths of exactly k arcs. n^
O(mn) augmentations.
Note:
(mn) augmentations necessary on some networks.
n^
Try to decrease time per augmentation instead. n^
Dynamic trees
O(mn log n)
Sleator-Tarjan, 1983
n^
Simple idea
O(mn
2
Two types of augmentations.
n^
Normal augmentation: length of shortest path doesn’t change. n^
Special augmentation: length of shortest path strictly increases.
L3. Group of normal augmentations takes O(mn) time.
n^
Explicitly maintain level graph - it changes by at most 2n arcs aftereach normal augmentation. n^
Start at s, advance along an arc in L
G
until reach t or get stuck.
if reach t, augment and delete at least one arc - if get stuck, delete node
s
2 3
5 6
t
l
l
l
l
G
51
s
2 3
5 6
t
G
s
2 3
5 6
t
G
s
2
5 6
t
G
augment delete 3 augment
s
2
5 6
t
G
s
2
5 6
t
G
STOP: length of shortest path must havestrictly increased
augment Docsity.com
53
ARRAY pred[v
G
level graph of G
f
v
s, pred[v]
nil
WHILE (there exists (v,w)
G
pred[w]
v, v
w
IF (v = t)
path defined by pred[]
f
augment(f, P)
update L
G
v
s, pred[v]
nil
delete v from L
G
UNTIL (v =
s)
RETURN f
AdvanceRetreat(V, E, f, s, t)
advance retreat
augment
Two types of augmentations.
n^
Normal augmentation: length of shortest path doesn’t change. n^
Special augmentation: length of shortest path strictly increases.
L3. Group of normal augmentations takes O(mn) time.
n^
Explicitly maintain level graph - it changes by at most 2n arcs aftereach normal augmentation. n^
Start at s, advance along an arc in L
G
until reach t or get stuck.
if reach t, augment and delete at least one arc - if get stuck, delete node - at most n advance steps before one of above events
Theorem. Algorithm runs in O(mn
2 ) time.
n^
O(mn) time between special augmentations. n^
At most n special augmentations.
55
First 4 rules assume arc capacities are between 0 and U.
Method
Augmentations
Augmenting path
nU
Max capacity
m
log U
Capacity scaling
m
log U
Shortest path
mn
Running time
mnU
m log U (m + n log n)
m
2
log U m
2 n
Improved shortest path
mn
mn
2
Improved capacity scaling
m
log U
mn log U
Dantzig Discoverer
MethodSimplex
Big-Ohmn
Year 1951
Ford, Fulkerson
Augmenting path
mnU
Edmonds-Karp
Shortest path
m
2 n
Dinitz
Shortest path
mn
2
Edmonds-Karp, Dinitz
Capacity scaling
m
2 log U
Dinitz-Gabow
Capacity scaling
mn log U
Karzanov
Preflow-push
n
3
Sleator-Tarjan
Dynamic trees
mn log n
Goldberg-Tarjan
FIFO preflow-push
mn log (n
2
/ m)
Goldberg-Rao
Length function
m
3/
log (n
2 / m) log U
mn
2/
log (n
2 / m) log U
Docsity.com