Escolar Documentos
Profissional Documentos
Cultura Documentos
05 — 08 — 2009
Sören Wellhöfer
Introduction
Definitions
Problems / Solutions
References
Table of Contents
1 Introduction
2 Definitions
3 Problems / Solutions
4 References
Flow network
Abstract
• Directed graph
• Source s and sink t
Flow network
a
Abstract
• Directed graph
• Source s and sink t s t
• Edges have capacity
Flow network
a
Abstract 1
5
• Directed graph
• Source s and sink t s 3 t
• Edges have capacity
• Flow: s → t 2 5
b
Flow network
a
Abstract 1
5
• Directed graph
• Source s and sink t s 3 t
• Edges have capacity
• Flow: s → t 2 5
b
Flow network
a
Abstract 1/1
3/5
• Directed graph
• Source s and sink t s 2/ 3 t
• Edges have capacity
• Flow: s → t 2/2 4/ 5
• Flow from s b
equals flow into t
Flow network
a
Abstract 1/1
3/5
• Directed graph
• Source s and sink t s 2/ 3 t
• Edges have capacity
• Flow: s → t 2/2 4/ 5
• Flow from s b
equals flow into t
Formal definition
Nf = G (V , E )
Formal definition
Nf = G (V , E )
Formal definition
Nf = G (V , E )
Formal definition
Nf = G (V , E )
Formal definition
Nf = G (V , E )
Formal definition
Nf = G (V , E )
Network Properties
Capacity constraints
0 ≤ f (u, v ) ≤ c(u, v )
Network Properties
Capacity constraints
0 ≤ f (u, v ) ≤ c(u, v )
Skew symmetry
f (u, v ) = −f (v , u)
Network Properties
Capacity constraints
0 ≤ f (u, v ) ≤ c(u, v )
Skew symmetry
f (u, v ) = −f (v , u)
Properties
Flow conservation
P
u∈V f (u, w ) = 0,
if u 6= s ∧ u 6= t
Properties
Flow conservation
P
u∈V f (u, w ) = 0,
if u 6= s ∧ u 6= t
Properties
Flow conservation
P
u∈V f (u, w ) = 0,
if u 6= s ∧ u 6= t
Properties
Flow conservation
P
u∈V f (u, w ) = 0,
if u 6= s ∧ u 6= t
3 1
n
Properties
Flow conservation
P
u∈V f (u, w ) = 0,
if u 6= s ∧ u 6= t
3 -1
n
-2
Properties
Flow conservation
P
u∈V f (u, w ) = 0,
if u 6= s ∧ u 6= t
3 -1
n
P -2
=0
Sören Wellhöfer Flow Networks
Formal definition
Introduction
Network Properties
Definitions
Path capacity
Problems / Solutions
Residual network
References
Network cuts
Capacity of a Path
a
5 1
s 3 t
2 5
b
p = (s, a, b, t)
Capacity of a Path
a
5 1
s 3 t
2 5
b
p = (s, a, b, t)
c(p) = min(c(s, a), c(a, b), c(b, t))
Capacity of a Path
a
5 1
s 3 t
2 5
b
p = (s, a, b, t)
c(p) = min(c(s, a), c(a, b), c(b, t))
Capacity of a Path
a
5 1
s 3 t
2 5
b
p = (s, a, b, t)
c(p) = min(c(s, a), c(a, b), c(b, t))
c(p) = min(5, 3, 5)
Capacity of a Path
a
5 1
s 3 t
2 5
b
p = (s, a, b, t)
c(p) = min(c(s, a), c(a, b), c(b, t))
c(p) = min(5, 3, 5) = 3
Capacity of a Path
a
5 1
s 3 t
2 5
b
p = (s, a, b, t)
c(p) = min(c(s, a), c(a, b), c(b, t))
c(p) = min(5, 3, 5) = 3
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v )
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
a
3/5 1/1
s 2/3 t
2/2 4/5
b
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
a
3/5 1/1
-3
s 2/3 t
2/2 4/5
b
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
a
3/5 1/1
-3 -1
s 2/3 -2 t
-2 -4
2/2 4/5
b
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
a
2 0
3 1
s 1 3 t
2 4
0 1
b
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
a
2 0
Augmenting path:
3 1
pa = (s, a, b, t)
s 1 3 t
2 4
0 1
b
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
a
2 0
Augmenting path:
3 1
pa = (s, a, b, t)
s 1 3 t
2 4 cr (pa ) = min(2, 1, 1) = 1
0 1
b
Residual Network
Nr = Gr (V , Er ) Er ... residual edges
cr (u, v ) = c(u, v ) − f (u, v ) ... residual edge capacity
a
2 0
Augmenting path:
3 1
pa = (s, a, b, t)
s 1 3 t
2 4 cr (pa ) = min(2, 1, 1) = 1
0 1
b
Network cut
Partition of G into two sets S and T
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
a
5 1
s 3 t
2 5
b
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
a
5 1
s 3 t
2 5
b
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
a
5 1
s 3 t
S
2 5
b
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
a
Cut Capacity:
5 1
P
c(S, T ) = u∈S∧v ∈T c(u, v )
s 3 t
S T =G −S
2 5
b
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
a
Cut Capacity:
5 1
P
c(S, T ) = u∈S∧v ∈T c(u, v )
s 3 t
c(S, T ) = 5 + 5 = 10
S T =G −S
2 5
b
Network cut
Partition of G into two sets S and T s ∈S ∧t ∈T
a
Cut Capacity:
5 1
P
c(S, T ) = u∈S∧v ∈T c(u, v )
s 3 t
c(S, T ) = 5 + 5 = 10
S T =G −S
2 5
b
Maximum Flow
Maximum Flow
Maximum Flow
a
3/5 1/1
s 2/3 t
2/2 4/5
b
Maximum Flow
a
2 0
3 1
s 1 3 t
2 4
0 1
b
Maximum Flow
a
2 0
3 1
s 1 3 t
2 4
0 1
b
Maximum Flow
a
1 0
3 1
s 0 3 t
2 4
0 0
b
Maximum Flow
a
4/5 1/1
s 3/3 t
2/2 5/5
b
Ford-Fulkerson Algorithm
Ford-Fulkerson Algorithm
Ford-Fulkerson Algorithm
Ford-Fulkerson Algorithm
Idea:
While there exist augmenting paths,
increase flow along those.
Ford-Fulkerson Algorithm
Idea:
While there exist augmenting paths,
increase flow along those.
Ford-Fulkerson Algorithm
Initialization
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
· compute cr (pa )
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
· compute cr (pa )
· ∀(u, v ) ∈ pa
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
· compute cr (pa )
· ∀(u, v ) ∈ pa
f (u, v ) += cr (pa )
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
· compute cr (pa )
· ∀(u, v ) ∈ pa
f (u, v ) += cr (pa ) (forward arc)
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
· compute cr (pa )
· ∀(u, v ) ∈ pa
f (u, v ) += cr (pa ) (forward arc)
f (v , u) -= cr (pa )
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
· compute cr (pa )
· ∀(u, v ) ∈ pa
f (u, v ) += cr (pa ) (forward arc)
f (v , u) -= cr (pa ) (backward arc)
Ford-Fulkerson Algorithm
Initialization
∀(u, v ) ∈ E → f (u, v ) = 0
Augmentation
while ∃pa ∈ Gr (there exist augmenting paths)
· compute cr (pa )
· ∀(u, v ) ∈ pa
f (u, v ) += cr (pa ) (forward arc)
f (v , u) -= cr (pa ) (backward arc)
a
0/5 0/1
s 0/3 t
0/2 0/5
b
P P
f (s, t) = u∈V f (s, u) = u∈V f (u, t)
=0
a
1/5 1/1
s 0/3 t
0/2 0/5
b
P P
f (s, t) = u∈V f (s, u) = u∈V f (u, t)
=1
a
4/5 1/1
s 3/3 t
0/2 3/5
b
P P
f (s, t) = u∈V f (s, u) = u∈V f (u, t)
=4
a
4/5 1/1
s 3/3 t
2/2 5/5
b
P P
f (s, t) = u∈V f (s, u) = u∈V f (u, t)
=6
s 3/3 t
2/2 5/5
b
P P
f (s, t) = u∈V f (s, u) = u∈V f (u, t)
fmax (s, t) = 6
a
5 1
s 3 t
2 5
b
a
5 1
s 3 t
2 5
b
a
5 1
s 3 t
2 5
b
cmin (S, T ) = 5 + 1 = 6
Sören Wellhöfer Flow Networks
Introduction
Definitions Maximum Flow
Problems / Solutions Ford-Fulkerson Algorithm
References
a
4/5 1/1
s 3/3 t
2/2 5/5
b
Summary
Summary
Summary
Practical applications
• Pipe networks
Summary
Practical applications
• Pipe networks
• Traffic flow modeling
Summary
Practical applications
• Pipe networks
• Traffic flow modeling
• Commodity/Market flow
Summary
Practical applications
• Pipe networks
• Traffic flow modeling
• Commodity/Market flow
Flow Networks
05 — 08 — 2009
Sören Wellhöfer