Download presentation
Presentation is loading. Please wait.
Published byTerΓ©z Veres Modified over 5 years ago
1
Lecture 6: Counting triangles Dynamic graphs & sampling
Left to the title, a presenter can insert his/her own image pertinent to the presentation.
2
Plan Problem 3: Counting triangles Streaming for dynamic graphs
Scriber?
3
Streaming for Graphs Graph πΊ Stream: list of edges
π vertices π edges Stream: list of edges (e.g., on a hard drive) ( , ) ( , ) ( , ) ( , ) ( , ) ( , )
4
Streaming for Graphs Small (work)space: Aim: to use ~π space
E.g., for web can have π=1β
nodes π=100β
edges Small (work)space: Aim: to use ~π space or O(πβ
log π ) Still much less than the size of the graph, π (that could be up to π2) βͺπ is usually not achievable ( , ) ( , ) ( , ) ( , ) ( , ) ( , )
5
Problems 1. connectivity 2. distances 3. Count # trianglesβ¦
Exact in π(π) space 2. distances πΌ (odd) approximation in π π 1+ 2 πΌ+1 3. Count # trianglesβ¦
6
Problem 3: triangle counting
π= number of triangles Motivation: How often 2 friends of a person know each other? πΉ= π 3 π£ deg π£ 2 πΉβ[0,1] Can we compute π£ deg π£ in π π space? Yes: just count the degrees, and compute π? Hard to distinguish π=0 vs π=1 in βͺπ space Suppose we have a lower bound π‘β€π πΉ=
7
Triangle counting: Approach
Define a vector π₯ with coordinate for each subset π of 3 nodes π₯ π = how many edges among π π= # of coordinates which are 3 Remember frequencies: πΉ π = π π₯ π π Claim: π= πΉ 0 β1.5 πΉ πΉ 2 2 1 3 β¦
8
Triangle counting: Approach
Claim: π= πΉ 0 β1.5 πΉ πΉ 2 if π₯ π =0, contributes 0 on the right if π₯ π =1, contributes 0 If π₯ π =2, contributes 0 if π₯ π =3, contributes 1 ! Why such a formula exist? Want a polynomial π π₯ π which is =0 on {0,1,2} and =1 on {3} Polynomial interpolation! Need a polynomial of degree 3, but πΉ 0 provides a degree of freedom, hence degree=2 is sufficient
9
Triangle Counting: Algorithm
π= πΉ 0 β1.5 πΉ πΉ 2 Algorithm: Let πΉ 0 , πΉ 1 , πΉ 2 be 1+πΎ estimates General streaming! Edge (π,π) increases count for all π₯ π s.t. π,π βπ π = πΉ 0 β1.5 πΉ πΉ 2 How do we set πΎ? Not a 1+πΎ multiplicative! Additive error: π πΎ πΉ 0 =π(πΎππ) Set πΎ= π π‘ πππ for Β±ππ‘ additive error Total space: π πΎ β2 log π =π ππ ππ‘ 2 log π
10
Triangle Counting: Algorithm 2
Letβs consider an even simpler algorithm: Pick a few random π 1 ,β¦ π π of 3 nodes (at start) Compute π₯ π π , for πβ[π] while stream goes by Let π be the number of π s.t. π₯ π π =3 Estimate: π
= π π β
π, where π= π 3 We can see: πΈ π
=π πππ π
β€ π π π Chebyshev: |π
βπ|β€π ππ π
11
Triangle Counting: Algorithm 2+
|π
βπ|β€π ππ π Need π= π(1) π 2 β
π π‘ where π=π π 3 Better? Sample π from set of smaller size π β² βͺπ! for which π₯ π β₯1 Then obtain: Chebyshev: |π
βπ|β€π π β² π π Need π= π(1) π 2 β
π β² π‘ =π 1 π 2 β
ππ π‘ since πβ²=π ππ
12
Sampling in Graphs Setting 1: Setting 2:
Suppose we just have positive updates Not linear Setting 2: General steaming: also negative updates⦠Why? Dynamic graphs
13
Dynamic Graphs Stream contains both insertions and deletions of edges
Use 1: a log of updates to the graph [Ahn-Guha-McGregorβ12]: βhyperlinks can be removed and tiresome friends can be de-friendedβ Use 2: graph is distributed over a number of computers Then want linear sketches Generally: dynamic streams ο³ linear sketches Use 3: if time-efficient, then itβs a data structure!
14
Revisit Problem 1: Connectivity
Can we do connectivity in dynamic graphs? Algorithm from the previous lecture? Noβ¦ Theorem [AGM12]: can check s-t connectivity in dynamic graphs with π πβ
log 5 π space (with 90% success probability) Approach: sampling in (dynamic) graphs
15
Sub-Problem: dynamic sampling
Stream: general updates to a vector π₯β β1,0,1 π (will work for general π₯ too) Goal: Output π with probability π₯ π π | π₯ π | Does βstandardβ sampling work? No: After putting π₯ π =1 for π/2 coordinates, add 1 more and delete the first π/2β¦
16
Dynamic Sampling Goal: output π with probability π₯ π π | π₯ π |
Let π΄={π s.t. π₯ π β 0} Intuition: Suppose |π΄|=10 How can we sample π with non-zero π₯ π ? Use CountSketch! Each π₯ π β 0 (πβπ΄) is a 1/10-heavy hitter Can recover all of them π log π space total Suppose π΄=π/10 Downsample first: pick a random set π·β[π], of size π· β100 Focus on substream on πβπ· only (ignore the rest) Whatβs |π΄β©π·| ? In expectation =10 Use CountSketch on the downsampled streamβ¦ In general: prepare for all levels
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.