Nisarg Shah 373F19 - Nisarg Shah & Karan Singh 1 Recap Some - - PowerPoint PPT Presentation

nisarg shah
SMART_READER_LITE
LIVE PREVIEW

Nisarg Shah 373F19 - Nisarg Shah & Karan Singh 1 Recap Some - - PowerPoint PPT Presentation

CSC373 Week 5: Network Flow (contd) Nisarg Shah 373F19 - Nisarg Shah & Karan Singh 1 Recap Some more DP Edit distance (aka sequence alignment) Traveling salesman problem (TSP) Start of network flow Problem statement


slide-1
SLIDE 1

CSC373 Week 5: Network Flow (contd)

373F19 - Nisarg Shah & Karan Singh 1

Nisarg Shah

slide-2
SLIDE 2

Recap

373F19 - Nisarg Shah & Karan Singh 2

  • Some more DP

➢ Edit distance (aka sequence alignment) ➢ Traveling salesman problem (TSP)

  • Start of network flow

➢ Problem statement ➢ Ford-Fulkerson algorithm ➢ Running time ➢ Correctness using max-flow, min-cut

slide-3
SLIDE 3

This Lecture

373F19 - Nisarg Shah & Karan Singh 3

  • Network flow in polynomial time

➢ Edmonds-Karp algorithm (shortest augmenting path)

  • Applications of network flow

➢ Bipartite matching & Hall’s theorem ➢ Edge-disjoint paths & Menger’s theorem ➢ Multiple sources/sinks ➢ Circulation networks ➢ Lower bounds on flows ➢ Survey design ➢ Image segmentation

slide-4
SLIDE 4

Ford-Fulkerson Recap

373F19 - Nisarg Shah & Karan Singh 4

  • Define the residual graph 𝐻𝑔 of flow 𝑔

➢ 𝐻𝑔 has the same vertices as 𝐻 ➢ For each edge e = (𝑣, 𝑤) in 𝐻, 𝐻𝑔 has at most two edges

  • Forward edge 𝑓 = (𝑣, 𝑤) with capacity 𝑑 𝑓 − 𝑔 𝑓
  • We can send this much additional flow on 𝑓
  • Reverse edge 𝑓𝑠𝑓𝑤 = (𝑤, 𝑣) with capacity 𝑔(𝑓)
  • The maximum “reverse” flow we can send is the maximum

amount by which we can reduce flow on 𝑓, which is 𝑔(𝑓)

  • We only add each edge if its capacity > 0
slide-5
SLIDE 5

Ford-Fulkerson Recap

373F19 - Nisarg Shah & Karan Singh 5

  • Example!

s t u v

20/20 20/30 20/20 0/10 0/10

s t u v

𝟑𝟏 𝟐𝟏 𝟑𝟏 𝟐𝟏 𝟐𝟏 𝟑𝟏

Flow 𝑔 Residual graph 𝐻𝑔

slide-6
SLIDE 6

Ford-Fulkerson Recap

373F19 - Nisarg Shah & Karan Singh 6

MaxFlow(𝐻):

// initialize: Set 𝑔 𝑓 = 0 for all 𝑓 in 𝐻 // while there is an 𝑡-𝑢 path in 𝐻𝑔: While 𝑄 = FindPath(s, t,Residual(𝐻, 𝑔))!=None: 𝑔 = Augment(𝑔, 𝑄) UpdateResidual(𝐻,𝑔) EndWhile Return 𝑔

slide-7
SLIDE 7

Ford-Fulkerson Recap

373F19 - Nisarg Shah & Karan Singh 7

  • Running time:

➢ #Augmentations:

  • At every step, flow and capacities remain integers
  • For path 𝑄 in 𝐻𝑔, bottleneck 𝑄, 𝑔 > 0 implies bottleneck 𝑄, 𝑔 ≥ 1
  • Each augmentation increases flow by at least 1
  • At most 𝐷 = σ𝑓 leaving 𝑡 𝑑(𝑓) augmentations

➢ Time for an augmentation:

  • 𝐻𝑔 has 𝑜 vertices and at most 2𝑛 edges
  • Finding an 𝑡-𝑢 path in 𝐻𝑔 takes 𝑃(𝑛 + 𝑜) time

➢ Total time: 𝑃( 𝑛 + 𝑜 ⋅ 𝐷)

slide-8
SLIDE 8

Edmonds-Karp Algorithm

373F19 - Nisarg Shah & Karan Singh 8

  • At every step, find the shortest path from 𝑡 to 𝑢 in

𝐻𝑔, and augment.

MaxFlow(𝐻): // initialize: Set 𝑔 𝑓 = 0 for all 𝑓 in 𝐻 // Find shortest 𝑡-𝑢 path in 𝐻𝑔 & augment: While 𝑄 = BFS(s, t,Residual(𝐻, 𝑔))!=None: 𝑔 = Augment(𝑔, 𝑄) UpdateResidual(𝐻,𝑔) EndWhile Return 𝑔

Minimum number of edges

slide-9
SLIDE 9

Edmonds-Karp Proof Overview

373F19 - Nisarg Shah & Karan Singh 9

  • Overview

➢ Lemma 1: The length of the shortest 𝑡 → 𝑢 path in 𝐻𝑔

never decreases.

  • (Proof ahead)

➢ Lemma 2: After at most 𝑛 augmentations, the length of

the shortest 𝑡 → 𝑢 path in 𝐻𝑔 must strictly increase.

  • (Proof ahead)

➢ Theorem: The algorithm takes 𝑃(𝑛2𝑜) time.

  • Proof:
  • Length of shortest 𝑡 → 𝑢 path in 𝐻𝑔 can go from 0 to 𝑜 − 1
  • Using Lemma 2, there can be at most 𝑛 ⋅ 𝑜 augmentations
  • Each takes 𝑃(𝑛) time using BFS. ∎
slide-10
SLIDE 10

Level Graph

373F19 - Nisarg Shah & Karan Singh 10

  • Level graph 𝑀𝐻 of a directed graph 𝐻 = (𝑊, 𝐹):

➢ Level: ℓ(𝑤) = length of shortest 𝑡 → 𝑤 path ➢ Level graph 𝑀𝐻 = (𝑊, 𝐹𝑀) is a subgraph of 𝐻 where we

  • nly retain edges 𝑣, 𝑤 ∈ 𝐹 where ℓ 𝑤 = ℓ 𝑣 + 1
  • Intuition: Keep only the edges useful for shortest paths
slide-11
SLIDE 11

Level Graph

373F19 - Nisarg Shah & Karan Singh 11

  • Level graph 𝑀𝐻 of a directed graph 𝐻 = (𝑊, 𝐹):

➢ Level: ℓ(𝑤) = length of shortest 𝑡 → 𝑤 path ➢ Level graph 𝑀𝐻 = (𝑊, 𝐹𝑀) is a subgraph of 𝐻 where we

  • nly retain edges 𝑣, 𝑤 ∈ 𝐹 where ℓ 𝑤 = ℓ 𝑣 + 1
  • Intuition: Keep only the edges useful for shortest paths
  • Property: 𝑄 is a shortest 𝑡 → 𝑤 path in 𝐻 if and
  • nly if 𝑄 is an 𝑡 → 𝑤 path in 𝑀𝐻.
slide-12
SLIDE 12

Edmonds-Karp Proof

373F19 - Nisarg Shah & Karan Singh 12

  • Lemma 1:

➢ Length of the shortest 𝑡 → 𝑢 path in 𝐻𝑔 never decreases.

  • Proof:

➢ Let 𝑔 and 𝑔′ be flows before and after an augmentation

step, and 𝐻𝑔 and 𝐻𝑔′ be their residual graphs.

Residual graph 𝐻𝑔 Residual graph 𝐻𝑔′

slide-13
SLIDE 13

Edmonds-Karp Proof

373F19 - Nisarg Shah & Karan Singh 13

  • Lemma 1:

➢ Length of the shortest 𝑡 → 𝑢 path in 𝐻𝑔 never decreases.

  • Proof:

➢ Let 𝑔 and 𝑔′ be flows before and after an augmentation

step, and 𝐻𝑔 and 𝐻𝑔′ be their residual graphs.

➢ Augmentation happens along a path in 𝑀𝐻𝑔 ➢ For each edge on the path, we either remove it, add an

  • pposite direction edge, or both.

➢ Opposite direction edges can’t help reduce the length of

the shortest 𝑡 → 𝑢 path (exercise!).

➢ QED!

slide-14
SLIDE 14

Edmonds-Karp Proof

373F19 - Nisarg Shah & Karan Singh 14

  • Lemma 2:

➢ After at most 𝑛 augmentations, the length of the

shortest 𝑡 → 𝑢 path in 𝐻𝑔 must strictly increase.

  • Proof:

➢ In each augmentation step, we remove at least one edge

from 𝑀𝐻𝑔

  • Because we make the flow on at least one edge on the shortest

path equal to its capacity

➢ No new edges are added in 𝑀𝐻𝑔 unless the length of the

shortest 𝑡 → 𝑢 path strictly increases

➢ This cannot happen more than 𝑛 times! ∎

slide-15
SLIDE 15

Edmonds-Karp Proof Overview

373F19 - Nisarg Shah & Karan Singh 15

  • Overview

➢ Lemma 1: The length of the shortest 𝑡 → 𝑢 path in 𝐻𝑔

never decreases.

➢ Lemma 2: After at most 𝑛 augmentations, the length of

the shortest 𝑡 → 𝑢 path in 𝐻𝑔 must strictly increase.

➢ Theorem: The algorithm takes 𝑃(𝑛2𝑜) time.

slide-16
SLIDE 16

Edmonds-Karp Proof Overview

373F19 - Nisarg Shah & Karan Singh 16

  • Note:

➢ Some graphs require Ω(𝑛𝑜) augmentation steps ➢ But we may be able to reduce the time to run each

augmentation step

  • Two algorithms use this idea to reduce run time

➢ Dinitz’s algorithm [1970] ⇒ 𝑃(𝑛𝑜2) ➢ Sleator–Tarjan algorithm [1983] ⇒ 𝑃(𝑛 𝑜 log 𝑜)

  • Using the dynamic trees data structure
slide-17
SLIDE 17

373F19 - Nisarg Shah & Karan Singh 17

Network Flow Applications

slide-18
SLIDE 18

373F19 - Nisarg Shah & Karan Singh 18

Rail network connecting Soviet Union with Eastern European countries

(Tolstoǐ 1930s)

slide-19
SLIDE 19

373F19 - Nisarg Shah & Karan Singh 19

Rail network connecting Soviet Union with Eastern European countries

(Tolstoǐ 1930s) Min-cut

slide-20
SLIDE 20

Integrality Theorem

373F19 - Nisarg Shah & Karan Singh 20

  • Before we look at applications, we need the

following special property of the max-flow computed by Ford-Fulkerson and its variants

  • Observation:

➢ If edge capacities are integers, then the max-flow

computed by Ford-Fulkerson and its variants are also integral (i.e. the flow on each edge is an integer).

➢ Easy to check that each augmentation step preserves

integral flow

slide-21
SLIDE 21

Bipartite Matching

373F19 - Nisarg Shah & Karan Singh 21

  • Problem

➢ Given a bipartite graph 𝐻 = (𝑉 ∪ 𝑊, 𝐹), find a maximum

cardinality matching

  • We do not know any efficient greedy or dynamic

programming algorithm for this problem.

  • But it can be reduced to max-flow.
slide-22
SLIDE 22

Bipartite Matching

373F19 - Nisarg Shah & Karan Singh 22

  • Create a directed flow graph where we…

➢ Add a source node 𝑡 and target node 𝑢 ➢ Add edges, all of capacity 1:

  • 𝑡 → 𝑣 for each 𝑣 ∈ 𝑉, 𝑤 → 𝑢 for each 𝑤 ∈ 𝑊
  • 𝑣 → 𝑤 for each 𝑣, 𝑤 ∈ 𝐹

𝑉 𝑊 𝑉 𝑊

slide-23
SLIDE 23

Bipartite Matching

373F19 - Nisarg Shah & Karan Singh 23

  • Observation

➢ There is a 1-1 correspondence between matchings of size

𝑙 in the original graph and flows with value 𝑙 in the corresponding flow network.

  • Proof: (matching ⇒ integral flow)

➢ Take a matching 𝑁 =

𝑣1, 𝑤1 , … , 𝑣𝑙, 𝑤𝑙

  • f size 𝑙

➢ Construct the corresponding unique flow 𝑔

𝑁 where…

  • Edges 𝑡 → 𝑣𝑗, 𝑣𝑗 → 𝑤𝑗, and 𝑤𝑗 → 𝑢 have flow 1, for all 𝑗 = 1, … , 𝑙
  • The rest of the edges have flow 0

➢ This flow has value 𝑙

slide-24
SLIDE 24

Bipartite Matching

373F19 - Nisarg Shah & Karan Singh 24

  • Observation

➢ There is a 1-1 correspondence between matchings of size

𝑙 in the original graph and flows with value 𝑙 in the corresponding flow network.

  • Proof: (integral flow ⇒ matching)

➢ Take any flow 𝑔 with value 𝑙 ➢ The corresponding unique matching 𝑁

𝑔 = set of edges

from 𝑉 to 𝑊 with a flow of 1

  • Since flow of 𝑙 comes out of 𝑡, unit flow must go to 𝑙 distinct

vertices in 𝑉

  • From each such vertex in 𝑉, unit flow goes to a distinct vertex in 𝑊
  • Uses integrality theorem
slide-25
SLIDE 25

Bipartite Matching

373F19 - Nisarg Shah & Karan Singh 25

  • Perfect matching = flow with value 𝑜

➢ where 𝑜 = 𝑉 = 𝑊

  • Recall naïve Ford-Fulkerson running time:

➢ 𝑃(𝑛 ⋅ 𝑜 ⋅ 𝐷), where 𝐷 = sum of capacities of edges

leaving 𝑡

➢ Q: What’s the runtime when used for bipartite matching?

  • Some variants are faster…

➢ Dinitz’s algorithm runs in time 𝑃 𝑛 𝑜 when all edge

capacities are 1

slide-26
SLIDE 26

Hall’s Marriage Theorem

373F19 - Nisarg Shah & Karan Singh 26

  • When does a bipartite graph have a perfect matching?

➢ Well, when the corresponding flow network has value 𝑜 ➢ But can we interpret this condition in terms of edges of the

  • riginal bipartite graph?

➢ For 𝑇 ⊆ 𝑉, let 𝑂 𝑇 ⊆ 𝑊 be the set of all nodes in 𝑊 adjacent

to some node in 𝑇

  • Observation:

➢ If 𝐻 has a perfect matching, 𝑂 𝑇

≥ |𝑇| for each 𝑇 ⊆ 𝑊

➢ Because each node in 𝑇 must be matched to a distinct node

in 𝑂(𝑇)

slide-27
SLIDE 27

Hall’s Marriage Theorem

373F19 - Nisarg Shah & Karan Singh 27

  • We’ll consider a slightly different flow network,

which is still equivalent to bipartite matching

➢ All 𝑉 → 𝑊 edges now have ∞ capacity ➢ 𝑡 → 𝑉 and 𝑊 → 𝑢 edges are still unit capacity

𝑉 𝑊 𝑉 𝑊 ∞ ∞ 1 1 1 1

slide-28
SLIDE 28

Hall’s Marriage Theorem

373F19 - Nisarg Shah & Karan Singh 28

  • Hall’s Theorem:

➢ 𝐻 has a perfect matching iff 𝑂 𝑇

≥ |𝑇| for each 𝑇 ⊆ 𝑊

  • Proof (reverse direction, via network flow):

➢ Suppose 𝐻 doesn’t have a perfect matching

  • Hence, max-flow = min-cut < 𝑜
  • Let (𝐵, 𝐶) be the min-cut
  • Can’t have any 𝑉 → 𝑊 (∞ capacity edges)
  • Has unit capacity edges 𝑡 → 𝑉 ∩ 𝐶 and 𝑊 ∩ 𝐵 → 𝑢

➢ 𝑑𝑏𝑞 𝐵, 𝐶 = 𝑉 ∩ 𝐶 + 𝑊 ∩ 𝐵 < 𝑜 = 𝑉

  • So 𝑊 ∩ 𝐵 < |𝑉 ∩ 𝐵|
  • But 𝑂 𝑉 ∩ 𝐵 ⊆ 𝑊 ∩ 𝐵 because the cut doesn’t include any ∞ edges
  • So 𝑂 𝑉 ∩ 𝐵

≤ 𝑊 ∩ 𝐵 < |𝑉 ∩ 𝐵|. ∎

slide-29
SLIDE 29

Some Notes

373F19 - Nisarg Shah & Karan Singh 29

  • Runtime for bipartite perfect matching

➢ 1955: 𝑃(𝑛𝑜2) → Ford-Fulkerson ➢ 1973: 𝑃 𝑛 𝑜 → blocking flow (Hopcroft-Karp, Karzanov) ➢ 2004: 𝑃 𝑜2.378 → fast matrix multiplication (Mucha–

Sankowsi)

➢ 2013: ෨

𝑃 𝑛

Τ 10 7 → electrical flow (Mądry)

➢ Best running time is still an open question

  • Nonbipartite graphs

➢ Hall’s theorem → Tutte’s theorem ➢ 1965: 𝑃(𝑜4) → Blossom algorithm (Edmonds) ➢ 1980/1994: 𝑃 𝑛 𝑜 → Micali-Vazirani

slide-30
SLIDE 30

Edge-Disjoint Paths

373F19 - Nisarg Shah & Karan Singh 30

  • Problem

➢ Given a directed graph 𝐻 = (𝑊, 𝐹), two nodes 𝑡 and 𝑢,

find the maximum number of edge-disjoint 𝑡 → 𝑢 paths

➢ Two 𝑡 → 𝑢 paths 𝑄 and 𝑄′ are edge-disjoint if they don’t

share an edge

slide-31
SLIDE 31

Edge-Disjoint Paths

373F19 - Nisarg Shah & Karan Singh 31

  • Application:

➢ Communication networks

  • Max-flow formulation

➢ Assign unit capacity on all edges

slide-32
SLIDE 32

Edge-Disjoint Paths

373F19 - Nisarg Shah & Karan Singh 32

  • Theorem:

➢ There is 1-1 correspondence between 𝑙 edge-disjoint

𝑡 → 𝑢 paths and integral flows of value 𝑙

  • Proof (paths → flow)

➢ If 𝑄

1, … , 𝑄𝑙 are 𝑙 edge-disjoint 𝑡 → 𝑢 paths, define the

following flow

➢ 𝑔 𝑓 = 1 whenever 𝑓 ∈ 𝑄

1 ∪ ⋯ ∪ 𝑄𝑙 and 0 otherwise

➢ Since paths are edge-disjoint, it satisfies flow

conservation and capacity constraints, and gives a unique integral flow of value 𝑙

slide-33
SLIDE 33

Edge-Disjoint Paths

373F19 - Nisarg Shah & Karan Singh 33

  • Theorem:

➢ There is 1-1 correspondence between 𝑙 edge-disjoint

𝑡 → 𝑢 paths and integral flows of value 𝑙

  • Proof (flow → paths)

➢ Let 𝑔 be an integral flow of value 𝑙 ➢ 𝑙 outgoing edges from 𝑡 have unit flow ➢ Pick one such edge (𝑡, 𝑣1)

  • By flow conservation, 𝑣1 must have unit outgoing flow (which we

haven’t used up yet).

  • Pick such an edge and continue building a path until you hit 𝑢

➢ Repeat this for the other 𝑙 − 1 edges coming out of 𝑡

with unit flow. ∎

slide-34
SLIDE 34

Edge-Disjoint Paths

373F19 - Nisarg Shah & Karan Singh 34

  • Maximum number of edge-disjoint 𝑡 → 𝑢 paths

➢ Equals max flow in this network ➢ By max-flow min-cut theorem, also equals minimum cut ➢ Exercise: minimum cut = minimum number of edges we

need to delete to disconnect 𝑡 from 𝑢

  • Hint: Show each direction separately (≤ and ≥)
slide-35
SLIDE 35

Edge-Disjoint Paths

373F19 - Nisarg Shah & Karan Singh 35

  • Exercise!

➢ Show that to compute the maximum number of edge-

disjoint 𝑡 → 𝑢 paths in an undirected graph, you can create a directed flow network by adding each undirected edge in both directions and setting all capacities to 1

  • Menger’s Theorem

➢ In any directed/undirected graph, the maximum number

  • f edge-disjoint (resp. vertex-disjoint) 𝑡 → 𝑢 paths equals

the minimum number of edges (resp. vertices) whose removal disconnects 𝑡 and 𝑢

slide-36
SLIDE 36

Multiple Sources/Sinks

373F19 - Nisarg Shah & Karan Singh 36

  • Problem

➢ Given a directed graph 𝐻 = (𝑊, 𝐹) with edge capacities

𝑑: 𝐹 → ℕ, sources 𝑡1, … , 𝑡𝑙 and sinks 𝑢1, … , 𝑢ℓ, find the maximum total flow from sources to sinks.

slide-37
SLIDE 37

Multiple Sources/Sinks

373F19 - Nisarg Shah & Karan Singh 37

  • Network flow formulation

➢ Add a new source 𝑡, edges from 𝑡 to each 𝑡𝑗 with ∞ capacity ➢ Add a new sink 𝑢, edges from each 𝑢𝑘 to 𝑢 with ∞ capacity ➢ Find max-flow from 𝑡 to 𝑢 ➢ Claim: 1 − 1 correspondence between flows in two networks

slide-38
SLIDE 38

Circulation

373F19 - Nisarg Shah & Karan Singh 38

  • Input

➢ Directed graph 𝐻 = (𝑊, 𝐹) ➢ Edge capacities 𝑑 ∶ 𝐹 → ℕ ➢ Node demands 𝑒 ∶ 𝑊 → ℤ

  • Output

➢ Some circulation 𝑔 ∶ 𝐹 → ℕ satisfying

  • For each 𝑓 ∈ 𝐹 : 0 ≤ 𝑔 𝑓 ≤ 𝑑(𝑓)
  • For each 𝑤 ∈ 𝑊 : σ𝑓 entering 𝑤 𝑔(𝑤) − σ𝑓 leaving 𝑤 𝑔 𝑤 = 𝑒(𝑤)

➢ Note that you need σ𝑤:𝑒 𝑤 >0 𝑒(𝑤) = σ𝑤:𝑒 𝑤 <0 −𝑒(𝑤) ➢ What are demands?

slide-39
SLIDE 39

Circulation

373F19 - Nisarg Shah & Karan Singh 39

  • Demand at 𝑤 = amount of flow you need to take
  • ut at node 𝑤

➢ 𝑒 𝑤 > 0 : You need to take some flow out at 𝑤

  • So there should be 𝑒(𝑤) more incoming flow than outgoing flow
  • “Demand node”

➢ 𝑒 𝑤 < 0 : You need to put some flow in at 𝑤

  • So there should be 𝑒 𝑤

more outgoing flow than incoming flow

  • “Supply node”

➢ 𝑒 𝑤 = 0 : Node has flow conservation

  • Equal incoming and outgoing flows
  • “Transshipment node”
slide-40
SLIDE 40

Circulation

373F19 - Nisarg Shah & Karan Singh 40

  • Example
slide-41
SLIDE 41

Circulation

373F19 - Nisarg Shah & Karan Singh 41

  • Network-flow formulation 𝐻′

➢ Add a new source 𝑡 and a new sink 𝑢 ➢ For each “supply” node 𝑤 with 𝑒 𝑤 < 0, add edge (𝑡, 𝑤)

with capacity −𝑒(𝑤)

➢ For each “demand” node 𝑤 with 𝑒 𝑤 > 0, add edge

(𝑤, 𝑢) with capacity 𝑒(𝑤)

  • Claim: 𝐻 has a circulation iff 𝐻′ has max flow of

value σ𝑤:𝑒 𝑤 >0 𝑒(𝑤) = σ𝑤:𝑒 𝑤 <0 −𝑒(𝑤)

slide-42
SLIDE 42

Circulation

373F19 - Nisarg Shah & Karan Singh 42

  • Example
slide-43
SLIDE 43

Circulation

373F19 - Nisarg Shah & Karan Singh 43

  • Example
slide-44
SLIDE 44

Circulation with Lower Bounds

373F19 - Nisarg Shah & Karan Singh 44

  • Input

➢ Directed graph 𝐻 = (𝑊, 𝐹) ➢ Edge capacities 𝑑 ∶ 𝐹 → ℕ and lower bounds ℓ ∶ 𝐹 → ℕ ➢ Node demands 𝑒 ∶ 𝑊 → ℤ

  • Output

➢ Some circulation 𝑔 ∶ 𝐹 → ℕ satisfying

  • For each 𝑓 ∈ 𝐹 : ℓ(𝑓) ≤ 𝑔 𝑓 ≤ 𝑑(𝑓)
  • For each 𝑤 ∈ 𝑊 : σ𝑓 entering 𝑤 𝑔(𝑤) − σ𝑓 leaving 𝑤 𝑔 𝑤 = 𝑒(𝑤)

➢ Note that you still need σ𝑤:𝑒 𝑤 >0 𝑒(𝑤) = σ𝑤:𝑒 𝑤 <0 −𝑒(𝑤)

slide-45
SLIDE 45

Circulation with Lower Bounds

373F19 - Nisarg Shah & Karan Singh 45

  • Transform to circulation without lower bounds

➢ Do the following operation to each edge

  • Claim: Circulation in 𝐻 iff circulation in 𝐻′

➢ Proof sketch: 𝑔(𝑓) gives a valid circulation in 𝐻 iff

𝑔 𝑓 − ℓ(𝑓) gives a valid circulation in 𝐻′

slide-46
SLIDE 46

Survey Design

373F19 - Nisarg Shah & Karan Singh 46

  • Problem

➢ We want to design a survey about 𝑛 products

  • We have one survey question in mind for each product

➢ There are 𝑜 consumers ➢ Consumer 𝑗 owns a subset of products 𝑃𝑗

  • We can ask consumer 𝑗 questions only about these products

➢ We want to ask each consumer 𝑗 between 𝑑𝑗 and 𝑑𝑗

questions

➢ We want to ask between 𝑞𝑘 and 𝑞𝑘

′ question about each

product 𝑘

➢ Is there a survey meeting all these requirements?

slide-47
SLIDE 47

Survey Design

373F19 - Nisarg Shah & Karan Singh 47

  • Bipartite matching is a special case

➢ 𝑑𝑗 = 𝑑𝑗

′ = 𝑞𝑘 = 𝑞𝑘 ′ = 1 for all 𝑗 and 𝑘

  • Max-flow formulation:

➢ Use circulation with lower bounds model ➢ Create a network with special nodes 𝑡 and 𝑢 ➢ Edge from 𝑡 to node of consumer 𝑗 with flow ∈ [𝑑𝑗, 𝑑𝑗

′]

➢ Edge from consumer 𝑗 to product 𝑘 ∈ 𝑃𝑗 with flow ∈ [0,1] ➢ Edge from node of product 𝑘 to sink 𝑢 with flow ∈ [𝑞𝑘, 𝑞𝑘

′]

➢ Edge from 𝑢 to 𝑡 with flow in [0, ∞] ➢ All demands and supplies are 0

slide-48
SLIDE 48

Survey Design

373F19 - Nisarg Shah & Karan Singh 48

  • Max-flow formulation:

➢ Feasible survey iff feasible circulation in this network

slide-49
SLIDE 49

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 49

  • Foreground/background segmentation

➢ Given an image, separate “foreground” from “background”

  • Here’s the power of PowerPoint (or lack thereof)

Remove background

slide-50
SLIDE 50

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 50

  • Foreground/background segmentation

➢ Given an image, separate “foreground” from “background”

  • Here’s what remove.bg gets using AI

Remove background

slide-51
SLIDE 51

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 51

  • Informal problem

➢ Given an image (2D array of pixels), and likelihood

estimates of different pixels being foreground/background, label each pixel as foreground or background

➢ Want to prevent having too many

neighboring pixels where one is labeled foreground but the other is labeled background

slide-52
SLIDE 52

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 52

  • Input

➢ An image (2D array of pixels) ➢ 𝑏𝑗 = likelihood of pixels 𝑗 being in foreground ➢ 𝑐𝑗 = likelihood of pixels 𝑗 being in background ➢ 𝑞𝑗,𝑘 = penalty for separating pixels 𝑗 and 𝑘 (i.e. labeling

  • ne of them as foreground and the other as background)
  • Output

➢ Label each pixel as “foreground” or “background” ➢ Minimize total penalty

  • We want this to be high if 𝑏𝑗 is high but 𝑗 is labeled background, or

𝑐𝑗 is high but 𝑗 is labeled foreground, or 𝑞𝑗,𝑘 is high but 𝑗 and 𝑘 are separated

slide-53
SLIDE 53

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 53

  • Recall

➢ 𝑏𝑗 = likelihood of pixels 𝑗 being in foreground ➢ 𝑐𝑗 = likelihood of pixels 𝑗 being in background ➢ 𝑞𝑗,𝑘 = penalty for separating pixels 𝑗 and 𝑘 ➢ Let 𝐹 = pairs of neighboring pixels

  • Output

➢ Minimize total penalty

  • 𝐵 = set of pixels labeled foreground
  • 𝐶 = set of pixels labeled background
  • Penalty =

𝑗∈𝐵

𝑐𝑗 + ෍

𝑘∈𝐶

𝑏𝑘 + ෍

𝑗,𝑘 ∈𝐹 𝐵∩ 𝑗,𝑘 =1

𝑞𝑗,𝑘

slide-54
SLIDE 54

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 54

  • Formulate as min-cut problem

➢ Want to divide the set of pixels 𝑊 into (𝐵, 𝐶) to minimize

𝑗∈𝐵

𝑐𝑗 + ෍

𝑘∈𝐶

𝑏𝑘 + ෍

𝑗,𝑘 ∈𝐹 𝐵∩ 𝑗,𝑘 =1

𝑞𝑗,𝑘

➢ Add a node 𝑤𝑗 for each pixel 𝑗 ➢ Add a source node 𝑡, sink node 𝑢 ➢ Add 𝑡 → 𝑤𝑗 edge with capacity 𝑏𝑗 and 𝑤𝑗 → 𝑢 edge with

capacity 𝑐𝑗

➢ For neighboring (𝑗, 𝑘), add both 𝑤𝑗 → 𝑤𝑘 and 𝑤𝑘 → 𝑤𝑗

edges with capacity 𝑞𝑗,𝑘

slide-55
SLIDE 55

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 55

  • Formulate as min-cut problem

➢ Here’s what the network looks like

slide-56
SLIDE 56

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 56

➢ Consider the min-cut (𝐵, 𝐶)

𝑑𝑏𝑞 𝐵, 𝐶 = ෍

𝑗∈𝐵

𝑐𝑗 + ෍

𝑘∈𝐶

𝑏𝑘 + ෍

𝑗,𝑘 ∈𝐹 𝑗∈𝐵,𝑘∈𝐶

𝑞𝑗,𝑘

➢ Exactly what we want to minimize!

If 𝑗 and 𝑘 are labeled differently, it will add 𝑞𝑗,𝑘 exactly once

slide-57
SLIDE 57

Image Segmentation

373F19 - Nisarg Shah & Karan Singh 57

  • GrabCut [Rother-Kolmogorov-Blake 2004]