Improved graph sampling for triangle counting

John Kallaugher, Eric Price

Abstract

We study the problem of estimating the number of triangles in a graph stream. No streaming algorithm can get sublinear space on all graphs, so methods in this area bound the space in terms of parameters of the input graph such as the maximum number of triangles sharing a single edge. We give a sampling algorithm that is additionally parameterized by the maximum number of triangles sharing a single vertex. Our bound matches the best known turnstile results in all graphs, and gets better performance on simple graphs like $G(n, p)$ or a set of independent triangles. We complement the upper bound with a lower bound showing that no sampling algorithm can do better on those graphs by more than a log factor. In particular, any insertion stream algorithm must use $\sqrt{T}$ space when all the triangles share a common vertex, and any sampling algorithm must take $T^{1/3}$ samples when all the triangles are independent. We add another lower bound, also matching our algorithm's performance, which applies to all graph classes. This lower bound covers "triangle-dependent" sampling algorithms, a subclass that includes our algorithm and all previous sampling algorithms for the problem. Finally, we show how to generalize our algorithm to count arbitrary subgraphs of constant size.

The Challenge of Streaming Triangle Counting

Counting triangles is a fundamental task in network analysis, essential for understanding clustering and community structures. However, performing this count efficiently in a massive edge stream is mathematically challenging. It is known to be impossible to design a streaming algorithm that achieves sublinear memory for all possible graphs. Consequently, researchers parameterize space requirements based on graph properties, typically $\Delta_E$ (the maximum number of triangles sharing a single edge).

While effective for many graphs, previous methods remained suboptimal for specific topologies, such as "hub" graphs (where triangles share a central vertex) or sets of independent, disconnected triangles. This work seeks to close this gap by introducing an algorithm that adapts to these specific structures.

Methodology: A Hybrid Sampling Scheme

The authors propose a hybrid sampling scheme that introduces a new parameter: $\Delta_V$, the maximum number of triangles sharing a single vertex. The core idea is that different sampling strategies are required for different vertex types. Simple vertex sampling works well for "light" vertices but fails for "heavy" hub vertices due to massive variance in estimation.

To address this, the algorithm dynamically categorizes vertices. It conceptually uses a weight estimation phase to identify "heavy" vertices and a targeted sampling phase that applies a specialized "hub scheme." In this scheme, heavy vertices are sampled less frequently, but their incident edges are sampled more aggressively if the vertex is selected. The authors demonstrate how to collapse these conceptual passes into a single, efficient pass over the data.

Comparison of space complexity formulas across different algorithms.

Key Insights and Instance Optimality

  • The Sampling Continuum: By adjusting sampling weights based on local triangle density, the algorithm avoids the variance spikes that hindered previous methods.
  • Instance-Optimality: The authors prove "instance-optimal" lower bounds, showing that for specific graph classes like independent triangles or Erdős-Rényi random graphs, no sampling algorithm can significantly outperform their proposed method.
  • Triangle-Dependent Algorithms: The paper formalizes a subclass of "triangle-dependent sampling algorithms." They prove a universal lower bound for this class that matches their algorithm's performance up to logarithmic factors, suggesting their approach is near-optimal for sampling-based methods.

Results and Performance

The algorithm achieves an expected sample complexity of $O^*(m(\frac{\Delta_E}{T} + \frac{\sqrt{\Delta_V}}{T} + \frac{1}{T^{2/3}}))$, where $m$ is the number of edges and $T$ is the total triangle count. This leads to substantial gains in specific graph types:

  • Independent Triangles: Space requirements drop from $O(\sqrt{n})$ to $O(n^{1/3})$.
  • Random Graphs $G(n,p)$: Space requirements drop from $O(\sqrt{n/p})$ to $O(1/p)$.
Performance comparison of the proposed algorithm against state-of-the-art methods across various graph topologies.

Conclusion and Future Work

While this work provides tight lower bounds for the sampling model, it remains an open question whether these bounds hold for more general streaming models, such as turnstile streams or standard insertion-only streams. Future research may explore whether non-sampling-based linear sketches can break the $n^{1/3}$ barrier for independent triangles or if complex reductions from communication complexity can prove even broader lower bounds.

Summary updated

BibTeX
@inproceedings{kallaugher2017improved,
  author = {John Kallaugher and Eric Price},
  title = {{Improved graph sampling for triangle counting}},
  booktitle = {SODA},
  year = {2017},
  url = {https://openreview.net/forum?id=0wjtGPi9nI},
}
Figure