+ All Categories
Home > Documents > Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Date post: 30-Dec-2015
Category:
Upload: kenneth-benjamin-lindsey
View: 219 times
Download: 1 times
Share this document with a friend
28
Advanced Algorithms Advanced Algorithms Piyush Kumar Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405
Transcript
Page 1: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Advanced AlgorithmsAdvanced AlgorithmsAdvanced AlgorithmsAdvanced Algorithms

Piyush KumarPiyush Kumar(Lecture 4: MaxFlow MinCut Applications)(Lecture 4: MaxFlow MinCut Applications)

Welcome to COT5405

Page 2: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Announcements

• The project list is out, make sure you have a copy.

• Homework 1 is due NOW.• Preliminary Programming assignment 1 is

attached on the back of the homework solutions• Project Partner / Top 5 choices Due

– Before Wednesday morning (9:00am)– Send it to me by email.– Who doesn’t have a partner yet (and wants one)?– Email your choices to : [email protected] – Fill up the choice sheet now if you can.

Page 3: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Today

• Complete Preflow Push• Discuss Programming assignment

1– Preliminary Deadline: 26th

• Bipartite matching/Hall’s theorem • Application of MaxFlow MinCut

– Image segmentation– Edge Disjoint paths

Page 4: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

ApplicationsApplicationsMax Flow Min CutMax Flow Min Cut

ApplicationsApplicationsMax Flow Min CutMax Flow Min Cut

Page 5: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Matching.– Input: undirected graph G = (V, E).– M E is a matching if each node appears in at most edge

in M.– Max matching: find a max cardinality matching.

Bipartite Matching

Page 6: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Bipartite Matching• Bipartite matching.

– Input: undirected, bipartite graph G = (L R, E).– M E is a matching if each node appears in at most

edge in M.– Max matching: find a max cardinality matching.

1

3

5

1'

3'

5'

2

4

2'

4'

matching

1-2', 3-1', 4-5'

RL

Page 7: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Bipartite Matching• Bipartite matching.

– Input: undirected, bipartite graph G = (L R, E).– M E is a matching if each node appears in at most

edge in M.– Max matching: find a max cardinality matching.

1

3

5

1'

3'

5'

2

4

2'

4'

RL

max matching

1-1', 2-2', 3-3' 4-4'

Page 8: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Max flow formulation.

– Create digraph G' = (L R {s, t}, E' ).

– Direct all edges from L to R, and assign infinite (or unit) capacity.

– Add source s, and unit capacity edges from s to each node in L.

– Add sink t, and unit capacity edges from each node in R to t.

Bipartite Matching

s

1

3

5

1'

3'

5'

t

2

4

2'

4'

1 1

RL

G'

Page 9: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Theorem. Max cardinality matching in G = value of max flow in G'.

• Pf. – Given max matching M of cardinality k.– Consider flow f that sends 1 unit along each of k

paths.– f is a flow, and has cardinality k. ▪

Bipartite Matching: Proof of Correctness

s

1

3

5

1'

3'

5'

t

2

4

2'

4'

1 1

1

3

5

1'

3'

5'

2

4

2'

4'

G'G

Page 10: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Theorem. Max cardinality matching in G = value of max flow in G'.

• Pf. – Let f be a max flow in G' of value k.– Integrality theorem k is integral and can assume f is 0-

1.– Consider M = set of edges from L to R with f(e) = 1.

• each node in L and R participates in at most one edge in M

• |M| = k: consider cut (L s, R t) ▪

Bipartite Matching: Proof of Correctness

1

3

5

1'

3'

5'

2

4

2'

4'

G

s

1

3

5

1'

3'

5'

t

2

4

2'

4'

1 1

G'

Page 11: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Def. A matching M E is perfect if each node appears in exactly one edge in M.

• Q. When does a bipartite graph have a perfect matching?

• Structure of bipartite graphs with perfect matchings. – Clearly we must have |L| = |R|.– What other conditions are necessary?– What conditions are sufficient?

Perfect Matching

Page 12: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Notation. Let S be a subset of nodes, and let N(S) be the set of nodes adjacent to nodes in S.

• Lemma. If a bipartite graph G = (L R, E), has a perfect matching, then |N(S)| |S| for all subsets S L.

Perfect Matching

No perfect matching:

S = { 2, 4, 5 }

N(S) = { 2', 5' }.

1

3

5

1'

3'

5'

2

4

2'

4'

L R

• Pf. Each node in S has to be matched to a different node in N(S).

Page 13: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Marriage Theorem. [Frobenius 1917, Hall 1935] Let G = (L R, E) be a bipartite graph with |L| = |R|. Then, G has a perfect matching or there is exists S L such that

|N(S)| < |S|.

Marriage Theorem

Pf: When there is no perfect matching, Use max-flow min-cut theorem on a bipartite graph, to find the cut(A’,B’) < n.

Let A = L ∩ A’

Claim 1: N(A) A’Claim 2: |R ∩ A’| >= N(A)Claim 3: c(A’,B’) = |L ∩ B’ | + |R ∩ A’| < n

Page 14: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Which max flow algorithm to use for bipartite matching?

– Generic augmenting path: O(m val(f*) ) = O(mn).

– Capacity scaling: O(m2 log C ) = O(m2).– Shortest augmenting path: O(m n1/2).

• Non-bipartite matching.– Structure of non-bipartite graphs is more complicated, but

well-understood. [Tutte-Berge, Edmonds-Galai]– Blossom algorithm: O(n4). [Edmonds 1965]– Best known: O(m n1/2). [Micali-Vazirani 1980]

Bipartite Matching: Running Time

Page 15: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

15

7.10 Image Segmentation7.10 Image Segmentation7.10 Image Segmentation7.10 Image Segmentation

Page 16: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Image segmentation

Page 17: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Image Segmentation

• Image segmentation.– Central problem in image processing.– Divide image into coherent regions.

• Ex: To recognize a hand (or face/iris/fingerprint) from the background. (And find out if the person is known to the system)

Page 18: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Image Segmentation• Foreground / background segmentation.

– Label each pixel in picture as belonging toforeground or background.

– V = set of pixels, E = pairs of neighboring pixels.

– ai 0 is likelihood pixel i in foreground.

– bi 0 is likelihood pixel i in background.

– pij 0 is separation penalty for labeling one of iand j as foreground, and the other as background.

• Goals.

– Accuracy: if ai > bi in isolation, prefer to label i in foreground.

– Smoothness: if many neighbors of i are labeled foreground, we should be inclined to label i as foreground.

– Find partition (A, B) that maximizes:

a i i A b j

j B pij

(i, j) EA{i, j} 1

foreground background

Page 19: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Image Segmentation• Formulate as min cut problem.

– Maximization.– No source or sink.– Undirected graph.

• Turn into minimization problem.

– Maximizing

is equivalent to minimizing

– or alternatively

a j j B bi

i A pij

(i, j) EA{i, j} 1

a i i A b j

j B pij

(i, j) EA{i, j} 1

a ii V b jj V a constant

a i

i A bj

j B pij

(i, j) EA{i, j} 1

Page 20: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Image Segmentation• Formulate as min cut problem.

– G' = (V', E').– Add source to correspond to foreground;

add sink to correspond to background– Use two anti-parallel edges instead of

undirected edge.

s t

pij

pij

pij

i jpij

aj

G'

bi

Page 21: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Image Segmentation• Consider min cut (A, B) in G'.

– A = foreground.

– Precisely the quantity we want to minimize.

cap(A, B) a j j B bi

i A pij

(i, j) Ei A, j B

G'

s ti j

A

if i and j on different sides,pij counted exactly once

pij

bi

aj

Page 22: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Edge Disjoint pathsEdge Disjoint pathsEdge Disjoint pathsEdge Disjoint paths

Page 23: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths.

• Def. Two paths are edge-disjoint if they have no edge in common.

• Ex: communication networks.

s

2

3

4

Edge Disjoint Paths

5

6

7

t

Page 24: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Disjoint path problem. Given a digraph G = (V, E) and two nodes s and t, find the max number of edge-disjoint s-t paths.

• Def. Two paths are edge-disjoint if they have no edge in common.

• Ex: communication networks.

s

2

3

4

Edge Disjoint Paths

5

6

7

t

Page 25: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Max flow formulation: assign unit capacity to every edge.

• Theorem. Max number edge-disjoint s-t paths equals max flow value.• Pf.

– Suppose there are k edge-disjoint paths P1, . . . , Pk.

– Set f(e) = 1 if e participates in some path P i ; else set f(e) = 0.

– Since paths are edge-disjoint, f is a flow of value k. ▪

Edge Disjoint Paths

s t

1

1

1

1

1

1

11

1

1

1

1

1

1

Page 26: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

• Max flow formulation: assign unit capacity to every edge.

• Theorem. Max number edge-disjoint s-t paths equals max flow value.• Pf.

– Suppose max flow value is k.– Integrality theorem there exists 0-1 flow f of value k.– Consider edge (s, u) with f(s, u) = 1.

• by conservation, there exists an edge (u, v) with f(u, v) = 1• continue until reach t, always choosing a new edge

– Produces k (not necessarily simple) edge-disjoint paths. ▪

Edge Disjoint Paths

s t

1

1

1

1

1

1

11

1

1

1

1

1

1

can eliminate cycles to get simple paths if desired

Page 27: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

Menger’s theorem

• In every directed graph with nodes s and t, the maximum number of edge-disjoint s-t paths is equal to the minimum number of edges whose removal separates s from t.

• Special case of MaxFlow MinCut theorem.

• We cud use this theorem instead of the MaxFlow MinCut theorem in the proof of Hall’s theorem.

Page 28: Advanced Algorithms Piyush Kumar (Lecture 4: MaxFlow MinCut Applications) Welcome to COT5405.

References

• R.K. Ahuja, T.L. Magnanti, and J.B. Orlin. Network Flows. Prentice Hall, 1993. (Reserved in Dirac)

• K. Mehlhorn and S. Naeher. The LEDA Platform for Combinatorial and Geometric Computing. Cambridge University Press, 1999. 1018 pages


Recommended