0% found this document useful (0 votes)
27 views34 pages

Lec20 CS345

The document provides a detailed analysis of the Ford Fulkerson algorithm, which is used to solve the Max-Flow Min-Cut problem in directed graphs. It explains the formal description of flow, the concept of residual networks, and the algorithm's correctness and efficiency, highlighting its limitations in terms of time complexity for certain networks. Additionally, it discusses the integrality of maximum flow and its applications, including a rounding problem for matrices.

Uploaded by

97g2qsq26q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views34 pages

Lec20 CS345

The document provides a detailed analysis of the Ford Fulkerson algorithm, which is used to solve the Max-Flow Min-Cut problem in directed graphs. It explains the formal description of flow, the concept of residual networks, and the algorithm's correctness and efficiency, highlighting its limitations in terms of time complexity for certain networks. Additionally, it discusses the integrality of maximum flow and its applications, including a rounding problem for matrices.

Uploaded by

97g2qsq26q
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Design and Analysis of Algorithms

CS345

Lecture 20
Analysis of Ford Fulkerson algorithm
(Max-Flow Min-Cut Theorem)

1
FORD FULKERSON ALGORITHM

A simple path based algorithm


+
Residual Network

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

Flow :  such that


𝒖 4 𝒚 • For each edge (,)
flow leaving (,) (,)

• For each vertex

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

Let =(, ) be a network


: any valid - flow.

The residual network


Vertices of = ? 𝑽
Edges of = 𝑬 ?
𝒇

For each edge (,)


– If (,) < (,),
 edge (,) with capacity = ?
Forward edge (,) - (,)
– If (,) >
 edge (,) with capacity = ?
Backward edge (,)

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

𝒇 𝒊𝒏 (𝒖) 𝒇 𝒐𝒖𝒕 (𝒖)


𝒖
Mathematically,

𝒇 𝒊𝒏 (𝒖) 𝒇 𝒐𝒖𝒕 (𝒖)


Lemma: = 0 if
if
11
if
Useful Generalizations

Consider any valid flow . Question: How would you define ?

Question: What would be ?


Answer:
𝒔
Proof ?

12
Proof for =

Consider any valid flow . Proof :


= 𝒇 𝒐𝒖𝒕 ( 𝒔 ) − 𝒇 𝒊𝒏 ( 𝒔 )

𝒙
𝒔
𝒗

13
A SIMPLE RELATION

between
Flows and capacity of cuts

14
Flows and capacity of cuts

Consider any valid flow . Lemma: .


Proof:

𝒔 𝒕

𝑨 Theorem: the maximum value of -flow is


𝑨
bounded by the capacity of every -cut.
𝑮

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

: flow computed by Ford-Fulkerson algorithm.

𝒔 𝒕 𝒔 𝒕

𝑨 𝑨 𝑨 𝑨
𝑮 𝑮𝒇
=
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

: flow computed by Ford-Fulkerson algorithm.

𝒙 𝒙
𝒔 𝒚 𝒕 𝒔 𝒚 𝒕

𝑨 𝑨 𝑨 𝑨
𝑮 𝑮𝒇
If <
 must appear as forward edge in.
 is reachable from .
A contradiction. 21
Proof of max-flow min-cut Theorem

Consider the flow computed by Ford-Fulkerson algorithm.

𝒔 𝒙 𝒕 𝒔 𝒙 𝒕
𝒚 𝒚

𝑨 𝑨 𝑨 𝑨
𝑮 𝑮𝒇
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.

No. of bits required to store capacity = ? log 2 𝑪

 Ford-Fulkerson algorithm is not a polynomial time algorithm


even for networks with integer edge capacities 

28
INTEGRALITY OF MAX-FLOW

A useful tool for many applications of Max-Flow

29
Integrality of max-flow

Theorem: Given a network =(,), and two vertices ,,


if edge capacities are integers, then there exists a maximum -flow
which is “integral”.
for each

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
𝟏𝟏 𝟏𝟏. 𝟕 𝟏𝟐

Design an algorithm to round a matrix, if possible ?

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

You might also like