Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015.

Similar presentations


Presentation on theme: "Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015."— Presentation transcript:

1 Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015

2 2 Max flow problem. Find s-t flow of maximum value. Maximum Flow Problem 10 9 9 14 4 10 4 8 9 1 0 0 0 14 capacity flow s 2 3 4 5 6 7 t 15 5 30 15 10 8 15 9 6 10 15 4 4 0 Value = 28

3 3 Ford-Fulkerson with Capacity Scaling Scaling-Max-Flow(G, s, t, c) { foreach e  E f(e)  0   smallest power of 2 greater than or equal to C G f  residual graph while (   1) { G f (  )   -residual graph while (there exists augmenting path P in G f (  )) { f  augment(f, c, P) update G f (  ) }    / 2 } return f }

4 Bipartite Matching

5 5 Matching. n Input: undirected graph G = (V, E). n M  E is a matching if each node appears in at most edge in M. n Max matching: find a max cardinality matching. Matching

6 6 Bipartite Matching Bipartite matching. n Input: undirected, bipartite graph G = (L  R, E). n M  E is a matching if each node appears in at most one edge in M. n 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

7 7 Bipartite Matching Bipartite matching. n Input: undirected, bipartite graph G = (L  R, E). n M  E is a matching if each node appears in at most edge in M. n 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'

8 8 Max flow formulation. n Create digraph G' = (L  R  {s, t}, E' ). n Direct all edges from L to R, and assign unit capacity. n Add source s, and unit capacity edges from s to each node in L. n 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 1 RL G'

9 9 Theorem. Max cardinality matching in G = value of max flow in G'. Pf.  n Given max matching M of cardinality k. n Consider flow f that sends 1 unit along each of k paths. n 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' 11 1 1 3 5 1' 3' 5' 2 4 2' 4' G' G

10 10 Theorem. Max cardinality matching in G = value of max flow in G'. Pf.  n Let f be a max flow in G' of value k. n Integrality theorem  k is integral and can assume f is 0-1. n 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' 11 1 G'

11 11 Which max flow algorithm to use for bipartite matching? n Generic augmenting path: O(m val(f*) ) = O(mn). n Capacity scaling: O(m 2 log C ) = O(m 2 ). n Shortest augmenting path: O(m n 1/2 ). Non-bipartite matching. n Structure of non-bipartite graphs is more complicated, but well-understood. [Tutte-Berge, Edmonds-Galai] n Blossom algorithm: O(n 4 ). [Edmonds 1965] n Best known: O(m n 1/2 ). [Micali-Vazirani 1980] Bipartite Matching: Running Time

12 Disjoint Paths

13 13 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

14 14 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

15 15 Max flow formulation: assign unit capacity to every edge. Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf.  n Suppose there are k edge-disjoint paths P 1,..., P k. n Set f(e) = 1 if e participates in some path P i ; else set f(e) = 0. n Since paths are edge-disjoint, f is a flow of value k. ▪ Edge Disjoint Paths st 1 1 1 1 1 1 1 1 1 1 1 1 1 1

16 16 Max flow formulation: assign unit capacity to every edge. Theorem. Max number edge-disjoint s-t paths equals max flow value. Pf.  n Suppose max flow value is k. n Integrality theorem  there exists 0-1 flow f of value k. n 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 n Produces k (not necessarily simple) edge-disjoint paths. ▪ Edge Disjoint Paths st 1 1 1 1 1 1 1 1 1 1 1 1 1 1 can eliminate cycles to get simple paths if desired

17 17 Network connectivity. Given a digraph G = (V, E) and two nodes s and t, find min number of edges whose removal disconnects t from s. Def. A set of edges F  E disconnects t from s if all s-t paths uses at least on edge in F. Network Connectivity s 2 3 4 5 6 7 t

18 18 Edge Disjoint Paths and Network Connectivity Theorem. [Menger 1927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf.  n Suppose the removal of F  E disconnects t from s, and |F| = k. n All s-t paths use at least one edge of F. Hence, the number of edge- disjoint paths is at most k. ▪ s 2 3 4 5 6 7 t s 2 3 4 5 6 7 t

19 19 Disjoint Paths and Network Connectivity Theorem. [Menger 1927] The max number of edge-disjoint s-t paths is equal to the min number of edges whose removal disconnects t from s. Pf.  n Suppose max number of edge-disjoint paths is k. n Then max flow value is k. n Max-flow min-cut  cut (A, B) of capacity k. n Let F be set of edges going from A to B. n |F| = k and disconnects t from s. ▪ s 2 3 4 5 6 7 t s 2 3 4 5 6 7 t A

20 Image Segmentation

21 21 Image Segmentation Image segmentation. n Central problem in image processing. n Divide image into coherent regions. Ex: Three people standing in front of complex background scene. Identify each person as a coherent object.

22 22 Image Segmentation Foreground / background segmentation. n Label each pixel in picture as belonging to foreground or background. n V = set of pixels, E = pairs of neighboring pixels. n a i  0 is likelihood pixel i in foreground. n b i  0 is likelihood pixel i in background. n p ij  0 is separation penalty for labeling one of i and j as foreground, and the other as background. Goals. n Accuracy: if a i > b i in isolation, prefer to label i in foreground. n Smoothness: if many neighbors of i are labeled foreground, we should be inclined to label i as foreground. n Find partition (A, B) that maximizes: foreground background

23 23 Image Segmentation Formulate as min cut problem. n Maximization. n No source or sink. n Undirected graph. Turn into minimization problem. n Maximizing is equivalent to minimizing n or alternatively

24 24 Image Segmentation Formulate as min cut problem. n G' = (V', E'). n Add source to correspond to foreground; add sink to correspond to background n Use two anti-parallel edges instead of undirected edge. st p ij ij ajaj G' bibi

25 25 Image Segmentation Consider min cut (A, B) in G'. n A = foreground. n Precisely the quantity we want to minimize. G' st ij A if i and j on different sides, p ij counted exactly once p ij bibi ajaj

26 Project Selection

27 27 Project Selection Projects with prerequisites. n Set P of possible projects. Project v has associated revenue p v. – some projects generate money: create interactive e-commerce interface, redesign web page – others cost money: upgrade computers, get site license n Set of prerequisites E. If (v, w)  E, can't do project v and unless also do project w. n A subset of projects A  P is feasible if the prerequisite of every project in A also belongs to A. Project selection. Choose a feasible subset of projects to maximize revenue. can be positive or negative

28 28 Project Selection: Prerequisite Graph Prerequisite graph. n Include an edge from v to w if can't do v without also doing w. n {v, w, x} is feasible subset of projects. n {v, x} is infeasible subset of projects. v w x v w x feasibleinfeasible

29 29 Min cut formulation. n Assign capacity  to all prerequisite edge. n Add edge (s, v) with capacity -p v if p v > 0. n Add edge (v, t) with capacity -p v if p v < 0. n For notational convenience, define p s = p t = 0. st -p w u v w x yz Project Selection: Min Cut Formulation  pvpv -p x      pypy pupu -p z 

30 30 Claim. (A, B) is min cut iff A  { s } is optimal set of projects. n Infinite capacity edges ensure A  { s } is feasible. n Max revenue because: s t -p w u v w x yz Project Selection: Min Cut Formulation pvpv -p x pypy pupu    A


Download ppt "Prof. Swarat Chaudhuri COMP 382: Reasoning about Algorithms Fall 2015."

Similar presentations


Ads by Google