ma/cs 6a - 2015-16/1term/ma006a/14. flow exercises.pdfย ยท 10/30/2015 1 ma/cs 6a class 14: various...
TRANSCRIPT
10/30/2015
1
Ma/CS 6a
Class 14: Various (Flow) Execises
Reminder: Flow Networks
A flow network is a digraph ๐บ = ๐, ๐ธ , together with a source vertex ๐ โ ๐, a sink vertex ๐ก โ ๐, and a capacity function ๐: ๐ธ โ โ.
s t
a
b
c
d
eSource
7
3
1
1
1
3
5
3
5
5 Sink
Capacity
10/30/2015
2
Reminder: Flow in a Network
Given a flow network ๐บ = (๐, ๐ธ, ๐ , ๐ก, ๐), a flow in ๐บ is a function ๐: ๐ธ โ โ that satisfies
โฆ Every ๐ โ ๐ธ satisfies ๐ ๐ โค ๐ ๐ .
โฆ Every ๐ฃ โ ๐ โ ๐ , ๐ก satisfies
๐ข,๐ฃ โ๐ธ
๐ ๐ข, ๐ฃ =
๐ฃ,๐ค โ๐ธ
๐ ๐ฃ,๐ค
Total flow entering ๐ฃ.
Total flow exiting ๐ฃ.
Example: Flow
s t
a
b
c
d
e
2/7
The capacities are in red.
The flow is in blue.
2/3
2/5
0/3
0/1
2/3
1/1
1/1
1/5
3/5
10/30/2015
3
Reminder: Cuts
A cut is a partitioning of the vertices of the flow network into two sets ๐, ๐ such that ๐ โ ๐ and ๐ก โ ๐.
The size of a cut is the sum of the capacities of the edges from ๐ to ๐.
s t
a
b
c
d
e
7
3
1
1
1
3
5
3
5
5
Reminder: Max Flow โ Min Cut
Max flow โ min cut theorem. In every flow network, the size of the minimum cut is equal to the size of the maximum flow.
s t
a
b
c
d
e
7
3
1
1
1
3
5
3
5
5
10/30/2015
4
Warm-up: Anti-Parallel Edges
Two directed edges are said to be anti-parallel if they have the same endpoints, but are in opposite directions.
Problem. Consider a flow network (๐, ๐ธ, ๐ , ๐ก, ๐), and let ๐, ๐โฒ โ ๐ธ be anti-parallel edges. Prove that there exists a maximum flow in which at least one of ๐, ๐โฒ has no flow through it.
a
b
Solution
Consider a maximum flow ๐.
โฆ If either ๐ or ๐โฒ has no flow through it in ๐, we are done.
โฆ Assume, WLOG, that ๐ ๐ โค ๐(๐โฒ).
โฆ By decreasing ๐(๐โฒ) by ๐ ๐ and then setting ๐ ๐ = 0, we obtain a valid flow of the same size.
Let ๐ = ๐ฃ, ๐ข . Both the incoming and the outgoing flows of ๐ฃ and ๐ข were decreased by the same amount, so they remain equivalent.
10/30/2015
5
An Illustration
๐ข ๐ฃ ๐ข ๐ฃ
Recall: The Rand corporation studied the Soviet train system.
They studied the Soviet ability to transport things from the Asian side to the European side.
10/30/2015
6
They also studied the minimum cut.
Problem. In this scenario there are several sources and several sinks!
The bottleneck
Problem 2: Several Sources and Sinks Problem. We are given a flow network
with several sources and several sinks. Explain how to use an algorithm for finding a maximum flow (in a standard flow network) for this case.
1s
a
b
c
2t
1t1
2s
3s
1
5
55
3
33
3
11
10/30/2015
7
Solution
We add a โsuper sourceโ ๐, and add an edge from it to each of the sources. Each of these edges has an infinite capacity.
We symmetrically add a โsuper sinkโ ๐.
Run the original algorithm from ๐ to ๐.
1s
a
b
c
2t
1t
2s
3s
1
5
55
3
33
3
11
s t
Correctness
There is a bijection between the flows of the original network and the flows of the new network (obtained by adding a super source and a super sink).
โฆ A flow in the new network yields a flow in the original one by removing the source and the sink, and vice versa.
โฆ Two corresponding flows have the same size.
โฆ A max flow in the new network corresponds to a max flow in the original one.
10/30/2015
8
Problem 3: Even Flow
Problem. Given a flow network ๐, ๐ธ, ๐ , ๐ก, ๐ such that all of the capacities
are even, prove that the size of the maximum flow is even.
The capacities are even.
Every cut has an even size.
The minimum cut has an even size.
The maximum flow has an even size.
Max flow โ min cut
10/30/2015
9
Problem 4: Edge-disjoint Paths
Problem. Given a digraph ๐บ = ๐, ๐ธ and vertices ๐ , ๐ก โ ๐, describe an algorithm that finds the maximum number of edge-disjoint paths from ๐ to ๐ก.
s st t
Solution: Edge-disjoint Paths
We give every edge a capacity of 1. A network with only 1-capacities is called a0-1 network (max flow can be computed more
efficiently in such networks).
Find a max flow in the resulting 0-1 network.
1\1
1\1 1\1
1\1
1\11\1
1\11\1
1\1
1\1 1\1
1\1
1\0
1\0
s t
10/30/2015
10
Correctness of Solution
Given a 0-1 flow network with a max flow ๐ and maximum number of edge-disjoint paths ๐, we need to prove ๐ = ๐.
๐ โฅ ๐: By having a flow of 1 through every disjoint path, we obtain a flow of size ๐.
๐ โค ๐: Proof by induction on ๐ .โฆ Induction basis: obvious when ๐ = 0.
Correctness of Solution (2)
Induction step (show that ๐ = ๐ โค ๐).
โฆ Consider a maximum flow (of size ๐).
โฆ Remove every edge with 0 flow through it.
โฆ Find a path from ๐ to ๐ก (it exists since ๐ > 0).
โฆ Remove the edges of the path, to obtain a network with a flow of size ๐ โ 1.
โฆ By the induction hypothesis, there are ๐ โ 1edge-disjoint paths in this network.
โฆ Bring back the path that was removed, to obtain at least ๐ edge-disjoint paths.
10/30/2015
11
Perhaps RAND were also studying the minimum number of train tracks needed to be destroyed to prevent any transportation from the Asian side to the European side?
Problem 5: Disconnecting Edges
Problem. Given a digraph ๐บ = ๐, ๐ธ and vertices ๐ , ๐ก โ ๐, describe an algorithm that finds the minimum number of edges needed to be removed so that there would be no path from ๐ to ๐ก.
s t
10/30/2015
12
Solution: Disconnecting Edges
As before, we give every edge a capacity of 1, to obtain a 0-1 network.
Find a max flow in the network.
We already proved that the max flow equals the maximum number of edge-disjoint paths.
It remains to prove that the max number of edge-disjoint paths equals the min number of edges needed to disconnect ๐ from ๐ก.
Proof
๐ โ maximum number of edge disjoint paths.
โ โ minimum number of disconnecting edges.
โ โฅ ๐: There are ๐ edge-disjoint paths, and we need to remove at least one edge from each.
โ โค ๐: The min cut is a set of disconnecting edges. By the max flow โmin cut theorem, there are ๐ edges in themin cut.
10/30/2015
13
Mengerโs Theorem
The idea that the min number of disconnecting edges is equal to the max number of edge-disjoint paths is called Mengerโs Theorem, and is from 1927.
Ich heisse Karl und ich mag Flรผsse in
Netzwerken
Problem 6: Vertex-disjoint Paths
Problem. Given a digraph ๐บ = ๐, ๐ธ and vertices ๐ , ๐ก โ ๐, describe an algorithm that finds the maximum number of vertex-disjoint paths from ๐ to ๐ก.
s t
10/30/2015
14
Solution: Vertex-disjoint Paths
We split every vertex of ๐ โ ๐ , ๐ก as follows:
v outvinv
In the resulting graph, paths are edge disjoint if and only if they are vertex disjoint.
As before, we add capacities of 1, to obtain a 0-1 network.
11
1
1
1
1
Solution: Vertex-disjoint Paths (2)
Algorithm:
โฆ We build a 0-1 network as described in the previous slide.
โฆ Find max flow in the resulting network.
It remains to prove:
โฆ There is a bijection between sets of vertex-disjoint paths in the original graph and sets of edge-disjoint paths in the new network.
10/30/2015
15
Proof
Every path in the new network is of the form๐ โ ๐ฃ๐๐ โ ๐ฃ๐๐ข๐ก โ ๐ข๐๐ โ โฏ โ ๐ค๐๐ โ ๐ค๐๐ข๐ก โ ๐ก.
It corresponds to the path in the original graph:๐ โ ๐ฃ โ ๐ข โ โฏ โ ๐ค โ ๐ก.
A set of vertex-disjoint paths in the original graph corresponds to a set of vertex-disjoint paths in the new network, and these are edge-disjoint.
In the new network, a set of edge-disjoint paths are also vertex-disjoint, and so also the corresponding paths in the original graph.
The End