Professional Documents
Culture Documents
nf04__maximum_flows-4965
nf04__maximum_flows-4965
Network Flows
UPCOPENCOURSEWARE number 34414
F.-Javier Heredia
MFP- 4
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS
i
2 • Residual capacity of the s-t cut, r[S,S] :
rij s 1 sum of the residual capacities of the
2 1 4 t
forward arcs in the cut (S,S) :
j 3 – S={1,2} , S={3,4}, (i,j)∈(S,S) = {(2,3)}
G(x) – r[S,S] = 2
v≤ ∑u ij = u[S , S ]
( i , j )∈( S , S )
(10,25)
(10,20)
1 2 (0,5) 7 i j
(2,4)
3 6
(3,6)
Find:
– Four s-t cuts, each one with 4 forward arcs, indicating their
capacity, residual capacity and the flow across the cut.
– Represent the residual graph G(x) and indicating two
MFP- 8
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS
1 3 4
uij
i j
2 rij 2
i j
1 3 4 1 3 4
3 3
MFP- 11
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS
MFP- 14
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS
Ford-Fulkerson
Ford-FulkersonAlgorithm: convergence(II).
Algorithm: convergence (II).
• Max-Flow Min-Cut Theorem:
“The maximum flow between the source node s and
the sink node t in a capacited network is equal to the
minimum capacity among all s-t cuts.”
• Augmenting Path Theorem:
“A flow x* is a maximun flow if and only if the
residual network G(x*) contains no augmenting
path.”
• Integrality Theorem:
“If all arc capacities are integer, the maximum flow
MFP- 15
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS
Ford-Fulkerson
Ford-FulkersonAlgorithm:
Algorith: complexity.
complexity.
• Worst-case complexity: we compute an upper bound of
the number of iterations of Ford-Fulkerson:
– Calculation of the augmenting path: each augmentation visits
each arc at most once, and therefore the cost is O(m).
– Number of augmenting paths:
If all capacities are integer and bounded by U, then the capacity
of the cut (s,N-{s}) is ≤ nU, and the maximum flow is ≤ nU.
The algorithm increase the flow at least one unit in any
augmentation, i.e., then the number of augmentations is ≤ nU.
• Theorem 4.2:
MFP- 17
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS Shortest augmenting path algorithm (1)
Distance Labels
MFP- 18
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS Shortest augmenting path algorithm
P has k
d(i) ≤ k d(j) ≤ k-1 … d(h) ≤ 2 d(l) ≤ 1 0 arcs
i j … t
MFP- 20
F.-Javier Heredia http://gnom.upc.edu/heredia
MEIO/UPC-UB : NETWORK FLOWS Shortest augmenting path algorithm
2 4
s 4 t
3 2
1
3
This is the original network, and
the original residual network.
Initialize Distances
4
5 2 5
1
3 1 1 1
4
2 4
3
s
2 4
1 0t
2 2 s 3 2
1
1 3 4 5
0 t 3
1
MFP- 25
F.-Javier Heredia http://gnom.upc.edu/heredia 25
MEIO/UPC-UB : NETWORK FLOWS
3 2 4
s
2 4
1 0t
2 2 s 3 2
1
1 3 4 5
0 t 3
1
An arc (i,j) is admissible if d(i) = d(j) + 1.
MFP- 26
F.-Javier Heredia http://gnom.upc.edu/heredia 26
MEIO/UPC-UB : NETWORK FLOWS
3 22 44
s
2 4
1 0t
2 2 s 3 2
1
1 3 4 5
0 t 3
1
5 2 5
1
3 1 1 1
4
2 2
4
3
s
2 4
1 2 0t
2 2 s 3 2
1
1 3 4 5
0 t 3
1
MFP- 28
F.-Javier Heredia http://gnom.upc.edu/heredia 28
MEIO/UPC-UB : NETWORK FLOWS
5
2 5
1
3 1 1 1
4
2 2
4
3
s
2 4
1 2 0t
2 2 s 3 2
1
1 3 4 5
0 t 3
1
5 2 5
1
3 1 1 1
4
2 2
4
3
s
2 4
1 2 0t
2 2 s 1
1
1 3 4 5 2 2
0 t 3
1
MFP- 30
F.-Javier Heredia http://gnom.upc.edu/heredia 30
MEIO/UPC-UB : NETWORK FLOWS
3 2 2
4
s
2 4
1 2 0t
2 2 s 1
1
1 3 4 5 2 2
0 t 3
1
Start with s and do a depth first search using admissible arcs.
3 2 2
4
s
2 4
1 2 0t
2 2 s 3 1
1
1 4 5 2 2
0 t 3
1
2
Start with s and do a depth first search using admissible arcs.
5 2 5
1
3 1 1 1
4
2 2
4
3 s
s
2
3 4
1 2 0t
2 2 s 3 1
1
1 4 5 2 2
0 t 3
1
2
Start with s and do a depth first search using admissible arcs.
5 2 5
1
3 1 1 1
4
2 2
4
3 s
s
2
3 4
1 2 0t
2 2 3 1
1
1 4 5 2 2
0 t 3
1
2
Continue the path from where it left off.
5
2 1 5
1
2 1 1 1
4 1
2 2
4
3 s
s
2
3 4
1 2 0t
2 2 3 1
1
1 4 5 2 2
0 t
3
2
1
MFP- 35
F.-Javier Heredia http://gnom.upc.edu/heredia 35
MEIO/UPC-UB : NETWORK FLOWS
5 2 1 5
1
2 1 1 1
4 1
2 2
4
3 s
s
2
3 4
1 2 0t
2 2 3 1
1
1 4 5 2 2
0 t 3
2
1
Search for a shortest s-t path starting from s
MFP- 36
F.-Javier Heredia http://gnom.upc.edu/heredia 36
MEIO/UPC-UB : NETWORK FLOWS
5 2
3 1 5
1
2
2 1 1 1
4 1
2 2
4
3 s 2
s
2
3 4
1 2 0t
2 2 3 5 1
1
1 4 5 2 2
0 t 3
2
1
Search for a shortest s-t path starting from s
MFP- 37
F.-Javier Heredia http://gnom.upc.edu/heredia 37
MEIO/UPC-UB : NETWORK FLOWS
5 2
3 1 5
2
1
2 1 1 1
4 1
2 2
4
3 s 2
s
2
3 4
1 2 0t
2 3 5 1
1
1 4 5 2 2
0 t 3
1
2
Search for a shortest s-t path starting from s
MFP- 38
F.-Javier Heredia http://gnom.upc.edu/heredia 38
MEIO/UPC-UB : NETWORK FLOWS
5 2
3 1 5
2
1
2 1 1 1
4 1
2 1
4
3 s 2
s
2
3 4
1 3 0t
2 3 5
1
1 4 5 3 2
0 t 3
2
1
MFP- 39
F.-Javier Heredia http://gnom.upc.edu/heredia 39
MEIO/UPC-UB : NETWORK FLOWS
5 2
3 1 5
1
2
2 1 1 1
4 s 1
2 1
4
3 s 2
s
2
4
3 4
1 3 0t
2 3 5
1
1 4 5 3 2
0 t 3
2
1
5 2
3 2 5
2
1
1 1 1
4 s 2 1
3 2 2
s
2
4
3 4
1 4 0t
2 3 5
1
1 4 5 3 2
0 t 3
2
1
MFP- 41
F.-Javier Heredia http://gnom.upc.edu/heredia 41
MEIO/UPC-UB : NETWORK FLOWS
5 2 2
3
5 2 5
1
2
4
1 1 1
4 s 5 2 1
3 2 2
s
2
3
4
6 4
1 4 0t
2 3 5
1
1 4 5 3 2
0 t 3
2
1
5 2 2
3
5 2 5
2
1
4
1 1 1
4 5 2 1
3 2 2
s
2
4
3
6 4
1 4 0t
2 3 5
1
1 4 5 3 2
0 t 3
2
1
• Convergence:
– Lemma 4.1: “The SAPA maintains valid distance labels at each step.
Moreover, each relabel operation strictly increases the distance label
of a node”
– Theorem 4.3: “The SAPA correctly computes a maximum flow”
Rationale: The SAPA terminates when d(s)>n+1 ⇒ the network contains no
augmenting path s→t (Prop. 7.2). Consequently, the flow x is a max. flow.
• Complexity :
– We can determine each augmentation in O(n).
– The total time to maintain and update all distance labels is O(nm).
– The total number of augmentations is O(nm).
– Conclusion. The total running time is O(n2m).
Alg. Ford-Fulkerson
Ford-Fulkerson : exercicis
Algorithm : exercises(II).
(II).
• The following exercises will be assigned to:
– 6.1(), 6.2 (), 6.3 (), 6.5 (), 6.16 (), 6.32 ().
• Each one represent an application of the MFP.
Tasks to complete:
– MFP formulation.
– If the statement does not define the MFP, formulate
the problem with a topology of the network and its
respective costs.
– Solve numerically with any software the MFP
formulated.