Testable Algorithms for Approximately Counting Edges and Triangles in Sublinear Time and Space

Talya Eden, Ronitt Rubinfeld, Arsen Vasilyan

TL;DR

This paper introduces the first instance-adaptive, sublinear-time algorithms for approximately counting triangles and edges in graphs without requiring prior knowledge of the graph's structural sparsity. By leveraging a novel "testable algorithms" framework, the proposed method automatically detects incorrect structural assumptions on the fly, providing robust correctness guarantees while achieving optimal runtimes that scale gracefully with the graph's actual complexity.

What Problem Does This Paper Address?

Counting triangles and edges in massive graphs is a foundational task in network analysis, social sciences, and database theory. To perform these counts in sublinear time—meaning we only look at a tiny fraction of the graph—existing state-of-the-art algorithms rely on a "promise" that the graph's arboricity (a standard measure of graph sparsity) is bounded by a known parameter.

However, this creates a dangerous vulnerability: if the promise is violated (i.e., the graph is denser than assumed), these algorithms fail silently, returning completely incorrect estimates without warning. While one could try to estimate the arboricity first to verify the promise, doing so is inherently expensive and wipes out the efficiency gains of the sublinear approach. The authors address a fundamental dilemma: How can we design sublinear algorithms that exploit graph sparsity for massive speedups, but remain robustly correct when our assumptions about that sparsity are completely wrong?

Methods

The authors bridge this gap by adapting the formal framework of testable algorithms (originally introduced in agnostic learning theory) to property estimation.

  1. Testable Algorithm with Unreliable Advice: Instead of assuming a guaranteed bound, the algorithm accepts an unreliable guess ($\tilde{\alpha}$) for the arboricity. As it samples the graph, it explicitly checks whether the structural properties implied by $\tilde{\alpha}$ hold true. If the graph behaves unexpectedly, the algorithm aborts and flags "bad advice" (Soundness). If the advice is correct, it is guaranteed to output a correct $(1 \pm \epsilon)$-approximation (Completeness).
  2. Instance-Adaptive Doubling Trick: To eliminate the need for any advice entirely, the authors wrap the testable algorithm in a sequential search loop. It starts with a guess of $\tilde{\alpha} = 1$ and repeatedly doubles the guess until the testable algorithm accepts the candidate. Because of the soundness guarantee, the first accepted run is guaranteed to be correct with high probability, incurring only a minor logarithmic runtime overhead.
  3. Dynamic Thresholding: The algorithm carefully re-calibrates how it classifies "heavy" (high-degree or triangle-dense) edges. By using a general $O(m^{3/2})$ global triangle bound, it ensures that hidden dense subgraphs cannot distort the final count without triggering the "bad advice" rejection criteria.

Datasets

Not discussed in the paper. The work is purely theoretical and algorithmic; it provides mathematical proofs of correctness, runtime complexities, and lower bounds rather than empirical evaluations on benchmark datasets.

Key Insights and Ideas

  • Verification is Cheaper than Estimation: A core insight is that computing a graph's exact structural properties upfront is often too slow, but verifying whether a graph satisfies the specific preconditions needed for a counting algorithm to succeed can be done incredibly fast and on the fly.
  • The Cost of Faulty Advice: The paper establishes a strict mathematical separation between trusted-advice settings and instance-adaptive settings. If advice cannot be trusted, an algorithm must pay an additive information-theoretic overhead of $\Omega(m/t^{2/3})$ queries to avoid being fooled by a hidden dense clique.
  • Query Depth to Streaming Passes: The authors show that the adaptivity depth (how many sequential rounds of queries are needed) of their sublinear algorithm directly dictates the pass complexity in a streaming data model, allowing them to easily derive a space-efficient streaming variant.

Key Results

The paper's main algorithmic contributions and how they compare to prior work are neatly summarized in the authors' comparison table:

Summary of results compared to the state of the art for general and bounded arboricity graphs.
  • Optimal Triangle Counting: The instance-adaptive algorithm achieves a $(1\pm\epsilon)$-approximation of the triangle count $t$ in an expected runtime of $O^*\left( \frac{m\cdot \alpha(G)}{t} + \frac{m}{t^{2/3}} \right)$, where $\alpha(G)$ is the true arboricity. This matches the best-known bounded-arboricity algorithms up to the unavoidable additive overhead.
  • Proving Optimality via Lower Bounds: The authors complement their algorithm with an information-theoretic lower bound, proving that any testable triangle-counting algorithm given advice $\tilde{\alpha} < t^{1/3}$ must perform $\Omega(m/t^{2/3} + m\cdot\alpha(G)/t)$ queries to succeed, proving their algorithm is optimal.
  • Adaptive Edge Counting: They provide a testable edge-counting algorithm that runs in $O^*\left(\frac{n \cdot \alpha(G)}{m}\right)$ time, completely removing the standard requirement of knowing the total number of edges $m$ in advance.

Limitations and Future Work

  • Streaming Constraints: When ported to the streaming model, the algorithm requires a rough initial constant-factor estimate of the total triangle count ($\tilde{t} = \Theta(t)$) to maintain a constant number of passes (9 passes). Eliminating this requirement without blowing up the space or round complexity remains an open challenge.
  • Space/Round Optimality: For the streaming variant, it is still unknown whether the 9-pass round complexity and space bounds are strictly optimal or if they can be tightened further.
  • Augmented Query Model: The edge-counting algorithm relies on an "augmented query model" that includes uniform edge sampling. In applications where uniform edge samples are unavailable or expensive to obtain, the algorithm cannot be applied.

Summary updated

BibTeX
@inproceedings{eden2026testable,
  author = {Talya Eden and Ronitt Rubinfeld and Arsen Vasilyan},
  title = {{Testable Algorithms for Approximately Counting Edges and Triangles in Sublinear Time and Space}},
  booktitle = {ITCS},
  year = {2026},
  doi = {10.4230/lipics.itcs.2026.54},
}
Figure