cs3000: algorithms & data jonathan ullman · cs3000: algorithms & data jonathan ullman...

19
CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

Upload: others

Post on 12-Oct-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

CS3000:Algorithms&DataJonathanUllman

Lecture17:MoreApplicationsofNetworkFlow

March25,2020

Page 2: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ImageSegmentation

• Separateimageintoforegroundandbackground• Wehavesomeideaof:• whetherpixeliisintheforegroundorbackground• whetherpair(i,j)arelikelytogotogether

backgroundforeground

e me d

I o.o II Du

Set of pixels n xEm

e g middlepixelsmore

likely tobe

foreground

Page 3: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ImageSegmentation

• Input:• anundirectedgraph! = ($, &);$ =“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 ∈<=>?8@AB:

Assume all values in the graph

q ofme 9 m externally

a likelihood of foreground

foregroundI

background

i jPij

Page 4: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• DifferencesbetweenSEGandMINCUT:• SEGasksustomaximize,MINCUTasksustominimize

max8,: 6()�

)∈8+6*0

0∈:− 6 /)0

),0 ∈<=>?8@AB:

min8,: 6*)�

)∈8+6(0

0∈:+ 6 /)0

),0 ∈<=>?8@AB:

yShort for Image Segmentation

DMin f x

may f x

Fon Fa FB bi PiiA

DEbtv A B

am Ea ai E bi Epi

I

Page 5: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• DifferencesbetweenSEGandMINCUT:• SEGallowsanypartition,MINCUTrequiresH ∈ 2,I ∈ 3

SE Af t C B

EE B O_0

se Aqd tqg

Solution Add dummy nodes

s and t to the graph

Page 6: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• DifferencesbetweenSEGandMINCUT:• SEGhasedgesbetweenAandB,MINCUTconsidersedgesfromAtoB

min8,: 6 /)0�

),0 ∈<JKLM8>L:

min8,: 6*)�

)∈8+6(0

0∈:+ 6 /)0

),0 ∈<=>?8@AB:

A B

solution yes

Replace undirected oe go no

edge Cii ul Ilyi j and j i B A

both with capacity pi i0 0j Mandy.netjsnmbth

Page 7: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• DifferencesbetweenSEGandMINCUT:• SEGhastermsforeachnodeinA,B,MINCUTonlyhastermsforedgesfromAtoB

min8,: 6 /)0�

),0 ∈<JKLM8>L:

min8,: 6*)�

)∈8+6(0

0∈:+ 6 /)0

),0 ∈<=>?8@AB:MIMI

so

sit inedges from s Izand t 7ft capacity we want

t.IT Etb

Page 8: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• Howshouldthereductionwork?• capacityofthecutshouldcorrespondtothefunctionwe’retryingtominimize

min8,: 6*)�

)∈8+6(0

0∈:+ 6 /)0

),0 ∈<JKLM8>L:

Replace max with men

Replace undirected edges w pairs of directededge

Add dummy nodes Stbax

Add dummy edges s x x e

Page 9: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

Step1:TransformtheInput

InputG,{a,b,p}forSEG

InputG’forMINCUT

ourReplace Max with man

Replace undirected edges w pairs of directededges

Add dummy nodes Stbax

Add dummy edges s x x e

Total Time 0 mtn

Page 10: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

Step2:ReceivetheOutput

Solve

InputG’forMINCUT

Output(A,B)forMINCUT

u u v x3were the

original graph

1

A B is a mmmm satat in G

T IneSolve mascot on a

Agraph with n 12 nodes

B and 2Mt 2n edgesso 0Cmn t.me

Page 11: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

Step3:TransformtheOutput

Output(A,B)forSEG

Output(A,B)forMINCUT

Return partition

A fu v3B f w x 3

O

OA

B

Time 0 n

Page 12: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• correctness?

• runningtime?

Every patron A B of the original nodes

corresponds to an s C at A 0953 Bu Et3

For every sf we Auss3 Bust 3 the

capacity is ftp.biifrsaitif.EIEEJPTxatg whatSEG wants to

Total Time 0 mn m.nm.ae

Bottleneck is solving minimum at

Page 13: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ImageSegmentation

• Wanttoidentifycommunitiesinanetwork• “Community”:asetofnodesthathavealotofconnectionsinsideandfewoutside

Mammootty Densest Subgraph

ofedges inside

070

madeHr

i

Page 14: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

DensestSubgraph

• Input:• anundirectedgraph! = $, &

• Output:• asubsetofnodes2 ⊆ $ thatmaximizesO < 8,8

|8|

2 ttmsideA

of nodes in A

1

F ASA set of edges w both endpoints in A

ECA B set of edges w one endpoint in A one MB

Page 15: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

DS uses an undirectedgraph

Ds ieesuscnooseayseiafmmiIT.es ie

I

iOS O

Add dummy nodes s t

Same transformations as SEG

Need to transform the objective function

DS MINCUT

2 IECA A I E C i jCi j EE

I Al f IEA jtBIs it

FA ai Eff bite cijbtw A B

usang dummy edges

Page 16: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• Differentobjectives

• maximizeO < 8,88 vs.minimize & 2, 3

• SupposeO < 8,88 ≥ Qandseewhatthatimplies

⇔ 2 & 2, 2 ≥ Q 2⇔ ΣU∈8 deg Y − & 2, 3 ≥ Q 2⇔ ΣU∈Z deg Y − ΣU∈: deg Y − & 2, 3 ≥ Q 2⇔ 2 & − ΣU∈: deg Y − & 2, 3 ≥ Q 2⇔ ΣU∈: deg Y + Q 2 + & 2, 3 ≤ 2 &⇔ ΣU∈: deg Y + ΣU∈8Q + Σ\JKLM8>L:1 ≤ 2 &

If I can ask yes no

questions Is the DS der w

f

Em

than 8 then I can findthe densest subgraph

DO E meoof

Page 17: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut• Differentobjectives

• maximizeO < 8,88 vs.minimize & 2, 3

• SupposeO < 8,88 ≥ Qandseewhatthatimplies

⇔ 2 & 2, 2 ≥ Q 2⇔ ΣU∈8 deg Y − & 2, 3 ≥ Q 2⇔ ΣU∈Z deg Y − ΣU∈: deg Y − & 2, 3 ≥ Q 2⇔ 2 & − ΣU∈: deg Y − & 2, 3 ≥ Q 2⇔ ΣU∈: deg Y + Q 2 + & 2, 3 ≤ 2 &⇔ ΣU∈: deg Y + ΣU∈8Q + Σ\JKLM8>L:1 ≤ 2 &

If I can ask yes no

questions Is the DS der w

f

Em

than 8 then I can findthe densest subgraph

DOEadegenTEAdegcul jfdegh E.de o

IFudegCu TEodesh

IECAB IE L

Sla efromA B

3 SvC A

Page 18: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

Ifs degli t Fa s t Ee L

fromA to B

If the value is E 21 El

then the subgraph A has

2 IEEa AlTai 38

Page 19: CS3000: Algorithms & Data Jonathan Ullman · CS3000: Algorithms & Data Jonathan Ullman Lecture 17: More Applications of Network Flow March 25, 2020

ReductiontoMinCut

ΣU∈: deg Y + ΣU∈8Q + Σ\JKLM8>L:1 ≤ 2 &000

Isdegg

I s

degce

Thisgraphhas mmeat ELIE if andonly if F a subgraphof dusty 8