












Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













Max flow extensions and applications.
n^
Disjoint paths and network connectivity. n^
Bipartite matchings. n^
Circulations with upper and lower bounds. n^
Census tabulation (matrix rounding). n^
Airline scheduling. n^
Image segmentation. n^
Project selection (max weight closure). n^
Baseball elimination.
3
Disjoint path network: G = (V, E, s, t).
n^
Directed graph (V, E), source s, sink t. n^
Two paths are edge-disjoint if they have no arc in common.
Disjoint path problem: find max number of edge-disjoint s-t paths.
n^
Application: communication networks.s
2 3 4
5 6 7
t
Disjoint path network: G = (V, E, s, t).
n^
Directed graph (V, E), source s, sink t. n^
Two paths are edge-disjoint if they have no arc in common.
Disjoint path problem: find max number of edge-disjoint s-t paths.
s
2 3 4
5 6 7
t
5
Max flow formulation: assign unit capacity to every edge.Theorem. There are k edge-disjoint paths from s to t if and only if themax flow value is k.Proof.
n^
Suppose there are k edge-disjoint paths P
.k
n^
Set f(e) = 1 if e participates in some path P
; otherwise, set f(e) = 0.i
n^
Since paths are edge-disjoint, f is a flow of value k.
s^
t
1 1 1
1 1
1 1
(^111)
1 1
1 1
Max flow formulation: assign unit capacity to every edge.Theorem. There are k edge-disjoint paths from s to t if and only if themax flow value is k.Proof.
n^
Suppose max flow value is k. By integrality theorem, there exists{0, 1} flow f of value k. n^
Consider edge (s,v) with f(s,v) = 1.
-^
by conservation, there exists an arc (v,w) with f(v,w) = 1
-^
continue until reach t, always choosing a new edge
n^
Produces k (not necessarily simple) edge-disjoint paths.
s^
t
1 1 1
1 1
1 1
(^111)
1 1
1 1
7
Network connectivity network: G = (V, E, s, t).
n^
Directed graph (V, E), source s, sink t. n^
A set of edges F
E disconnects t from s if all s-t paths uses at
least on edge in F.
Network connectivity: find min number of edges whose removaldisconnects t from s.
s
2 3 4
5 6 7
t
Network connectivity network: G = (V, E, s, t).
n^
Directed graph (V, E), source s, sink t. n^
A set of edges F
E disconnects t from s if all s-t paths uses at
least on edge in F.
Network connectivity: find min number of edges whose removaldisconnects t from s.
s
2 3 4
5 6 7
t
13
Bipartite matching.
n^
Input: undirected, bipartite graph G = (L
n^
E is a matching if each node appears in at most edge in M.
n^
Max matching: find a max cardinality matching.
1 3 5
1’ 3’ 5’
2 4
2’ 4’
Matching 1-2’, 3-1’, 4-5’
Bipartite matching.
n^
Input: undirected, bipartite graph G = (L
n^
E is a matching if each node appears in at most edge in M.
n^
Max matching: find a max cardinality matching.
1 3 5
1’ 3’ 5’
2 4
2’ 4’
Matching
1-1’, 2-2’, 3-3’, 4-4’ R
15
Max flow formulation.
n^
Create directed graph G’ = (L
{s, t}, E’ ).
n^
Direct all arcs from L to R, and give infinite (or unit) capacity. n^
Add source s, and unit capacity arcs from s to each node in L. n^
Add sink t, and unit capacity arcs from each node in R to t.
s
1 3 5
1’ 3’ 5’
t
2 4
2’ 4’
Claim. Matching in G of cardinality k induces flow in G’ of value k.
n^
Given matching M = { 1 - 2’, 3 - 1’, 4 - 5’ } of cardinality 3. n^
Consider flow that sends 1 unit along each of 3 paths:s- 1- 2’- t, s- 3- 1’- t, s - 4- 5’- t. n^
f is a flow, and has cardinality 3.
s
1 3 5
1’ 3’ 5’
t
2 4
2’ 4’
1
1
1 3 5
1’ 3’ 5’
2 4
2’ 4’
17
Claim. Flow f of value k in G’ induces matching of cardinality k in G.
n^
By integrality theorem, there exists {0, 1}-valued flow f of value k. n^
Consider M = set of edges from L to R with f(e) = 1.
-^
each node in L and R participates in at most one edge in M
-^
|M| = k: consider cut (L
s, R
t)
s
1 3 5
1’ 3’ 5’
t
2 4
2’ 4’
1
1
1 3 5
1’ 3’ 5’
2 4
2’ 4’
Perfect matching.
n^
Input: undirected graph G = (V, E). n^
A matching M
E is perfect if each node appears in exactly one
edge in M.
Perfect bipartite matching.
n^
Input: undirected, bipartite graph G = (L
R, E), |L| = |R| = n.
n^
Can determine if bipartite graph has perfect matching by runningmatching algorithm.
Is there an easy way to convince someone that a bipartite graph doesnot have a perfect matching?
n^
Need good characterization of such graphs.
19
Let X be a subset of nodes, and let N(X) be the set of nodes adjacentto nodes in x.Observation. If a bipartite graph G = (L
R, E), has a perfect
matching, then |N(X)|
|X| for every X
n^
Each node in X has to be matched to a different node in N(X).
1 3 5
1’ 3’ 5’
2 4
2’ 4’
No perfect matching:X = {2, 4, 5}, N(X) = {2’, 5’}.
Hall’s Theorem. Let G = (L
R, E) be a bipartite graph with |L| = |R|.
Then, either
n^
(i) G either has a perfect matching, or n^
(ii) There exists a subset X
L such that |N(X)| < |X|.
1 3 5
1’ 3’ 5’
2 4
2’ 4’
25
Given an undirected graph G = (V, E), a vertex cover is a subset ofvertices C
V such that:
n^
Every arc (v, w)
E has either v
C or w
C orboth.
1 3 5
1’ 3’ 5’
2 4
2’ 4’
Given an undirected graph G = (V, E), a vertex cover is a subset ofvertices C
V such that:
n^
Every arc (v, w)
E has either v
C or w
C orboth.
1 3 5
1’ 3’ 5’
2 4
2’ 4’
27
Given an undirected graph G = (V, E), a vertex cover is a subset ofvertices C
V such that:
n^
Every arc (v, w)
E has either v
C or w
C orboth.
Observation. Let M be a matching, and let C be a vertex cover.Then, |M|
n^
Each vertex can cover at most one edge in any matching.
1 3 5
1’ 3’ 5’
2 4
2’ 4’
Given an undirected graph G = (V, E), a vertex cover is a subset ofvertices C
V such that:
n^
Every arc (v, w)
E has either v
C or w
C orboth.
König-Egerváry Theorem: In a bipartite, undirected graph the maxcardinality of a matching is equal to the min cardinality of a vertexcover.
1 3 5
1’ 3’ 5’
2 4
2’ 4’
29
Suffices to find matching M* and cover C* such that |M| = |C|. n^
Use max flow formulation,and let (S, T) be min cut. n^
Define L
S^
T^
S
T^
T , and C* = L
T
S^
n^
Claim 1. C* is a vertex cover.
-^
consider (v, w)
-^
v
S
, w
T^
impossible since infinite capacity
-^
thus, v
T^
or w
S
or both s
1 3 5
1’ 3’ 5’
t
2 4
2’ 4’
Suffices to find matching M* and cover C* such that |M| = |C|. n^
Use max flow formulation,and let (S, T) be min cut. n^
Define L
S^
T^
S
T^
T , and C* = L
T
S^
n^
Claim 1. C* is a vertex cover. n^
Claim 2. |C| = |M|.
-^
max-flow min-cut theorem
|M*| = cap(S, T)
-^
only arcs of form (s, v) or (w, t) contribute to cap(S, T)
-^
|M*| = u(S, T) = |L
s
1 3 5
1’ 3’ 5’
t
2 4
2’ 4’
31
Which max flow algorithm to use for bipartite matching / vertex cover?
n^
Generic augmenting path: O( m |f *| ) = O(mn). n^
Capacity scaling: O(m
2
log U ) = O(m
n^
Shortest augmenting path: O(m n
Seems to indicate "more clever" algorithms are not as good as wefirst thought.
No - just need more clever analysis! For bipartite matching,shortest augmenting path algorithm runs in O(m n
1/
) time.
Unit capacity simple network.
n^
Every arc capacity is one. n^
Every node has either:(i) at most one incoming arc, or(ii) at most one outgoing arc. n^
If G is simple unit capacity, then so isG
, assuming f is {0, 1} flow.f
Shortest augmenting path algorithm.
n^
Normal augmentation: length of shortest path doesn’t change. n^
Special augmentation: length of shortest path strictly increases.
Theorem. Shortest augmenting path algorithm runs in O(m n
1/
) time.
n^
L1. Each phase of normal augmentations takes O(m) time. n^
L2. After at most n
1/
phases, | f |
| f *| - n
1/
n^
L3. After at most n
1/
additional augmentations, flow is optimal.
1
1
1
37
Lemma 1. Phase of normal augmentations takes O(m) time.
n^
Start at s, advance along an arc in L
G
until reach t or get stuck.
-^
if reach t, augment and delete ALL arcs on path
-^
if get stuck, delete node and go to previous node
n^
O(m) running time.
-^
O(m) to create level graph
-^
O(1) per arc, since each arc traversed at most once
-^
O(1) per node deletion
ARRAY pred[v
G^
level graph of G
f
v
s, pred[v]
nil
WHILE (there exists (v,w)
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
39
Lemma 2. After at most n
1/
phases, | f |
| f *| - n
1/
n^
After n
1/
phases, length of shortest augmenting path is > n
1/
n^
Level graph has more than n
1/
levels.
n^
Let 1
h
n
1/
be layer with min number of nodes: |V
|h
n
1/
h
0
n
1/
Level graph
1
Lemma 2. After at most n
1/
phases, | f |
| f *| - n
1/
n^
After n
1/
phases, length of shortest augmenting path is > n
1/
n^
Level graph has more than n
1/
levels.
n^
Let 1
h
n
1/
be layer with min number of nodes: |V
|h
n
1/
n^
S := {v :
l
(v) < h}
{v :
l
(v) = h and v has
1 outgoing residual arc}.
n^
cap
(S, T)f^
|h
n
1/
| f |
| f *| - n
1/
h
0
n
1/
1
Level graph
Residual arcs
41
Over on the radio side the producer’s saying,
n^
"See that thing in the paper last week about Einstein?... Somereporter asked him to figure out the mathematics of the pennantrace. You know, one team wins so many of their remaining games,the other teams win this number or that number. What are themyriad possibilities? Who’s got the edge?" n^
"The hell does he know?" n^
"Apparently not much. He picked the Dodgersto eliminate the Giants last Friday."
43
Which teams have a chance of finishing the season with most wins?
n^
Montreal eliminated since it can finish with at most 80 wins, butAtlanta already has 83. n^
w
< wi^
j^
team i eliminated.
n^
Only reason sports writers appear to be aware of. n^
Sufficient, but not necessary!
Team
i
Against = r
ij
Wins
w
i
To play
ri
Losses
li
Atl
Phi
Mon
Montreal
New York
Philly
Atlanta
Which teams have a chance of finishing the season with most wins?
n^
Philly can win 83, but still eliminated... n^
If Atlanta loses a game, then some other team wins one.
Answer depends not just on how many games already won and left toplay, but also on whom they’re against.
Team
i
Against = r
ij
Wins
w
i
To play
ri
Losses
li
Atl
Phi
Mon
Montreal
New York
Philly
Atlanta
49
Which teams have a chance of finishing the season with most wins?
n^
Detroit could finish season with 49 + 27 = 76 wins.
Consider subset R = {NY, Bal, Bos, Tor}
n^
Have already won w(R) = 278 games. n^
Must win at least r(R) = 27 more.
Average team in R wins at least 305/4 > 76 games.
Team
i
Against = r
ij
Wins
w
i
To play
ri
Losses
li^
Bal
Bos
Tor
Toronto
Boston
Baltimore
Detroit
Det
AL East: August 30, 1996
Certificate of elimination.If
then x is eliminated (by R).
Theorem (Hoffman-Rivlin, 1967). Team x is eliminated if and only ifthere exists a subset R that eliminates x.
n^
Proof idea. Let R = team nodes on source side of min cut.
games
remaining #
, 12
wins #^
∈
∈
R j i^
ij
R i^
i^
x
x^
won
games#
avg on LB
51
Proof of Theorem.
n^
Use max flow formulation, and consider min cut (S, T). n^
Define R = team nodes on source side of min cut = T
n^
Claim. i-j
S if and only if i
R and j
-^
infinite capacity arcs ensure if i-j
S then i
S and j
-^
if i
S and j
S but i-j
T, then adding i-j to S decreases
capacity of cut s
2 4
t
1-2 1-4 2-
1
r^24
= 7
∞ ∞
w
3
3
4
team 4 can still win thismany more games
games left
Proof of Theorem.
n^
Use max flow formulation, and consider min cut (S, T). n^
Define R = team nodes on source side of min cut = T
n^
Claim. i-j
S if and only if i
R and j
s
2 4
t
1-2 1-4 2-
1
r^24
= 7
∞ ∞
w
3
3
4
team 4 can still win thismany more games
games left
∈
R i^
i
x
x^
53
Proof of Theorem.
n^
Use max flow formulation, and consider min cut (S, T). n^
Define R = team nodes on source side of min cut = T
n^
Claim. i-j
S if and only if i
R and j
n^
Rearranging terms:
x
x
x
x
R i^
i
x
x
∈
Circulation with demands.
n^
Directed graph G = (V, E). n^
Arc capacities u(e), e
n^
Node supply and demands d(v), v
-^
demand if d(v) > 0; supply if d(v) < 0; transshipment if d(v) = 0
A circulation is a function f: E
that satisfies:
n^
For each e
f(e)
u(e)
(capacity)
n^
For each v
(conservation)
Circulation problem: given (V, E, u, d), does there exist a circulation?
of out
to in
v d
e f
e f^
v
e
v
e
∑
∑
55
A circulation is a function f: E
that satisfies:
n^
For each e
f(e)
u(e)
(capacity)
n^
For each v
(conservation)
1
2 3
5 6
8
10 3
6
11
4
7 9
3
10
0
7
4 4
6
6
1 7
4
2
Capacity
Flow
of out
to in
v d
e f
e f^
v
e
v
e
∑
∑
A circulation is a function f: E
that satisfies:
n^
For each e
f(e)
u(e)
(capacity)
n^
For each v
(conservation)
Necessary condition: sum of supplies = sum of demands.
n^
Proof: sum conservation constraints for every demand node v.
v d
v d
v d v v d v
0 ) ( : 0 ) ( :
∑
∑
<
of out
to in
v d
e f
e f^
v
e
v
e
∑
∑
61
Feasible circulation.
n^
Directed graph G = (V, E). n^
Arc capacities u(e) and lower bounds
l
(e), e
-^
force flow to make use of certain edges
n^
Node supply and demands d(v), v
A circulation is a function f: E
that satisfies:
n^
For each e
l(e)
f(e)
u(e)
(capacity)
n^
For each v
(conservation)
Given (V, E,
l
, u, d), is there a circulation?
of out
to in
v d
e f
e f^
v
e
v
e
∑
∑
A circulation is a function f: E
that satisfies:
n^
For each e
l(e)
f(e)
u(e)
(capacity)
n^
For each v
(conservation)
Idea: model lower boundswith supply / demands.Create network G’.
to in
of out
v d
e f
e f^
v
e
v
e
∑
∑
v^
w
2,
Lower bound
9
Capacity
2
Flow
v^
w
7
Capacity
d(v)
d(w)
d(v) + 2
d(w) - 2
∑
∑
v
e
v
e
e e v d v d
e
e u
e u
to in
of out
l
l
l
63
A circulation is a function f: E
that satisfies:
n^
For each e
l(e)
f(e)
u(e)
(capacity)
n^
For each v
(conservation)
Create network G’.Theorem. There exists a circulation in G if and only if there exists acirculation in G’. If all demands, capacities, and lower bounds in G areintegers, then there is a circulation in G that is integer-valued.
n^
Proof idea: f(e) is a circulation in G if and only if f’(e) = f(e) -
l
(e) is
a circulation in G’.
to in
of out
v d
e f
e f^
v
e
v
e
∑
∑
∑
∑
v
e
v
e
e e v d v d
e
e u
e u
to in
of out
l
l
l
Feasible matrix rounding.
n^
Given a p x q matrix D = {d
i j
} of real numbers.
n^
Row i sum = a
, column j sum bi
.j
n^
Round each d
, aij
, bi
j^
up or down to integer so that sum of rounded
elements in each row (column) equal row (column) sum. n^
Original application: publishing US Census data.
Theorem: for any matrix, there exists a feasible rounding.
Original Data
Possible Rounding
65
Feasible matrix rounding.
n^
Given a p x q matrix D = {d
i j
} of real numbers.
n^
Row i sum = a
, column j sum bi
.j
n^
Round each d
, aij
, bi
j^
up or down to integer so that sum of rounded
elements in each row (column) equal row (column) sum. n^
Original application: publishing US Census data.
Theorem: for any matrix, there exists a feasible rounding.
n^
Note: "threshold rounding" doesn’t work.
Original Data
Possible Rounding
Max flow formulation.
n^
Original data provides circulation (all demands 0). n^
Integrality theorem
there always exists feasible rounding!
s
1 2 3
1’ 2’ 3’
t
Row
Column
17, 18
12, 1311, 12
16, 1710, 11 14, 15
Lowerbound
Upperbound
67
Airline scheduling.
n^
Complex computational problem faced by nation’s airline carriers. n^
Produces schedules for thousands of routes each day that areefficient in terms of:
-^
equipment usage, crew allocation, customer satisfaction
-^
in presence of unpredictable issues like weather, breakdowns
n^
One of largest consumers of high-powered algorithmic techniques.
"Toy problem."
n^
Manage flight crews by reusing them over multiple flights. n^
Input: list of cities V. n^
Travel time t(v, w) from city v to w. n^
Flight i: (o
, di
, ti
) consists of origin and destination cities, andi
departure time.
Max flow formulation.
n^
For each flight i, include two nodes u
and vi
.i
n^
Add source s with demand -c, and arcs (s, u
) with capacity 1.i
n^
Add sink t with demand c, and arcs (v
, t) with capacity 1.j
n^
For each i, add arc (u
, vi
) with lower bound and capacity 1.i
n^
if flight j reachable from i, add arc (v
, ui
) with capacity 1.i
s
u^1
u^2
u^3
v^1
v^3
v^2
t
0, 1
1, 1
u^4
v^4
0, 1
0, 1
crew can beginday with any flight
flight is performed
crew can end daywith any flight
same crew can do flights 2 and 4
-c
c
use c crews
73
Formulate as min cut problem.
n^
Maximization. n^
No source or sink. n^
Undirected graph.
Turn into minimization problem.
n^
Since
is a constant,
maximizingis equivalent to minimizing
∑
∑
∈
∈
V v
v
V v
v^
b
a
∑
∑
∑
=
∈
∈
∈
1
} , } { , {
w v
S
E
w v
vw
S v
v
T v
v
p
b
a
I
∑
∑
∑
=
∈
∈
∈
1
} , } { , {
w v
S
E
w v
vw
T v
v
S v
v
p
b
a
I
Formulate as min cut problem: G’ = (V’, E’).
n^
Maximization. n^
No source or sink.
-^
add source to correspond to foreground
-^
add sink to correspond to background
n^
Undirected graph.
-^
add two anti-parallel arcs s^
t
v pvw w
b
v
p
vw p
vw p
vw
av
75
Consider min cut (S, T) in resulting graph.
n n^
Precisely the quantity we want to minimize.
-^
note if v and w on different sides, p
vw
counted exactly once
s^
t
v w
av
b
v
∑
∑
∑
∈
∈
∈
∈
∈
T w S v
E
w v
vw
S v
v
T v
v
p
b
a
cap
), , (
p
vw
Projects with prerequisites.
n^
Set P of possible projects. Project v has associated revenue p
.v
-^
some projects generate money: create interactive e-commerceinterface, redesign cs web page
-^
others cost money: upgrade computers, get site license forencryption software
n^
Set of prerequisites E. If (v, w)
E, can’t do project v and unless
also do project w.
-^
can’t start on e-commerce opportunity unless you’ve gotencryption software
n^
A subset of projects A
P is feasible if the prerequisite of every
project in A also belongs to A.
-^
for each v
P, and (v, w)
E, we have w
Project selection (max weight closure) problem: choose a feasiblesubset of projects to maximize revenue.
77
Prerequisite graph.
n^
Include an arc from v to w if can’t do v without also doing w. n^
{v, w, x} is feasible subset of projects. n^
{v, x} is infeasible subset of projects.
v
w x
v
w x
Feasible
Infeasible
Project selection formulation.
n^
Assign infinite capacity to all prerequisite arcs. n^
Add arc (s, v) with capacity p
v^
if p
v^
n^
Add arc (v, t) with capacity -p
v^
if p
v^
n^
For notational convenience, define p
s^
= p
t^
s^
t
-p
w
u v
w x
y^
z
p
v^
-p
x
79
Claim. (S, T) is min cut if and only if S \ {s} is optimal set of projects.
n^
Infinite capacity arcs ensure S \ {s} is feasible. n^
Max revenue because:
s^
t
-p
w
u
w v
x
y^
z
p
v^
-p
∑ x
∑
∑
∑
∈
<
∈
∈
S v
v
p v
v
p S v
v
p T v
v
p
p
p
p
cap
v
v
v^0
:
0
:
0
:
constant
p
y p
u
Open-pit mining (studied since early 1960’s).
n^
Blocks of earth are extracted from surface to retrieve ore. n^
Each block v has net value p
v^
= value of ore - processing cost.
n^
Can’t remove block v before w or x.
v
x
w