[Paper Review] Hierarchical Agglomerative Graph Clustering in Nearly-Linear Time
This paper presents a novel algorithmic framework for hierarchical agglomerative clustering (HAC) on edge-weighted graphs, achieving near-linear time complexity by leveraging dynamic low-outdegree graph orientations and a modular neighbor-heap data structure. It provides the first exact $ ilde{O}(m)$-time algorithms for complete- and WPGMA-linkage, and the first subquadratic $ ilde{O}(nar{eta})$-time exact algorithm for average-linkage, with a complementary $ ilde{O}(m)$-time $$-close approximation, enabling up to 76.5x speedups on large datasets while preserving clustering quality.
We study the widely used hierarchical agglomerative clustering (HAC) algorithm on edge-weighted graphs. We define an algorithmic framework for hierarchical agglomerative graph clustering that provides the first efficient $ ilde{O}(m)$ time exact algorithms for classic linkage measures, such as complete- and WPGMA-linkage, as well as other measures. Furthermore, for average-linkage, arguably the most popular variant of HAC, we provide an algorithm that runs in $ ilde{O}(n\sqrt{m})$ time. For this variant, this is the first exact algorithm that runs in subquadratic time, as long as $m=n^{2-ε}$ for some constant $ε> 0$. We complement this result with a simple $ε$-close approximation algorithm for average-linkage in our framework that runs in $ ilde{O}(m)$ time. As an application of our algorithms, we consider clustering points in a metric space by first using $k$-NN to generate a graph from the point set, and then running our algorithms on the resulting weighted graph. We validate the performance of our algorithms on publicly available datasets, and show that our approach can speed up clustering of point datasets by a factor of 20.7--76.5x.
Motivation & Objective
- To address the inefficiency of traditional $O(n^2)$ HAC algorithms when only $o(n^2)$ similarities are non-zero in real-world data.
- To design a general algorithmic framework that enables efficient, exact, and approximate HAC on sparse edge-weighted graphs.
- To achieve subquadratic or near-linear time complexity for widely used linkage measures, especially average-linkage, which lacked such algorithms prior to this work.
- To validate the practical scalability and clustering quality of the proposed algorithms on real-world point datasets using $k$-NN graphs.
Proposed method
- The framework uses a neighbor-heap data structure to modularize core HAC operations, enabling efficient priority queue operations over graph edges.
- For average-linkage, the algorithm dynamically maintains a low-outdegree orientation of the graph, ensuring maximum outdegree $O(\alpha)$, where $\alpha$ is the arboricity of the graph.
- The exact algorithm runs in $\tilde{O}(n\bar{\alpha})$ time, where $\bar{\alpha}$ is the maximum arboricity across all contraction steps, and achieves $\tilde{O}(n\sqrt{m})$ time due to $\alpha = O(\sqrt{m})$.
- An approximate algorithm for average-linkage achieves $\tilde{O}(m)$ time by maintaining $\epsilon$-close linkage values using a sampling-based approach.
- The method applies to $k$-NN graphs constructed from metric space point sets, transforming the clustering pipeline into a graph-based HAC workflow.
- The framework assumes undefined similarities as $\bot$ (for complete/WPGMA) or zero (for average-linkage), and uses edge-weighted graph representations to avoid storing full $n \times n$ similarity matrices.
Experimental results
Research questions
- RQ1Can we design an exact HAC algorithm for average-linkage that runs in subquadratic time when only $o(n^2)$ similarities are non-zero?
- RQ2Can we achieve near-linear time complexity for classic linkage measures like complete- and WPGMA-linkage in sparse graph settings?
- RQ3Is it possible to design an approximate HAC algorithm for average-linkage that runs in $\tilde{O}(m)$ time while preserving clustering quality?
- RQ4Can the proposed framework scale to large-scale datasets (e.g., 60k+ points) with significant end-to-end speedups over standard $O(n^2)$ implementations?
Key findings
- The exact average-linkage HAC algorithm runs in $\tilde{O}(n\sqrt{m})$ time, which is subquadratic for $m = n^{2-\epsilon}$, making it the first such exact algorithm for this measure.
- The framework achieves $\tilde{O}(m)$-time exact algorithms for complete- and WPGMA-linkage, significantly improving over the standard $O(n^2)$ complexity.
- On the Fashion-MNIST dataset (60,000 points), the graph-based approach achieves a 20.7x end-to-end speedup over sklearn’s $O(n^2)$ metric-based HAC.
- On the Last.fm dataset (292,385 points), the approximate average-linkage algorithm achieves a 76.5x speedup, with extrapolated estimates suggesting 200x–500x speedups for full datasets.
- The approximate and simple-exact algorithms produce clustering quality within 1% of the exact sklearn baseline, with the exact algorithm achieving 1.8% better ARI and 0.5% better NMI on average.
- The algorithm’s memory usage is approximately $56m + O(n)$ bytes, enabling processing of graphs with several billion vertices and 2–3 billion edges on a 256GB machine.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.