Counting Triangles in Massive Graphs with MapReduce

Tamara G. Kolda, Ali Pinar, Todd D. Plantenga, C. Seshadhri, Christine Task · DOI

TL;DR

This paper presents a scalable MapReduce implementation of a wedge-sampling algorithm for efficiently counting triangles and estimating clustering coefficients in massive graphs. It demonstrates that this approach can handle graphs with billions of edges in a reasonable time, significantly outperforming exact enumeration methods.

What Problem Does This Paper Address?

Graphs and networks are ubiquitous for modeling relationships, from social connections to web links. Understanding their structure often involves analyzing "triangles" – three nodes all connected to each other. Metrics like the clustering coefficient, which measures how likely two neighbors of a node are to be connected, are derived from triangle counts. However, for the massive graphs encountered today (billions of nodes and edges), exactly counting triangles is computationally prohibitive due to memory and time constraints. This paper addresses the challenge of efficiently and accurately computing these crucial graph metrics on such large-scale networks.

Methods

The core of this work is the adaptation of a wedge-sampling algorithm to the MapReduce framework. A wedge is a path of three nodes where only the middle two are connected. A triangle is formed when the two outer nodes of a wedge are also connected. Instead of checking every possible wedge (which is still too expensive), wedge sampling randomly selects a subset of wedges and checks if they form triangles.

The authors implement this in MapReduce, a distributed computing paradigm. Their approach involves several phases:

  1. Degree and Wedge Computation: Calculating the degree of each vertex and the number of wedges associated with different degree groups (bins).
  2. Sample Wedge Selection: Strategically selecting a sample of wedges to analyze.
  3. Wedge Closure Check: Determining if the selected wedges form triangles.
  4. Post-processing: Aggregating results and calculating various statistics, including binned clustering coefficients and triangle counts.

A key innovation is their careful management of data shuffling between MapReduce tasks to minimize communication overhead, which is often a bottleneck in distributed graph processing. They also introduce a degree-binning strategy to analyze how triangle properties vary across different node degrees.

Datasets

The authors evaluated their approach on a variety of datasets:

  • Real-world networks: Including graphs from the Laboratory for Web Algorithms (e.g., amazon-2008, ljournal-2008, hollywood-2009/2011, twitter-2010, it-2004, uk-2006-06, uk-union, sk-2005). The largest of these, uk-union, has 132 million nodes and 4.7 billion edges.
  • Artificially generated networks: Using the Graph500 benchmark, which generates Stochastic Kronecker Graphs (SKG). The largest Graph500 graph analyzed had 240 million nodes and 8.5 billion edges.

Key Insights and Ideas

  • Scalability of Wedge Sampling: The paper demonstrates that wedge sampling, previously effective for smaller graphs, can be successfully scaled to massive networks using MapReduce. This is a significant step towards analyzing real-world large-scale graphs.
  • Efficiency Gains: By avoiding full enumeration, their MapReduce implementation achieves substantial speedups, making triangle counting feasible for graphs that were previously intractable.
  • Degree-wise Analysis is Crucial: Simply reporting a global clustering coefficient can hide important structural differences. Analyzing these metrics per degree bin reveals nuanced behaviors, particularly distinguishing social networks from others.
  • Social Networks are Different: The study highlights that social networks exhibit distinct triangle properties (e.g., degree assortativity) compared to web graphs or artificial networks, reinforcing the importance of understanding network topology.
  • MapReduce Optimization: The authors emphasize the critical role of minimizing data shuffling in MapReduce for graph algorithms, showcasing specific techniques to achieve this.

Key Results

  • Performance: The algorithm can process graphs with up to 240 million nodes and 8.5 billion edges. For the largest graph (uk-union), the analysis took less than 30 minutes on a 32-node cluster.
  • Speed: The runtime shows a near-linear correlation with the number of edges, with a fixed overhead of approximately 225 seconds and an incremental cost of 0.33 seconds per million edges.
  • Accuracy: The wedge-sampling approach provides accurate estimates of clustering coefficients and triangle counts, with errors significantly lower than worst-case probabilistic bounds.
  • Comparison: For the hollywood-2011 graph, their sampling method achieved a speedup of up to 293X compared to exact enumeration methods.
  • Triangle Characteristics: The study reveals that while low-degree nodes are most numerous, most triangles tend to involve higher-degree nodes, especially in social and some web graphs.

Limitations and Future Work

  • Phase 1a Bottleneck: The paper identifies Phase 1a (computing degree per vertex) as the most expensive step, suggesting that further optimization in this area would be beneficial.
  • Configuration Parameter Size: Hadoop's limit on configuration parameter size (5MB) could be an issue for very large numbers of wedge centers, though they mention the Hadoop distributed cache as a potential alternative.
  • Future Work: The authors suggest that their framework can be extended to analyze other graph properties and that further research into optimizing Phase 1a is warranted. They also highlight the potential for their work to aid in understanding and generating more realistic graph models.

Summary updated

BibTeX
@article{kolda2014counting,
  author = {Tamara G. Kolda and Ali Pinar and Todd D. Plantenga and C. Seshadhri and Christine Task},
  title = {{Counting Triangles in Massive Graphs with MapReduce}},
  journal = {SIAM J. Sci. Comput.},
  year = {2014},
  doi = {10.1137/13090729x},
}
Figure