You are on page 1of 64

The Maximum Flow problem

Flow problem
Input
• Let G=(V,A) be a directed graph with capacities on
arcs
• V={v1,…,vn} is the vertex set
• A is the arc set
• Kij is the capacity associated with each arc (i,j) ∈ A
• Let s (=source) and t (=sink) be two distinct vertices in V
• A feasible flow is a vector x of dimension |A| that
contains a value xij for each arc (i,j) ∈ A such that:
• the flow originates in s and is collected in t
• the flow along each arc (i,j) ∈ A is not larger than the capacity
Kij

1
Maximum Flow (MF) problem
Input
• Let G=(V,A) be a directed graph with capacities on the
arcs
• V={v1,…,vn} is the vertex set
• A is the arc set
• Kij is the capacity associated with each arc (i,j) ∈ A
• Let s (=source) and t (=sink) be two distinct vertices in V
Objective
• Determine the maximum flow from s to t.

2
MF: applications
• Transportation: determine the maximum
number of vehicles that can travel on a given
network (detect bottleneck roads)
• Network design: compute the maximum
number of edge-disjoint paths between s and t
• MF is a subproblem of many more complex
optimization problems

3
MF: cut and capacity
• An s-t cut induces a partition (S, V\S) of the
vertex set such that s ∈ S and t ∈ V\S
• The capacity of an s-t cut is given by

• Observation: only arcs from S to V\S


contribute to the capacity value

4
MF: example

3
1 6
2 |V| = 6 vertices
2 1
2
|A| = 8 arcs
4 2
3 4
2
s=1, t=5
5 4

5
MF: solution

2,3
1 6
2,2 |V| = 6 vertices
2 1,1
2,2
|A| = 8 arcs
2,4 1,2
3 4
0,2 s=1, t=5
5 3,4

Flow value: 2+2+1=5


S={1,2,3} has capacity K(S) = 3+4+2=9
6
MF and Min-Cut
Observation: the maximum flow cannot be
larger than the capacity of any s-t cut

S V\S
t

Indeed, for any s-t cut, the flow that originates


in s and is collected in t must travers the s-t
cut from S to V\S using arcs that contribute to
the capacity value K(S).
7
MF and Min-Cut
Therefore, the maximum flow is smaller than or
equal to the capacity of the minimum s-t cut.

We will show (Ford-Fulkerson’s Theorem) that


there exists a flow with the same value of the
capacity of the minimum s-t cut, i.e., the
maximum flow is equal to the capacity of the
minimum s-t cut.

8
MF: ILP model
• Assume the graph is complete
• Possibly add non-existing arcs and set a zero-
capacity for these arcs
• Decision variables

9
MF: ILP model
(maximize the flow)

(all flow goes from s to t,


flow conservation on the
intermediate vertices)

(flow on each arc cannot


be negative and cannot
be larger than the arc
capacity)

10
Ford-Fulkerson’s Theorem
Let G=(V,A) be a graph with capacities Kij,
source s and sink t.
The value of the maximum flow from s to t is
equal to the capacity of the minimum s-t cut.

11
Ford-Fulkerson’s Theorem
Proof:
The maximum flow cannot obviously be
greater than the capacity of any s-t cut. We
show through a constructive proof that there
exists a flow equal to the capacity of the
minimum s-t cut.

12
Ford-Fulkerson’s Theorem
Proof (cont’d):
Let x be a feasible flow in G and let us try to
determine an s-t cut by this procedure:

𝑆= 𝑠 ;
while ∃ 𝑖 ∈ 𝑆 and j ∉ 𝑆: 𝑥𝑖𝑗 < 𝐾𝑖𝑗 or 𝑥𝑗𝑖 > 0
do 𝑆 ≔ 𝑆 ∪ {𝑗}

When the procedure terminates, we can have two


cases: 𝑡 ∈ 𝑆 or 𝑡 ∉ 𝑆.
13
Ford-Fulkerson’s Theorem
Proof (cont’d):
CASE 1 (𝒕 ∈ 𝑺): Therefore, there is a sequence of arcs from s
to t. This sequence is called an augmenting chain (because it
allows increasing the flow) and can be made of both:
1. forward arcs: a forward arc is directed in the same direction
of the corresponding arc in G
2. backward arcs: a backward arc is directed in the opposite
direction of the corresponding arc in G.

By construction based on the procedure,


the forward arcs 𝑖, 𝑗 satisfy that with 𝑥𝑖𝑗 < 𝐾𝑖𝑗 and
the backward arcs (𝑘, 𝑙) satisfy that 𝑥𝑘𝑙 > 0.
14
Ford-Fulkerson’s Theorem
Proof (cont’d):
We define:
𝛿1 = min{ 𝐾𝑖𝑗 − 𝑥𝑖𝑗 : 𝑖, 𝑗 forward arc}
𝛿2 = min{𝑥𝑘𝑙 : 𝑘, 𝑙 backward arc}
𝛿 = min{𝛿1 , 𝛿2 }
By adding 𝛿 to the flow of each forward arc and by subtracting
𝛿 from each backward arc, we obtain a new flow 𝑥 with value
increased by 𝛿.

15
Ford-Fulkerson’s Theorem
Proof (cont’d):
This flow is feasible:
1. it satisfies 0 ≤ 𝑥𝑖𝑗 ≤ 𝐾𝑖𝑗 , for every arc 𝑖, 𝑗 ∈ 𝐴 by definition
of 𝛿: indeed, 𝑥 is increased on each forward arc (𝑖, 𝑗) by at most
the residual capacity 𝐾𝑖𝑗 − 𝑥𝑖𝑗 and 𝑥 is decreased on each
backward arc 𝑘, 𝑙 by at most the current flow value 𝑥𝑘𝑙 .
2. it satisfies:

as shown in the next slide.

16
Ford-Fulkerson’s Theorem
Proof (cont’d):
Flow conservation for a vertex 𝑖 in the augmenting chain
+δ +δ
i

-δ +δ
i

-δ -δ
i

+δ -δ
i

17
Ford-Fulkerson’s Theorem
Proof (cont’d):
We have thus found a new flow with value increased by 𝛿.
Hence, we have not yet found an s-t cut. We repeat the
procedure to find a new augmenting chain, until we end in
CASE 2.

18
Ford-Fulkerson’s Theorem
Proof (cont’d):
CASE 2 (𝒕 ∉ 𝑺): Therefore, we have found an s-t cut. This
means that the procedure has terminated because of the two
control conditions in the while loop, hence:
𝑥𝑖𝑗 = 𝐾𝑖𝑗 ∀ 𝑖, 𝑗 : 𝑖 ∈ 𝑆, 𝑗 ∉ 𝑆
𝑥𝑘𝑙 = 0 ∀ 𝑘, 𝑙 : 𝑘 ∉ 𝑆, 𝑙 ∈ 𝑆
The flow value is:
𝑥𝑖𝑗 − 𝑥𝑘𝑙 = 𝐾𝑖𝑗
𝑖,𝑗 :𝑖∈𝑆,𝑗∉𝑆 𝑘,𝑙 :𝑘∉𝑆,𝑙∈𝑆 𝑖,𝑗 :𝑖∈𝑆,𝑗 ∉ 𝑆

This is the value of an s-t cut, hence it is optimal.


19
Ford-Fulkerson’s algorithm
Outline:
Start with a feasible flow (e.g. 𝑥 = 0).
Iteratively increase the flow by augmenting chains.
When no augmenting chain exists, then the flow is
maximum.

In the execution of the algorithm, in order to find augmenting


chains, we iteratively assign to each vertex 𝑣𝑖 a label:
[+𝑣𝑘 , 𝛿(𝑣𝑖 )] if the flow 𝑥𝑘𝑖 along arc (𝑣𝑘 , 𝑣𝑖 ) can be increased
[−𝑣𝑘 , 𝛿(𝑣𝑖 )] if the flow 𝑥𝑖𝑘 along arc (𝑣𝑖 , 𝑣𝑘 ) can be decreased
where 𝛿(𝑣𝑖 ) is the maximum flow that can be sent from s to 𝑣𝑖
20
Ford-Fulkerson’s algorithm
In particular, we start by labelling the source with [+𝑠, +∞].
Then, iteratively, from each labelled vertex 𝑣𝑖 with label
±𝑣𝑘 , 𝛿 𝑣𝑖 , we label each unlabelled vertex 𝑣𝑗 connected with
𝑣𝑖 as follows:
• If 𝑣𝑗 ∈ Γ + (𝑣𝑖 ) and 𝑥𝑖𝑗 < 𝐾𝑖𝑗 the label of 𝑣𝑗 is
[+𝑣𝑖 , min 𝛿 𝑣𝑖 , 𝐾𝑖𝑗 − 𝑥𝑖𝑗 ]
• If 𝑣𝑗 ∈ Γ − (𝑣𝑖 ) and 𝑥𝑗𝑖 > 0 the label of 𝑣𝑗 is
[−𝑣𝑖 , min 𝛿 𝑣𝑖 , 𝑥𝑗𝑖 ]
Vertex 𝑣𝑖 is then marked as explored.

We repeat the labelling until either 𝑡 is explored (i.e., we have


found an augmenting chain) or no vertex can be labelled (we
have found an s-t cut and hence the maximum flow).
21
Ford-Fulkerson’s algorithm
begin
for i:=1 to n do
for j:=1 to n do xij := 0;
opt := false;
while opt = false do
begin
label s with [+s,+];
repeat //find an augmenting chain
let vi labeled [ vk ,  (vi)] and not explored
for each vj +(vi) : vj not lableled and xij  Kij do
label vj as [+vi , min( (vi) , Kij – xij )];
for each vj –(vi) : vj not labelled and xji  0 do
label vj as [–vi , min( (vi) , xji )];
mark vi as explored;
until t is labeled or no vertex can be labeled

22
Ford-Fulkerson’s algorithm
if t not labeled
then opt := true
else begin //increase the flow
* :=  ( t ); p := t;
repeat
if label of p is [+y ,  (p)]
then xyp := xyp + *
else xpy := xpy – * ; (i.e. [–y ,  (p)] )
p = y;
until p = s;
delete all labels
end;
end; //min s-t cut: 𝑆 = {𝑙𝑎𝑏𝑒𝑙𝑙𝑒𝑑 𝑣𝑖 }
end.

23
Example
Capacities are shown in the
circles. Find the maximum flow
v5
2
v6 from 𝑠 to 𝑡.
4
1 1
2
2
s t
2 2
v1 v2 v3 v7
2
1
2
1
v4

24
Initialization

2
v5 v6
4
1 1
2
2
s t
2 2
v1 v2 v3 v7
2
1
2 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0
v4 xij = 0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

25
First iteration (1)

2
v5 v6
4
1 1
2
2
s t
2 2
v1 v2 v3 v7
2
[+s,] 1
2 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0
v4 xij = 0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

26
First iteration (1)
[+v1,2]
2
v5 v6
4
1 1
2
2
s [+v1,2] t
2 2
v1 v2 v3 v7
2
[+s,] 1
2 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0
v4 xij = 0 0 0 0 0 0 0
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

27
First iteration (1)
At each iteration choose vertex vi
[+v1,2] labeled and not explored with
2 minimum index
v5 v6
4
1 1
2
2
s [+v1,2] t
2 2
v1 v2 v3 v7
2
[+s,] 1
2 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0
v4 xij = 0 0 0 0 0 0 0
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

28
First iteration (2)
[+v1,2] [+v2,2]
2
v5 v6
4
1 1
2
2
s [+v1,2] t
2 2
v1 v2 v3 v7
2
[+s,] 1 [+v2,2]
2 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0
v4 xij = 0 0 0 0 0 0 0
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

29
First iteration (3)
[+v1,2] [+v2,2]
2
v5 v6
4
1 1
2
2
s [+v1,2] t
2 2
v1 v2 v3 v7
2
[+s,] 1 [+v2,2] [+v3,2]
2 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0
v4 xij = 0 0 0 0 0 0 0
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

30
First iteration (4)
[+v1,2] [+v2,2]
2
v5 v6
4
1 1
2
2
s [+v1,2] t
2 2 2 2
v1 v2 v3 v7
2 2
[+s,] 1 [+v2,2] [+v3,2]
2 0 20 0 0 0 0 0 * = 2
1 0 0 20 0 0 0 0
0 0 0 0 0 0 20
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

31
First iteration (5)

2
v5 v6
4
1 1
2
2
s t
2 2 2 2
v1 v2 v3 v7
2 2
1
2 0 2 0 0 0 0 0 * = 2
1 0 0 2 0 0 0 0
0 0 0 0 0 0 2
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

32
Second iteration (1)
[+v1,2]
2
v5 v6
4
1 1
2
2
s t
2 2 2 2
v1 v2 v3 v7
2 2
[+s,] 1
2 0 2 0 0 0 0 0 * = 2
1 0 0 2 0 0 0 0
0 0 0 0 0 0 2
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

33
Second iteration (2)
[+v1,2]
2
v5 v6
4
1 1
2
2
s t
2 2 2 2
v1 v2 v3 v7
2 2
[+s,] 1 [+v4,1]
2 0 2 0 0 0 0 0 * = 2
1 0 0 2 0 0 0 0
0 0 0 0 0 0 2
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

34
Second iteration (3)
[+v1,2]
2
v5 v6
4
1 1
2
2
s [–v3,1] t
2 2 2 2
v1 v2 v3 v7
2 2
[+s,] 1 [+v4,1]
2 0 2 0 0 0 0 0 * = 2
1 0 0 2 0 0 0 0
0 0 0 0 0 0 2
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

35
Second iteration (4)
[+v1,2] [+v2,1]
2
v5 v6
4
1 1
2
2
s [–v3,1] t
2 2 2 2
v1 v2 v3 v7
2 2
[+s,] 1 [+v4,1]
2 0 2 0 0 0 0 0 * = 2
1 0 0 2 0 0 0 0
0 0 0 0 0 0 2
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

36
Second iteration (5)
[+v1,2] [+v2,1]
2
v5 v6
4
1 1
2
2
s [–v3,1] t
2 2 2 2
v1 v2 v3 v7
2 2
[+s,] 1 [+v4,1]
2 0 2 0 0 0 0 0 * = 2
1 0 0 2 0 0 0 0
0 0 0 0 0 0 2
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

37
Second iteration (6)
[+v1,2] [+v2,1]
2
v5 v6
4
1 1
2
2
s [–v3,1] t
2 2 2 2
v1 v2 v3 v7
2 2
[+s,] 1 [+v4,1] [+v6,1]
2 0 2 0 0 0 0 0 * = 2
1 0 0 2 0 0 0 0
0 0 0 0 0 0 2
v4 xij = 0 0 0 0 0 0 0
flow = 2
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 0
0 0 0 0 0 0 0

38
Second iteration (7)
[+v1,2] [+v2,1]
2
v5 v6
4 1
1 1
2
2 1
s [–v3,1] t
2 2 2 2
v1 v2 v3 v7
2 2
1 [+v4,1] [+v6,1]
[+s,] 1
2 1 0 2 0 10 0 0 0 * = 1
1 1 0 0 12 0 0 10 0
0 0 0 0 0 0 2
v4 xij = 0 0 10 0 0 0 0
flow = 2+1
0 0 0 0 0 0 0
[+v1,2] 0 0 0 0 0 0 10
0 0 0 0 0 0 0

39
Second iteration (8)

2
v5 v6
4 1
1 1
2
2 1
s t
2 2 2 2
v1 v2 v3 v7
2 1
1
2 1 0 2 0 1 0 0 0 * = 1
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3
0 0 0 0 0 0 0
0 0 0 0 0 0 1
0 0 0 0 0 0 0

40
Third iteration (1)
[+v1,2]
2
v5 v6
4 1
1 1
2
2 1
s t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1
2 1 0 2 0 1 0 0 0 * = 1
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3
0 0 0 0 0 0 0
[+v1,1] 0 0 0 0 0 0 1
0 0 0 0 0 0 0

41
Third iteration (2)
[+v1,2]
2
v5 v6
4 1
1 1
2
2 1
s t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1
2 1 0 2 0 1 0 0 0 * = 1
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3
0 0 0 0 0 0 0
[+v1,1] 0 0 0 0 0 0 1
0 0 0 0 0 0 0

42
Third iteration (3)
[+v1,2] [+v5,2]
2
v5 v6
4 1
1 1
2
2 1
s [+v5,1] t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1
2 1 0 2 0 1 0 0 0 * = 1
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3
0 0 0 0 0 0 0
[+v1,1] 0 0 0 0 0 0 1
0 0 0 0 0 0 0

43
Third iteration (4)
[+v1,2] [+v5,2]
2
v5 v6
4 1
1 1
2
2 1
s [+v5,1] t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1 [+v2,1]
2 1 0 2 0 1 0 0 0 * = 1
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3
0 0 0 0 0 0 0
[+v1,1] 0 0 0 0 0 0 1
0 0 0 0 0 0 0

44
Third iteration (5)
[+v1,2] [+v5,2]
2
v5 v6
4 1
1 1
2
2 1
s [+v5,1] t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1 [+v2,1]
2 1 0 2 0 1 0 0 0 * = 1
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3
0 0 0 0 0 0 0
[+v1,1] 0 0 0 0 0 0 1
0 0 0 0 0 0 0

45
Third iteration (6)
[+v1,2] [+v5,2]
2
v5 v6
4 1
1 1
2
2 1
s [+v5,1] t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1 [+v2,1] [+v6,2]
2 1 0 2 0 1 0 0 0 * = 1
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3
0 0 0 0 0 0 0
[+v1,1] 0 0 0 0 0 0 1
0 0 0 0 0 0 0

46
Third iteration (7)
[+v1,2] [+v5,2]
2 2
v5 v6
4 1
2 1 3
2 1
2 1
s [+v5,1] t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1 [+v2,1] [+v6,2]
2 1 0 2 0 1 20 0 0 * = 2
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 3+2
0 0 0 0 0 20 0
[+v1,1] 0 0 0 0 0 0 31
0 0 0 0 0 0 0

47
Third iteration (8)

2 2
v5 v6
4 3
2 1
2 1
2 1
s t
2 2 2 2
v1 v2 v3 v7
2 1
1
2 1 0 2 0 1 2 0 0 * = 2
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 5
0 0 0 0 0 2 0
0 0 0 0 0 0 3
0 0 0 0 0 0 0

48
Fourth iteration

2 2
v5 v6
4 3
2 1
2 1
2 1
s t
2 2 2 2
v1 v2 v3 v7
2 1
[+s,] 1
2 1 0 2 0 1 2 0 0 * = 2
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 5
0 0 0 0 0 2 0
[+v1,1] 0 0 0 0 0 0 3
0 0 0 0 0 0 0

49
Optimal solution
Arcs in the s-t cut are saturated (flow equal to the capacity)
2 2
s-t cut v5 v6
4 3
2 1
1
2 V1 =v1 , v4 
2 1
s t
2 2 2 2 V2 =v2 , v3 , v5 , v6 , v7 
v1 v2 v3 v7
2 1
[+s,] 1
2
1
0 2 0 1 2 0 0 * = 2
1 1 0 0 1 0 0 1 0
0 0 0 0 0 0 2
v4 xij = 0 0 1 0 0 0 0
flow = 5
0 0 0 0 0 2 0
[+v1,1] 0 0 0 0 0 0 3
0 0 0 0 0 0 0

50
Example
Capacities are shown in the circles. Find
the maximum flow from 𝑠 to 𝑡.
5 7
v1 v3 v6 t

6 4
9
9
s

9 3
v2 v4 v5

51
iteration 1

[+s,9] [+v1,5] [+v3,5]


5 5 7 5
v1 v3 v6 t

5
6 4
9
[+s,] 9
* = 5
s
flow = 5

9 3
v2 v4 v5
[+s,9] [+v2,9] [+v1,6]

52
iteration 2

[+s,4] [+v4,4] 7 [+v3,2]


5 5 7 5
v1 v3 v6 t

5
6 4
9
[+s,] 2 9
* = 2
s
flow = 5 + 2

9
2
9 2 3
v2 v4 v5
[+s,9] [+v2,9] [+v1,4]

53
iteration 3

[+s,4] [+v4,2] [+v5,4]


5 5 7 7
v1 v3 v6 t
9
5
6 4
9
[+s,] 4 2 9
* = 4
s 4
flow = 7 + 4

9
2
9 2 3
v2 v4 v5
[+s,7] [+v2,7] [+v1,4]

54
iteration 4

[–v3,2] [+v4,2] [+v5,3]


5 5 7 7
v1 v3 v6 t

9
6 4
9
[+s,] 4 2 9
7 * = 3
s 4
flow = 11 + 3

9
2 5
5 9 2 3 3
v2 v4 v5
[+s,7] [+v2,7] [+v4, 3]

55
iteration 5

[–v3,2] 3 [+v4,2] [+v5,2]


5 5 7 7
v1 v3 v6 t

9
6 4
9 4
[+s,] 4 2 9
6
9 * = 2
s 7
flow = 14 +2

9
5 7
7 9 5 3 3
v2 v4 v5
[+s,4] [+v2,4] [+v1,2]

56
iteration 6

s-t cut 5 3 7 7
v1 v3 v6 t
9
6 4
9
[+s,] 6 4 9
s 9
flow = 16

9
7
9 7 3 3
v2 v4 v5
[+s,2] [+v2,2]

57
Other flow problems:
Multiple sources and sinks
Given:
G=(V, A) with capacity Kij
S, T  V S  T = 
send the maximum flow from the set S of
sources to the set T of sinks

58
Solution
Create a new graph G’=(V’, A’) :
V’  V   vs , vt 
A’  A   (vs , vi) : vi  S    (vj , vt) : vj  T 

S G

vs vt

59
Solution (cont’d)
If no additional constraint is given, set the
capacity of the additional arcs as:
Ksi = Kjt = +   i, j
otherwise:
Ksi = Production limit of source vi
Kjt = Storage limit of sink vj

To solve the problem, we can compute the


maximum flow from vs to vt

60
Other flow problems:
Capacity on the vertices
Given:
G=(V, A) with Kij = capacity of arc (vi ,vj)
pi = capacity of vertex vi
s, t  V
send the maximum flow from s to t satisfying
the additional constraint:

x
vk–(vi)
ki  pi  vi  V
total flow entering vi
must be  pi ,  viV
61
Solution
Create a new graph G’=(V’, A’  A”) :
V’   vi+ : vi  V    vi– : vi  V 
A’   (vi– , vj+ ) : (vi , vj)  A  with capacity of (vi– , vj+ ) = Kij
A”   (vi+ , vi– ) : vi  V  with capacity of (vi+ , vi– ) = pi
p2 p2
v2 v2 + v2–
K12 K24 K12 K24
p1 p1 p4
K23 – K23
s t s+ s t+ t–
p4
K13 K34 K13 K34
v3 v3+ v3–
p3 p3

62
Solution (cont’d)
Since the total flow entering vertex vi+
must travers arc (vi+ , vi– ), then the new
capacity constraint is satisfied for every
vertex.

To solve the problem, we can compute


the maximum flow from s+ to t –

63

You might also like