algorithms at scale
play

Algorithms at Scale (Week 2) Puzzle of the Day: A bag contains a - PowerPoint PPT Presentation

Algorithms at Scale (Week 2) Puzzle of the Day: A bag contains a collection of blue and red balls. Repeat: Take two balls from the bag. If they are the same color, discard them both and add a blue ball. If they are different colors,


  1. Approximate Connected Components Key Idea 3: Approximate Cost cost(w) = 1/6 Ignore low cost cost(x) = 1/6 w x components: A If cost(u) < 𝜁 /2, round up. Total added cost ≀ 𝜁 n /2 . cost(y) = 1/3 B y c cost(z) = 1 z

  2. Approximate Connected Components Key Idea 3: Approximate Cost cost(w) = 1/6 Define: per-node cost cost(x) = 1/6 w x Let n(u) = number of nodes in the A connected component containing node u. Let ñ(u) = min(n(u), 2/ 𝜁 ). cost(y) = 1/3 B y Let cost(u) = max(1/n(u), 𝜁 /2). c = 1/ñ(u). cost(z) = 1 z

  3. Approximate Connected Components Key Idea 3: Approximate Cost Define: per-node cost Define: Let n(u) = number of nodes in the connected component containing node u. Note: Let ñ(u) = min(n(u), 2/ 𝜁 ). Let cost(u) = max(1/n(u), 𝜁 /2). = 1/ñ(u).

  4. Approximate Connected Components Key Idea 3: Approximate Cost Define: per-node cost Define: Let n(u) = number of nodes in the connected component containing node u. Note: Let ñ(u) = min(n(u), 2/ 𝜁 ). Let cost(u) = max(1/n(u), 𝜁 /2). = 1/ñ(u).

  5. Approximate Connected Components Close enough approximation: Intuition: By rounding cost(u) up to 𝜁 /2, we increase the error at most 𝜁 n/2.

  6. Approximate Connected Components Close enough approximation: Intuition: By rounding cost(u) up to 𝜁 /2, we increase the error at most 𝜁 n/2.

  7. Approximate Connected Components Close enough approximation: Intuition: By rounding cost(u) up to 𝜁 /2, we increase the error at most 𝜁 n/2.

  8. Approximate Connected Components Close enough approximation: Intuition: By rounding cost(u) up to 𝜁 /2, we increase the error at most 𝜁 n/2.

  9. Approximate Connected Components Close enough approximation: Intuition: By rounding cost(u) up to 𝜁 /2, we increase the error at most 𝜁 n/2.

  10. Approximate Connected Components Close enough approximation: Intuition: By rounding cost(u) up to 𝜁 /2, we increase the error at most 𝜁 n/2.

  11. Approximate Connected Components Algorithm 3 sum = 0 cost(w) = 1/6 cost(x) = 1/6 w for j = 1 to s: x Choose u uniformly at random. A sum = sum + cost(u) return nβˆ™(sum/s) We have shown: cost(y) = 1/3 B y Sufficient to approximate c cost(u) by rounding up. cost(z) = 1 z

  12. Approximate Connected Components Algorithm 3 Define: per-node cost How to efficiently compute cost(u)? Let n(u) = number of nodes in the connected component containing node u. Let ñ(u) = min(n(u), 2/ 𝜁 ). Let cost(u) = max(1/n(u), 𝜁 /2). = 1/ñ(u).

  13. Approximate Connected Components Algorithm 3 Define: per-node cost How to efficiently compute cost(u)? Let n(u) = number of nodes in the connected component containing node u. Let ñ(u) = min(n(u), 2/ 𝜁 ). Let cost(u) = max(1/n(u), 𝜁 /2). = 1/ñ(u).

  14. Approximate Connected Components Algorithm 3 sum = 0 for j = 1 to s: Choose u uniformly at random. Perform a BFS from u; stop after seeing 2/ 𝜁 nodes. if BFS found > 2/ 𝜁 nodes: sum = sum + 𝜁 /2 else if BFS found n(u) nodes: sum = sum + 1/n(u) return nβˆ™(sum/s)

  15. Approximate Connected Components Analysis Goal:

  16. Approximate Connected Components Analysis Goal: Implies:

  17. Approximate Connected Components Algorithm 3 Analysis Define random variables: Y 1 , Y 2 , … , Y s Rounded up cost

  18. Approximate Connected Components Algorithm 3 Analysis Define random variables: Y 1 , Y 2 , … , Y s

  19. Approximate Connected Components Algorithm 3 Analysis Unbiased estimator:

  20. Approximate Connected Components Algorithm 3 Analysis Notice: Expected output of algorithm is:

  21. Approximate Connected Components Algorithm 3 Analysis Goal:

  22. Approximate Connected Components Algorithm 3 Analysis Derivation:

  23. Approximate Connected Components Algorithm 3 Analysis Derivation:

  24. Approximate Connected Components Analysis Goal: Implies:

  25. Approximate Connected Components Algorithm 3 sum = 0 for j = 1 to s: Choose u uniformly at random. Perform a BFS from u; stop after seeing 2/ 𝜁 nodes. if BFS found > 2/ 𝜁 nodes: sum = sum + 𝜁 /2 else if BFS found n(u) nodes: sum = sum + 1/n(u) return nβˆ™(sum/s)

  26. Approximate Connected Components Algorithm 3 We have shown: cost(w) = 1/6 cost(x) = 1/6 w x With probability > 2/3, A output is equal to: CC(G) ± 𝜁 n cost(y) = 1/3 B y c cost(z) = 1 z

  27. Approximate Connected Components Algorithm 3 Cost of BFS: O((2 / 𝜁 )βˆ™d) sum = 0 for j = 1 to s: Choose u uniformly at random. Perform a BFS from u; stop after seeing 2/ 𝜁 nodes. if BFS found > 2/ 𝜁 nodes: sum = sum + 𝜁 /2 else if BFS found n(u) nodes: sum = sum + 1/n(u) return nβˆ™(sum/s)

  28. Approximate Connected Components Algorithm 3 Cost of BFS: O((2 / 𝜁 )βˆ™d) sum = 0 for j = 1 to s: Choose u uniformly at random. Perform a BFS from u; stop after seeing 2/ 𝜁 nodes. if BFS found > 2/ 𝜁 nodes: sum = sum + 𝜁 /2 Total cost: else if BFS found n(u) nodes: O(s(2/ 𝜁 )βˆ™d) = sum = sum + 1/n(u) O((1/ 𝜁 2 )(2/ 𝜁 )d) = return nβˆ™(sum/s) O(d/ 𝜁 3 )

  29. Approximate Connected Components Algorithm 3 We have shown: cost(w) = 1/6 cost(x) = 1/6 w x With probability > 2/3, A output is equal to: CC(G) ± 𝜁 n cost(y) = 1/3 B y Running time: c cost(z) = 1 z

  30. Approximate Connected Components Algorithm 3 We have shown: cost(w) = 1/6 cost(x) = 1/6 w x With probability > 1 - 1/ δ , A output is equal to: CC(G) ± 𝜁 n cost(y) = 1/3 B y Running time: c cost(z) = 1 z

  31. Summary Today: Last Week: Number of connected components in Toy example 1 : array all 0’s? a graph. β€’ Gap-style question: β€’ Approximation algorithm. All 0’s or far from all 0’s? Toy example 2: Faction of 1’s? β€’ Weight of MST Additive Β± 𝜁 approximation β€’ β€’ Approximation algorithm. Hoeffding Bound Is the graph connected? β€’ Gap-style question. β€’ O(1) time algorithm. 9 dots β€’ Correct with probability 2/3. 4 lines

  32. Today’s Problem: Minimum Spanning Tree Assumptions: 3 3 Graph G = (V,E) 2 β€’ Undirected 2 2 1 β€’ Weighted, max weight W 2 β€’ Connected 1 β€’ n nodes 3 β€’ m edges 2 β€’ maximum degree d 3 Error term: 𝜁 < 1/2 1 Output: Example: output 16 Weight of MST.

  33. Today’s Problem: Minimum Spanning Tree Approximation: 3 3 Output M such that: 2 2 2 1 2 1 Alternate form: 3 2 3 1 Correct output: w.p. > 2/3 Example: 𝜁 = 1/4 Output ∊ [12,20]

  34. Today’s Problem : Minimum Spanning Tree When is this useful? What are trivial values of 𝜁 ? What are hard values of 𝜁 ? What sort of applications is this useful for? Why multiplicative approximation for MST and additive approximation for connected components?

  35. Simple Minimum Spanning Tree Assume all weights 1 or 2 Which edges must be in MST? 2 2 2 2 2 How many weight-2 edges in 1 2 MST? 1 1 2 Best (exact) algorithm? 2 2 1

  36. Simple Minimum Spanning Tree Assume all weights 1 or 2 Let G 1 = graph containing only 2 2 edges of weight 1. 2 2 2 1 2 1 1 2 2 2 1

  37. Simple Minimum Spanning Tree Assume all weights 1 or 2 Let G 1 = graph containing only 2 2 edges of weight 1. 2 2 2 1 2 Let C 1 = number of connected 1 components in G 1 . 1 2 2 2 1 Ex: C 1 = 6

  38. Simple Minimum Spanning Tree Assume all weights 1 or 2 Let G 1 = graph containing only 2 2 edges of weight 1. 2 2 2 1 2 Let C 1 = number of connected 1 components in G 1 . 1 2 2 Claim: MST contains example 2 C 1 -1 edges of weight 2. 1 Ex: C 1 = 6

  39. Simple Minimum Spanning Tree Assume all weights 1 or 2 Claim: MST contains example 2 2 C 1 -1 edges of weight 2. 2 2 2 1 2 Basic MST Property: 1 For any cut, minimum weight 1 2 edge across cut is in MST. 2 2 1 Ex: C 1 = 6

  40. Simple Minimum Spanning Tree Assume all weights 1 or 2 Claim: MST contains example 2 2 C 1 -1 edges of weight 2. 2 2 2 1 2 Algorithm: 1 For any connected component, 1 2 add minimum weight outgoing edge. 2 2 Here all the edges have weight 2, 1 so add C 1 -1 edges of weight 2. Ex: C 1 = 6

  41. Simple Minimum Spanning Tree Assume all weights 1 or 2 Claim: MST contains example 2 2 C 1 -1 edges of weight 2. 2 2 2 1 2 Weight of MST? 1 1 2 2 2 1 Ex: C 1 = 6

  42. Simple Minimum Spanning Tree Assume all weights 1 or 2 Claim: MST contains example 2 2 C 1 -1 edges of weight 2. 2 2 2 1 2 Weight of MST? 1 1 2 2 2 1 Ex: 10 + 6 – 2 = 14 Ex: C 1 = 6

  43. Simple Minimum Spanning Tree Assume all weights 1 or 2 Weight of MST: n + C 1 - 2 2 2 2 Algorithm idea? 2 2 1 2 1 1 2 2 2 1 Ex: C 1 = 6

  44. Simple Minimum Spanning Tree Assume all weights 1 or 2 Weight of MST: n + C 1 - 2 2 2 2 Algorithm idea: 2 2 1 2 Approximate connected components of G 1 . 1 1 2 2 2 1 Ex: C 1 = 6

  45. Approximate Minimum Spanning Tree Weights {1, 2, … , W} 3 Let G 1 = graph containing only 3 edges of weight 1. 2 2 2 1 2 Let G 2 = graph containing only 1 edges of weight {1, 2}. 3 … 2 3 Let G j = graph containing only 1 edges of weights {1, 2, … , j}. Ex: G 2

  46. Approximate Minimum Spanning Tree Weights {1, 2, … , W} 3 Let C 1 = number CC in G 1 . 3 2 2 2 Let C 2 = number CC in G 2 . 1 2 … 1 3 Let C j = number CC in G j . 2 3 1 Ex: G 2

  47. Approximate Minimum Spanning Tree Weights {1, 2, … , W} 3 Claim: 3 MST(G) contains C j – 1 edges 2 2 2 of weight > j. 1 2 1 3 2 3 1 Ex: G 2

  48. Approximate Minimum Spanning Tree Weights {1, 2, … , W} 3 Claim: 3 MST(G) contains C j – 1 edges 2 2 2 of weight > j. 1 2 1 Why? 3 There are C j connected 2 components in G j . There 3 much be C j – 1 edges 1 connecting them, and each must have weight > j. Ex: G 2

  49. Approximate Minimum Spanning Tree Weights {1, 2, … , W} 3 Lemma: 3 2 2 2 1 2 1 3 2 3 1 Ex: G 2

  50. Approximate Minimum Spanning Tree Weights {1, 2, … , W} 3 Edges of weight 1: 3 2 2 2 n – 1 edges total in MST 1 2 C 1 – 1 edges of weight > 1 1  3 (n – 1) – (C 1 – 1) edges of 2 weight 1. 3  1 (n – C 1 ) edges of weight 1. Ex: G 2

  51. Approximate Minimum Spanning Tree Weights {1, 2, … , W} 3 Edges of weight j+1: 3 2 2 2 C j – 1 edges of weight > j 1 2 C j+1 – 1 edges of weight > j+1 1  3 (C j – 1) – (C j+1 – 1) edges of 2 weight j+1. 3  1 (C j – C j+1 ) edges of weight j+1. Ex: G 2 Note: C j β‰₯ C j+1

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend