NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Counting triangles and the curse of the last reducer

Siddharth Suri, Sergei Vassilvitskii

Abstract

This paper introduces two efficient MapReduce algorithms designed to count triangles in massive social networks, a fundamental task for calculating clustering coefficients. Traditional parallel approaches often suffer from the "curse of the last reducer," where a small number of high-degree nodes create computational bottlenecks. By implementing node ordering and graph partitioning strategies, the authors achieve 10-100x speedups, successfully processing graphs with over 2 billion edges, such as the Twitter social graph.

Introduction

In social network analysis, the clustering coefficient is a vital metric for understanding community structure. It measures the probability that two neighbors of a node are also connected to each other. Mathematically, this task is equivalent to counting the number of triangles in a graph. As modern networks scale to billions of edges, sequential algorithms become impractical, necessitating distributed solutions like MapReduce.

The Challenge: Data Skew and the Last Reducer

The primary obstacle in scaling triangle counting is data skew. In power-law graphs, a few "celebrity" nodes possess a disproportionately high number of connections. Naive MapReduce implementations that pivot around these nodes often result in a few reducers handling the vast majority of the workload. This phenomenon, termed the "curse of the last reducer," leads to a situation where hundreds of machines sit idle while a single machine struggles to finish, dragging down the entire job's performance.

Histogram of clustering coefficients for the Twitter dataset, illustrating the scale of nodes processed.

Proposed MapReduce Algorithms

The authors propose two distinct strategies to mitigate skew and improve efficiency:

1. MR-NodeIterator++

This algorithm adapts sequential node iteration by imposing a total ordering on nodes, typically based on degree. By ensuring that each triangle is only counted by the node with the lowest order, the algorithm eliminates redundant computations. This approach reduces the theoretical complexity from $O(\sum d_v^2)$ to $O(m^{3/2})$, drastically lowering the volume of intermediate data shuffled across the network.

2. MR-GraphPartition

MR-GraphPartition divides the graph into $\rho$ overlapping subsets using a universal hash function. This ensures that every potential triangle is contained within at least one partition. A key advantage of this framework is its flexibility; any sequential triangle-counting algorithm can be used as a "black box" within the partitions. Furthermore, it allows for a practical trade-off between disk space and RAM: by increasing the number of partitions, the memory requirement per machine decreases.

Experimental Results

The algorithms were tested on massive datasets, including a 2010 Twitter crawl containing 42 million nodes and 2.4 billion edges.

Distribution of reducer completion times for (a) NodeIterator, (b) NodeIterator++, and (c) GraphPartition. The proposed methods (b and c) show significantly faster and more balanced execution compared to the naive approach (a).

The results demonstrate the effectiveness of the proposed methods in overcoming the curse of the last reducer. As shown in the distribution of completion times, the naive NodeIterator approach is plagued by a long tail, with some reducers taking over 60 minutes. In contrast, MR-NodeIterator++ finishes in under 2 minutes for the same dataset (LiveJournal), with work distributed evenly across the cluster.

On the Twitter dataset, MR-NodeIterator++ reduced the number of intermediate "2-paths" from a projected 247 trillion to just 301 billion, a reduction that made the computation feasible on standard hardware.

Conclusion

By focusing on work distribution rather than just total computational volume, the authors provide a robust framework for large-scale graph analysis. The ability to trade disk space for memory and the use of node ordering to break symmetry are powerful techniques that enable the processing of graphs previously considered too large for standard MapReduce clusters.

Summary updated

BibTeX
@inproceedings{suri2011counting,
  author = {Siddharth Suri and Sergei Vassilvitskii},
  title = {{Counting triangles and the curse of the last reducer}},
  booktitle = {The Web Conference},
  year = {2011},
  doi = {10.1145/1963405.1963491},
}
Figure