Graph Sample and Hold: A Framework for Big-Graph Analytics

Nesreen K. Ahmed, Nick Duffield, Jennifer Neville, Ramana Kompella

TL;DR

This paper introduces Graph Sample and Hold (gSH), a generic, single-pass streaming framework designed to estimate multiple global properties of massive graphs simultaneously. By maintaining a tiny fraction of the graph’s edges and using unbiased Horvitz-Thompson estimators, gSH achieves high accuracy and significant speedups compared to both brute-force analysis and specialized state-of-the-art sampling algorithms.

What Problem Does This Paper Address?

Analyzing "Big Graphs"—like the Facebook social network or the global web graph—is computationally grueling. Brute-force methods are often too slow or require massive distributed clusters. While sampling is a common solution, most existing techniques are "one-trick ponies" designed to estimate a single specific property (like triangle counts) and often require multiple passes over the data.

Furthermore, many real-world graphs are dynamic and arrive as a stream of edges. There is a critical need for a generic framework that can:

  1. Process edges in a single pass (streaming).
  2. Maintain a very small memory footprint (state).
  3. Provide unbiased estimates for various properties (links, triangles, paths, clustering coefficients) from the same sample.

Methods

The authors propose Graph Sample and Hold (gSH), inspired by the "Sample and Hold" method used in network traffic monitoring. The core logic is simple but powerful:

  • The $gSH(p, q)$ Algorithm: As edges arrive in a stream, the algorithm decides whether to sample them based on two probabilities. If an arriving edge is "fresh" (not adjacent to any currently sampled edge), it is sampled with a low probability $p$. If it is adjacent to an edge already in the sample, it is sampled with a higher probability $q$.
  • Unbiased Estimation: To ensure the estimates aren't skewed by the sampling process, the framework uses Horvitz-Thompson estimators. Every sampled edge is weighted by the inverse of the probability with which it was selected. The authors prove that this approach yields unbiased estimates for counts of arbitrary subgraphs.
  • Triangle Optimization ($gSH_T$): A specialized variant, $gSHT$, automatically samples any edge that completes a triangle with edges already in the sample (setting $r=1$), significantly improving the accuracy of triangle-related metrics.

Datasets

The authors evaluated gSH on two distinct types of real-world networks:

  1. Social Facebook Graphs: Friendship networks from CMU, UCLA, and the University of Wisconsin. These are relatively dense.
  2. Web Graphs: Hyperlink networks from Stanford, Google, and BerkStan (Berkeley/Stanford). These are significantly larger (up to 6.6M edges) and sparser.

Key Insights and Ideas

  • Generic vs. Specific: Unlike previous work that required different sampling logic for triangles vs. paths, gSH allows a single sampled "sketch" of the graph to answer multiple structural queries.
  • The Power of Adjacency: By setting $q > p$, the algorithm effectively "holds" onto connected components. This bias toward sampling neighbors is what allows it to capture complex structures like triangles and paths much more efficiently than simple uniform edge sampling.
  • Order Matters: In a streaming context, the arrival order of edges affects which components are "held." The authors demonstrate that while the estimators remain unbiased regardless of order, the variance (and thus the precision) of the estimate can be influenced by the stream's sequence.
  • Parallel Variance Estimation: While calculating the statistical variance of these estimators can be complex, the authors show it can be efficiently parallelized, making it practical for real-time analytics.

Key Results

The framework demonstrates impressive efficiency and accuracy across all tested datasets:

  • High Accuracy: For a sample size of only ~40,000 edges (often <1% of the total graph), the relative error for edge counts, triangle counts, and path counts was consistently under 1%.
  • Convergence: As shown in Figure 3, the estimates are centered exactly on the true values (unbiased) and the confidence intervals tighten rapidly as the sample size increases.
Convergence of estimates for UCLA and Wisconsin graphs
  • Massive Speedups: On the BerkStan web graph, gSH reduced the time to count triangles and paths from 113.9 seconds to just 1.05 seconds—a 100x improvement.
  • Superiority over State-of-the-Art: Compared to the specialized "Streaming-Triangles" algorithm by Jha et al., gSH achieved relative errors that were orders of magnitude lower (e.g., 0.0023 vs 0.07 for the Stanford graph) while using similar or smaller memory footprints.

Limitations and Future Work

The authors acknowledge that while the estimators are unbiased, the variance can be high if the sampling probabilities $p$ and $q$ are set too low, especially for very sparse graphs. Figure 4 illustrates how the sampling fraction changes based on these parameters; finding the optimal "sweet spot" for $p$ and $q$ remains a balancing act between memory usage and precision.

Figure 2: Sampling Fraction ( SSize

Future work aims to extend the gSH framework to estimate even more complex graph properties, such as cliques, coloring numbers, and the size of connected components.

Summary updated

BibTeX
@inproceedings{ahmed2014graph,
  author = {Nesreen K. Ahmed and Nick Duffield and Jennifer Neville and Ramana Kompella},
  title = {{Graph Sample and Hold: A Framework for Big-Graph Analytics}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2014},
  url = {https://openreview.net/forum?id=05otAfRc5R},
}
Figure