Abstract
Sampling edges uniformly at random is a foundational primitive for sublinear-time graph algorithms and network analysis. While existing algorithms provide efficient solutions for sampling a single edge, many downstream applications—such as subgraph counting—require a large batch of samples. This paper introduces an amortized edge sampling algorithm that achieves a query complexity of $O^*(\sqrt{q} \cdot n/\sqrt{m})$ for $q$ samples, representing a significant asymptotic improvement over the naive approach of repeating single-edge sampling $q$ times.
1. Introduction
In the study of massive graphs, where the size of the data precludes full traversal, researchers rely on sublinear-time algorithms to estimate global properties. A critical component of these algorithms is the ability to sample edges almost uniformly at random. This primitive is essential for tasks such as approximating the number of triangles, stars, or other motifs within a network.
This work operates within the standard adjacency list query model, where an algorithm can:
- Query a uniformly random vertex.
- Query the degree of a specific vertex.
- Query the $i$-th neighbor of a specific vertex.
Prior to this research, the state-of-the-art for sampling a single edge required $O^*(n/\sqrt{m})$ queries, where $n$ is the number of vertices and $m$ is the number of edges. For applications requiring $q$ samples, the standard approach was to invoke this algorithm $q$ times, resulting in a total complexity of $O^*(q \cdot n/\sqrt{m})$. This paper addresses whether a one-time preprocessing cost can reduce the marginal cost of subsequent samples.
2. Methodology
The proposed algorithm utilizes a two-phase approach—Preprocessing and Sampling—centered on a vertex partitioning strategy. Vertices are categorized as either "light" or "heavy" based on a degree threshold $\tau$.
2.1 Preprocessing Phase
The algorithm first samples a subset of vertices to identify and index heavy vertices. It constructs a specialized data structure that allows for sampling heavy vertices with a probability proportional to their degree in $O(1)$ time. The cost of this phase is $O^*(n^2/(m \cdot x))$, where $x$ is a tunable trade-off parameter.
2.2 Sampling Phase
To generate an edge sample, the algorithm decides between sampling a light edge or a heavy edge via a coin flip:
- Light Edges: The algorithm selects a random vertex and employs rejection sampling, keeping the vertex with a probability proportional to its degree divided by $\tau$. If accepted, a random neighbor is selected.
- Heavy Edges: The algorithm utilizes the precomputed data structure to select a heavy vertex and then chooses a random neighbor.
By setting $x = \frac{n/\sqrt{m}}{\sqrt{q}}$, the algorithm balances the preprocessing overhead against the per-query cost, leading to the optimized amortized bound.
3. Key Insights
3.1 Pointwise vs. Total Variation Distance
A significant contribution of this work is the guarantee of pointwise $\epsilon$-closeness to a uniform distribution. Unlike Total Variation Distance (TVD), which allows for a small fraction of edges to be entirely ignored, pointwise closeness ensures that every edge has a near-uniform probability of being selected. This is vital for counting rare subgraphs, where missing a single dense clique could lead to massive estimation errors.
3.2 Decoupling the Threshold
Earlier single-edge sampling techniques often relied on random walks from light vertices to reach heavy ones, forcing the degree threshold $\tau$ to be high ($\Omega(\sqrt{m})$). By introducing a dedicated preprocessing step to index heavy vertices, this algorithm decouples the threshold from the success probability of the walk, enabling a significantly lower per-sample query cost.
4. Results and Complexity
The algorithm achieves a total query complexity of $O^*(\sqrt{q} \cdot n/\sqrt{m})$. To illustrate the impact, consider a graph where $m = \Theta(n)$ and the required number of samples is $q = O(\sqrt{n})$. The naive approach would require $O(n)$ queries, effectively negating the benefits of a sublinear approach. In contrast, the amortized algorithm completes the task in $O(n^{3/4})$ queries.
Furthermore, the paper notes that this $\Omega(\sqrt{q} \cdot n/\sqrt{m})$ bound is theoretically optimal within the adjacency list query model, as confirmed by subsequent independent lower-bound proofs.
5. Conclusion and Future Work
This research demonstrates that batch edge sampling is fundamentally more efficient than repeated single-edge sampling. However, the current approach requires prior knowledge of the sample size $q$ to optimize the trade-off parameter $x$. Future research may explore adaptive methods that do not require $q$ in advance. Additionally, investigating whether this amortized approach can be further optimized for graphs with bounded arboricity—where single-edge sampling is known to be even faster—remains an open and promising direction.
Summary updated