Abstract
Graphs are used to model interactions in a variety of contexts, and there is a growing need to quickly assess the structure of a graph. Some of the most useful graph metrics, especially those measuring social cohesion, are based on triangles. Despite the importance of these triadic measures, associated algorithms can be extremely expensive. We discuss the method of wedge sampling. This versatile technique allows for the fast and accurate approximation of all current variants of clustering coefficients and enables rapid uniform sampling of the triangles of a graph. Our methods come with provable and practical time-approximation tradeoffs for all computations. We provide extensive results that show our methods are orders of magnitude faster than the state-of-the-art, while providing nearly the accuracy of full enumeration. Our results will enable more wide-scale adoption of triadic measures for analysis of extremely large graphs, as demonstrated on several real-world examples.
Introduction
In network science, triangles are the "gold standard" for measuring social cohesion and transitivity—the principle that "a friend of my friend is also my friend." Metrics such as the clustering coefficient quantify this structure, enabling researchers to detect spam, identify common web topics, or model epidemic spread.
However, as graphs scale to millions or billions of edges, exact triangle counting becomes computationally prohibitive, often requiring $O(m^{1.5})$ time. While previous sampling methods like "Doulion" (edge-based sampling) offered improvements, they frequently suffered from high variance and struggled with local, vertex-level statistics. This paper introduces Wedge Sampling, a faster, more accurate, and more versatile approach to estimating triadic measures.
Methodology: Wedge Sampling
A "wedge" is a path of length two, consisting of three vertices connected by two edges. A wedge is "closed" if its endpoints are connected, forming a triangle. The core innovation is a general algorithmic template:
- Select a center vertex: For global counts, pick a vertex $v$ with probability proportional to the number of wedges centered at it ($d_v(d_v-1)/2$).
- Form a wedge: Randomly select two distinct neighbors of $v$.
- Check for closure: Determine if an edge exists between these two neighbors.
- Estimate: Repeat this process $k$ times; the fraction of closed wedges estimates the clustering coefficient.
By adjusting the vertex selection process, this framework can estimate the Global Clustering Coefficient ($C$), the Local Clustering Coefficient ($\bar{C}$), and Degree-wise Clustering Coefficients ($C_d$).
Theoretical Bounds and Insights
A key insight of wedge sampling is that wedges are the "right" unit for sampling. Unlike edge-based methods that may miss triangles in sparse regions, wedge sampling begins with two-thirds of a triangle already identified.
Crucially, the authors use Chernoff-Hoeffding bounds to prove that the number of samples required for a specific accuracy level is independent of the graph's total size. As shown in Figure 4, achieving an error $\epsilon = 0.01$ (1%) with 99.9% confidence requires approximately 38,000 samples, regardless of whether the graph contains a million or a billion edges.
Experimental Results
The authors evaluated wedge sampling on 13 large-scale real-world graphs from the Stanford Network Analysis Project (SNAP), including social networks (flickr, livejournal), web graphs (web-Google), and infrastructure (roadNet-CA).
Performance and Accuracy
- Massive Speedups: Wedge sampling is up to four orders of magnitude ($10,000\times$) faster than full enumeration. For the
as-skittergraph, it took 0.015 seconds compared to 90 seconds for exact counting. - High Precision: With 32,000 samples, absolute error in the clustering coefficient was typically under 0.01 across all datasets.
- Fast Convergence: In practice, estimates converge to true values much faster than theoretical worst-case bounds suggest. Figure 5 illustrates this convergence, showing the Hoeffding estimate stabilizing quickly within the 99.9% confidence interval.
Conclusion
Wedge sampling provides a robust solution for analyzing massive graphs where exact triadic measures are infeasible. Its independence from graph size and its ability to estimate local metrics make it superior to previous edge-sampling techniques. Future work includes scaling the method via MapReduce for graphs with billions of edges and extending the framework to directed and attributed graphs.
Summary updated