flow networks
DESCRIPTION
Flow Networks. [email protected]. Formalization. Basic Results. Min-cut. Ford-Fulkerson. Edmunds-Karp. Bipartite Matching. Flow Network. Directed Graph G = (V, E) Each edge has a capacity. Properties of Flow. Capacity Constraint Skew Symmetry Flow Conservation. Maximum Flow. - PowerPoint PPT PresentationTRANSCRIPT
Flow [email protected]
Formalization
Basic Results
Ford-Fulkerson
Edmunds-Karp
Bipartite Matching
Min-cut
Flow Network
• Directed Graph G = (V, E)• Each edge has a capacity
Properties of Flow
Capacity Constraint
Skew Symmetry
Flow Conservation
Maximum Flow
– Returns Maximum Flow of G
Value of Flow
|𝒇 |=∑𝑣∈𝑉
𝑓 (𝑠 ,𝑣 )
Motivating Problem
s
v1
v2
v3
v4
tFact
ory
Warehouse
16
10 4
1220
9 7
414
13
Motivating Problem
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
12/12
15/20
4/9 7/7
4/411/14
8/13
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
15/20
4/9 7/7
4/411/14
8/13
12/12
Multiple Sources / Sinks
s1
v1
v2
v3
v4
t1
16
10 4
1220
9 74
14
13
t24s2
4
Multiple Sources / Sinks
s1
v1
v2
v3
v4
t1
16
10 4
1220
9 74
14
13
t24s2
4
S t∞
∞ ∞
∞
Implicit Summation Notation
Key EqualitiesLet G = (V, E) be a flow network, and let f be a flow in G. Then
Capacity Constraint
Skew Symmetry
Flow Conservation
Homomorphism
Flow Value
Prove
DefinitionHomomorphismFlow ConservationSkew SymmetryHomomorphismFlow Conservation
Ford-Fulkerson
flow=0while(augmenting path p)) { augment flow f along p}return flow
Residual network
Induced network from G=(V, E) and flow f
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
12/12
15/20
4/9 7/7
4/411/14
8/13
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
15
411
811
4 7
5
3
0
5
3
00
5
Augmenting Path
A path of
non-zero weight
from s to t in Gf
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
12/12
15/20
4/9 7/7
4/411/14
8/13
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
15
411
811
4 7
5
3
0
5
3
00
5
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
12/12
15/20
4/9 7/7
4/411/14
8/13
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
15
411
811
4 7
5
3
0
5
3
00
5
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
12/12
15/20
4/9 7/7
4/411/14
8/13
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
15
411
811
4 7
5
3
0
5
3
00
5
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
12/12
20/20
0/9 7/7
4/411/14
13/13
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
20
411
1311
0 7
0
3
0
9
3
00
0
S-T Cut
• A cut C=(S, T) of a flow network G=(V, E) is a partition of V into S and T = V – S
• Net flow across• Capacity of cut:
s
v1
v2
v3
v4
tFact
ory
Warehouse
11/16
10 1/4
12/12
15/204/9 7/
7
4/411/14
8/13
f(S, T) = 12 – 4 + 11 = 19c(S, T) = 12 + 14 = 26
Let f be a flow in a flow network G with source s and sink t, and let (S, T) be a cut of G. Then the net flow across (S, T) is f(S, T) = |f|
HomomorphismFlow ConservationHomomorphismFlow ConservationDefinition
|𝑓 |= 𝑓 (𝑆 ,𝑇 )The value of any flow f in a flow network G is bounded by the capacity of any cut of G
Min-Cut Max-Flow
1. f is a maximum flow in G2. The residual network Gf contains no
augmenting path3. |f|= c(S, T) for some cut (S, T) of G
(1 )⇒ (2)1. Premise: f is a max-flow in G2. Assume Gf has augmenting path p3. We can augment Gf with p to get a flow f’ > f– Contradicts [1]
• Hence Gf has no augmenting paths
(2 )⇒ (3)1. Premise: Gf has no augmenting paths2. Let
1. T = V-S3. (S, T) is a cut
1. Otherwise
(3 )⇒ (1)
1. , |f| is maximum
The value of any flow f in a flow network G is bounded by the capacity of any cut of G
Ford-Fulkerson
flow=0while(augmenting path p)) { augment flow f along p}return flow
Termination: Gf has no augmenting path iff flow is maximum
Run-time
flow=0while(augmenting path p)) { augment flow f along p}return flow
O(E|f*|) where |f*| is the maximum flow
s
v1
v2
t1
1,000,000 1,000,000
1,000,0001,000,000
s
v1
v2
t1
1,000,000 1,000,000
1,000,0001,000,000
s
v1
v2
t1
999,999 1,000,000
1,000,0001,000,000
1
1
s
v1
v2
t1
999,999 1,000,000
1,000,0001,000,000
1
1
s
v1
v2
t1
999,999 999,999
1,000,000999,999
1
11
1
s
v1
v2
t1
999,999 999,999
1,000,000999,999
1
11
1
Edmunds Karp
flow=0while(augmenting path p)) { find augmenting path by BFS augment flow f along p}return flow
Run-time: O(VE2)
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
15
411
811
4 7
5
3
0
5
3
00
5
Critical Edge
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
15
411
811
4 7
5
3
0
5
3
00
5
Critical Edge
Lemma: Edges can be critical at most times
s
v1
v2
v3
v4
tFact
ory
Warehouse
11
5
12
15
411
811
4 7
5
3
0
5
3
00
5
𝛿 𝑓 (𝑢 ,𝑣 )≔ h𝑠 𝑜𝑟𝑡𝑒𝑠𝑡− h𝑝𝑎𝑡 h𝑙𝑒𝑛𝑔𝑡 𝑓𝑟𝑜𝑚𝑢→𝑣
𝛿 𝑓 (𝑢 ,𝑣 )≔ h𝑠 𝑜𝑟𝑡𝑒𝑠𝑡− h𝑝𝑎𝑡 h𝑙𝑒𝑛𝑔𝑡 𝑓𝑟𝑜𝑚𝑢→𝑣1. Assume (u, v) is a critical edge2. Augmenting-paths are shortest path [by EK]3. [from 1]4. After flow-augmentation, cf(u,v) = 0• (u, v) cannot be critical path until another
augmenting path containing (v, u).• Let the flow at this point be f’5.
6. i.e, each time (u, v) is augmenting-path, path length increases by 2
7. (u, v) can be critical edge at most times
Lemma: Edges can be critical at most times
Since there are O(E) edges, the number of augmenting path is bounded by O(VE) [by Lemma].
Run-time: O(VE2)
Bipartite Matching
Bipartite Matching
Bipartite Matching MaxFlow
s t
Bipartite Matching MaxFlow
s t