Introduction
Counting triangles—cliques of three nodes—is a fundamental task in network analysis, essential for community detection, spam filtering, and computing clustering coefficients. However, as modern graphs like Twitter or Facebook scale to billions of nodes and edges, they exceed the memory capacity of single machines. While MapReduce-based distributed approaches exist, they often suffer from massive intermediate data generation and high runtime overheads. This paper presents two MPI-based distributed-memory parallel algorithms designed for exact triangle counting at scale: the Algorithm with Overlapping Partitioning (AOP) for speed and the Algorithm with Non-Overlapping Partitioning (ANOP) for memory efficiency.
Methodology
The proposed algorithms extend the sequential NodeIteratorN baseline, which utilizes degree-based node ordering and fast set intersections.
- Algorithm with Overlapping Partitioning (AOP): This approach partitions the graph such that each processor receives a core set of nodes along with all their immediate neighbors. This overlap allows processors to count triangles independently without inter-node communication, maximizing speed at the cost of higher memory usage.
- Algorithm with Non-Overlapping Partitioning (ANOP): To optimize for memory-constrained environments, ANOP strictly partitions edges without overlap. This necessitates communication between processors to identify triangles spanning partition boundaries.
- Surrogate Communication Approach: To mitigate the communication bottleneck in ANOP, the authors introduce a "surrogate" method. Instead of repeatedly requesting neighbor lists, a processor sends its data once to a target processor and delegates the computation, reducing message volume by up to 90%.
- Predictive Load Balancing: To handle skewed degree distributions, a custom cost function (
DPD) estimates the computational weight of each node, ensuring an even workload distribution across the MPI ranks.
Experimental Setup
The algorithms were evaluated using a diverse set of real-world and synthetic networks, ranging from small email graphs to massive social networks with billions of edges.
Key Insights
A critical finding of this work is the mathematical optimality of degree-based node ordering. The authors prove that ordering nodes by degree minimizes the runtime of the sequential counting algorithm. Empirical results across various networks confirm that degree ordering consistently outperforms other heuristics like K-core, random, or ID-based ordering.
Furthermore, the "Surrogate" approach demonstrates that delegating computation is significantly more efficient than requesting data in a distributed environment. By avoiding the generation of massive intermediate "2-paths" typical of MapReduce implementations, these MPI-based algorithms achieve superior scalability.
Results and Discussion
The proposed algorithms demonstrate exceptional performance on massive datasets:
- Scale and Speed: AOP processed a 10-billion-edge Preferential Attachment graph in 15.5 minutes using 200 processors. On the 2.4-billion-edge Twitter network, it achieved a runtime of 9.4 minutes—over 45x faster than state-of-the-art MapReduce solutions.
- Memory Efficiency: ANOP reduces memory consumption by up to 25x compared to AOP, with only a 20% increase in runtime, thanks to the surrogate communication strategy.
- Scalability: Both algorithms exhibit near-linear strong scaling, validated by the effectiveness of the
DPDload-balancing scheme.
Conclusion
This work provides a highly scalable framework for triangle counting in massive graphs. By combining optimized sequential kernels with clever distributed partitioning and communication strategies, the authors enable analysis of graphs with billions of edges in minutes. Future work includes extending these primitives to parallel local clustering coefficient computation and higher-level graph mining tasks.
Summary updated