1 / 116

CS5234 Combinatorial and Graph Algorithms

CS5234 Combinatorial and Graph Algorithms. Welcome!. Problem Sets Programming Assignment Exams. Administrative. CS5234 Overview. Problem set 1 due PS1: Hand it in now! Problem set 2 released tonight PS2: Submit next week IVLE (optional, electronic submission)

allan
Download Presentation

CS5234 Combinatorial and Graph 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. CS5234Combinatorial and Graph Algorithms Welcome!

  2. Problem Sets • Programming Assignment • Exams Administrative

  3. CS5234 Overview • Problem set 1 due PS1: Hand it in now! • Problem set 2 released tonight PS2: Submit next week • IVLE (optional, electronic submission) Soon: Once registration completes…

  4. CS5234 Overview • Problem set grading Distributed grading scheme: Once registration completes, there will be an IVLE survey where you choose a week. Grading supervised (and verified) by the TA.

  5. CS5234 Overview • How to draw pictures? By hand: Either submit hardcopy, or scan, or take a picture with your phone! Or use a tablet / iPad… Digitally: 1. xfig (ugh) 2. OmniGraffle (mac) 3. Powerpoint (hmmm) 4. ???

  6. CS5234 Overview • Programming assignment(s): Berth assignment problem: Last 3-4 weeks of the semester. Very hard algorithmic problem (related to graph partitioning). Design the best solution you can! Must know or learn: C++ More details later…

  7. CS5234 Overview • Mid-term exam October 8 In class • Final exam November 19Reading Week Exams will be graded and returned.

  8. Vertex Cover Quick Review

  9. Vertex Cover • Definition: Given: graph G = (V,E) Find: smallest cover C ⊆ V such that every edge e ∈ E is covered by some node v ∈ V. • Challenge: NP-complete: No polynomial time algorithm unless P = NP.

  10. Vertex Cover Example: (Suboptimal) cover (size 9)

  11. Vertex Cover Example: Optimal cover? (size 6)

  12. Vertex Cover • Greedy approximation algorithm: repeat: until every edge is covered 1. Let e = (u,v) be an uncovered edge. 2. Add u and v to the cover. • Details: Graph representation: Sorted adjacency list…

  13. Vertex Cover Analysis: 1. For every matching M: OPT ≥ |M|. 2. The cover C contains a matching of size |C|/2. 3. Therefore: OPT ≥ |C|/2. Conclusion:|C| ≤ 2OPT  2-approximation algorithm

  14. Vertex Cover (Review) • Set Cover (Review + Analysis) • Steiner Trees Today’s Plan

  15. Set Cover • Definition: Given: set X subsets S1, S2, …, Smwhere Sj⊆ X Find: smallest collection I ⊆ {1, …, m} such that: • Challenge: NP-complete: No polynomial time algorithm unless P = NP.

  16. Set Cover X = {C, C++, Java, Ruby, Python} • Example: Alice: C, C++ Bob:C++, Java Collin:C++, Ruby, Python Dave:C, Java • Choose a good team: Collin and Dave: optimal solution.

  17. Set Cover set that contains the most uncovered elements

  18. Set Cover Example: 1. Choose S2.

  19. Set Cover Example: Choose S2. Choose S3.

  20. Set Cover Example: Choose S2. Choose S3. Choose S4.

  21. Set Cover Example: Choose S2. Choose S3. Choose S4. Choose S1

  22. Set Cover Example: Output: S1, S2, S3, S4 OPT: S1, S4, S5

  23. Set Cover To get a good approximation, show a lower bound on OPT. • “OPT has to be AT LEAST this large.” • E.g., “OPT ≥ |M|”

  24. Set Cover Example: Note: 12 elements ≤ 6 elements per set  OPT ≥ 2

  25. Set Cover Example: Note: 6 uncovered elements ≤ 3 elements per set  OPT ≥ 2

  26. Set Cover Example: General rule: k uncovered elements ≤ t elements per set  OPT ≥ (k / t)

  27. Notation Assume GREEDY covers elements in order: x1, x2, x3, x4, x5, x6, x7, x8, …, xn xj= the jth item covered

  28. Notation Assume GREEDY covers elements in order: x1, x2, x3, x4, x5, x6, x7, x8, …, xn S4 covers 1 new item S3 covers 3 items S1 covers 2 new items S6 covers 2 new items

  29. Notation Assume GREEDY covers elements in order: x1, x2, x3, x4, x5, x6, x7, x8, …, xn 2 2 1 3

  30. Notation Assume GREEDY covers elements in order: x1, x2, x3, x4, x5, x6, x7, x8, …, xn c1, c2, c3, c4, c5, c6, c7, c8, …, cn 3, 3, 3, 2, 2, 2, 2, 1, …, cj = number of items covered in same step as xj 2 2 1 3

  31. Notation Assume GREEDY covers elements in order: x1, x2, x3, x4, x5, x6, x7, x8, …, xn • cost(x1) = 1/3 • cost(x2) = 1/3 • cost(x3) = 1/3 • cost(x4) = 1/2 • cost(x5) = 1/2 • … cost(xj) = 1/cj= amount payed to cover xj 2 2 1 3

  32. Notation Assume GREEDY covers elements in order: x1, x2, x3, x4, x5, x6, x7, x8, …, xn cost(xj) = 1/cj= amount payed to cover xj 2 2 1 3

  33. Set Cover Example: Note: 6 uncovered elements ≤ 3 elements per set  OPT ≥ 2

  34. Analysis Assume (x1, x2, …, xj-1) are covered: • How does OPT cover (xj, xj+1, …, xn)?

  35. Analysis Assume (x1, x2, …, xj-1) are covered: • How does OPT cover (xj, xj+1, …, xn)? Fact: No set covers more than c(xj) elements in the set (xj, xj+1, …, xn). Why? If it did, GREEDY would have chosen it! (Tip: use the fact that algorithm is GREEDY.)

  36. Analysis Assume (x1, x2, …, xj-1) are covered: • How does OPT cover (xj, xj+1, …, xn)? As before: n – j + 1 uncovered elements ≤ c(xj) elements per set  OPT ≥ (n – j + 1) / c(xj) = (n – j + 1)cost(xj)

  37. Analysis Assume (x1, x2, …, xj-1) are covered: • How does OPT cover (xj, xj+1, …, xn)? As before: n – j + 1 uncovered elements ≤ c(xj) elements per set  OPT ≥ (n – j + 1) / c(xj) = (n – j + 1)cost(xj)  cost(xj) ≤ OPT / (n – j + 1)

  38. Analysis Assume GREEDY covers elements in order: x1, x2, x3, x4, x5, x6, x7, x8, …, xn 2 2 1 3

  39. Algebra

  40. Set Cover Conclusion: Theorem: Greedy-Set-Cover is an O(log n) approximation algorithm for set cover.

  41. Vertex Cover (Review) • Set Cover (Review + Analysis) • Steiner Trees Today’s Plan

  42. A Warm-Up Problem • Problem Statement: Given: 2d (Euclidean) map & set of points of interest Find: shortest set of roads connecting all points

  43. A Warm-Up Problem • Problem Statement: Given: 2d (Euclidean) map & set of points of interest Find: shortest set of roads connecting all points

  44. A Warm-Up Problem • Algorithm: Compute: for every pair (u,v): distance(u,v) Build: complete graph G = (V, E) where w(u,v) = distance(u,v) Find: minimum spanning tree of G.

  45. Spanning Tree Definition: a spanning tree is an acyclic subset of the edges that connects all nodes Weight: 32 13 4 5 9 9 1 2 8

  46. Minimum Spanning Tree Definition: a spanning tree with minimum weight 13 4 5 9 9 1 2 8

  47. Minimum Spanning Tree Definition: a spanning tree with minimum weight Weight: 20 13 4 5 9 9 1 2 8

  48. Properties of MST Property 1: No cycles

  49. Properties of MST Property 2: If you cut an MST, the two pieces are both MSTs.

  50. Properties of MST Property 3: Cycle property For every cycle, the maximum weight edge is not in the MST. max-weight edge on cycle

More Related