Sublinear Algorithms Lecture 3 Sofya Raskhodnikova Penn State University 1
Graph Properties
Testing if a Graph is Connected [Goldreich Ron] Input: a graph π» = (π, πΉ) on π vertices β’ in adjacency lists representation (a list of neighbors for each vertex) β’ maximum degree d , i.e., adjacency lists of length d with some empty entries Query (π€, π) , where π€ β π and π β [π] : entry π of adjacency list of vertex π€ Exact Answer: W (dn) time β’ Approximate version: Is the graph connected or Β² -far from connected? # ππ πππ’ππ ππ‘ ππ πππππππππ§ πππ‘π’π‘ ππ π₯βππβ π» 1 πππ π» 2 ππππππ dist π» 1 , π» 2 = ππ 1 Time: π π 2 π today No dependence on n! + improvement on HW 3
Testing Connectedness: Algorithm Connectedness Tester(G, d, Ξ΅ ) Repeat s=16/ e d times: 1. pick a random vertex π£ 2. determine if connected component of π£ is small: 3. perform BFS from π£ , stopping after at most 8/ e d new nodes Reject if a small connected component was found, otherwise accept. 4. Run time: O( π / e 2 π 2 )=O(1/ e 2 π ) Analysis: β’ Connected graphs are always accepted. β’ Remains to show: 2 If a graph is Β² -far from connected, it is rejected with probability β₯ 3 4
Testing Connectedness: Analysis Claim 1 If G is e -far from connected, it has β₯ e ππ 4 connected components. Claim 2 If G is e -far from connected, it has β₯ e ππ 8 connected components of size at most 8/ e d . If Claim 2 holds, at least e ππ 8 nodes are in small connected components. β’ 2β 8 16 e ππ/π = e π nodes to detect one β’ By Witness lemma, it suffices to sample from a small connected component. 5
Testing Connectedness: Proof of Claim 1 Claim 1 If G is e -far from connected, it has β₯ e ππ 4 connected components. We prove the contrapositive: If G has < e ππ 4 connected components, one can make G connected by modifying < e fraction of its representation, i.e., < e ππ entries. β’ If there are no degree restrictions, k components can be connected by adding k-1 edges, each affecting 2 nodes. Here, k < e ππ 4 , so 2k-2 < e ππ . β’ What if adjacency lists of all vertices in a component are full, i.e., all vertex degrees are d? 6
Freeing up an Adjacency List Entry Claim 1 If G is e -far from connected, it has β₯ e ππ 4 connected components. What if adjacency lists of all vertices in a component are full, i.e., all vertex degrees are d? π€ β’ Consider an MST of this component. Let π€ be a leaf of the MST. β’ Disconnect π€ from a node other than its parent in the MST. β’ β’ Two entries are changed while keeping the same number of components. β’ Thus, k components can be connected by adding 2k-1 edges, each affecting 2 nodes. Here, k < e ππ 4 , so 4k-2 < e ππ . 7
Testing Connectedness: Proof of Claim 2 Claim 1 If G is e -far from connected, it has β₯ e ππ 4 connected components. Claim 2 If G is e -far from connected, it has β₯ e ππ 8 connected components of size at most 8/ e d . If Claim 1 holds, there are at least e ππ 4 connected components. β’ π 4 Their average size β€ e ππ/4 = β’ e π . β’ By an averaging argument (or Markov inequality), at least half of the components are of size at most twice the average. 8
Testing if a Graph is Connected [Goldreich Ron] Input: a graph π» = (π, πΉ) on π vertices β’ in adjacency lists representation (a list of neighbors for each vertex) β’ maximum degree d Connected or π -far from connected? 1 π π 2 π time (no dependence on π ) 9
Randomized Approximation in sublinear time Simple Examples
Randomized Approximation: a Toy Example Input: a string π₯ β 0,1 π 0 0 0 1 β¦ 0 1 0 0 Goal: Estimate the fraction of 1βs in π₯ (like in polls) It suffices to sample π‘ = 1 β π 2 positions and output the average to get the fraction of 1βs Β±π (i.e., additive error π ) with probability ΒΈ 2/3 Hoeffding Bound Let Y 1 , β¦ , Y s be independently distributed random variables in [0,1] and π‘ β₯ Ξ΄ β€ 2e β2π 2 /π‘ . let Y = β Y i (sample sum). Then Pr Y β E Y π=1 π‘ Y i = value of sample π . Then E[Y] = β E[Y i ] = π‘ β (fraction of 1βs in π₯ ) π=1 Pr (sample average) β fraction of 1β²s in π₯ β₯ π = Pr Y β E Y β₯ ππ‘ β€ 2e β2π 2 /π‘ = 2π β2 < 1/3 substitute π‘ = 1 β π 2 Apply Hoeffding Bound with π = ππ‘ 11
Approximating # of Connected Components [Chazelle Rubinfeld Trevisan] Input: a graph π» = (π, πΉ) on n vertices β’ in adjacency lists representation (a list of neighbors for each vertex) β’ maximum degree d Exact Answer: W (dn) time Additive approximation: # of CC Β± Ξ΅ n with probability ΒΈ 2/3 Time: π 1 π β’ Known: π π 2 log π , W π 2 π β’ Today: π π 3 . No dependence on n! Partially based on slides by Ronitt Rubinfeld: 12 http://stellar.mit.edu/S/course/6/fa10/6.896/courseMaterial/topics/topic3/lectureNotes/lecst11/lecst11.pdf
Approximating # of CCs: Main Idea Let π· = number of components β’ For every vertex π£ , define β’ π π£ = number of nodes in uβs component Breaks C up into 1 for each component A : β π π£ = 1 β π£βπ΅ contributions 1 of different nodes β = π· π π£ π£βπ β’ Estimate this sum by estimating π π£ βs for a few random nodes β If π£ βs component is small, its size can be computed by BFS. β If π£ βs component is big, then 1/π π£ is small, so it does not contribute much to the sum β Can stop BFS after a few steps Similar to property tester for connectedness [Goldreich Ron] 13
Approximating # of CCs: Algorithm Estimating π π£ = the number of nodes in π£ βs component : 2 Let estimate π π£ = min π π£ , β’ π π β When π£ βs component has Β· 2/ e nodes , π π£ = π π£ π 1 β 1 β€ π π π£ = 2/ e , and so 0 < 1 π£ β 1 π π£ < 1 π£ = π 2 β Else π 2 π π£ π π£ π π 1 = β Corresponding estimate for C is π· β’ . It is a good estimate: π£βπ π£ π 1 1 1 1 ππ β π· = β β β β€ β π· π£ β π π£ β€ π£βπ π£βπ π£βπ π π£ π π£ π 2 APPROX_#_CCs (G, d, Ξ΅ ) Repeat s= Ξ (1/ e 2 ) times: 1. pick a random vertex π£ 2. π£ via BFS from π£ , stopping after at most 2/ e new nodes compute π 3. = (average of the values 1/π 4. Return π· π£ ) β π Run time: O(d / e 3 ) 14
Approximating # of CCs: Analysis ππ 1 β π· > Want to show: Pr π· β€ 3 2 Hoeffding Bound Let Y 1 , β¦ , Y s be independently distributed random variables in [0,1] and π‘ β₯ Ξ΄ β€ 2e β2π 2 /π‘ . let Y = β Y i (sample sum). Then Pr Y β E Y π=1 Let Y i = 1/π π£ for the i th vertex π£ in the sample π‘ π‘ π‘π· 1 1 π‘π· π β β’ Y = β Y i = π and E[Y] = β E[Y i ] = π‘ β E[Y 1 ] = π‘ β = π π£βπ π π€ π=1 π=1 2 β€ 2π β π2π‘ ππ π π ππ ππ‘ β π· > Pr π· = Pr π‘ π β π‘ πΉ π > = Pr Y β E Y > 2 2 2 1 1 Need π‘ = Ξ π 2 samples to get probability β€ β’ 3 15
Approximating # of CCs: Analysis ππ β π· β€ So far: π· 2 ππ 1 β π· > Pr π· β€ 3 2 2 β’ With probability β₯ 3 , β π· β€ ππ 2 + ππ β π· β€ π· β π· + π· π· 2 β€ ππ Summary: The number of connected components in π -vetex graphs of π degree at most π can be estimated within Β±ππ in time π π 3 . 16
Minimum spanning tree (MST) β’ What is the cheapest way to connect all the dots? Input: a weighted graph 3 with n vertices and m edges 4 2 7 1 5 β’ Exact computation: β Deterministic π(π β inverse-Ackermann (π)) time [Chazelle] β Randomized π(π) time [Karger Klein Tarjan] Partially based on slides by Ronitt Rubinfeld: 17 http://stellar.mit.edu/S/course/6/fa10/6.896/courseMaterial/topics/topic3/lectureNotes/lecst11/lecst11.pdf
Approximating MST Weight in Sublinear Time [Chazelle Rubinfeld Trevisan] Input: a graph π» = (π, πΉ) on n vertices β’ in adjacency lists representation β’ maximum degree d and maximum allowed weight w β’ weights in {1,2,β¦, w } Output: (1+ Ξ΅ )-approximation to MST weight, π₯ πππ Time: ππ₯ ππ₯ ππ₯ No dependence on n! , W β’ Known: π π 3 log π 2 π ππ₯ 3 log π₯ β’ Today: π π 3 18
Idea Behind Algorithm β’ Characterize MST weight in terms of number of connected components in certain subgraphs of G β’ Already know that number of connected components can be estimated quickly 19
MST and Connected Components: Warm-up β’ Recall Kruskalβs algorithm for computing MST exactly. Suppose all weights are 1 or 2. Then MST weight = (# weight-1 edges in MST) + 2 β (# weight-2 edges in MST) = π β 1 + (# of weight-2 edges in MST) MST has π β 1 edges = π β 1 + (# of CCs induced by weight-1 edges) β1 By Kruskal weight 1 MST connected components weight 2 induced by weight-1 edges
Recommend
More recommend