Lec20 CS345
Lec20 CS345
CS345
Lecture 20
Analysis of Ford Fulkerson algorithm
(Max-Flow Min-Cut Theorem)
1
FORD FULKERSON ALGORITHM
2
Formal Description of Flow
2
𝒗 4 𝒙 =(, ) : a directed graph with
5 : source,
5 11 : sink
6 1 15
8 6 𝒕:
𝒔 7 1
(,) = capacity of edge (,)
7
7 14 7 17
3
Formal Description of Flow
2
𝒗 𝒙 =(, ) : a directed graph with
5 : source,
: sink
6 15
8 6 𝒕:
𝒔 (,) = capacity of edge (,)
7 14 7 17
𝒖 4 𝒚
Max-Flow Problem:
flow leaving Given a network =(,),
and two vertices ,,
find a flow from to of maximum value.
4
Residual network
5
Ford Fulkerson algorithm
Ford-Fulkerson-algo(,,)
{ ;
While (there is - path in ) do
{ Let be an - path in
Let be bottleneck capacity of ; Correctness of
the algorithm ?
For each (,) do
{ If (,) is a forward edge then
(,) (,) + ;
Else
(,) (,) - ;
}
} return ;
}
6
-CUTS
7
-cut
, with
,
𝒔 𝒕
𝑨 𝑨
𝑮
8
-cut
, with
,
=
{ | or }
𝒔 𝒕 Capacity of a cut:
=
𝑨 𝑨
𝑮
Note: capacity of only outgoing edges is
considered in capacity of a cut.
9
CUTS AND FLOWS
10
Useful Generalizations
conservation constraint:
For each vertex
12
Proof for =
𝒙
𝒔
𝒗
13
A SIMPLE RELATION
between
Flows and capacity of cuts
14
Flows and capacity of cuts
𝒔 𝒕
15
A DEEP RELATION
between
Flows and capacity of cuts
16
Max-Flow Min-Cut Theorem
Theorem: the maximum value of -flow is equal to the capacity of min -cut.
Based on
Ford Fulkerson Algorithm
17
Ford Fulkerson algorithm
Ford-Fulkerson-algo(,,)
{ ;
While (there is - path in ) do
{ Let be an - path in
Let be bottleneck capacity of ;
For each (,) do
Which is this cut defined by
{ If (,) is a forward edge then Ford Fulkerson algorithm?
(,) (,) + ;
Else
(,) (,) - ;
}
} return ;
}
18
Proof of max-flow min-cut Theorem
How does
: flow computed by Ford-Fulkerson algorithm. look like ?
𝒔 𝒕 𝒔 𝒕
𝑨 𝑨 𝑨 𝑨
𝑮 𝑮𝒇
Claim: = .
: set of vertices reachable from in
19
Proof of max-flow min-cut Theorem
𝒔 𝒕 𝒔 𝒕
𝑨 𝑨 𝑨 𝑨
𝑮 𝑮𝒇
=
Question: For to be equal to = , what must happen ?
Answer: 1. All out going edges must be fully saturated.
2. Every incoming edge must have zero flow. How will you
20
show this ?
Proof of max-flow min-cut Theorem
𝒙 𝒙
𝒔 𝒚 𝒕 𝒔 𝒚 𝒕
𝑨 𝑨 𝑨 𝑨
𝑮 𝑮𝒇
If <
must appear as forward edge in.
is reachable from .
A contradiction. 21
Proof of max-flow min-cut Theorem
𝒔 𝒙 𝒕 𝒔 𝒙 𝒕
𝒚 𝒚
𝑨 𝑨 𝑨 𝑨
𝑮 𝑮𝒇
If >
appears as a backward edge in .
is reachable from .
A contradiction. 22
Ford Fulkerson algorithm
Ford-Fulkerson-algo(,,)
{ ; Theorem: Ford Fulkerson algorithm
While (there is - path in ) do indeed computes the maximum - flow
upon termination of the While loop..
{ Let be an - path in
Let be bottleneck capacity of ;
For each (,) do
{ If (,) is a forward edge then
(,) (,) + ; Time complexity ?
Else
(,) (,) - ;
}
} return ;
}
23
Ford Fulkerson algorithm
Ford-Fulkerson-algo(,,)
{ ; This algorithm does not say anything about
While (there is - path in ) do the way has to be selected.
{ Let be an - path in
Let be bottleneck capacity of ;
For each (,) do it is up to us (or the adversary) to select so
as to force the execution of the algorithm to
{ If (,) is a forward edge then
take huge time
(,) (,) + ;
Else
We shall use the above idea
(,) (,) - ;
to show a bad example of a network with
} integer edge capacities.
} return ;
}
24
A worst case example for
networks with integer edge weights
𝑮 𝑮𝒇
𝒙 𝒙
1
1000 1000
1000 1000
𝒔 1 1 𝒕 𝒔 1 𝒕
1
1000 1000 1000 1000
𝒚 𝒚
25
A worst case example for
networks with integer edge weights
𝑮 𝑮𝒇
𝒙 𝒙
1
1 1
1000 999 1000
1000
𝒔 1 1 𝒕 𝒔 1 𝒕
1 1
1000 1000 1000 999
𝒚 𝒚
26
A worst case example for
networks with integer edge weights
𝑮 𝑮𝒇
𝒙 𝒙
1 1
1
2 1
1000 999
1000 999
𝒔 1 1 𝒕 𝒔 1 𝒕
1 12
1000 1000 999 999
1
1
𝒚 𝒚
The algorithm will run for 2000
iterations to compute max-flow ! 27
Theorem:
There are networks with integer edge capacities on which Ford-Fulkerson algo
may take () time, where is max-edge capacity.
28
INTEGRALITY OF MAX-FLOW
29
Integrality of max-flow
1.67 1
.67
1 1
1
𝒔 .33
0 .33
0
1
𝒕
1 1
30
Proof for Integrality theorem
Ford-Fulkerson-algo(,,) {
; Claim:
While (there is - path in ) do Ford Fulkerson algorithm computes a maximum
flow which is integral.
{ Let be an - path in Proof: (By induction on the no. of iteration)
Let be bottleneck capacity of ; Inductive Assertion:
For each (,) do At the end of th iteration, is integral.
{ If (,) is a forward edge then
(,) (,) + ; [Homework: give all details of the proof].
Else
(,) (,) - ; In fact, the statement can be shown to hold for
any flow (not necessarily max flow) whose
} value is an integer.
} return ;
}
31
A motivating application of
Integrality theorem Max Flow
ROUNDING OF A MATRIX
32
Rounding of a matrix
𝟏𝟏 𝟏𝟏. 𝟕 𝟏𝟐
Make sincere attempt to solve this problem. We shall discuss it after midsem. 33
A useful exercise
to internalize Ford Fulkerson algorithm
Execute Ford Fulkerson algorithm on
𝒙 this example when
• The first path selected for sending
the flow is <, , , >.
10 3 9
5
Show the execution of the iterations
of the algorithm along with the
𝒔 𝒕 residual network.
8
𝒖 10 𝒗 10
3 3
• What if the first path selected is
6
5 <, , , >.
Internalize the entire algorithm fully
through this example.
𝒚
34