Академический Документы
Профессиональный Документы
Культура Документы
How to do it...
Why you want it...
Where you find it...
Flow Networks
Flow Network:
- digraph
- weights, called capacities on edges
- two distinguishes vertices, namely
- Source, s:
Vertex with no incoming edges.
- Sink, t:
Vertex with no outgoing edges.
2
2
Source
s
1
3
2
2
2
4
1
t
Sink
Maximum Flow
Maximum Flow
flow(u,v) = flow(v,w)
uin(v)
wout(v)
-Value of flow:
uin(t)
Note:
- means for all
- in(v) is the set of vertices u such that there is and
edge from u to v
- out(v) is the set of vertices w such that there is an
edge from v to w
Maximum Flow
11
2
2
2
1
2
1
2
2
Source
s
11
22
t
Sink
3
2
2
1
21
4
0
1
1
Maximum Flow
Augmenting Flow
2
2
2
1
s
1
1
t
2
1
2
2
s
2
2
1
0
2
2
Augmenting
path
t
2
2
2
2
s
1
0
t
2
2
2
2
Maximum Flow
Augmenting Path
Forward Edges
flow(u,v) < capacity(u,v)
flow can be increased!
v
u
Backward Edges
flow(u,v) > 0
flow can be decreased!
v
u
Maximum Flow
Maximum Flow
Maximum Flow
Maximum Flow
s
1
0
t
s
1
1
t
s
1
1
t
2
0
2
0
2
0
2
1
2
0
2
1
10
Maximum Flow
s
1
1
t
s
1
0
t
s
1
0
t
2
1
2
2
2
2
2
2
2
2
2
2
11
Residual Network
Residual Network Nf = (V, Ef, cf, s, t)
N
Nf
v
f(u,v)
c(u,v)
cf(u,v)=c(u,v)f(u,v)
v
u
cf(v,u)=f(u,v)
s
1
1
t
2
1
2
2
s
2
1
1
t
1
Augmenting paths can be found performing a
depth-first search on the residual network Nf
Maximum Flow
12
Maximum Flow
13
O( F (n + m) )
where F is the maximum flow value, n is the
number of vertices, and m is the number of edges
The problem with this algorithm, however, is that it
is strongly dependent on the maximum flow value F.
For example, if F=2n the algorithm may take
exponential time.
Then, along came Edmonds & Karp...
Maximum Flow
14
O((n + m) n m) =
5
O(n )
Note:
- Edmonds & Karp algorithm runs in time O(n5)
regardless of the maximum flow value.
- The worst case usually does not happen in
practice.
Maximum Flow
15
CUTS
What is a cut ?
a)a skin-piercing laceration
b)sharp lateral movement
c)opposite of paste
d)getting dropped from the team
e)frontsies on the lunch line
f)common CS16 attendence phenomenon
g)line of muscular definition
h)Computer Undergraduate Torture (e.g., CS16,
Roberto Tamassia, dbx, etc.)
i)a partition of the vertices X=(Vs,Vt), with s Vs
and t Vt
The answer is:
j)all of the above...but for the educational purposes,
well use choice i)
Maximum Flow
16
What Is A Cut?
Vs
2
4
Source
s
6
Vt
2
4
2
8
t
Sink
Maximum Flow
17
Vs
41
62
11
40
22
83
Vt
20
1 1
6 3
73
t
Sink
18
Vs
41
62
11
40
22
83
Vt
20
1 1
6 3
73
t
Sink
19
t
X
Maximum Flow
20