cs3000: algorithms & data jonathan ullman · 2018-12-06 · image segmentation •separate...
TRANSCRIPT
CS3000:Algorithms&DataJonathanUllman
Lecture21:MoreApplicationsofNetworkFlow
Nov30,2018
ImageSegmentation
ImageSegmentation
• Separateimageintoforegroundandbackground• Wehavesomeideaof:• whetherpixeliisintheforegroundorbackground• whetherpair(i,j)arelikelytogotogether
ImageSegmentation
• Input:• adirectedgraph! = ($, &);$ =“pixels”,& =“pairs”• likelihoods(), *) ≥ 0 forevery- ∈ $• separationpenalty/)0 ≥ 0 forevery -, 1 ∈ &
• Output:• apartitionof$ into 2, 3 thatmaximizes
4 2, 3 = 6()�
)∈8+6*0
�
0∈:− 6 /)0
�
),0 ∈<=>?@8A?:
O O OI F IOes O O OF I I0 O O O
foreggand background
Lquality
ReductiontoMinCut• DifferencesbetweenSEGandMINCUT:• SEGasksustomaximize,MINCUTasksustominimize
• SEG allowsanypartition,MINCUTrequiresB ∈ 2,C ∈ 3
max8,: 6()�
)∈8+6*0
�
0∈:− 6 /)0
�
),0 ∈<=>?@8A?:
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
max g ASB nfib g ASBA B
miner graph has nodeVoss 13
MinA B partitioning
cap A0553 Bose
Add two nodes sit
ReductiontoMinCut• Howshouldthereductionwork?• capacityofthecutshouldcorrespondtothefunctionwe’retryingtominimize
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
min 2 cap i ji j EEA B fromA to B
ReductiontoMinCut• Howshouldthereductionwork?• capacityofthecutshouldcorrespondtothefunctionwe’retryingtominimize
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
A AB cap Auss Busts
IzabitjEsa's PijfromAtoB
Assume Gonly has nodes
i j3
ReductiontoMinCut• Howshouldthereductionwork?• capacityofthecutshouldcorrespondtothefunctionwe’retryingtominimize
min8,: 6*)�
)∈8+6(0
�
0∈:+ 6 /)0
�
),0 ∈<=>?@8A?:
A B
so
Step1:TransformtheInput
InputG,{a,b,p}forSEG
InputG’forMINCUT
so
time 0 mtn
Step2:ReceivetheOutput
Solve
InputG’forMINCUT
Output(A,B)forMINCUTA
time time to solveMsn art on a graph
ath
Nt 2 nodes
B2n t m edges
0 nm time
Step3:TransformtheOutput
Output(A,B)forSEG
Output(A,B)forMINCUT
i
on
ReductiontoMinCut• correctness?
• runningtime?
Max gCA BA B
itransform its Y 3 thief D0 ntm t O nm t 0 n
O nm
DensestSubgraph
ImageSegmentation
• Wanttoidentifycommunitiesinanetwork• “Community”:asetofnodesthathavealotofconnectionsinsideandfewoutside
MMMMMMMe Community Detection
DensestSubgraph
• Input:• anundirectedgraph! = $, &
• Output:• asubsetofnodes2 ⊆ $ thatmaximizesJ < 8,8
|8|
Fund AB
E AB u u c E o UEA E B
IECA A I
why not maxmax.m.zed.by on edgeA
ReductiontoMinCut• Differentobjectives
• find 2, 3 tomaximizeJ < 8,88
• find 2, 3 tominimize & 2, 3
• SupposeJ < 8,88 ≥ Landseewhatthatimplies
⇔ 2 & 2, 2 ≥ L 2⇔ ΣP∈8 deg T − & 2, 3 ≥ L 2⇔ ΣP∈U deg T − ΣP∈: deg T − & 2, 3 ≥ L 2⇔ 2 & − ΣP∈: deg T − & 2, 3 ≥ L 2⇔ ΣP∈: deg T + L 2 + & 2, 3 ≤ 2 &
We will solve the yeshoquestion is there a communitywith density s S
r
Mincut if c e i
Ea ai t.E.bit.ci eeiaiii
ReductiontoMinCut
ΣP∈WX deg T + Y Z + & Z, Z[ ≤ 2 &
Ive the yeshoquestion is there a communitywith density 8
MinCut if c e i
Ea ai Fersbi t.ci eeiaiiiO
If deg v
21ECA A IIECA B I
ReductiontoMinCut
ΣP∈WX deg T + Y Z + & Z, Z[ ≤ 2 &
We will solve the yeshoquestion is there a communitywith density s S
r
Mincut if c e i
Ea ai t.E.bit.ci eeiaiij
Zpsdeg r uEa8 e.iFeECaiD I
Edge-DisjointPaths
Ezeizagsxoffft ff ffff.BE
(Edge)DisjointPaths• Input: directedgraph! = $, &, B, C• Output: alargestsetofedge-disjoints-tpaths• Asetofs-tpaths\],… , \_ isedgedisjointifthepathsdonotshareanyedges
Alargesetofdisjointpathsmeanswecantolerateedgefailures.
s t
EBAY.IR tHBF AfEfsd2E
BipartiteMatching
• Thereisareductionthatusesintegermaximums-tflow tosolveedgedisjointpaths.
Step1:TransformtheInput
InputGforEDP InputG’forMAXFLOW
s t s t
Step2:ReceivetheOutput
SolveA
InputG’forMAXFLOW
OutputfforMAXFLOW
Red arrowmeansf(e)=1Blackmeans f(e)=0
s t
Step3:TransformtheOutput
OutputMforMCBM
OutputfforMAXFLOW
Correctness• EasyDirection:Iftherearekedgedisjointpathsthenthereisaflowofvaluek
s t
Correctness• HarderDirection:Ifthereisaflowofvaluek,thentherearekedgedisjointpaths
s t
RunningTime• Needtoanalyzethetimefor:• (1)ProducingG’givenG• (2)FindingamaximumflowinG’• (3)ProducingMgivenG’
Summary
• CansolveedgedisjointpathsintimeO(nm)usingFord-Fulkerson
Solvingmaximums-tflowinagraphwithnnodesandmedgesandc(e)=1 intimeT
SolvingedgedisjointpathsinagraphwithnnodesandmedgesintimeT+O(mn)
(Node)DisjointPaths• Input: directedgraph! = $, &, B, C• Output: alargestsetofnode-disjoints-tpaths• Asetofs-tpaths\],… , \_ isnode-disjointifthepathsdonotshareanynodes
Alargesetofdisjointpathsmeanswecantolerateedge failures.
s t
Step1:TransformtheInput
InputGforNDP InputG’forEDP
s t s t