05 GraphAlgorithms II 17 12 Ann
05 GraphAlgorithms II 17 12 Ann
GraphAlgorithms
AlgorithmTheory
WS2013/14
FabianKuhn
AlgorithmTheory,WS2013/14 FabianKuhn 2
Example:FlowNetwork
2u
2u
1u
1u
Su
AlgorithmTheory,WS2013/14 FabianKuhn 3
Notation
Wedefine:
In
: c
c Into
,
out
: (c)
c out oI
ForasetS F:
In
S c
c Into S
,
out
S (c)
c out oI S
Flowconservation: : I s, t :
In
: =
out
(:)
Flowvalue: =
out
s =
In
(t)
Forsimplicity:Assumethatallcapacities arepositiveintegers
AlgorithmTheory,WS2013/14 FabianKuhn 4
TheMaximumFlowProblem
MaximumFlow:
Givenaflownetwork,findaflowofmaximumpossiblevalue
Classicalgraphoptimizationproblem
Manyapplications(alsobeyondtheobviousones)
Requiresnewalgorithmictechniques
AlgorithmTheory,WS2013/14 FabianKuhn 5
FordFulkersonAlgorithm
Improveflowusinganaugmentingpathaslongaspossible:
1. Initially, c = u foralledgesc E,0
]
= 0
2. whilethereisanaugmentingstpathP in0
]
do
3. LetP beanaugmentingstpathin0
]
;
4.
i
augment(, P);
5. update tobe;
6. updatetheresidualgraph0
]
7. end;
AlgorithmTheory,WS2013/14 FabianKuhn 6
MaxFlowMinCutTheorem
Theorem:(MaxFlowMinCutTheorem)
Ineveryflownetwork,themaximumvalueofanst flowis
equaltotheminimumcapacityofanst cut.
Proof:
AlgorithmTheory,WS2013/14 FabianKuhn 7
IntegerCapacities
Theorem:(IntegerValuedFlows)
Ifallcapacitiesintheflownetworkareintegers,thenthereisa
maximumflow forwhichtheflow c ofeveryedgec isan
integer.
Proof:
AlgorithmTheory,WS2013/14 FabianKuhn 8
NonIntegerCapacities
Whatifcapacitiesarenotintegers?
rationalcapacities:
canbeturnedintointegersbymultiplyingthemwithlargeenoughinteger
algorithmstillworkscorrectly
real(nonrational)capacities:
notclearwhetherthealgorithmalwaysterminates
evenforintegercapacities,timecanlinearlydependonthevalue
ofthemaximumflow
AlgorithmTheory,WS2013/14 FabianKuhn 9
SlowExecution
Numberofiterations:2uuu (valueofmax.flow)
1uuu
1uuu
1uuu
1uuu
1
1
1
1
1
1
2 2
2 2
AlgorithmTheory,WS2013/14 FabianKuhn 10
ImprovedAlgorithm
Idea:Findthebestaugmentingpathineachstep
best:pathP withmaximumbottleneck(P, )
Bestpathmightberatherexpensivetofind
findalmostbestpath
ScalingparameterA:
(initially, = "max c
c
iounueu uown to next powei of 2")
Aslongasthereisanaugmentingpaththatimprovestheflowby
atleast,augmentusingsuchapath
Ifthereisnosuchpath:
A
2
AlgorithmTheory,WS2013/14 FabianKuhn 11
ScalingParameterAnalysis
Lemma:Ifallcapacitiesareintegers,numberofdifferentscaling
parametersusedis 1 +|log
2
Cj.
Ascalingphase:Timeduringwhichscalingparameteris
AlgorithmTheory,WS2013/14 FabianKuhn 12
LengthofaScalingPhase
Lemma:If istheflowattheendofthescalingphase,the
maximumflowinthenetworkhasvalueatmost +m.
AlgorithmTheory,WS2013/14 FabianKuhn 13
LengthofaScalingPhase
Lemma:Thenumberofaugmentationsineachscalingphaseis
atmost2m.
AlgorithmTheory,WS2013/14 FabianKuhn 14
RunningTime:ScalingMaxFlowAlg.
Theorem:Thenumberofaugmentationsofthealgorithmwith
scalingparameterandintegercapacitiesisatmost0(mlog C).The
algorithmcanbeimplementedintime0 m
2
log C .
AlgorithmTheory,WS2013/14 FabianKuhn 15
StronglyPolynomialAlgorithm
TimeofregularFordFulkersonalgorithmwithintegercapacities:
0(mC)
Timeofalgorithmwithscalingparameter:
0 m
2
log C
0(log C) ispolynomialinthesizeoftheinput,butnotinn
Canwegetanalgorithmthatrunsintimepolynomialinn?
Alwayspickingashortestaugmentingpathleadstorunningtime
0(m
2
n)
AlgorithmTheory,WS2013/14 FabianKuhn 16
OtherAlgorithms
Therearemanyotheralgorithmstosolvethemaximumflow
problem,forexample:
Preflowpushalgorithm:
Maintainsapreflow ( nodes:inflow outflow)
Alg.guarantees:Assoonaswehaveaflow,itisoptimal
Detaileddiscussioninlastyearslecture
Runningtimeofbasicalgorithm:0 m n
2
Doingstepsintherightorder:0 n
3
Currentbestknowncomplexity:O m n
Forgraphswithm n
1+c
[King,Rao,Tarjan 1992/1994]
(foreveryconstante > u)
Forsparsegraphswithm n
16 15 -6
[Orlin,2013]
AlgorithmTheory,WS2013/14 FabianKuhn 17
MaximumFlowApplications
Maximumflowhasmanyapplications
Reducingaproblemtoamaxflowproblemcanevenbeseenas
animportantalgorithmictechnique
Examples:
relatednetworkflowproblems
computationofsmallcuts
computationofmatchings
computingdisjointpaths
schedulingproblems
assignmentproblemswithsomesideconstraints
AlgorithmTheory,WS2013/14 FabianKuhn 18
UndirectedEdgesandVertexCapacities
UndirectedEdges:
Undirectededge{u, :]:addedges u, : and(:, u) tonetwork
VertexCapacities:
Notonlyedge,butalso(oronly)nodeshavecapacities
Capacityc
In
: =
out
: c
Replacenode: byedgec
= {:
In
, :
out
]:
In In out out
u
AlgorithmTheory,WS2013/14 FabianKuhn 19
Minimum Cut
Given: undirectedgraph0 = (I, E),nodess, t I
xt cut:Partition(A, B) ofI suchthats A,t B
Sizeofcut(A, B):numberofedgescrossingthecut
Objective: findst cutofminimumsize
AlgorithmTheory,WS2013/14 FabianKuhn 20
EdgeConnectivity
Definition: Agraph0 = I, E iskedgeconnectedforaninteger
k 1 ifthegraph0
X
= (I, E X) isconnectedforeveryedgeset
X E, X k -1.
Goal:Computeedgeconnectivityz(0) of0
(andedgesetX ofsizez(0) thatdivides0 into 2 parts)
minimumsetX isaminimumst cutforsomes, t I
Actuallyforalls, t indifferentcomponentsof0
X
= (I, E X)
Possiblealgorithm:fixs andfindminst cutforallt = s
AlgorithmTheory,WS2013/14 FabianKuhn 21
Minimum VertexCut
Given: undirectedgraph0 = (I, E),nodess, t I
xt vertexcut:SetX I suchthats, t X ands andt arein
differentcomponentsofthesubgraph0|I X] inducedbyI X
Sizeofvertexcut:|X|
Objective: findst vertexcutofminimumsize
Replaceundirectededge{u, :] by(u, :) and(:, u)
Computemaxst flowforedgecapacities andnodecapacities
c
= 1 foi : = s, t
Replaceeachnode: by:
In
and:
out
:
Minedgecutcorrespondstominvertexcutin0
AlgorithmTheory,WS2013/14 FabianKuhn 22
VertexConnectivity
Definition: Agraph0 = I, E iskvertexconnectedforaninteger
k 1 ifthesubgraph0|I X] inducedbyI X isconnectedfor
everyedgeset
X I, X k -1.
Goal:Computevertexconnectivity(0) of0
(andnodesetX ofsize(0) thatdivides0 into 2 parts)
Computeminimumst vertexcutforfixeds andallt = s
AlgorithmTheory,WS2013/14 FabianKuhn 23
EdgeDisjointPaths
Given:Graph0 = (I, E) withnodess, t I
Goal:Findasmanyedgedisjointst pathsaspossible
Solution:
Findmaxst flowin0 withedgecapacitiesc
c
= 1 forallc E
Flow induces edgedisjointpaths:
Integralcapacitiescancomputeintegralmaxflow
Get edgedisjointpathsbygreedilypickingthem
Correctnessfollowsfromflowconservation
In
: =
out
(:)
AlgorithmTheory,WS2013/14 FabianKuhn 24
EdgeDisjointPaths
Flow induces edgedisjointpaths:
Get edgedisjointpathsbygreedilypickingthem
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
AlgorithmTheory,WS2013/14 FabianKuhn 25
EdgeDisjointPaths
Flow induces edgedisjointpaths:
Get edgedisjointpathsbygreedilypickingthem
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
AlgorithmTheory,WS2013/14 FabianKuhn 26
EdgeDisjointPaths
Flow induces edgedisjointpaths:
Decompose intoonest pathandaflowofvalue -1
1
1
1
1
1
1
1
1
1
1
1
1
1
AlgorithmTheory,WS2013/14 FabianKuhn 27
VertexDisjointPaths
Given:Graph0 = (I, E) withnodess, t I
Goal:Findasmanyinternallyvertexdisjointst pathsaspossible
Solution:
Findmaxst flowin0 withnodecapacitiesc
= 1 forall: I
Flow induces vertexdisjointpaths:
Integralcapacitiescancomputeintegralmaxflow
Get vertexdisjointpathsbygreedilypickingthem
Correctnessfollowsfromflowconservation
In
: =
out
(:)
AlgorithmTheory,WS2013/14 FabianKuhn 28
Mengers Theorem
Theorem:(edgeversion)
Foreverygraph0 = (I, E) withnodess, t I,thesizeofthe
minimumst (edge)cutequalsthemaximumnumberofpairwise
edgedisjointpathsfroms tot.
Theorem:(nodeversion)
Foreverygraph0 = (I, E) withnodess, t I,thesizeofthe
minimumst vertexcutequalsthemaximumnumberofpairwise
internallyvertexdisjointpathsfroms tot
Bothversionscanbeseenasaspecialcaseofthemaxflowmin
cuttheorem