0% found this document useful (0 votes)
66 views21 pages

Advanced Algorithm Design and Analysis (Lecture 8) : SW5 Fall 2004

Uploaded by

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

Advanced Algorithm Design and Analysis (Lecture 8) : SW5 Fall 2004

Uploaded by

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

Advanced Algorithm

Design and Analysis (Lecture 8)


SW5 fall 2004
Simonas altenis
E1-215
simas!cs"aau"d#
AALG, lecture 8, Simonas
altenis, 2004
2
Maximum flow

Main goals of the lecture:

to understand ho$ %lo$ net$or#s and


ma&imum %lo$ 'rolem can e formalized(

to understand the Ford-Fulkerson method and


to e ale to 'rove that it $or#s correctly(

to understand the Edmonds-Karp algorithm


and the intuition ehind the analysis o% its
$orst-case running time"

to e ale to a''ly the )ord-)ul#erson method


to solve the maximum-bipartite-matching
'rolem"
AALG, lecture 8, Simonas
altenis, 2004
3
Flow networks

*hat i% $eights in a gra'h are ma&imum


ca'acities o% some %lo$ o% material?

Pipe network to transport flui !e"g"# water# oil$


% &ges ' pipes# (ertices ' )unctions of pipes

*ata communication network


% &ges ' network connections of ifferent capacit+#
(ertices ' routers !o not prouce or consume ata
)ust mo(e it$

,oncepts !informall+$:
% Source (ertex s !where material is prouce$
% Sink (ertex t !where material is consume$
% For all other (ertices ' what goes in must go out
% +oal, ma&imum rate o% material %lo$ %rom source to
sin#
AALG, lecture 8, Simonas
altenis, 2004
4
Formali-ation

-o$ do $e %ormali.e %lo$s?

.raph +/!01E$ ' a flow network


% *irecte# each ege has capacity c!u1v$ 0
% /wo special (ertices: source s1 an sink t
% For an+ other (ertex v1 there is a path s2v2t

Flow ' a function % : 0 0 R


% 3a'acity constraint: For all u1 v 0: %!u1v$ c!u1v$
% S#e$ symmetry: For all u1 v 0: %!u1v$ 0 '%!v1u$
% )lo$ conservation, For all u 0 ' 1s1 t2:
, or ( , ) ( , ) 0
( , ) ( , ) 0
v V
v V
f u v f u V
f v u f V u

= =
= =

AALG, lecture 8, Simonas


altenis, 2004
5
,ancellation of flows

Do $e $ant to have 'ositive %lo$s going in


oth directions et$een t$o vertices4

3o4 such flows cancel !ma+5e partiall+$ each


other

Skew s+mmetr+ ' notational con(enience


67
66
5
4
65
60
64
68
7
s
t 8
a
c d
2 5
7
7
9
9
67
66
5
4
65
60
64
68
7
s
t 8
a
c d
7
7
7
9
9
AALG, lecture 8, Simonas
altenis, 2004
6
Maximum flow

*hat do $e $ant to ma&imi.e?

Value of the flow %:


( , ) ( , ) ( , )
v V
f f s v f s V f V t

= = =

*e $ant to %ind a %lo$ o% ma&imum value5


67
66
5
4
65
60
64
68
7
s
t 8
a
c d
5
67
7
:
9
60
:
2
AALG, lecture 8, Simonas
altenis, 2004
7
;ugmenting path

6dea %or the algorithm:

<f we ha(e some flow#=

=an can fin a path ' from s to t


!augmenting path$1 such that there is a > 0#
an for each ege !u1v$ in ' we can a a units
of flow: %!u1v$ ? a c!u1v$

/hen )ust o it# to get a 5etter flow4

Augmenting 'ath in this gra'h?


67
66
5
4
65
60
64
68
7
s
t 8
a
c d
5
67
7
:
9
60
:
2
AALG, lecture 8, Simonas
altenis, 2004
8
/he For@Fulkerson metho
Ford-Fulkerson(G,s,t)
01 initialize flow f to 0 everywhere
02 while there is an augmenting path p do
03 augment flow f along p
04 return f

Sketch of the metho:

-o$ do $e %ind augmenting 'ath4

-o$ much additional %lo$ can $e send


through that 'ath4

Does the algorithm al$ays %ind the


ma&imum %lo$4
AALG, lecture 8, Simonas
altenis, 2004
9
Aesiual network

-o$ do $e %ind augmenting 'ath?

<t is an+ path in residual network:


% Aesiual capacities: c
%
!u1v$ 0 c!u1v$ ' %!u1v$
% Aesiual network: +
%
0!01E
%
$# where
E
%
0 1!u1v$ 0 0 : c
%
!u1v$ > 02
% *hat ha''ens $hen %(u1v) 7 8 (and c(u1v) / 8)?
% B5ser(ation ' eges in E
%
are either eges in E or their
re(ersals: CE
%
C 2CEC

3om'ute residual net$or#,


67
66
5
4
65
60
64
68
7
s
t 8
a
c d
5
67
7
:
9
60
:
2
AALG, lecture 8, Simonas
altenis, 2004
10
Aesiual capacit+ of a path

-o$ much additional %lo$ can $e send


through an augmenting 'ath?

9esidual ca'acity of a path ' in +


%
:
c
%
!'$ 0 min1c
%
!u1v$: !u1v$ is in '2

*oing augmentation: for all !u1v$ in '# we )ust


a this c
%
!'$ to %!u1v$ !an su5tract it from
%!v1u$$

Aesulting flow is a (ali flow with a larger (alue"

*hat is the residual ca'acity o% the 'ath


!s1a11t$?
AALG, lecture 8, Simonas
altenis, 2004
11
/he For@Fulkerson metho
Ford-Fulkerson(G,s,t)
01 for each edge (u,v) in G! do
02 f(u,v) f(v,u) 0
03 while there e"ists a path p from s to t in residual
networ# G
f
do
04 c
f
$ min%c
f
(u,v)& (u,v) is in p'
0( for each edge (u,v) in p do
0) f(u,v) f(u,v) * c
f
0+ f(v,u) ,f(u,v)
0- return f

/he algorithms 5ase on this metho iffer in how


the+ choose ' in step 07"
AALG, lecture 8, Simonas
altenis, 2004
12
,uts

; cut is a partition of 0 into S an : / 0 ; S1


such that s S and t :

/he net flow !%!S1:$$ through the cut is the


sum of flows %!u1v$# where u S and v :

/he capacity !c!S1:$$ of the cut sum of


capacities c!u1v$# where u S and v :

inimum cut ' a cut with the smallest


capacit+ of all cuts

<%C/ %!S1:$

Does it al$ays %ind the ma&imum %lo$4


67
66
5
4
65
60
64
68
7
s
t 8
a
c d
5
67
7
:
9
60
8
6
6
AALG, lecture 8, Simonas
altenis, 2004
13
,orrectness of For@Fulkerson

=a&-%lo$ min-cut theorem:

<f % is the flow in .# the following conitions a re


eDui(alent:
% 6" % is a maximum flow in +
% 2" /he resiual network .
f
contains no augmenting
paths
% 7" C%C 0 c!S1:$ for some cut !S1:$ of +

We ha(e to pro(e three parts:


From this we ha(e 6"2"# which means that the


For@Fulkerson metho alwa+s correctl+ fins a
maximum flow
6"
2" 7"
AALG, lecture 8, Simonas
altenis, 2004
14
Worst@case running time

*hat is the $orst-case running time o% this


method4

EetFs assume integer flows"

&ach augmentation increases the (alue of the


flow 5+ some positi(e amount"

;ugmentation can 5e one in >!E$"

/otal $orst-case running time >!EC%?C$# where


%? is the max@flow foun 5+ the algorithm"

3an $e run into this $orst-case?

Lesson, ho$ an augmenting 'ath is chosen is


very im'ortant5
AALG, lecture 8, Simonas
altenis, 2004
15
&mons@Garp algorithm

:a#e shortest path (in terms o% numer


o% edges) as an augmenting 'ath ;
Edmonds-@ar' algorithm

-o$ do $e %ind such a shortest 'ath4

Aunning time >!0E


2
$# 5ecause the num5er of
augmentations is >!0E$

/o pro(e this we nee to pro(e that:


% :he length o% the shortest 'ath does not decrease
% Each edge can ecome critical at most A 0B2 times"
&ge !u1v$ on an augmenting path ' is critical if it has
the minimum resiual capacit+ in the path,
c
%
!u1v$ 0 c
%
!'$
AALG, lecture 8, Simonas
altenis, 2004
16
3on@ecreasing shortest paths

*hy does the length o% a shortest 'ath


%rom s to any v does not decrease4

B5ser(ation: ;ugmentation ma+ a some


eges to resiual network or remo(e some"

Bnl+ the ae eges !HshortcutsI$ ma+


potentiall+ ecrease the length of a shortest
path"

EetFs supose !s121v$ ' the shortest ecrease@


length path an letFs eri(e a contraiction
AALG, lecture 8, Simonas
altenis, 2004
17
3um5er of augmentations

*hy each edge can ecome critical at most


A0B2 times?

Scenario for ege !u1v$:


% ,ritical the first time: !u1v$ on an augmenting path
% *isappears from the network
% Aeappears on the network: !v1u$ has to 5e on an
augmenting path
% We can show that in@5etween these e(ents the
istance from s to u increase 5+ at least 2"
% /his can happen at most 0B2 times

We ha(e pro(e that the running time of


&mons@Garp is >!0E
2
$"
AALG, lecture 8, Simonas
altenis, 2004
18
&xample of &mons@Garp

9un the Edmonds-@ar' algorithm on the


%ollo$ing gra'h,
67
66
5
4
65
60
64
68
7
s
t 8
a
c d
AALG, lecture 8, Simonas
altenis, 2004
19
Multiple sources or sinks

*hat i% $e have more sources or sin#s4

;ugment the graph to make it with one source


an one sink4
67
66
5
4
60
8
s
1
t
1
s
2
t
2
s
C
66 J
4
9
:
67
66
5
4
60

s t
8
s
1
t
1
s
2
t
2
s
C
66 J
4
9
:

AALG, lecture 8, Simonas


altenis, 2004
20
;pplication of max@flow

=a&imum i'artite matching 'rolem

atching in a graph is a su5set = of eges


such that each (ertex has at most one ege of
= incient on it" <t puts (ertices in pairs"

We look for ma&imum matching in a bipartite


graph# where 0 0 L 91 L an 9 are is)oint
an all eges go 5etween L an 9

*ating agenc+ example:


% L ; women1 9 ; men"
% ;n ege 5etween (ertices: the+ ha(e a chance to 5e
Hcompati5leI !can 5e matche$
% *o as man+ matches 5etween Hcompati5leI persons as
possi5le
AALG, lecture 8, Simonas
altenis, 2004
21
Maximum 5ipartite matching

-o$ can $e re%ormulate this 'rolem to


ecome a ma&-%lo$ 'rolem?

*hat is the running time o% the algorithm i%


$e use the )ord-)ul#erson method?

You might also like