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

TeraHAC: Hierarchical Agglomerative Clustering of Trillion-Edge Graphs

Laxman Dhulipala, Jason Lee, Jakub Łącki, Vahab Mirrokni

TL;DR

TeraHAC is a new $(1+\epsilon)$-approximate hierarchical clustering algorithm designed to handle massive datasets, scaling up to trillion-edge graphs. By combining the classic nearest-neighbor chain algorithm with a novel local "good merge" criterion, it achieves a 100x reduction in communication rounds and up to an 8.3x speedup over existing state-of-the-art distributed methods while maintaining higher clustering quality.

What Problem Does This Paper Address?

Hierarchical Agglomerative Clustering (HAC) is a gold standard for data organization because it doesn't require a pre-specified number of clusters and produces a rich, tree-like structure (a dendrogram). However, HAC is notoriously difficult to scale. The exact algorithm is inherently sequential—you find the globally most similar pair, merge them, and repeat.

For modern "big data" applications involving billions of points and trillions of edges, standard HAC is computationally impossible. Existing distributed alternatives like SCC or Affinity Clustering scale better but often sacrifice quality or require hundreds of synchronization rounds across a cluster of machines, leading to massive communication overhead. The authors of TeraHAC sought a way to achieve the high quality of HAC with provable guarantees, but with the massive parallelism needed for trillion-edge scales.

Methods

TeraHAC's core innovation is a new approach to $(1+\epsilon)$-approximate HAC. In this framework, an algorithm is allowed to merge any pair of clusters whose similarity is within a $(1+\epsilon)$ factor of the global maximum.

The authors introduce a local "good merge" criterion. Instead of looking for the global maximum, TeraHAC identifies merges that are "good enough" based solely on a cluster's immediate neighbors and its own history. Specifically, they track $M(v)$, the minimum similarity of all merges that went into creating cluster $v$. A merge between clusters $u$ and $v$ is considered "good" if the similarity of the merge is sufficiently high relative to the maximum edge weights incident to $u$ and $v$, and the historical $M$ values.

This local check is a game-changer for parallelism. As shown in Figure 1, TeraHAC identifies a much larger set of valid merges at any given time compared to previous parallel algorithms like RAC or ParHAC.

Figure 1: Comparison of the merges available at the start of the algorithm for different parallel HAC algorithms.

The distributed implementation works in rounds:

  1. Partition: The graph is split across machines using a size-constrained affinity clustering.
  2. Local HAC: Each machine runs a specialized SubgraphHAC to perform as many "good merges" as possible within its partition without talking to other machines.
  3. Contract & Prune: The graph is updated globally, and low-weight edges are pruned to keep the graph size manageable.

Datasets

The authors evaluated TeraHAC across a wide spectrum of data:

  • Ground-Truth Benchmarks: Small standard datasets (Iris, Wine, Digits, Faces) to verify clustering quality against exact HAC.
  • Large Real-World Graphs: Social and web graphs including com-Orkut (234M edges), Twitter (2.4B edges), and ClueWeb (74B edges).
  • Trillion-Edge Scale: A massive Web-Query graph representing similarities between 31 billion queries, totaling 8.6 trillion edges.
  • Synthetic Scaling: rMAT graphs were used to test how the algorithm scales as the number of vertices and edges increases.

Key Insights and Ideas

  • Breaking the Sequential Bottleneck: By proving that local "good merges" eventually result in a globally $(1+\epsilon)$-approximate dendrogram, the authors removed the need for frequent global synchronization.
  • The Importance of History: The $M(v)$ parameter is crucial. Without tracking the "weakest link" in a cluster's history, an approximate merge early on could force a very poor merge later, violating the $(1+\epsilon)$ guarantee. Figure 4 in the paper illustrates this subtle but vital point.
  • Geometric Convergence: Empirically, the number of edges in the graph shrinks at a geometric rate. This means the algorithm finishes in very few rounds (typically fewer than 20), even for the largest datasets.

Key Results

TeraHAC demonstrates a superior balance of speed and quality:

  • Massive Speedup: On large web graphs, TeraHAC is up to 8.3x faster than SCC-100 (the high-quality setting for the previous state-of-the-art).
  • Reduced Communication: It requires 100x fewer rounds than previous parallel HAC implementations like RAC (see Figure 2).
  • Higher Quality: TeraHAC achieved 1.16x higher quality than SCC on web graphs and stayed within 1-3% of the quality of exact HAC on ground-truth benchmarks.
  • Unprecedented Scale: It successfully processed the 8.6 trillion-edge Web-Query graph, delivering better precision-recall trade-offs than competitors while being significantly faster.
Figure 2: Number of rounds used by TeraHAC compared with OptimizedRAC (TeraHAC using 𝜖= 0), ParHAC and RAC on four large real-world graph datasets. All algorithms use a weight threshold of 𝑡= 0.01 (see Section 6).

Limitations and Future Work

The primary limitation acknowledged is the Vertex Pruning Optimization. To achieve peak performance, the algorithm prunes edges below a certain similarity threshold $t$. While this has a negligible impact on quality for the datasets studied, it effectively limits the algorithm to computing the "top" (most similar) parts of the hierarchy.

Future work includes:

  • Developing theoretical bounds for the number of rounds required.
  • Exploring if the algorithm can be extended to compute the entire dendrogram without pruning.
  • Applying the "good merge" concept to dynamic graph settings where the data changes over time.

Summary updated

BibTeX
@inproceedings{dhulipala2023terahac,
  author = {Laxman Dhulipala and Jason Lee and Jakub Łącki and Vahab Mirrokni},
  title = {{TeraHAC: Hierarchical Agglomerative Clustering of Trillion-Edge Graphs}},
  booktitle = {Proc. ACM Manag. Data},
  year = {2023},
  url = {https://openreview.net/forum?id=U6VYNP2lseA},
}
Figure