chapter 6 graph algorithms - uni-freiburg.deac.informatik.uni-freiburg.de/teaching/ws18_19/...ย ยท...
Post on 05-Jul-2020
3 Views
Preview:
TRANSCRIPT
Algorithm Theory, WS 2018/19 Fabian Kuhn 3
Network Flow: Definition
Flow: function ๐: ๐ฌ โ โโฅ๐
โข ๐(๐) is the amount of flow carried by edge ๐
Capacity Constraints:
โข For each edge ๐ โ ๐ธ, ๐ ๐ โค ๐๐
Flow Conservation:
โข For each node ๐ฃ โ ๐ โ ๐ , ๐ก ,
๐ into ๐ฃ
๐ ๐ =
๐ out of ๐ฃ
๐ ๐
Flow Value:
|๐| โ
๐ out of ๐
๐ ๐ , ๐ข =
๐ into ๐ก
๐ ๐ฃ, ๐ก
Algorithm Theory, WS 2018/19 Fabian Kuhn 4
The Maximum-Flow Problem
Maximum Flow:
Given a flow network, find a flow of maximum possible value
โข Classical graph optimization problem
โข Many applications (also beyond the obvious ones)
โข Requires new algorithmic techniques
Algorithm Theory, WS 2018/19 Fabian Kuhn 5
Residual Graph
Given a flow network ๐บ = ๐, ๐ธ with capacities ๐๐ (for ๐ โ ๐ธ)
For a flow ๐ on ๐บ, define directed graph ๐บ๐ = (๐๐ , ๐ธ๐) as follows:
โข Node set ๐๐ = ๐
โข For each edge ๐ = (๐ข, ๐ฃ) in ๐ธ, there are two edges in ๐ธ๐:
โ forward edge ๐ = (๐ข, ๐ฃ) with residual capacity ๐๐ โ ๐(๐)
โ backward edge ๐โฒ = (๐ฃ, ๐ข) with residual capacity ๐(๐)
๐ ๐ก
๐ข
๐ฃ
20
20
10
10
30
๐๐
๐๐
๐๐
Algorithm Theory, WS 2018/19 Fabian Kuhn 6
Residual Graph: Example
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
1520
20
15
10
10
20
15
20
15
15
15
10
5
20
20
Algorithm Theory, WS 2018/19 Fabian Kuhn 7
Residual Graph: Example
Flow ๐
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
1520
20
15
10
10
20
15
20
15
15
15
10
5
20
20๐๐
๐
๐๐
๐
๐๐
๐
๐๐
๐๐
๐๐
๐๐
๐๐
๐๐
๐๐
๐๐
510 15
5
0
15
Algorithm Theory, WS 2018/19 Fabian Kuhn 8
Residual Graph: Example
Residual Graph ๐ฎ๐
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
510 15
5
0
15
100
0 5
0
1015
15
0
10
10
05
20
10
10
10
1010 10
10
10
0
5 5
5
Algorithm Theory, WS 2018/19 Fabian Kuhn 9
Augmenting Path
Residual Graph ๐ฎ๐
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
510 ๐๐
5
0
15
๐๐0
0 5
0
10๐๐
๐๐
0
10
10
05
20
๐๐
10
10
1010 10
10
๐๐
0
5 5
5
Algorithm Theory, WS 2018/19 Fabian Kuhn 10
Augmenting Path
Augmenting Path
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
1520
20
15
10
10
20
15
20
15
15
15
10
5
20
20๐๐
๐
๐๐
๐
๐๐
๐
๐๐
๐๐
๐๐
๐๐
๐๐
๐๐
๐๐
๐๐
Algorithm Theory, WS 2018/19 Fabian Kuhn 11
Augmenting Path
New Flow
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
1520
20
15
10
10
20
15
20
15
15
15
10
5
20
20๐๐
๐ + ๐๐
๐๐ โ ๐๐
๐ + ๐๐
๐๐
๐
๐๐
๐๐ + ๐๐
๐๐
๐๐
๐๐
๐๐ โ ๐๐
๐๐
๐๐
๐ + ๐๐
Algorithm Theory, WS 2018/19 Fabian Kuhn 12
Augmenting Path
Definition:An augmenting path ๐ is a (simple) ๐ -๐ก-path on the residual graph ๐บ๐ on which each edge has residual capacity > 0.
bottleneck(๐, ๐): minimum residual capacity on any edge of theaugmenting path ๐
Augment flow ๐ to get flow ๐โฒ:
โข For every forward edge (๐ข, ๐ฃ) on ๐:
๐โฒ ๐, ๐ โ ๐ ๐, ๐ + ๐๐จ๐ญ๐ญ๐ฅ๐๐ง๐๐๐ค ๐ท, ๐
โข For every backward edge (๐ข, ๐ฃ) on ๐:
๐โฒ ๐, ๐ โ ๐ ๐, ๐ โ ๐๐จ๐ญ๐ญ๐ฅ๐๐ง๐๐๐ค(๐ท, ๐)
Algorithm Theory, WS 2018/19 Fabian Kuhn 13
Augmented Flow
Lemma: Given a flow ๐ and an augmenting path ๐, the resulting augmented flow ๐โฒ is legal and its value is
๐โฒ = ๐ + ๐๐จ๐ญ๐ญ๐ฅ๐๐ง๐๐๐ค ๐ท, ๐ .
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 14
Augmented Flow
Lemma: Given a flow ๐ and an augmenting path ๐, the resulting augmented flow ๐โฒ is legal and its value is
๐โฒ = ๐ + ๐๐จ๐ญ๐ญ๐ฅ๐๐ง๐๐๐ค ๐ท, ๐ .
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 15
Ford-Fulkerson Algorithm
โข Improve flow using an augmenting path as long as possible:
1. Initially, ๐ ๐ = 0 for all edges ๐ โ ๐ธ, ๐บ๐ = ๐บ
2. while there is an augmenting ๐ -๐ก-path ๐ in ๐บ๐ do
3. Let ๐ be an augmenting ๐ -๐ก-path in ๐บ๐;
4. ๐โฒ โ augment(๐, ๐);
5. update ๐ to be ๐โฒ;
6. update the residual graph ๐บ๐
7. end;
Algorithm Theory, WS 2018/19 Fabian Kuhn 16
Ford-Fulkerson Running Time
Theorem: If all edge capacities are integers, the Ford-Fulkerson algorithm terminates after at most ๐ถ iterations, where
๐ถ = "max flow value" โค
๐ out of ๐
๐๐ .
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 17
Ford-Fulkerson Running Time
Theorem: If all edge capacities are integers, the Ford-Fulkerson algorithm can be implemented to run in ๐(๐๐ถ) time.
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 18
๐ -๐ก Cuts
Definition:An ๐ -๐ก cut is a partition (๐ด, ๐ต) of the vertex set such that ๐ โ ๐ดand ๐ก โ ๐ต
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
1520
20
15
10
10
20
15
20
15
15
15
10
5
20
20
๐จ
๐ฉ
Algorithm Theory, WS 2018/19 Fabian Kuhn 19
Cut Capacity
Definition:The capacity ๐ ๐ด, ๐ต of an ๐ -๐ก-cut (๐ด, ๐ต) is defined as
๐ ๐จ,๐ฉ โ
๐ ๐จ๐ฎ๐ญ ๐จ๐ ๐จ
๐๐ .
๐
๐ฅ
๐ข
๐ฆ
๐ฃ
๐ค
๐
๐ง
๐ก
1520
20
15
10
10
20
๐๐
20
15
15
15
10
๐
๐๐
๐๐
๐จ
๐ฉ
Algorithm Theory, WS 2018/19 Fabian Kuhn 20
Cuts and Flow Value
Lemma: Let ๐ be any ๐ -๐ก flow, and (๐ด, ๐ต) any ๐ -๐ก cut. Then,
๐ = ๐๐จ๐ฎ๐ญ ๐จ โ ๐๐ข๐ง ๐จ .
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 21
Cuts and Flow Value
Lemma: Let ๐ be any ๐ -๐ก flow, and (๐ด, ๐ต) any ๐ -๐ก cut. Then,
๐ = ๐๐จ๐ฎ๐ญ ๐จ โ ๐๐ข๐ง ๐จ .
Lemma: Let ๐ be any ๐ -๐ก flow, and (๐ด, ๐ต) any ๐ -๐ก cut. Then,
๐ = ๐๐ข๐ง ๐ฉ โ ๐๐จ๐ฎ๐ญ ๐ฉ .
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 22
Upper Bound on Flow Value
Lemma:
Let ๐ be any ๐ -๐ก flow and (๐ด, ๐ต) any ๐ -๐ก cut. Then ๐ โค ๐(๐จ,๐ฉ).
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 23
Ford-Fulkerson Gives Optimal Solution
Lemma: If ๐ is an ๐ -๐ก flow such that there is no augmenting path in ๐บ๐, then there is an ๐ -๐ก cut (๐ดโ, ๐ตโ) in ๐บ for which
๐ = ๐ ๐จโ, ๐ฉโ .
Proof:
โข Define ๐จโ: set of nodes that can be reached from ๐ on a path with positive residual capacities in ๐บ๐:
โข For ๐ตโ = ๐ โ ๐ดโ, (๐ดโ, ๐ตโ) is an ๐ -๐ก cutโ By definition ๐ โ ๐ดโ and ๐ก โ ๐ดโ
Algorithm Theory, WS 2018/19 Fabian Kuhn 24
Ford-Fulkerson Gives Optimal Solution
Lemma: If ๐ is an ๐ -๐ก flow such that there is no augmenting path in ๐บ๐, then there is an ๐ -๐ก cut (๐ดโ, ๐ตโ) in ๐บ for which
๐ = ๐ ๐จโ, ๐ฉโ .
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 25
Ford-Fulkerson Gives Optimal Solution
Lemma: If ๐ is an ๐ -๐ก flow such that there is no augmenting path in ๐บ๐, then there is an ๐ -๐ก cut (๐ดโ, ๐ตโ) in ๐บ for which
๐ = ๐ ๐จโ, ๐ฉโ .
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 26
Ford-Fulkerson Gives Optimal Solution
Theorem: The flow returned by the Ford-Fulkerson algorithm is a maximum flow.
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 27
Min-Cut Algorithm
Ford-Fulkerson also gives a min-cut algorithm:
Theorem: Given a flow ๐ of maximum value, we can compute an ๐ -๐ก cut of minimum capacity in ๐(๐) time.
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 28
Max-Flow Min-Cut Theorem
Theorem: (Max-Flow Min-Cut Theorem)
In every flow network, the maximum value of an ๐ -๐ก flow is equal to the minimum capacity of an ๐ -๐ก cut.
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 29
Integer Capacities
Theorem: (Integer-Valued Flows)
If all capacities in the flow network are integers, then there is a maximum flow ๐ for which the flow ๐ ๐ of every edge ๐ is an integer.
Proof:
Algorithm Theory, WS 2018/19 Fabian Kuhn 30
Non-Integer Capacities
What if capacities are not integers?
โข rational capacities:โ can be turned into integers by multiplying them with large enough integer
โ algorithm still works correctly
โข real (non-rational) capacities:โ not clear whether the algorithm always terminates
โข even for integer capacities, time can linearly depend on the value of the maximum flow
Algorithm Theory, WS 2018/19 Fabian Kuhn 31
Slow Execution
โข Number of iterations: 2000 (value of max. flow)
๐ ๐ก
๐ข
๐ฃ
1000
1000
1000
1000
1
๐
๐
๐
๐
๐
๐
๐๐
๐ ๐
Algorithm Theory, WS 2018/19 Fabian Kuhn 32
Improved Algorithm
Idea: Find the best augmenting path in each step
โข best: path ๐ with maximum bottleneck(๐, ๐)
โข Best path might be rather expensive to find find almost best path
โข Scaling parameter ๐ซ: (initially, ฮ = "max ๐๐ rounded down to next power of 2")
โข As long as there is an augmenting path that improves the flow by at least ฮ, augment using such a path
โข If there is no such path: ฮ โ ฮคฮ 2
Algorithm Theory, WS 2018/19 Fabian Kuhn 33
Scaling Parameter Analysis
Lemma: If all capacities are integers, number of different scaling parameters used is โค 1 + โlog2 ๐ถโ.
โข ๐ซ-scaling phase: Time during which scaling parameter is ฮ
Algorithm Theory, WS 2018/19 Fabian Kuhn 34
Length of a Scaling Phase
Lemma: If ๐ is the flow at the end of the ฮ-scaling phase, the maximum flow in the network has value at most ๐ + ๐ฮ.
Algorithm Theory, WS 2018/19 Fabian Kuhn 35
Length of a Scaling Phase
Lemma: The number of augmentation in each scaling phase is at most 2๐.
Algorithm Theory, WS 2018/19 Fabian Kuhn 36
Running Time: Scaling Max Flow Alg.
Theorem: The number of augmentations of the algorithm with scaling parameter and integer capacities is at most ๐(๐ log ๐ถ). The algorithm can be implemented in time ๐ ๐2 log ๐ถ .
Algorithm Theory, WS 2018/19 Fabian Kuhn 37
Strongly Polynomial Algorithm
โข Time of regular Ford-Fulkerson algorithm with integer capacities:
๐(๐๐ถ)
โข Time of algorithm with scaling parameter:
๐ ๐2log ๐ถ
โข ๐(log ๐ถ) is polynomial in the size of the input, but not in ๐
โข Can we get an algorithm that runs in time polynomial in ๐?
โข Always picking a shortest augmenting path leads to running time
๐ ๐2๐
โ also works for arbitrary real-valued weights
Algorithm Theory, WS 2018/19 Fabian Kuhn 38
Other Algorithms
โข There are many other algorithms to solve the maximum flow problem, for example:
โข Preflow-push algorithm:โ Maintains a preflow (โ nodes: inflow โฅ outflow)
โ Alg. guarantees: As soon as we have a flow, it is optimal
โ Detailed discussion in 2012/13 lecture
โ Running time of basic algorithm: ๐ ๐ โ ๐2
โ Doing steps in the โrightโ order: ๐ ๐3
โข Current best known complexity: ๐ถ ๐ โ ๐โ For graphs with ๐ โฅ ๐1+๐ [King,Rao,Tarjan 1992/1994]
(for every constant ๐ > 0)
โ For sparse graphs with ๐ โค ๐ ฮค16 15โ๐ฟ [Orlin, 2013]
top related