Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sketching data structures for massive graph pro...

Sketching data structures for massive graph problems

Juan Lopes

August 31, 2018
Tweet

More Decks by Juan Lopes

Other Decks in Programming

Transcript

  1. SKETCHING DATA STRUCTURES FOR MASSIVE GRAPH PROBLEMS Juan P. A.

    Lopes1, Fabiano S. Oliveira2, Paulo E. D. Pinto2, Valmir C. Barbosa1 August 31st, 2018 VLDB Workshop Poly'18 1 Federal University of Rio de Janeiro (UFRJ) 2 State University of Rio de Janeiro (UERJ)
  2. Some real-life graphs are massive Observing global structures is hard

    2.2 billion 128 MB 233 billion 23 billion 100’s of billions Number of connected devices, 2018. Internet Estimated number of directed edges, 2018. Twitter Number of active users, 2018. Facebook Typical amount of RAM in a typical router. Routers Number of basepairs in a typical metagenomic sample. Metagenomic assemblies 4
  3. Space Optimal Representations General Graphs Trees Complete Graphs Adjacency Matrix:

    O(n2) Adjacency List: O(m log n) • A representation is said to be space optimal if it requires O(f(n)) bits to represent a class containing 2ϴ(f(n)) graphs on n vertices; • Optimality depends on the represented class. 7 Spinrad, J. P. (2003). Efficient graph representations. American Mathematical Society.
  4. Implicit Representations A representation is said to be implicit if

    it has the following properties: Space optimal O(f(n)) bits to represent a class containing 2ϴ(f(n)) graphs on n vertices; Distributes information Each vertex stores O(f(n)/n) bits; Local adjacency test Only local vertex information is required to test adjacency; 8 Spinrad, J. P. (2003). Efficient graph representations. American Mathematical Society.
  5. Probabilistic Implicit Representations Space optimal O(f(n)) bits to represent a

    class containing 2ϴ(f(n)) graphs on n vertices; Distributes information Each vertex stores O(f(n)/n) bits; Local adjacency test Only local vertex information is required to test adjacency; For probabilistic implicit representations, we introduce a fourth property: Probabilistic adjacency test Constant relative probability of false positives or false negatives. 9
  6. Bloom filter Represents sets, allowing membership tests with a probability

    of false positives. • There are no false negatives; • 10 bits per element are enough to ensure for a false positive probability of less than 1%. 10 Bloom, B. H. (1970). Space/time trade-offs in hash coding with allowable errors. Communications of the ACM.
  7. Bloom filter Idea: to replace each vertex set in an

    adjacency list with a Bloom filter. • Each edge would require only O(1) bits, instead of O(log n); • By using Bloom filters, there would be no false negatives, only false positives. • Similarly, a single Bloom filter could be used to store the entire edge set, but technically this would not be an implicit representation. 2 1 3 2 2 4 1 3 3 5 REGULAR ADJACENCY LIST 0 BLOOM FILTER REPRESENTATION 1 1 0 1 0 1 1 0 1 1 1 0 1 1 0 0 1 0 1 11
  8. MinHash Represents sets through a constant-sized signature and allow computing

    the Jaccard coefficient between two or more sets. 6 MinHash(A) 71 57 106 81 MinHash(B) 80 34 73 88 6 71 57 106 81 80 73 88 11 6 1 34 11 6 1 34 12 Broder, A. Z. (1997). On the resemblance and containment of documents. In Compression and complexity of sequences.
  9. MinHash Idea: construct a set for each vertex, such that

    the Jaccard index between any pair of vertices encodes their adjacency. 0 1 δ A δ B 13
  10. MinHash Example of sets construction for δ A = ⅓

    and δ B = ½. {1, 2, 3, 4, 5, 6, 7, 8} {1, 3, 5, 7} {1, 4, 5, 8} {1, 3, 5, 7, 9, 10, 11, 12} {1, 3, 5, 7, 13, 14, 15, 16} {1, 4, 5, 8, 17, 18, 19, 20} {1, 5, 9, 11} root selection extension selection {1, 5, 17, 19} {1, 8, 17, 20} {1, 5, 18, 20} O(n) bits 14
  11. Experimental Results For MinHash-based representation 1 Increasing the threshold seems

    to increase the rate of false negatives and decrease false positives. 2 The perfect threshold depends on the application tolerance for false positives and false negatives. 3 Observations The experiment was run with k=128 hash functions and a graph with n=200 vertices. 15
  12. Experimental Results For MinHash-based representation 1 Increasing the signature size

    seems to have more effect on the rate of false negatives than positives. 2 This effect appears the same for whatever choice of threshold. 3 Observations The experiment was run with δ = 0.375 and a graph with n=200 vertices. 16
  13. Other results Any efficient representation for bipartite, co-bipartite or split

    graphs can be used to represent general graphs efficiently. 1 3 2 5 4 1 2 3 4 5 1 2 3 4 5 17
  14. Other results Modeling this problem through integer programming allows proving

    the infeasibility of specific configurations. x A x AB S A S B S C x B x C x AC x BC x ABC A B C • Each possible subset of vertices is modelled as a variable. • Each variable describes the size of the set intersection between those vertices. 18
  15. Other results Modeling this problem through integer programming allows proving

    the infeasibility of specific configurations. • Each possible subset of vertices is modelled as a variable. • Each variable describes the size of the set intersection between those vertices. • Do all threshold values have an infeasible bipartite graph? Still an open problem. K 3,3 • Impossible for δ A = 0.4 e δ B = 0.6. • Possible for δ A = ⅓ e δ B = ½. 19
  16. Graph Streams Graph Streams are graphs represented in the data

    stream model, i.e. single-pass through a stream of edge insertions and deletions. Can we compute global parameters in sublinear space? Ahn, K. J., Guha, S., and McGregor, A. (2012). Analyzing graph structure via linear measurements. In Proceedings of SODA’12. McGregor, A. (2014). Graph stream algorithms: a survey. ACM SIGMOD. A B C E D F +DF, -BC, +BE, +AC +BC, -DF, -BD, +AE 21
  17. Graph Streams Can we construct a full spanning forest of

    the graph in sublinear space? A B C E D F 22
  18. Graph Streams Idea: we can sample an edge from each

    vertex and merge its endpoints in a single “super-vertex”. Repeat. This procedures finishes in O(log n) steps. A B C E D F 23
  19. Graph Streams Idea: we can sample an edge from each

    vertex and merge its endpoints in a single “super-vertex”. Repeat. This procedures finishes in O(log n) steps. A B C E D F 24
  20. Graph Streams Idea: we can sample an edge from each

    vertex and merge its endpoints in a single “super-vertex”. Repeat. This procedures finishes in O(log n) steps. A B C E D F 25
  21. Graph Streams A simpler problem: Is it possible to sample

    a random edge from any cut-set [S, V\S] in a graph stream storing less than O(n2) bits? A B C E D F 26
  22. Sampling edges from cut-set Idea: to represent graph through a

    modified incidence matrix, where each edge is represented twice (once in each “direction”). A B C E D F A B C D E F 1 -1 1 -1 0 0 0 0 0 0 0 0 0 0 0 AB BA AC CA BD DB BE EB CD DC CE EC CF FC DF FD 0 -1 1 0 0 1 -1 1 -1 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 0 0 1 -1 1 -1 1 -1 0 0 0 0 0 0 -1 1 0 0 -1 1 0 0 0 0 1 -1 0 0 0 0 0 0 -1 1 0 0 -1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 -1 1 27
  23. Sampling edges from cut-set The main benefit from this representation

    is the ability to sum incidence vectors to find the corresponding vector of a cut-set. Being able to sample nonzero coordinates from this vector implies sampling edges from such cut-set. A B C E D F A +B +D {A, B, D} 1 -1 1 -1 0 0 0 0 0 0 0 0 0 0 0 AB BA AC CA BD DB BE EB CD DC CE EC CF FC DF FD 0 -1 1 0 0 1 -1 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0 0 -1 1 0 0 0 0 1 -1 0 0 1 -1 0 0 -1 1 -1 1 0 0 0 0 1 -1 28
  24. What is ℓ 0 -sampling? Sampling, with uniform probability, of

    a nonzero coordinate from a vector a, represented incrementally by a stream of updates. • Some updates may cancel others; • Must be done in sublinear space; • Known lower-bound: Ω(log2 n). Cormode, G., Muthukrishnan, S., and Rozenbaum, I. (2005). Summarizing and mining inverse distributions on data streams via dynamic inverse sampling. In Proceedings of VLDB’05. Jowhari, H., Saglam, M., and Tardos, G. (2011). Tight bounds for lp-samplers, finding duplicates in streams, and related problems. In Proceedings of PODS’11. 1 0 8 -4 0 -7 -15 9 -1 0 1 a 2 3 4 5 6 7 8 9 10 (3, +8) (1, +1) (4, -4) (9, +3) (10, -5) (10, -1) 29
  25. What is ℓ 0 -sampling? Sampling, with uniform probability, of

    a nonzero coordinate from a vector a, represented incrementally by a stream of updates. • Some updates may cancel others; • Must be done in sublinear space; • Known lower-bound: Ω(log2 n). Cormode, G., Muthukrishnan, S., and Rozenbaum, I. (2005). Summarizing and mining inverse distributions on data streams via dynamic inverse sampling. In Proceedings of VLDB’05. Jowhari, H., Saglam, M., and Tardos, G. (2011). Tight bounds for lp-samplers, finding duplicates in streams, and related problems. In Proceedings of PODS’11. 1 0 8 -4 0 -7 -15 9 -1 0 1 a 2 3 4 5 6 7 8 9 10 30
  26. Sampling edges from cut-set Is it possible to encode each

    incidence vector in a compact representation? random projection 0 0 1 -1 0 0 -1 1 -1 1 0 0 0 0 1 -1 ℓ 0 -sampler 31
  27. ℓ 0 -sampling algorithm Assign each coordinate a random bucket

    Use hash functions. Each bucket must have exponentially decreasing probabilities of representing each coordinate. Find 1-sparse vector There is a high probability that at least one bucket will represent a 1-sparse vector, that is, a vector with a single nonzero coordinate. Recover its only nonzero coordinate Through a randomized procedure called 1-sparse recovery, it is possible to recover the nonzero coordinates from 1-sparse vectors, using O(log n) bits. The sampling algorithm is based on the following idea: 32
  28. 1-sparse recovery Tests if a vector is 1-sparse. If yes,

    it recovers the single nonzero coordinate. linear transform not 1-sparse yes no 100% sure prob. ≥ 1 - n/p O(log n) bits 33
  29. Variant (a) Variant (b) p=1/4 p=1/2 p=1/8 p=1/16 p=2-m 1

    2 3 4 m (u i ,Δ i ) h(u i ) p=1/2 p=1/8 p=1/16 p=2-m p=1/4 1 2 3 4 m (u i ,Δ i ) h j (u i ) • Single hash function (more efficient); • Non-independent buckets. • Multiple hash function; • Independent buckets (easier). 34
  30. ℓ 0 -sampling algorithm 1 It is easy to see

    that for every value of r, there will always be a bucket with high probability of recovery (~0.35). 2 There will also be other adjacent buckets with high probability of recovery. 3 Observations We define r, the number of nonzero coordinates in a vector. p i is the probability of the ith bucket being 1-sparse. r = 200 r = 4096 r = 10.000.000 35
  31. ℓ 0 -sampling algorithm m = ⌈log 2 n +

    5⌉ is enough to ensure a failure probability of less than 0.31. analyzing factors’ maxima 36
  32. Experimental results Correcly sized setup. Variant (a) Variant (b) 1

    Variants behave similarly, with error apparently constant under 20% in both tests. 2 The distribution of sampled coordinates (not shown) was also similar in both tests. 3 Observations We tested both variants in a correctly sized setup, i.e. r ≤ 4096, m = 17. 37
  33. Experimental results Undersized setup. Variant (a) Variant (b) 1 Variants

    behave similarly, with error growing from under 20% to almost 100% in both tests. 2 The distribution of sampled coordinates (not shown) was also similar in both tests. 3 Observations We tested both variants in an undersized setup, i.e. r ≤ 4096, m = 10. 38
  34. In this talk... Bloom Filter Adjacency test on general graphs

    in O(m) bits. Specially useful for sparse massive graphs. Has constant probability of false positives. No false negatives. MinHash Adjacency test on trees in O(n) bits. Better space complexity than the optimal deterministic representation. Useful for giant trees (over a billion nodes). ℓ 0 -Sampler Dynamic spanning forest in O(n log3 n) bits. Useful for very dense graphs. … I presented the application of three sketching data structures for massive graph problems. # 40
  35. Not only a theory. Not only for graphs. Sketching data

    structures are growing Mash: Fast genome and metagenome distance estimation using MinHash. Redis PFCOUNT: set distinct count using HyperLogLog. MMDS book chapter 4: several sketch-based stream algorithms. 41
  36. Our next steps ℓ 0 -Sampler The ability to sample

    edges from cut-sets is very useful and can help to produce many new graph algorithms. We are searching for new algorithms that use ℓ 0 -sampling as a primitive 42