CS 573: Algorithms, Fall 2013
Network Flow VI - Min-Cost Flow Applications
Lecture 17
October 24, 2013
Sariel (UIUC) CS573 1 Fall 2013 1 / 27
Network Flow VI - Min-Cost Flow Applications Lecture 17 October - - PowerPoint PPT Presentation
CS 573: Algorithms, Fall 2013 Network Flow VI - Min-Cost Flow Applications Lecture 17 October 24, 2013 Sariel (UIUC) CS573 1 Fall 2013 1 / 27 Lemma decomposing flow into cycles . Lemma . f :a circulation in G . Then, f can be
October 24, 2013
Sariel (UIUC) CS573 1 Fall 2013 1 / 27
.
. . f:a circulation in G. Then, f can be decomposed into m cycles, C1, . . . , Cm, such that, ∀e ∈ E(G): f(e) = ∑t
i=1 λi · χCi(e),
λ1, . . . , λt > 0 and t ≤ m, m = |E(G)|. .
. . .
1
By conservation of flow, if f is not zero, then there is a cycle in f. (i) ... v: vertex non-zero flow into it. (ii) walk on an adjacent edge that has positive flow on it. (iii) Repeat, till visit a vertex that was already visited. (iv) Extract cycle contained in this walk.
Sariel (UIUC) CS573 2 Fall 2013 2 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . .
1
C1: such a cycle. . .
2
every edge of C1 has positive flow. . .
3
λ1: smallest amount of flow on any edge of C1. e1 this edge. . .
4
g = f − λ1 · χC1. g has zero flow on e1. It is a (weak) circulation. . .
5
Removed e1 from G. H: new graph. . .
6
By induction on g on H... . .
7
= ⇒ g can be decomposed into m − 1 cycles with positive coefficients. . .
8
These cycles + C1 (with λ1) implies the claim.
Sariel (UIUC) CS573 3 Fall 2013 3 / 27
.
. . A flow f is a minimum cost feasible circulation ⇐ ⇒ each directed cycle of Gf has nonnegative cost. .
. . .
1
C: a negative cost cycle in Gf. . .
2
Circulate more flow on C and reduce price. . .
3
ε > 0: sufficiently small constant: g = f + ε ∗ χC is feasible circulation . .
4
cost(g) = cost(f) + ∑
e∈C κ(e) ∗ ε
= cost(f) + ε ∗ ∑
e∈C κ(e) = cost(f) + ε ∗ κ(C)
< cost(f), since κ(C) < 0. A contradiction.
Sariel (UIUC) CS573 4 Fall 2013 4 / 27
.
. . A flow f is a minimum cost feasible circulation ⇐ ⇒ each directed cycle of Gf has nonnegative cost. .
. . .
1
C: a negative cost cycle in Gf. . .
2
Circulate more flow on C and reduce price. . .
3
ε > 0: sufficiently small constant: g = f + ε ∗ χC is feasible circulation . .
4
cost(g) = cost(f) + ∑
e∈C κ(e) ∗ ε
= cost(f) + ε ∗ ∑
e∈C κ(e) = cost(f) + ε ∗ κ(C)
< cost(f), since κ(C) < 0. A contradiction.
Sariel (UIUC) CS573 4 Fall 2013 4 / 27
.
. . A flow f is a minimum cost feasible circulation ⇐ ⇒ each directed cycle of Gf has nonnegative cost. .
. . .
1
C: a negative cost cycle in Gf. . .
2
Circulate more flow on C and reduce price. . .
3
ε > 0: sufficiently small constant: g = f + ε ∗ χC is feasible circulation . .
4
cost(g) = cost(f) + ∑
e∈C κ(e) ∗ ε
= cost(f) + ε ∗ ∑
e∈C κ(e) = cost(f) + ε ∗ κ(C)
< cost(f), since κ(C) < 0. A contradiction.
Sariel (UIUC) CS573 4 Fall 2013 4 / 27
.
. . A flow f is a minimum cost feasible circulation ⇐ ⇒ each directed cycle of Gf has nonnegative cost. .
. . .
1
C: a negative cost cycle in Gf. . .
2
Circulate more flow on C and reduce price. . .
3
ε > 0: sufficiently small constant: g = f + ε ∗ χC is feasible circulation . .
4
cost(g) = cost(f) + ∑
e∈C κ(e) ∗ ε
= cost(f) + ε ∗ ∑
e∈C κ(e) = cost(f) + ε ∗ κ(C)
< cost(f), since κ(C) < 0. A contradiction.
Sariel (UIUC) CS573 4 Fall 2013 4 / 27
.
. . A flow f is a minimum cost feasible circulation ⇐ ⇒ each directed cycle of Gf has nonnegative cost. .
. . .
1
C: a negative cost cycle in Gf. . .
2
Circulate more flow on C and reduce price. . .
3
ε > 0: sufficiently small constant: g = f + ε ∗ χC is feasible circulation . .
4
cost(g) = cost(f) + ∑
e∈C κ(e) ∗ ε
= cost(f) + ε ∗ ∑
e∈C κ(e) = cost(f) + ε ∗ κ(C)
< cost(f), since κ(C) < 0. A contradiction.
Sariel (UIUC) CS573 4 Fall 2013 4 / 27
.
. . .
1
Assume all cycles in Gf have non-negative cost. . .
2
g any feasible circulation. . .
3
Weak circulation: h = g − f. . .
4
By lemma: all edges used by h are in Gf. . .
5
By other lemma: ∃t ≤ |E(Gf)| cycles C1, . . . , Ct in Gf, and coefficients λ1, . . . , λt: h(e) = ∑t
i=1 λiχCi(e).
. .
6
cost(g) − cost(f) = cost(h) = cost
(∑t
i=1 λiχCi
)
=
∑t
i=1 λicost(χCi) = ∑t i=1 λiκ (Ci) ≥ 0, as κ(Ci) ≥ 0,
since there are no negative cycles in Gf. . .
7
= ⇒ cost(g) ≥ cost(f). = ⇒ f minimum-cost circulation.
Sariel (UIUC) CS573 5 Fall 2013 5 / 27
.
. . .
1
Assume all cycles in Gf have non-negative cost. . .
2
g any feasible circulation. . .
3
Weak circulation: h = g − f. . .
4
By lemma: all edges used by h are in Gf. . .
5
By other lemma: ∃t ≤ |E(Gf)| cycles C1, . . . , Ct in Gf, and coefficients λ1, . . . , λt: h(e) = ∑t
i=1 λiχCi(e).
. .
6
cost(g) − cost(f) = cost(h) = cost
(∑t
i=1 λiχCi
)
=
∑t
i=1 λicost(χCi) = ∑t i=1 λiκ (Ci) ≥ 0, as κ(Ci) ≥ 0,
since there are no negative cycles in Gf. . .
7
= ⇒ cost(g) ≥ cost(f). = ⇒ f minimum-cost circulation.
Sariel (UIUC) CS573 5 Fall 2013 5 / 27
.
. . .
1
Assume all cycles in Gf have non-negative cost. . .
2
g any feasible circulation. . .
3
Weak circulation: h = g − f. . .
4
By lemma: all edges used by h are in Gf. . .
5
By other lemma: ∃t ≤ |E(Gf)| cycles C1, . . . , Ct in Gf, and coefficients λ1, . . . , λt: h(e) = ∑t
i=1 λiχCi(e).
. .
6
cost(g) − cost(f) = cost(h) = cost
(∑t
i=1 λiχCi
)
=
∑t
i=1 λicost(χCi) = ∑t i=1 λiκ (Ci) ≥ 0, as κ(Ci) ≥ 0,
since there are no negative cycles in Gf. . .
7
= ⇒ cost(g) ≥ cost(f). = ⇒ f minimum-cost circulation.
Sariel (UIUC) CS573 5 Fall 2013 5 / 27
.
. . .
1
Assume all cycles in Gf have non-negative cost. . .
2
g any feasible circulation. . .
3
Weak circulation: h = g − f. . .
4
By lemma: all edges used by h are in Gf. . .
5
By other lemma: ∃t ≤ |E(Gf)| cycles C1, . . . , Ct in Gf, and coefficients λ1, . . . , λt: h(e) = ∑t
i=1 λiχCi(e).
. .
6
cost(g) − cost(f) = cost(h) = cost
(∑t
i=1 λiχCi
)
=
∑t
i=1 λicost(χCi) = ∑t i=1 λiκ (Ci) ≥ 0, as κ(Ci) ≥ 0,
since there are no negative cycles in Gf. . .
7
= ⇒ cost(g) ≥ cost(f). = ⇒ f minimum-cost circulation.
Sariel (UIUC) CS573 5 Fall 2013 5 / 27
.
. . .
1
Assume all cycles in Gf have non-negative cost. . .
2
g any feasible circulation. . .
3
Weak circulation: h = g − f. . .
4
By lemma: all edges used by h are in Gf. . .
5
By other lemma: ∃t ≤ |E(Gf)| cycles C1, . . . , Ct in Gf, and coefficients λ1, . . . , λt: h(e) = ∑t
i=1 λiχCi(e).
. .
6
cost(g) − cost(f) = cost(h) = cost
(∑t
i=1 λiχCi
)
=
∑t
i=1 λicost(χCi) = ∑t i=1 λiκ (Ci) ≥ 0, as κ(Ci) ≥ 0,
since there are no negative cycles in Gf. . .
7
= ⇒ cost(g) ≥ cost(f). = ⇒ f minimum-cost circulation.
Sariel (UIUC) CS573 5 Fall 2013 5 / 27
.
. . .
1
Assume all cycles in Gf have non-negative cost. . .
2
g any feasible circulation. . .
3
Weak circulation: h = g − f. . .
4
By lemma: all edges used by h are in Gf. . .
5
By other lemma: ∃t ≤ |E(Gf)| cycles C1, . . . , Ct in Gf, and coefficients λ1, . . . , λt: h(e) = ∑t
i=1 λiχCi(e).
. .
6
cost(g) − cost(f) = cost(h) = cost
(∑t
i=1 λiχCi
)
=
∑t
i=1 λicost(χCi) = ∑t i=1 λiκ (Ci) ≥ 0, as κ(Ci) ≥ 0,
since there are no negative cycles in Gf. . .
7
= ⇒ cost(g) ≥ cost(f). = ⇒ f minimum-cost circulation.
Sariel (UIUC) CS573 5 Fall 2013 5 / 27
.
. . .
1
Assume all cycles in Gf have non-negative cost. . .
2
g any feasible circulation. . .
3
Weak circulation: h = g − f. . .
4
By lemma: all edges used by h are in Gf. . .
5
By other lemma: ∃t ≤ |E(Gf)| cycles C1, . . . , Ct in Gf, and coefficients λ1, . . . , λt: h(e) = ∑t
i=1 λiχCi(e).
. .
6
cost(g) − cost(f) = cost(h) = cost
(∑t
i=1 λiχCi
)
=
∑t
i=1 λicost(χCi) = ∑t i=1 λiκ (Ci) ≥ 0, as κ(Ci) ≥ 0,
since there are no negative cycles in Gf. . .
7
= ⇒ cost(g) ≥ cost(f). = ⇒ f minimum-cost circulation.
Sariel (UIUC) CS573 5 Fall 2013 5 / 27
. .
Sariel (UIUC) CS573 6 Fall 2013 6 / 27
. .
1
Start from a feasible circulation f. . .
2
Computed using unweighted algorithm (uses max-flow algorithm). . .
3
Repeat: (A) find cycle C of minimum average cost in Gf. (B) If cost of C is non-negative. Done. (C) Circulate as much flow as possible along C (without violating the lower-bound constraints and capacity constraints), (D) Reduces cost. (E) Compute such a cycle in O(mn) time.
Sariel (UIUC) CS573 7 Fall 2013 7 / 27
. .
1
Algorithm preserve integrality. . .
2
cost of the flow is monotonically decreasing. . .
3
algorithm would terminate if all the number involved are integers. . .
4
This algorithm performs a polynomial number of iterations in n and m. . .
5
Simple algorithm!
Sariel (UIUC) CS573 8 Fall 2013 8 / 27
f, g, h, i Flows or circulations Gf The residual graph for f c(e) The capacity of the flow on e ℓ(e) The lower-bound (i.e., demand) on the flow on e cost(f) The overall cost of the flow f κ(e) The cost of sending one unit of flow on e ψ(e) The reduced cost of e
Sariel (UIUC) CS573 9 Fall 2013 9 / 27
. .
1
fi: flow in the beginning of the ith iteration. . .
2
Ci cycle used in the ith iteration. . .
3
Cf: minimum average-length cycle of Gf. . .
4
µ(f) = κ(Cf)/ |Cf| average “cost” per edge of Cf. .
. . Let f be a flow, and let g the flow resulting from applying the cycle C = Cf to it. Then, µ(g) ≥ µ(f). .
. . See class notes.
Sariel (UIUC) CS573 10 Fall 2013 10 / 27
.
. . Let f be a flow used in the ith iteration of the algorithm, let g be the flow used in the (i + m)th iteration, where m is the number of edges in G. Furthermore, assume that the algorithm performed at least one more iteration on g. Then, µ(g) ≥ (1 − 1/n)µ(f). .
. . See class notes.
Sariel (UIUC) CS573 11 Fall 2013 11 / 27
.
. . Let f be the circulation maintained by the algorithm at iteration ρ. Then there exists an edge e in the residual network Gf such that it never appears in the residual networks of circulations maintained by the algorithm, for iterations larger than ρ + t, where t = 2nm ⌈ln n⌉. .
. . See class notes.
Sariel (UIUC) CS573 12 Fall 2013 12 / 27
. .
1
at least one edge disappears forever every O(mn log n) iterations. . .
2
it follows that after O(m2n log n) iterations algorithm terminates. . .
3
Every iteration takes O(mn) time. .
. . Given a digraph G with n vertices and m edges, lower bound and upper bound on the flow of each edge, and a cost associated with each edge, then one can compute a valid circulation of minimum-cost in O(m3n2 log n) time.
Sariel (UIUC) CS573 13 Fall 2013 13 / 27
. .
1
minimum average cost cycle algorithm is due to Karp Karp [1978]. . .
2
Our follows Schrijver [2004]. . .
3
First strongly polynomial time algorithm for minimum-cost circulation is due to ´ Eva Tardos Tardos [1985]. . .
4
Algorithm show Andrew Goldberg and Robert Tarjan Goldberg and Tarjan [1989]. . .
5
Initial research on this problem can be traced back to the 1940s. . .
6
Took almost fifty years to find a satisfactory solution!
Sariel (UIUC) CS573 14 Fall 2013 14 / 27
. .
Sariel (UIUC) CS573 15 Fall 2013 15 / 27
. .
1
A flow f would be considered to be efficient if it contains no cycles in it. . .
2
Ford-Fulkerson algorithm might generate flows with cycles. . .
3
See figure... . .
4
A in middle of edges: split the edge into multiple edges by introducing vertoces/ .
5
All edges have capacity one. .
6
Demonstrate how to get cycle...
s t
u v w
Sariel (UIUC) CS573 16 Fall 2013 16 / 27
. .
1
A flow f would be considered to be efficient if it contains no cycles in it. . .
2
Ford-Fulkerson algorithm might generate flows with cycles. . .
3
See figure... . .
4
A in middle of edges: split the edge into multiple edges by introducing vertoces/ .
5
All edges have capacity one. .
6
Demonstrate how to get cycle...
s t
u v w
Sariel (UIUC) CS573 16 Fall 2013 16 / 27
. .
1
A flow f would be considered to be efficient if it contains no cycles in it. . .
2
Ford-Fulkerson algorithm might generate flows with cycles. . .
3
See figure... . .
4
A in middle of edges: split the edge into multiple edges by introducing vertoces/ .
5
All edges have capacity one. .
6
Demonstrate how to get cycle...
s t
u v w
Sariel (UIUC) CS573 16 Fall 2013 16 / 27
. .
1
A flow f would be considered to be efficient if it contains no cycles in it. . .
2
Ford-Fulkerson algorithm might generate flows with cycles. . .
3
See figure... . .
4
A in middle of edges: split the edge into multiple edges by introducing vertoces/ .
5
All edges have capacity one. .
6
Demonstrate how to get cycle...
s t
u v w
Sariel (UIUC) CS573 16 Fall 2013 16 / 27
. .
1
A flow f would be considered to be efficient if it contains no cycles in it. . .
2
Ford-Fulkerson algorithm might generate flows with cycles. . .
3
See figure... . .
4
A in middle of edges: split the edge into multiple edges by introducing vertoces/ .
5
All edges have capacity one. .
6
Demonstrate how to get cycle...
s t
u v w
Sariel (UIUC) CS573 16 Fall 2013 16 / 27
. .
1
compute the max flow in G. . .
2
α be value of this flow. . .
3
compute min-cost flow in this network from s to t with flow α. . .
4
Every edge has cost one. . .
5
New flow will not contain any cycles! . .
6
Can also be achieved directly by removing cycles directly in the
.
. . Computing an efficient (i.e., acyclic) max-flow can be done in polynomial time.
Sariel (UIUC) CS573 17 Fall 2013 17 / 27
. .
1
compute the max flow in G. . .
2
α be value of this flow. . .
3
compute min-cost flow in this network from s to t with flow α. . .
4
Every edge has cost one. . .
5
New flow will not contain any cycles! . .
6
Can also be achieved directly by removing cycles directly in the
.
. . Computing an efficient (i.e., acyclic) max-flow can be done in polynomial time.
Sariel (UIUC) CS573 17 Fall 2013 17 / 27
. .
1
compute the max flow in G. . .
2
α be value of this flow. . .
3
compute min-cost flow in this network from s to t with flow α. . .
4
Every edge has cost one. . .
5
New flow will not contain any cycles! . .
6
Can also be achieved directly by removing cycles directly in the
.
. . Computing an efficient (i.e., acyclic) max-flow can be done in polynomial time.
Sariel (UIUC) CS573 17 Fall 2013 17 / 27
. .
1
AFWLB: acyclic flow with lower-bounds. . .
2
Compute efficient flow (acyclic) with lower bounds on the edges. . .
3
Require that the returned flow is integral, if all the numbers involved are integers. . .
4
This problem is NP-Complete. . .
5
Because...
Instance: A directed graph G and two vertices s and t. Question: Is there a Hamiltonian path (i.e., a path visiting every vertex exactly once) in G starting at s and ending at t?
Sariel (UIUC) CS573 18 Fall 2013 18 / 27
. .
1
AFWLB: acyclic flow with lower-bounds. . .
2
Compute efficient flow (acyclic) with lower bounds on the edges. . .
3
Require that the returned flow is integral, if all the numbers involved are integers. . .
4
This problem is NP-Complete. . .
5
Because...
Instance: A directed graph G and two vertices s and t. Question: Is there a Hamiltonian path (i.e., a path visiting every vertex exactly once) in G starting at s and ending at t?
Sariel (UIUC) CS573 18 Fall 2013 18 / 27
. .
1
Hamiltonian Path is NP-Complete . .
2
reduce Hamiltonian Path to AFWLB. . .
3
Replace vertex of G with two vertices and a direct edge in between them. (except for the source vertex s and the sink vertex t). . .
4
Set the lower-bound and capacity of each such edge to 1. Let H denote the resulting graph. . .
5
Consider an acyclic flow in H of capacity 1 from s to t which is
all the special edges we created. . .
6
Corresponds to a path in the original graph that starts at s, visits all the vertices of G and ends up at t.
Sariel (UIUC) CS573 19 Fall 2013 19 / 27
.
. . Computing an efficient (i.e., acyclic) max-flow with lower-bounds is
problem (of whether such a flow exist) is NP-Complete. . .
1
Confusing... . .
2
We can model an acyclic max-flow problem with lower bounds as min-cost flow, and solve it, no? . .
3
Not quite. Solution returned from the min-cost flow might have cycles. . .
4
Can not remove them by canceling the cycles. . .
5
Removing cycles was only possible when there was no lower bounds. .
6
min-cost flow algorithm would return us a solution with cycles in it if there are lower bounds on the edges.
Sariel (UIUC) CS573 20 Fall 2013 20 / 27
.
. . Computing an efficient (i.e., acyclic) max-flow with lower-bounds is
problem (of whether such a flow exist) is NP-Complete. . .
1
Confusing... . .
2
We can model an acyclic max-flow problem with lower bounds as min-cost flow, and solve it, no? . .
3
Not quite. Solution returned from the min-cost flow might have cycles. . .
4
Can not remove them by canceling the cycles. . .
5
Removing cycles was only possible when there was no lower bounds. .
6
min-cost flow algorithm would return us a solution with cycles in it if there are lower bounds on the edges.
Sariel (UIUC) CS573 20 Fall 2013 20 / 27
.
. . Computing an efficient (i.e., acyclic) max-flow with lower-bounds is
problem (of whether such a flow exist) is NP-Complete. . .
1
Confusing... . .
2
We can model an acyclic max-flow problem with lower bounds as min-cost flow, and solve it, no? . .
3
Not quite. Solution returned from the min-cost flow might have cycles. . .
4
Can not remove them by canceling the cycles. . .
5
Removing cycles was only possible when there was no lower bounds. .
6
min-cost flow algorithm would return us a solution with cycles in it if there are lower bounds on the edges.
Sariel (UIUC) CS573 20 Fall 2013 20 / 27
.
. . Computing an efficient (i.e., acyclic) max-flow with lower-bounds is
problem (of whether such a flow exist) is NP-Complete. . .
1
Confusing... . .
2
We can model an acyclic max-flow problem with lower bounds as min-cost flow, and solve it, no? . .
3
Not quite. Solution returned from the min-cost flow might have cycles. . .
4
Can not remove them by canceling the cycles. . .
5
Removing cycles was only possible when there was no lower bounds. .
6
min-cost flow algorithm would return us a solution with cycles in it if there are lower bounds on the edges.
Sariel (UIUC) CS573 20 Fall 2013 20 / 27
.
. . Computing an efficient (i.e., acyclic) max-flow with lower-bounds is
problem (of whether such a flow exist) is NP-Complete. . .
1
Confusing... . .
2
We can model an acyclic max-flow problem with lower bounds as min-cost flow, and solve it, no? . .
3
Not quite. Solution returned from the min-cost flow might have cycles. . .
4
Can not remove them by canceling the cycles. . .
5
Removing cycles was only possible when there was no lower bounds. .
6
min-cost flow algorithm would return us a solution with cycles in it if there are lower bounds on the edges.
Sariel (UIUC) CS573 20 Fall 2013 20 / 27
.
. . Computing an efficient (i.e., acyclic) max-flow with lower-bounds is
problem (of whether such a flow exist) is NP-Complete. . .
1
Confusing... . .
2
We can model an acyclic max-flow problem with lower bounds as min-cost flow, and solve it, no? . .
3
Not quite. Solution returned from the min-cost flow might have cycles. . .
4
Can not remove them by canceling the cycles. . .
5
Removing cycles was only possible when there was no lower bounds. .
6
min-cost flow algorithm would return us a solution with cycles in it if there are lower bounds on the edges.
Sariel (UIUC) CS573 20 Fall 2013 20 / 27
. .
1
G: a directed graph. . .
2
Q: Compute k-edge disjoint paths from s to t. . .
3
Solve with network flow. . .
4
Can compute shortest k-edge disjoint paths using min-cost flow. . .
5
Assign cost 1 for every edge, and capacity 1 for every edge. . .
6
min-cost flow in this graph with value k, corresponds to a set of k edge disjoint paths, such that their total length is minimized.
Sariel (UIUC) CS573 21 Fall 2013 21 / 27
. .
1
G: a directed graph. . .
2
Q: Compute k-edge disjoint paths from s to t. . .
3
Solve with network flow. . .
4
Can compute shortest k-edge disjoint paths using min-cost flow. . .
5
Assign cost 1 for every edge, and capacity 1 for every edge. . .
6
min-cost flow in this graph with value k, corresponds to a set of k edge disjoint paths, such that their total length is minimized.
Sariel (UIUC) CS573 21 Fall 2013 21 / 27
. .
1
G: a directed graph. . .
2
Q: Compute k-edge disjoint paths from s to t. . .
3
Solve with network flow. . .
4
Can compute shortest k-edge disjoint paths using min-cost flow. . .
5
Assign cost 1 for every edge, and capacity 1 for every edge. . .
6
min-cost flow in this graph with value k, corresponds to a set of k edge disjoint paths, such that their total length is minimized.
Sariel (UIUC) CS573 21 Fall 2013 21 / 27
. .
1
G: a directed graph. . .
2
Q: Compute k-edge disjoint paths from s to t. . .
3
Solve with network flow. . .
4
Can compute shortest k-edge disjoint paths using min-cost flow. . .
5
Assign cost 1 for every edge, and capacity 1 for every edge. . .
6
min-cost flow in this graph with value k, corresponds to a set of k edge disjoint paths, such that their total length is minimized.
Sariel (UIUC) CS573 21 Fall 2013 21 / 27
. .
1
G: a directed graph. . .
2
Q: Compute k-edge disjoint paths from s to t. . .
3
Solve with network flow. . .
4
Can compute shortest k-edge disjoint paths using min-cost flow. . .
5
Assign cost 1 for every edge, and capacity 1 for every edge. . .
6
min-cost flow in this graph with value k, corresponds to a set of k edge disjoint paths, such that their total length is minimized.
Sariel (UIUC) CS573 21 Fall 2013 21 / 27
. .
1
G: a directed graph. . .
2
Q: Compute k-edge disjoint paths from s to t. . .
3
Solve with network flow. . .
4
Can compute shortest k-edge disjoint paths using min-cost flow. . .
5
Assign cost 1 for every edge, and capacity 1 for every edge. . .
6
min-cost flow in this graph with value k, corresponds to a set of k edge disjoint paths, such that their total length is minimized.
Sariel (UIUC) CS573 21 Fall 2013 21 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: directed graph. . .
2
cover all its vertices by a set of cycles which are vertex disjoint. . .
3
can be done using min-cost flow. . .
4
∀u ∈ V(G) replace by an edge (u′ → u′′). . .
5
u: incoming edges connected u′. Outgoing edges start from u′′. . .
6
H: resulting graph. . .
7
All new edges have a lower bound/capacity = 1. . .
8
All other edges: no lower bound, capacity 1. . .
9
Compute minimum cost circulation in H. . .
10 corresponds to a collection of cycles in G covering all the
vertices of minimum cost. .
. . G + costs on edges. Compute cover of G by a collection of vertex disjoint cycles, of min total cost of the cycle edges.
Sariel (UIUC) CS573 22 Fall 2013 22 / 27
. .
1
G: undirected bipartite graph G, . .
2
Task: Compute max cardinality matching in G t of minimum cost. . .
3
Reduce to network flow as done before. . .
4
Compute maximum flow. . .
5
any edge has capacity 1. Compute ϕ = size of matching. . .
6
Compute min-cost flow in G with this value ϕ. . .
7
Zero cost to new edges, original cost on other. .
8
min-cost flow corresponds to a maximum cardinality min-cost flow in the original graph. . .
9
Using: flow computed is integral, and as such, it is a 0/1-flow.
Sariel (UIUC) CS573 23 Fall 2013 23 / 27
t s
1 1
1
1
Sariel (UIUC) CS573 24 Fall 2013 24 / 27
.
. . Given a bipartite graph G and costs on the edges, one can compute the maximum cardinality minimum cost matching in polynomial time.
Sariel (UIUC) CS573 25 Fall 2013 25 / 27
. .
1
Input: m facilities f1, . . . , fm. . .
2
fi: contains xi units of some commodity, for i = 1, . . . , m. . .
3
u1, . . . , un customers want to buy. . .
4
ui would like to by di units, for i = 1, . . . , n. . .
5
costs cij to send one unit of commodity from facility i to costumer j. . .
6
Q: how to supply the demands while minimizing the total cost.
Sariel (UIUC) CS573 26 Fall 2013 26 / 27
. .
1
Input: m facilities f1, . . . , fm. . .
2
fi: contains xi units of some commodity, for i = 1, . . . , m. . .
3
u1, . . . , un customers want to buy. . .
4
ui would like to by di units, for i = 1, . . . , n. . .
5
costs cij to send one unit of commodity from facility i to costumer j. . .
6
Q: how to supply the demands while minimizing the total cost.
Sariel (UIUC) CS573 26 Fall 2013 26 / 27
. .
1
Input: m facilities f1, . . . , fm. . .
2
fi: contains xi units of some commodity, for i = 1, . . . , m. . .
3
u1, . . . , un customers want to buy. . .
4
ui would like to by di units, for i = 1, . . . , n. . .
5
costs cij to send one unit of commodity from facility i to costumer j. . .
6
Q: how to supply the demands while minimizing the total cost.
Sariel (UIUC) CS573 26 Fall 2013 26 / 27
. .
1
Input: m facilities f1, . . . , fm. . .
2
fi: contains xi units of some commodity, for i = 1, . . . , m. . .
3
u1, . . . , un customers want to buy. . .
4
ui would like to by di units, for i = 1, . . . , n. . .
5
costs cij to send one unit of commodity from facility i to costumer j. . .
6
Q: how to supply the demands while minimizing the total cost.
Sariel (UIUC) CS573 26 Fall 2013 26 / 27
. .
1
Input: m facilities f1, . . . , fm. . .
2
fi: contains xi units of some commodity, for i = 1, . . . , m. . .
3
u1, . . . , un customers want to buy. . .
4
ui would like to by di units, for i = 1, . . . , n. . .
5
costs cij to send one unit of commodity from facility i to costumer j. . .
6
Q: how to supply the demands while minimizing the total cost.
Sariel (UIUC) CS573 26 Fall 2013 26 / 27
. .
1
Input: m facilities f1, . . . , fm. . .
2
fi: contains xi units of some commodity, for i = 1, . . . , m. . .
3
u1, . . . , un customers want to buy. . .
4
ui would like to by di units, for i = 1, . . . , n. . .
5
costs cij to send one unit of commodity from facility i to costumer j. . .
6
Q: how to supply the demands while minimizing the total cost.
Sariel (UIUC) CS573 26 Fall 2013 26 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
. .
1
Create a bipartite graph with f1, . . . , fm on one side, and u1, . . . , un on the other side. . .
2
edge from (fi → uj): costs cij. . .
3
s: a source connected to fi with capacity xi. . .
4
edges from uj to the sink t, with capacity di. . .
5
Compute min-cost flow pushing ϕ = ∑
j dk units.
. .
6
Solution encodes the required optimal solution to the transportation problem. .
. . The transportation problem can be solved in polynomial time. Sometime called the Earth mover distance.
Sariel (UIUC) CS573 27 Fall 2013 27 / 27
Sariel (UIUC) CS573 28 Fall 2013 28 / 27
Sariel (UIUC) CS573 29 Fall 2013 29 / 27
Sariel (UIUC) CS573 30 Fall 2013 30 / 27
Sariel (UIUC) CS573 31 Fall 2013 31 / 27
by canceling negative cycles. J. Assoc. Comput. Mach., 36(4): 873–886, 1989.
(Algorithms and Combinatorics). Springer, July 2004. ISBN 3540204563. ´
Sariel (UIUC) CS573 31 Fall 2013 31 / 27