1 / 52

CSE 421 Algorithms

CSE 421 Algorithms. Richard Anderson Lecture 24 Network Flow Applications. Today’s topics. Problem Reductions Undirected Flow to Flow Bipartite Matching Disjoint Path Problem Circulations Lowerbound constraints on flows Survey design. Problem Reduction. Reduce Problem A to Problem B

gale
Download Presentation

CSE 421 Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 421Algorithms Richard Anderson Lecture 24 Network Flow Applications

  2. Today’s topics • Problem Reductions • Undirected Flow to Flow • Bipartite Matching • Disjoint Path Problem • Circulations • Lowerbound constraints on flows • Survey design

  3. Problem Reduction • Reduce Problem A to Problem B • Convert an instance of Problem A to an instance Problem B • Use a solution of Problem B to get a solution to Problem A • Practical • Use a program for Problem B to solve Problem A • Theoretical • Show that Problem B is at least as hard as Problem A

  4. Problem Reduction Examples • Reduce the problem of finding the Maximum of a set of integers to finding the Minimum of a set of integers Find the maximum of: 8, -3, 2, 12, 1, -6 Construct an equivalent minimization problem

  5. Undirected Network Flow • Undirected graph with edge capacities • Flow may go either direction along the edges (subject to the capacity constraints) u 10 20 5 s t 20 10 v Construct an equivalent flow problem

  6. Bipartite Matching • A graph G=(V,E) is bipartite if the vertices can be partitioned into disjoints sets X,Y • A matching M is a subset of the edges that does not share any vertices • Find a matching as large as possible

  7. Application • A collection of teachers • A collection of courses • And a graph showing which teachers can teach which courses RA 303 PB 321 CC 326 DG 401 AK 421

  8. Converting Matching to Network Flow s t

  9. Finding edge disjoint paths t s Construct a maximum cardinality set of edge disjoint paths

  10. Theorem • The maximum number of edge disjoint paths equals the minimum number of edges whose removal separates s from t

  11. Circulation Problem • Directed graph with capacities, c(e) on the edges, and demands d(v) on vertices • Find a flow function that satisfies the capacity constraints and the vertex demands • 0 <= f(e) <= c(e) • fin(v) – fout(v) = d(v) • Circulation facts: • Feasibility problem • d(v) < 0: source; d(v) > 0: sink • Must have Svd(v)=0 to be feasible 10 u 20 10 -25 10 s t 20 20 10 v -5

  12. Find a circulation in the following graph 2 3 4 b e 3 2 6 5 3 -4 0 -2 2 7 2 1 a c f h 4 9 3 2 8 d g 5 -5 4 10

  13. Reducing the circulation problem to Network flow 10 u 20 10 -25 10 a b 20 20 10 v -5

  14. Formal reduction • Add source node s, and sink node t • For each node v, with d(v) < 0, add an edge from s to v with capacity -d(v) • For each node v, with d(v) > 0, add an edge from v to t with capacity d(v) • Find a maximum s-t flow. If this flow has size Svcap(s,v) then the flow gives a circulation satisifying the demands

  15. Circulations with lowerbounds on flows on edges • Each edge has a lowerbound l(e). • The flow f must satisfy l(e) <= f(e) <= c(e) -2 3 1,2 a x 0,2 1,4 b y 2,4 -4 3

  16. Removing lowerbounds on edges • Lowerbounds can be shifted to the demands b y 2,5 -4 3 b y 3 -2 1

  17. Formal reduction • Lin(v): sum of lowerbounds on incoming edges • Lout(v): sum of lowerbounds on outgoing edges • Create new demands d’ and capacities c’ on vertices and edges • d’(v) = d(v) + lout(v) – lin(v) • c’(e) = c(e) – l(e)

  18. Application • Customized surveys • Ask customers about products • Only ask customers about products they use • Limited number of questions you can ask each customer • Need to ask a certain number of customers about each product • Information available about which products each customer has used

  19. Details • Customer C1, . . ., Cn • Products P1, . . ., Pm • Si is the set of products used by Ci • Customer Ci can be asked between ci and c’i questions • Questions about product Pj must be asked on between pj and p’j surveys

  20. Circulation construction

  21. Today’s topics • Open Pit Mining Problem • Task Selection Problem • Reduction to Min Cut problem S, T is a cut if S, T is a partition of the vertices with s in S and t in T The capacity of an S, T cut is the sum of the capacities of all edges going from S to T

  22. Open Pit Mining • Each unit of earth has a profit (possibly negative) • Getting to the ore below the surface requires removing the dirt above • Test drilling gives reasonable estimates of costs • Plan an optimal mining operation

  23. Mine Graph -4 -3 -2 -1 -1 -3 3 -1 4 -7 -10 -2 8 3 -10

  24. Determine an optimal mine -5 -3 -4 -4 2 -4 3 -1 -7 -10 -1 -3 -3 3 4 4 -3 -10 -10 -10 4 7 -2 -10 3 -10 -10 -10 -10 6 8 6 -3 -10 -10 -10 -10 -10 -10 1 4 4 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10

  25. Generalization • Precedence graph G=(V,E) • Each v in V has a profit p(v) • A set F if feasible if when w in F, and (v,w) in E, then v in F. • Find a feasible set to maximize the profit -4 6 -2 -3 5 -1 -10 4

  26. Min cut algorithm for profit maximization • Construct a flow graph where the minimum cut identifies a feasible set that maximizes profit

  27. Precedence graph construction • Precedence graph G=(V,E) • Each edge in E has infinite capacity • Add vertices s, t • Each vertex in V is attached to s and t with finite capacity edges

  28. Show a finite value cut with at least two vertices on each side of the cut s Infinite Finite t

  29. The sink side of a finite cut is a feasible set • No edges permitted from S to T • If a vertex is in T, all of its ancestors are in T

  30. Setting the costs s • If p(v) > 0, • cap(v,t) = p(v) • cap(s,v) = 0 • If p(v) < 0 • cap(s,v) = -p(v) • cap(v,t) = 0 • If p(v) = 0 • cap(s,v) = 0 • cap(v,t) = 0 3 3 1 1 -3 -1 -3 0 3 2 1 2 3 t

  31. Enumerate all finite s,t cuts and show their capacities s 2 2 -2 1 2 -2 1 1 2 1 t

  32. Minimum cut gives optimal solutionWhy? s 2 2 -2 1 2 -2 1 1 2 1 t

  33. Computing the Profit • Cost(W) = S{w in W; p(w) < 0}-p(w) • Benefit(W) = S{w in W; p(w) > 0} p(w) • Profit(W) = Benefit(W) – Cost(W) • Maximum cost and benefit • C = Cost(V) • B = Benefit(V)

  34. Express Cap(S,T) in terms of B, C, Cost(T), Benefit(T), and Profit(T) Cap(S,T) = Cost(T) + Ben(S) = Cost(T) + Ben(S) + Ben(T) – Ben(T) = B + Cost(T) – Ben(T) = B – Profit(T)

  35. Summary • Construct flow graph • Infinite capacity for precedence edges • Capacities to source/sink based on cost/benefit • Finite cut gives a feasible set of tasks • Minimizing the cut corresponds to maximizing the profit • Find minimum cut with a network flow algorithm

  36. Today’s topics • More network flow reductions • Airplane scheduling • Image segmentation • Baseball elimination

  37. Airplane Scheduling • Given an airline schedule, and starting locations for the planes, is it possible to use a fixed set of planes to satisfy the schedule. • Schedule • [segments] Departure, arrival pairs (cities and times) • Approach • Construct a circulation problem where paths of flow give segments flown by each plane

  38. Example • Seattle->San Francisco, 9:00 – 11:00 • Seattle->Denver, 8:00 – 11:00 • San Francisco -> Los Angeles, 13:00 – 14:00 • Salt Lake City -> Los Angeles, 15:00-17:00 • San Diego -> Seattle, 17:30-> 20:00 • Los Angeles -> Seattle, 18:00->20:00 • Flight times: • Denver->Salt Lake City, 2 hours • Los Angeles->San Diego, 1 hour Can this schedule be full filled with two planes, starting from Seattle?

  39. Compatible segments • Segments S1 and S2 are compatible if the same plane can be used on S1 and S2 • End of S1 equals start of S2, and enough time for turn around between arrival and departure times • End of S1 is different from S2, but there is enough time to fly between cities

  40. Graph representation • Each segment, Si, is represented as a pair of vertices (di, ai, for departure and arrival), with an edge between them. • Add an edge between ai and dj if Si is compatible with Sj. di ai ai dj

  41. Setting up a flow problem 1,1 di ai 0,1 ai dj 1 -1 P’i Pi

  42. Result • The planes can satisfy the schedule iff there is a feasible circulation

  43. Image Segmentation • Separate foreground from background

  44. Image analysis • ai: value of assigning pixel i to the foreground • bi: value of assigning pixel i to the background • pij: penalty for assigning i to the foreground, j to the background or vice versa • A: foreground, B: background • Q(A,B) = S{i in A}ai + S{j in B}bj - S{(i,j) in E, i in A, j inB}pij

  45. Pixel graph to flow graph s t

  46. Mincut Construction s av pvu u v puv bv t

  47. Baseball elimination • Can the Dinosaurs win the league? • Remaining games: • AB, AC, AD, AD, AD, BC, BC, BC, BD, CD A team wins the league if it has strictly more wins than any other team at the end of the season A team ties for first place if no team has more wins, and there is some other team with the same number of wins

  48. Baseball elimination • Can the Fruit Flies win the league? • Remaining games: • AC, AD, AD, AD, AF, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, BF, CE, CE, CE, CF, CF, DE, DF, EF, EF

  49. Assume Fruit Flies win remaining games • Fruit Flies are tied for first place if no team wins more than 19 games • Allowable wins • Ants (2) • Bees (3) • Cockroaches (3) • Dinosaurs (5) • Earthworms (5) • 18 games to play • AC, AD, AD, AD, BC, BC, BC, BC, BC, BD, BE, BE, BE, BE, CE, CE, CE, DE

More Related