Presentation is loading. Please wait.

Presentation is loading. Please wait.

10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 22 Network.

Similar presentations


Presentation on theme: "10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 22 Network."— Presentation transcript:

1 10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 22 Network Flow Applications

2 Extensions/applications Partition problems –Think of minimum cut Circulations (in KT book) 10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

3 7.10 Image Segmentation

4 4 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.

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

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

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

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

9 7.11 Project Selection

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

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

12 12 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 

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

14 14 Open-pit mining. (studied since early 1960s) n Blocks of earth are extracted from surface to retrieve ore. n Each block v has net value p v = value of ore - processing cost. n Can't remove block v before w or x. Open Pit Mining v xw

15 7.7 Circulations

16 16 Circulation with Demands Circulation with demands. n Directed graph G = (V, E). n Edge capacities c(e), e  E. n Node supply and demands d(v), v  V. Def. A circulation is a function that satisfies: n For each e  E:0  f(e)  c(e) (capacity) n For each v  V: (conservation) Circulation problem: given (V, E, c, d), does there exist a circulation? demand if d(v) > 0; supply if d(v) < 0; transshipment if d(v) = 0

17 17 Necessary condition: sum of supplies = sum of demands. Pf. Sum conservation constraints for every demand node v. 3 10 6 -7 -8 11 -6 4 9 7 3 10 0 7 4 4 6 6 7 1 4 2 flow Circulation with Demands capacity demand supply

18 18 Circulation with Demands Max flow formulation. G: supply 3 10 6 -7 -8 11 -6 4 9 10 0 7 4 7 4 demand

19 19 Circulation with Demands Max flow formulation. n Add new source s and sink t. n For each v with d(v) < 0, add edge (s, v) with capacity -d(v). n For each v with d(v) > 0, add edge (v, t) with capacity d(v). n Claim: G has circulation iff G' has max flow of value D. G': supply 3 10 6 9 0 7 4 7 4 s t 11 7 8 6 saturates all edges leaving s and entering t demand

20 20 Circulation with Demands Integrality theorem. If all capacities and demands are integers, and there exists a circulation, then there exists one that is integer-valued. Pf. Follows from max flow formulation and integrality theorem for max flow. Characterization. Given (V, E, c, d), there does not exists a circulation iff there exists a node partition (A, B) such that  v  B d v > cap(A, B) Pf idea. Look at min cut in G'. demand by nodes in B exceeds supply of nodes in B plus max capacity of edges going from A to B

21 21 Circulation with Demands and Lower Bounds Feasible circulation. n Directed graph G = (V, E). n Edge capacities c(e) and lower bounds (e), e  E. n Node supply and demands d(v), v  V. Def. A circulation is a function that satisfies: n For each e  E: (e)  f(e)  c(e) (capacity) n For each v  V: (conservation) Circulation problem with lower bounds. Given (V, E,, c, d), does there exists a a circulation?

22 22 Circulation with Demands and Lower Bounds Idea. Model lower bounds with demands. n Send (e) units of flow along edge e. n Update demands of both endpoints. Theorem. There exists a circulation in G iff there exists a circulation in G'. If all demands, capacities, and lower bounds in G are integers, then there is a circulation in G that is integer-valued. Pf sketch. f(e) is a circulation in G iff f'(e) = f(e) - (e) is a circulation in G'. vw [2, 9] lower bound upper bound vw d(v)d(w) d(v) + 2 d(w) - 2 G G' 7 capacity

23 23 Census Tabulation (Exercise 7.39) Feasible matrix rounding. n Given a p-by-q matrix D = {d ij } of real numbers. n Row i sum = a i, column j sum b j. n Round each d ij, a i, b j up or down to integer so that sum of rounded elements in each row (column) equals row (column) sum. n Original application: publishing US Census data. Goal. Find a feasible rounding, if one exists. 17.243.146.87.3 12.79.62.40.7 11.33.61.26.5 16.3410.414.5 17377 131021 11317 161015 original matrix feasible rounding

24 24 Census Tabulation Feasible matrix rounding. n Given a p-by-q matrix D = {d ij } of real numbers. n Row i sum = a i, column j sum b j. n Round each d ij, a i, b j up or down to integer so that sum of rounded elements in each row (column) equals row (column) sum. n Original application: publishing US Census data. Goal. Find a feasible rounding, if one exists. Remark. "Threshold rounding" can fail. 1.050.35 1.650.55 0.9 original matrix feasible rounding 1001 2110 111

25 25 Census Tabulation Theorem. Feasible matrix rounding always exists. Pf. Formulate as a circulation problem with lower bounds. n Original data provides circulation (all demands = 0). n Integrality theorem  integral solution  feasible rounding. ▪ 17.243.146.87.3 12.79.62.40.7 11.33.61.26.5 16.3410.414.5 s 1 2 3 1' 2' 3' t row column 17, 18 12, 13 11, 12 16, 17 10, 11 14, 15 3, 4 0,  lower bound upper bound


Download ppt "10/11/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 22 Network."

Similar presentations


Ads by Google