Elamur Research

Modern hierarchical, agglomerative clustering algorithms

Paper · 2011 · Daniel Müllner

Summary

Hierarchical clustering builds a nested account of which observations belong together. It begins with every observation separate, repeatedly joins the closest available clusters, and ends with everything inside a single cluster. That description is easy to turn into a program, but a direct implementation spends much of its time searching again through distances it has already examined. Daniel Müllner’s paper asks how to perform this familiar procedure efficiently while preserving the precise output expected by scientific software. Its contribution concerns the computation of a hierarchy, rather than a new definition of what makes observations similar.

The paper studies the common setting in which all pairwise dissimilarities are supplied in advance. A dissimilarity describes how unlike two observations are; it need not satisfy every condition required of a mathematical metric. The required output is a stepwise dendrogram: an ordered record of individual cluster mergers and their associated distances. That output requirement matters because a broad description of the resulting hierarchy can omit information needed to reconstruct a valid sequence of mergers. Equal distances make the distinction particularly important.

The central result is a division of responsibility among algorithms. For single linkage, Müllner recommends a procedure derived from Rohlf’s minimum-spanning-tree approach. For complete, average, weighted, and Ward linkage, he recommends the nearest-neighbor-chain procedure associated with Murtagh. These approaches achieve quadratic running time in the stored-dissimilarity setting, matching the asymptotic cost of inspecting the input. For centroid and median linkage, which can produce a later merger at a smaller distance than an earlier one, Müllner introduces a generic algorithm that postpones unnecessary searches. Its worst-case upper bound remains cubic, but its behavior was quadratic across the synthetic cases examined.

The paper combines algorithm design, correctness proofs, complexity analysis, and timing experiments. It establishes why the recommended procedures produce valid stepwise outputs even when distances are tied, and it corrects an overly broad earlier claim about when nearest-neighbor chains are applicable. Its experiments also show why the best theoretical upper bound does not always identify the fastest practical implementation: maintaining extensive search structures can cost more than the searches they save. The resulting recommendations therefore depend on the linkage rule, the required output, and the representation of the input.

Interesting ideas

Specify the output before optimizing. A hierarchy represented only by the distance at which observations become connected is not always interchangeable with an ordered list of legal mergers. Müllner makes the richer output contract part of the correctness question. This is useful whenever an optimization preserves a broad mathematical result but may discard its history, ordering, or construction dependencies. An engineer can borrow the same discipline for any system whose downstream consumers require more than a visually similar or semantically related result.

Keep a certificate instead of refreshing every answer. The generic algorithm allows a cached nearest neighbor to become outdated while retaining a valid lower bound on the distance to the true nearest neighbor. That bound is enough to show that a cluster cannot yet determine the next global merger. A full search becomes necessary only when the bound reaches the front of the priority queue. The reusable idea is to preserve the information needed for a decision, rather than paying immediately to restore every cached detail.

Distinguish a sufficient condition from a suggestive property. The paper shows that reducibility alone does not justify nearest-neighbor-chain clustering for an arbitrary update rule. A further condition governs whether exchanging independent mergers changes the distance between their resulting clusters. This distinction applies broadly to algorithms that discover work in one order and later rearrange it: local safety does not automatically establish that the rearrangement preserves the complete computation.

Treat ties as ordinary inputs. Equal dissimilarities affect chain construction, sorting, and the conversion from cluster representatives to final labels. They are not merely a cosmetic nuisance in a plotted tree. The paper’s proofs make these cases explicit, including a rule that favors the preceding chain element when several nearest neighbors are equally close. This is a useful pattern for software that must remain correct when values are repeated, quantized, or otherwise unable to provide a unique ordering.

Separate discovery order from output order. Nearest-neighbor chains can find a merger that belongs later in the final sequence. Under the proved conditions, that is acceptable: the algorithm records provisional mergers, stably sorts them, and reconstructs cluster identities afterwards. The broader lesson is that execution need not follow presentation order when a proof establishes how to recover the required result. Stable ordering and dependency reconstruction then become substantive parts of the method.

Choose algorithms by the complete cost structure. The generic algorithm can outperform an alternative with a stronger worst-case bound because the alternative maintains a priority queue for every point and needs substantial additional bookkeeping. Similarly, the single-linkage procedure gains from leaving the input unchanged. These comparisons encourage an implementation decision that considers search work, maintenance work, memory, and actual input behavior together. An asymptotic guarantee remains important, but it does not replace measuring the operations that dominate a real implementation.

Deep dive: Modern hierarchical, agglomerative clustering algorithms

How Müllner’s hierarchical clustering algorithms speed up merging, preserve valid dendrograms, handle ties, and guide algorithm choice. · about 32 minutes to read

How Mova uses it

For Mova, the small transparent language system written in Rust, this paper offers an approach to a possible clustering component. There is no established Mova integration to report. The concrete opportunity would arise if Mova needed to organize language-related objects into nested groups and could supply a meaningful dissimilarity between them. The objects might be lexical entries, contextual representations, or other items that an experimenter wants to inspect together. Those are possible applications, not capabilities demonstrated by Müllner’s experiments.

The first useful decision would concern the representation of the evidence. If a Mova experiment already produced a stored array of pairwise dissimilarities, it would fit the paper’s main setting directly. The choice of clustering procedure could then follow the update rule: the minimum-spanning-tree-based procedure for single linkage, nearest-neighbor chains for the supported methods without inversions, and the generic procedure where inversions must be preserved. The hierarchy would remain an analysis of the supplied dissimilarities. Neither efficient computation nor a well-formed dendrogram would establish that the groups have the intended linguistic interpretation.

A transparent implementation could expose the merger record as an inspectable artifact. Each row would identify the clusters being joined and the dissimilarity associated with that decision. That would make it possible to examine an unexpected grouping through its construction history. The paper is especially relevant here because its output requirement preserves distinctions that a simplified tree picture may hide. In a system concerned with explaining its internal organization, retaining those distinctions could be more useful than producing only a final partition.

The handling of ties would deserve particular attention. A Rust implementation could reuse compact cluster representatives internally, perform the required stable ordering, and generate explicit output identities through union-find. For nearest-neighbor chains, it would also need to preserve the tie preference used in the proof. These are concrete implementation obligations if that algorithm is adopted. Choosing a familiar linkage name would not remove the need to verify that the chain logic and output conversion follow the conditions Müllner establishes.

The generic algorithm also suggests a design idea beyond clustering. If a future Mova subsystem repeatedly compares changing candidates, it might retain conservative bounds and postpone expensive recomputation until a candidate becomes relevant to a decision. That would be an adaptation of the paper’s reasoning, not an automatic consequence of importing its code. The bound would need its own justification for the new task, just as the nearest-neighbor bound is justified here.

The paper’s vector-data discussion gives another possible route. Where an experiment uses vector representations, some supported procedures can calculate distances as needed rather than storing the complete dissimilarity array. This could reduce memory requirements, although the proposed extensions do not establish a general escape from quadratic distance work. For Mova, the practical attraction would be an inspectable implementation with a clear accounting of stored evidence, temporary state, and merger decisions. Claims about improved language behavior would require a separate experiment.

The problem and its context

A simple definition creates repeated work

Hierarchical agglomerative clustering belongs to unsupervised machine learning. “Agglomerative” describes its direction: the procedure assembles larger groups from smaller ones. Initially, each observation forms a cluster by itself. The procedure chooses the closest available pair, replaces that pair with their union, updates the distances involving the new cluster, and continues.

The definition leaves an important choice open. After a merger, how should the new cluster’s dissimilarity to another cluster be calculated? A linkage rule answers that question. The paper considers the familiar single, complete, and average rules, together with weighted, Ward, centroid, and median linkage. They share the same outer procedure but differ in how a merger changes the distance information used by later decisions.

A literal implementation repeatedly scans every currently available pair to find the minimum. Although the active set becomes smaller as clustering proceeds, the repeated scans produce cubic running time. This is the primitive algorithm against which the more efficient procedures are judged. Its significance is therefore both computational and definitional: it provides a straightforward implementation, and it specifies which merger sequences count as valid answers.

The task is not to approximate that algorithm with a hierarchy that merely looks similar. An advanced procedure must return an output that the primitive procedure could have generated. Since several pairs may share the smallest distance, the primitive procedure can have several valid outputs. Müllner accepts any of those outputs. Correctness requires membership in that set, rather than agreement with a particular arbitrary rule for breaking ties.

Earlier algorithms and practical software

The paper situates the problem within a long history of attempts to avoid repeated exhaustive searches. Gower and Ross connected single linkage with minimum spanning trees in 1969. Subsequent contributions included methods associated with Sibson, Rohlf, and Anderberg, followed by work from Murtagh and from Day and Edelsbrunner. Müllner builds on these approaches instead of presenting hierarchical clustering as a new problem.

His practical concern is the distance between available algorithmic knowledge and widely used software. The paper discusses clustering functions in R and SciPy, along with the broader conventions shared by standard numerical packages. Müllner reports that implementations frequently used procedures inferior to alternatives already described in theoretical work. Improving that situation required more than repeating an asymptotic result: the algorithms had to fit the actual input arrays and output structures expected by those environments.

The paper therefore narrows its scope deliberately. Its main input is a finite collection of observations accompanied by all pairwise dissimilarities. This is the stored-matrix setting. The alternative, in which observations are retained as vectors and distances are calculated from them, is considered later and more briefly.

That distinction changes the meaning of an efficiency claim. With a stored dissimilarity array, the input itself is quadratic in the number of observations. Müllner argues that every entry can matter to the result, so a correct general-purpose procedure cannot simply ignore an arbitrary part of that array. Quadratic running time is consequently an appropriate optimality target. A vector input has a different size and may permit methods that exploit additional structure.

Why a dendrogram needs a precise definition

A dendrogram can refer to a mathematical hierarchy, a stored representation, or a picture of a tree. The paper separates these meanings because they do not preserve exactly the same information. A drawing can suggest an ordering of leaves that the clustering result does not specify. It can also conceal the ordering of several mergers occurring at the same distance.

One mathematical account describes a hierarchy through partitions indexed by a distance threshold. As the threshold increases, groups become coarser until all observations belong together. This is useful for describing connectivity at a given level. However, when several mergers occur at the same level, the partition-based account need not retain the individual decisions made inside that level.

The required software output is more specific. A stepwise dendrogram records each merger separately, identifying its participating clusters and its distance. It therefore preserves a legal construction sequence. This matters even when alternative sequences lead to the same partition at every distinct distance threshold.

Müllner illustrates the issue using configurations of the points x₀, x₁, and x₂. The configurations have dissimilarities labeled 2.0 and 3.0, and they share the same non-stepwise single-linkage hierarchy. Nonetheless, a particular initial merger can be legal for some configurations and illegal for another. No single stepwise answer can serve all of them.

This is not an objection to the mathematical notion of a hierarchy. It establishes that the software contract asks for additional information. An algorithm proved correct for a weaker representation may have discarded exactly what is needed to recover that additional information. The paper’s treatment of Sibson’s SLINK procedure turns on this distinction.

The special role of inversions

A separate issue arises when a merger changes distances so that the next merger occurs below a previous merger’s distance. The paper calls this an inversion. Centroid and median linkage can exhibit this behavior; the other common methods considered do not.

An inversion makes a merger sequence more than a sorted list of heights. Sorting its rows by distance would change the sequence and could invalidate references to clusters that do not yet exist. The generic algorithm is needed for this reason: it follows valid global-minimum decisions as they occur, even if their distances decrease.

The paper’s eventual algorithm recommendations reflect these different obstacles. Single linkage has a special graph-based route. Several methods permit reciprocal-neighbor discovery followed by careful reordering. Methods with inversions require a procedure that preserves the actual order of decisions. Treating all linkage rules as interchangeable would miss the properties that make the faster approaches correct.

The method, step by step

The paper presents a family of compatible procedures instead of a single universal replacement for every case. A shared definition of input and output comes first. The linkage rule then determines which accelerated search is justified, and some procedures require postprocessing before their records become the final dendrogram.

From dissimilarities to a valid merger sequence

The steps in order.

From dissimilarities to a valid merger sequenceStep 1: Specify input dissimilarities and linkage rule1. Specify input dissimilarities and linkage ruleStep 2: Choose the compatible search procedure2. Choose the compatible search procedureStep 3: Discover globally closest or reciprocal neighbors3. Discover globally closest or reciprocal neighborsStep 4: Record mergers and update required state4. Record mergers and update required stateStep 5: Stably sort records when the procedure permits5. Stably sort records when the procedure permitsStep 6: Reconstruct explicit cluster labels6. Reconstruct explicit cluster labels

Define what a dissimilarity supplies

The input is a finite set S and a dissimilarity function d. The function assigns a non-negative value to every pair of elements.

d: S × S → [0, ∞)

Here, S is the set of observations, S × S contains all ordered pairs of observations, and d is the function assigning their dissimilarities. The interval [0, ∞) states that the values cannot be negative.

The function must be symmetric.

d(x, y) = d(y, x)

The symbols x and y denote observations in S. Symmetry means that exchanging their order does not change the supplied value.

An observation also has zero dissimilarity from itself.

d(x, x) = 0

Again, x is an observation and d is the dissimilarity function. This condition does not imply that different observations must have positive dissimilarity. The paper permits distinct observations to have a zero value between them.

It also does not require the triangle inequality. As a consequence, statements proved for this input setting cover more than ordinary geometric distances. Throughout the algorithms, “distance” can mean this broader dissimilarity, so readers should not silently assume geometric properties that the input contract does not provide.

For N observations, the independent input values are the pairwise dissimilarities between distinct observations.

input size = N(N − 1)/2 ∈ Θ(N²)

The symbol N denotes the number of observations. The expression N(N − 1)/2 counts unordered pairs, and Θ(N²) describes the growth rate of the resulting input size. This is the quadratic input that motivates the paper’s lower-bound argument.

Define the merger record

Each output row identifies a merger and the distance at which it occurs.

(aᵢ, bᵢ, δᵢ)

The index i identifies a step. The labels aᵢ and bᵢ identify clusters active at that step, and δᵢ is their merger dissimilarity. The order of the participating labels inside the row has no significance.

After the merger, the participating clusters disappear from the active set and a label for their union replaces them.

Sᵢ₊₁ = (Sᵢ ∖ {aᵢ, bᵢ}) ∪ {nᵢ}

Here, Sᵢ is the active cluster set before the merger, Sᵢ₊₁ is the set afterwards, and nᵢ labels the newly joined cluster. The set difference removes the participating clusters; the union adds their replacement.

The final output contains N−1 such rows. The exact integers used as labels are a software convention. The paper discusses differing conventions in R, SciPy, and MATLAB, but the mathematical merger history does not depend on choosing one particular convention.

Internally, fresh public labels are not always the most efficient choice. An implementation can reuse an existing array index as the representative of a joined cluster. That permits distances to be updated in place. A later conversion reconstructs the explicit identities expected by the output format.

Use the primitive procedure as the reference

The primitive procedure begins with singleton clusters and repeatedly finds a globally closest pair among the active clusters. It records the merger, updates the distances involving the resulting union, and continues until the active set contains the complete dataset as a cluster.

Cluster sizes are maintained alongside dissimilarities because some update rules require them. Other rules depend only on the relevant distances. The efficient algorithms retain the same underlying linkage semantics while reducing the work required to identify the next valid merger.

For some linkage rules, the distance between completed clusters depends only on their memberships. For weighted and median linkage, the internal merger history can affect the value. That is why statements about exchanging or reordering clustering steps need care. Knowing the members of a cluster does not always determine every distance associated with it.

The paper gives a condition sufficient to prevent inversions.

d(I, J) ≤ min{d(I, K), d(J, K)} ⇒ d(I, J) ≤ d(I ∪ J, K)

The symbols I, J, and K denote disjoint clusters. The function d now refers to the inter-cluster dissimilarity produced by the selected linkage rule. The premise says that I and J are no farther apart than either is from K. The conclusion says that joining I and J cannot create a distance to K below their own merger distance.

This condition explains the relevance of an update formula to the ordering of output heights. It does not say that every useful property of a clustering algorithm follows from nondecreasing heights. The nearest-neighbor-chain proof needs a stronger condition and an additional requirement about exchanging independent mergers.

Cache nearest neighbors before making caching lazy

Anderberg’s approach begins with a useful simplification: maintain a nearest-neighbor entry for each cluster. Instead of searching every active pair from scratch at every step, the algorithm searches among these entries to identify a global candidate.

The paper further notes that an ordered set of indices permits searches to consider only higher-index neighbors. Symmetry ensures that every unordered pair still has a place in this representation. This avoids storing both directions of the same pair as independent nearest-neighbor obligations.

Maintaining the entries is the difficult part. Suppose the nearest neighbor of a surviving cluster participates in a merger. Its cached answer may no longer be valid. An eager implementation searches again immediately, even when that cluster is far from any pair likely to merge soon.

Müllner’s generic algorithm postpones this repair. A candidate neighbor is retained along with a lower bound for the distance to the actual nearest neighbor. The candidate can become inaccurate without destroying the usefulness of the lower bound.

The key validation check is:

d[x, nnghbr[x]] = mindist[x]

The symbol x identifies an active cluster. The entry nnghbr[x] is its cached neighbor candidate, d[x, nnghbr[x]] is the candidate’s current dissimilarity, and mindist[x] is the maintained lower bound. Equality certifies that the candidate attains the bound and is therefore a true nearest neighbor within the relevant search range.

The distinction between an answer and a bound is the algorithm’s central idea. If another cluster has a smaller certified distance, the uncertain entry need not be repaired yet. Its lower bound is sufficient to keep it from interfering with the immediate choice.

Let the priority queue decide when to repair

The generic procedure stores the lower bounds in a priority queue. This data structure exposes the smallest bound efficiently. The queue entry at the front identifies the cluster whose uncertainty is currently most relevant to choosing the next merger.

If that entry’s candidate attains its bound, the algorithm has found a globally closest pair. If not, it performs a full nearest-neighbor search for that cluster, updates the candidate and bound, repairs the queue, and examines the current minimum again.

This process can repeat before a valid merger is found. However, a cluster whose uncertain entry remains far from the queue minimum can pass through many clustering iterations without another full search. When a repair eventually becomes necessary, there may be fewer active clusters left to examine.

After a merger, the procedure updates the affected distances and the bookkeeping needed to keep every bound valid. It reuses an array label for the joined cluster, redirects references that would otherwise point to a removed label, and records any newly smaller distance that must lower a bound.

The implementation described uses a binary heap. Constructing the queue takes O(N), looking up its minimum takes O(1), and the relevant updates take O(log N). These operations support the search strategy; they do not eliminate the possibility of repeated full nearest-neighbor scans.

That qualification explains the complexity result. The generic algorithm has quadratic best-case behavior, but the paper retains an O(N³) worst-case upper bound. A sufficiently unfavorable sequence could repeatedly force expensive repairs. The improvement is a reduction in unnecessary work, supported by the experiments, instead of a proof that cubic behavior has become impossible.

Follow a nearest-neighbor chain

The nearest-neighbor-chain procedure uses a different route to finding safe mergers. It starts from an active cluster and follows a nearest neighbor, then a nearest neighbor of that cluster, and continues until it reaches a reciprocal pair.

Reciprocal nearest neighbors satisfy:

d[a, b] = min{x ∈ S, x ≠ a} d[a, x] = min{x ∈ S, x ≠ b} d[b, x]

The set S contains the active clusters. The labels a and b identify the proposed pair, x ranges over other active clusters, and d is the current inter-cluster dissimilarity. The equalities mean that b is among a’s closest neighbors and a is among b’s closest neighbors.

A globally closest pair is reciprocal, but a reciprocal pair need not be the globally closest pair currently present. The method gains efficiency because it can discover such a pair locally and record it before discovering some lower-distance mergers elsewhere.

That freedom requires a proof. The first condition is the reducibility property discussed in the paper.

d(I, J) ≤ min{d(I, K), d(J, K)} ⇒ min{d(I, K), d(J, K)} ≤ d(I ∪ J, K)

The clusters I, J, and K are disjoint, and d is the linkage-dependent dissimilarity. If I and J are sufficiently close to justify the premise, the new cluster cannot become closer to K than the smaller of their previous distances to K. This supports the continued validity of existing nearest-neighbor relations along the chain.

The further condition concerns disjoint mergers. For disjoint clusters I, J, K, and L, the distance between I∪J and K∪L must remain unchanged when the order of those mergers is exchanged. This permits the proof to move a discovered merger into the appropriate place in the final sequence without changing the state reached afterwards.

The theorem establishes these conditions for single, complete, and average linkage, together with weighted and Ward linkage. It does not grant the method unrestricted applicability to any distance update satisfying reducibility.

Preserve the correct meaning of ties

Chain construction includes a small but consequential tie rule. When the preceding chain element is among the current element’s nearest neighbors, the search prefers that preceding element. This ensures that a reciprocal pair closes the chain rather than being bypassed in favor of an equally distant alternative.

The core procedure records mergers in discovery order. It then sorts the records by dissimilarity. That sort must be stable: equal-distance records retain their original relative order.

Stability protects dependencies among mergers that share a distance. The paper’s proofs rely on those dependencies being preserved. Substituting an unstable sort would therefore change more than presentation.

Finally, union-find converts cluster representatives into explicit node labels. Union-find maintains which original representatives currently belong to the same accumulated cluster, allowing the output record to name the correct newly created nodes.

The sorting costs O(N log N), and the labeling conversion takes Θ(N). Both are below the quadratic complexity of the chain computation. Their smaller cost does not make them optional: they complete the transformation from internal discoveries to the required output.

Use the special structure of single linkage

For single linkage, the paper recommends a procedure based on Rohlf’s work and related to Prim’s minimum-spanning-tree construction. It operates on the complete weighted graph whose vertices are observations and whose edge weights are their supplied dissimilarities.

The simplified procedure does not retain enough information to reconstruct an actual minimum spanning tree. It retains what is necessary to recover single-linkage mergers. Consequently, Müllner supplies a direct correctness proof instead of treating the correctness of Prim’s algorithm as sufficient.

Its key maintained quantity is:

Dᵢ[s] = min{t ∈ Sᵢᶜ} d[s, t]

The set Sᵢ contains observations not yet removed from the current set. Its complement Sᵢᶜ contains observations already selected, s is an observation still in Sᵢ, and Dᵢ[s] is its smallest dissimilarity to the selected set. The index i identifies the current iteration.

Each new selection updates these distances and adds a provisional record. As with nearest-neighbor chains, stable sorting and union-find labeling produce the final stepwise dendrogram.

A major implementation advantage is that this procedure leaves the dissimilarity array unchanged. It therefore avoids the writable working copy needed by the other recommended procedures when the original input must be retained.

Establish the remaining mathematical conditions

Ward linkage requires particular care because a familiar geometric expression may assume Euclidean input. For the correctness discussion, the paper provides an expression in terms of original pairwise dissimilarities.

d(A, B) = √((2 Σₐ∈A Σᵦ∈B d(a, b)² − (|B|/|A|) Σₐ∈A Σₐ′∈A d(a, a′)² − (|A|/|B|) Σᵦ∈B Σᵦ′∈B d(b, b′)²)/(|A| + |B|))

The symbols A and B denote clusters, while |A| and |B| are their sizes. The symbols a and a′ range over observations in A; b and b′ range over observations in B. The summation sign Σ means to add the indicated squared dissimilarities, and √ denotes the square root.

This expression demonstrates that Ward dissimilarity is unaffected by the sequence in which cluster memberships were put together. That establishes the needed invariance for the proof without restricting the algebraic argument to a geometric picture.

Weighted linkage poses a different issue. Its distances can depend on internal merger history, but the theorem requires only a narrower exchange property.

d(I ∪ J, K ∪ L) = (d[I, K] + d[I, L] + d[J, K] + d[J, L])/4

The symbols I, J, K, and L denote disjoint clusters. The function d gives their current dissimilarities. This expression is unchanged when the merger of I with J and the merger of K with L exchange order.

Therefore, complete independence from merger history is unnecessary. The proof needs precisely the invariance involved in rearranging disjoint steps. This is why weighted linkage can satisfy the theorem despite depending on history more generally.

Extend cautiously to vectors

There is no training stage in these procedures. They operate on the observations and dissimilarities supplied for the clustering task. The vector extension changes how distances are obtained and stored, instead of introducing a learned component.

For single linkage, the minimum-spanning-tree-based procedure can calculate dissimilarities when needed. Since its access pattern reads each pairwise dissimilarity once, this can avoid storing the complete array without repeating that distance work.

The nearest-neighbor-chain extension is appropriate for Ward linkage with Euclidean vector input. The generic procedure can be adapted for Ward, centroid, and median linkage on Euclidean data.

The paper also describes a generic variant that gives each new cluster a label smaller than existing labels. This simplifies bookkeeping compared with reusing an index inside the current ordering. Its relative speed depends on the data structures and memory layout, so it is an implementation option instead of an unconditional replacement.

Experiments and results

What the measurements evaluate

The experiments evaluate computation time and resource behavior. They do not test whether a linkage rule discovers more useful scientific categories, and they do not compare external labels against predicted clusters. The clustering definitions are held fixed while alternative algorithms compute their outputs.

All compared procedures were implemented in C++, with Python and NumPy handling array input and output. The timing environment was shared across the implementations. This makes the comparisons more informative than a comparison between unrelated software packages whose interfaces, language overheads, and implementation decisions might differ substantially.

The synthetic vector datasets came from mixtures of multivariate Gaussian distributions. The covariance matrix was the identity, and the dimensions included 2, 3, 10, and 200. The mixture settings used 1 or 5 modes, as well as a setting written as [√N]. Their centers were themselves drawn using a Gaussian distribution.

Dataset sizes began at N=10 and increased until memory became the limiting resource. The paper reports N=20000 as the limit except in the single-linkage case. For the combinatorial linkage methods, it also generated 10 uniformly distributed dissimilarity datasets for each tested number of observations.

These choices exercise both distances derived from vectors and dissimilarity arrays without a corresponding vector construction. They provide variation in dimension, grouping structure, and numerical distance patterns. They do not establish coverage of every kind of application data.

The test computer used an Intel T7500 dual-core processor running at 2.2 GHz, with 4GB of RAM and no swap. The system was Ubuntu 11.04 in its 64-bit version. Python was version 2.7.1, NumPy was version 1.5.1, and the GNU C++ compiler was version 4.5.2. Computation used a single processor core.

The theoretical comparison

The paper first establishes bounds that do not depend on the particular random datasets. Both the single-linkage procedure and nearest-neighbor chains take Θ(N²) time in their supported settings, including the lower-order output conversion work.

For a supported method such as complete linkage, the difference from repeated exhaustive searches can be represented through the polynomial exponent in the stated worst-case bound. The following chart reports those exponents, not elapsed times or measured speedups.

Complete linkage with stored dissimilarities, worst-case polynomial exponent

Nearest-neighbor chains provide a quadratic guarantee where the other listed bounds are cubic.

Complete linkage with stored dissimilarities, worst-case polynomial exponentPrimitive algorithm: 3Primitive algorithm3Anderberg algorithm: 3Anderberg algorithm3Nearest-neighbor chain (this paper): 2Nearest-neighbor chain (this paper)2
The numbers
System or settingexponent of N in the worst-case time bound
Primitive algorithm3
Anderberg algorithm3
Nearest-neighbor chain (this paper)2

The chart does not imply that these algorithms differ by the same amount on every dataset. An upper bound describes possible growth under unfavorable inputs, whereas practical runtime also depends on how much of that unfavorable behavior occurs and on the cost of maintaining auxiliary structures.

The generic procedure has a quadratic best case and an O(N³) worst-case bound. Single linkage is a special case for it: the repeated-repair loop is unnecessary there, yielding Θ(N²) worst-case behavior. Nonetheless, the specialized single-linkage procedure remains preferable because of its practical speed and memory advantages.

The memory distinction is substantial when the original input must remain available. Nearest-neighbor chains and the generic procedure require a writable dissimilarity array plus linear additional state. The specialized single-linkage procedure only reads its input and needs linear temporary storage. It therefore avoids an additional quadratic array.

What the timing curves show

The paper presents average runtimes over the synthetic datasets and bands spanning the minimum and maximum runtime for each problem size. Its discussion identifies clear differences, but it does not supply a numerical table of elapsed-time values. The supported conclusions are therefore about the reported trends and ordering, rather than exact speedup factors.

For single linkage, the minimum-spanning-tree-based procedure is the fastest method tested. Its reduced memory requirement reinforces that result because more observations can fit within the same memory constraint. The recommendation is supported simultaneously by the asymptotic bound, the timing behavior, and the absence of a writable input copy.

For linkage methods without inversions, the generic procedure, nearest-neighbor chains, and Anderberg’s procedure have similar observed performance. The important result is that nearest-neighbor chains obtain their quadratic worst-case guarantee without an observed practical penalty in these experiments. The theorem is useful without requiring an unfavorable trade in ordinary runtime.

Centroid and median linkage provide the clearest practical advantage for the new generic procedure. Anderberg’s algorithm shows cubic behavior across the tested range, including the random datasets. The generic procedure instead remains within quadratic-looking behavior over the examined cases.

That is evidence for a useful implementation improvement, but it does not strengthen the proved worst-case upper bound. The paper does not establish that every possible centroid or median input will run quadratically. Its recommendation combines the general algorithm’s ability to preserve inversions with the favorable behavior observed on the chosen test families.

A stronger bound with a practical cost

The experiments also include the Day–Edelsbrunner approach. Its O(N² log N) worst-case bound is stronger than the cubic upper bound retained for the generic procedure in the inversion-capable setting.

However, that method maintains a separate priority queue for each point. In the implementation examined, the bookkeeping is expensive in both time and memory. The additional storage is quadratic, and the timing graphs stop at smaller datasets because memory is exhausted earlier.

This comparison is central to the paper’s engineering argument. The algorithm with the better established worst-case bound is not the practical recommendation for centroid and median linkage. Its guarantee has to be weighed against the actual price of obtaining it.

The author’s C++ implementations, with interfaces for R and Python, are associated with fastcluster, which the paper discusses as a separate implementation publication. The algorithmic article provides the reasoning behind those implementation choices instead of a user guide.

What the ablations show

The paper has no component-removal ablation study; it offers controlled algorithm comparisons, implementation variants, counterexamples, and correctness analyses.

Delayed repair addresses the observed bottleneck

The nearest comparison to an ablation is the relationship between Anderberg’s method and the generic procedure. Both keep nearest-neighbor information, and both retain a cubic worst-case upper bound. Their crucial difference is the treatment of invalidated entries.

Anderberg’s approach repairs nearest-neighbor information more eagerly. The generic procedure can leave a candidate unresolved while its lower bound remains irrelevant to the next merger. This changes when work is performed and can eliminate repeated searches altogether.

The centroid and median results are consistent with that explanation. Eager maintenance repeatedly incurs costly searches on the random inputs, while delayed repair avoids the same growth pattern. The experiment does not isolate every implementation operation independently, so it should not be read as a detailed accounting of time spent in each function. It does show that the combined design solves a practical weakness of the earlier approach.

The proof complements that observation. Delaying repair is safe because the queue is ordered by valid lower bounds, and a candidate is accepted only when its actual distance attains its bound. The algorithm therefore saves work without relaxing the definition of a valid next merger.

Cheaper theoretical maintenance is not automatically faster

The paper examines whether rebuilding the entire priority queue at the start of each iteration would improve the generic procedure. This changes the upper bound for queue-maintenance work from O(N² log N) to O(N²).

In practice, the rebuilding variant is slightly slower. The reason offered is that ordinary queue updates fall well short of their pessimistic frequency in the tested data. Rebuilding pays a regular cost to avoid a worst-case pattern that the experiments do not approach.

This is an informative controlled comparison because it separates a local asymptotic improvement from total runtime. Improving the bound of a subroutine does not guarantee an improvement to the complete procedure, especially when the subroutine rarely reaches that bound.

The paper also notes that a priority queue with constant-time decrease-key operations could reduce maintenance complexity. That alternative was not tested. It remains a suggested data-structure option, not an experimental result.

Reducibility alone fails the correctness test

A deliberately constructed distance update provides a different kind of controlled analysis.

d(I ∪ J, K) = d(I, K) + d(J, K) + d(I, J)

The symbols I, J, and K denote disjoint clusters, and d is their dissimilarity. The rule defines the new distance to K by adding the distances from the participating clusters and their merger distance.

This update satisfies the stated reducibility property, yet a nearest-neighbor chain can still return an invalid stepwise result. The paper supplies a dataset involving A, B, C, D, and E, and specifies a chain initialization that produces the failure.

Under the primitive procedure, the later merger of AB with CD occurs at 27, followed by the final merger at 85. The chain procedure instead merges CD with E at 28 and produces a final merger at 87. The discrepancy concerns the hierarchy’s construction, not merely the order of equal-height rows.

This counterexample establishes the need for the theorem’s additional exchange condition. Reducibility protects certain nearest-neighbor relationships, but it does not on its own ensure that rearranging disjoint mergers leaves subsequent distances unchanged. The example therefore limits the scope of a general algorithmic claim instead of comparing the quality of clustering objectives.

Ties expose an output-contract mismatch

The comparison with SLINK examines what happens when a compact representation discards distinctions. In the paper’s example configurations, SLINK returns the same representation despite differences in which stepwise outputs are legal.

No postprocessing rule can recover distinctions absent from that representation. Sorting and union-find are insufficient if the earlier algorithm has already collapsed cases that require different answers.

The paper gives a possible repair: impose a secondary order on equal dissimilarities so that they become distinct for algorithmic purposes. Its experiments find a small timing disadvantage from the additional comparisons, while acknowledging that the result could change with the environment or input access pattern.

The lesson is specific. SLINK remains correct for the weaker dendrogram notion it was designed to produce. The problem arises when its output is expected to support a richer stepwise contract without the additional handling that contract requires.

Label placement changes bookkeeping

The vector-oriented generic variant examines another implementation choice: assigning each joined cluster a new label positioned before the existing labels. This removes bookkeeping loops required when an internal index is reused.

The paper reports fewer nearest-neighbor recalculations on some datasets. It also states that relative performance depends strongly on representation and memory layout. This is useful evidence for an implementation option, but not a claim that the variant dominates every version of the original procedure.

Together, these analyses explain why the final recommendations are conditional. The paper does not reduce efficiency to a single clever subroutine. It connects mathematical properties, update timing, memory access, and output reconstruction.

Limitations

Limits the author explicitly identifies

The main scope restriction is the stored-dissimilarity setting. The quadratic optimality claim depends on receiving a quadratic array whose entries can affect the answer. It does not establish that quadratic time is unavoidable for every possible representation of the original observations.

The vector-data discussion explicitly leaves specialized low-dimensional methods outside the main analysis. Such methods may exploit a metric or geometric structure unavailable to a general-purpose procedure. The paper’s recommendations should therefore be applied within their stated input contract.

The generic procedure retains an O(N³) worst-case bound. Its favorable behavior on centroid and median experiments is not a proof of quadratic worst-case complexity. The author identifies the repeated full nearest-neighbor search as the unresolved bottleneck.

Practical timing conclusions also depend on the implementation, compiler, hardware, and dataset choices. The comparison uses careful implementations in a common environment, which supports the relative findings, but the author does not present the observed runtime ordering as independent of those conditions.

The discussion of alternative priority queues is incomplete by design. A binary heap was chosen for simplicity; other structures were not benchmarked. Similarly, the paper does not settle every possible improvement to the generic algorithm’s queue operations.

Parallel computation is largely outside the paper’s focus. The author suggests that vector-distance calculations, particularly in high-dimensional settings, could provide useful parallel work. That suggestion is not accompanied by a demonstrated parallel implementation or scaling result.

The memory advantage of the specialized single-linkage procedure also has a condition. It avoids a working copy when an unchanged original input is required. That is a different claim from reducing the supplied dissimilarity array itself to linear size.

Limits visible in the experimental design

The experiments use synthetic distributions and generated dissimilarity arrays. They are appropriate for examining runtime patterns under varied settings, but they do not establish behavior on every scientific dataset. Structured application data could produce different frequencies of candidate invalidation or different memory-access behavior.

The measurements concern exact computation under selected linkage rules. They provide no evidence that a recommended linkage yields better categories for a particular application. Algorithmic correctness says that the chosen clustering definition is implemented faithfully; it does not establish that the definition is suitable for the data’s substantive meaning.

There is also no external labeling task in the evaluation. The paper does not report classification accuracy, retrieval performance, or linguistic usefulness. Any claim that these faster procedures improve an application would need to connect computational savings to a separately evaluated application outcome.

The experiments use a particular memory-limited machine and a single processing core. They support conclusions about that shared execution environment. They do not measure how the balance among scanning, queue maintenance, and memory access changes on other architectures.

The nearest-neighbor-chain theorem requires verification of both stated conditions for a new update rule. A rule’s intuitive resemblance to a supported linkage is insufficient. The counterexample makes this a practical limitation on reuse, rather than a formality confined to the proof.

Finally, accepting any valid tie resolution means the paper does not promise identical output rows across every correct implementation. Different legal choices can produce different stepwise histories. A comparison that demands byte-for-byte agreement would impose an additional convention beyond the correctness criterion used here.

What came after

The later citing works listed alongside this paper show clustering appearing in research on language computation, reasoning, and structured knowledge. The available information identifies their subjects and their citation relationship to Müllner’s work. It does not establish which of his procedures they implement, which linkage rules they choose, or whether they reproduce his complexity analysis. Those distinctions matter because citing a clustering reference does not by itself identify an algorithm.

Transformer Feed-Forward Layers Build Predictions by Promoting Concepts in the Vocabulary Space, from 2022, concerns how feed-forward layers contribute to predictions through concepts expressed in vocabulary space. Its subject belongs to interpretability: explaining how internal computation relates to understandable concepts and outputs. Its citation places Müllner’s work in the methodological background of that later investigation. The listing does not specify a clustering-based finding or an exact use of a dendrogram, so a more detailed account of its dependence would go beyond the available evidence.

The connection is nonetheless useful for understanding the reach of the algorithmic question. If an interpretability analysis groups internal objects, the grouping procedure has its own semantics and computational requirements. Müllner’s distinction between an abstract hierarchy and an ordered merger record provides a way to describe that procedure precisely. This is a possible methodological relevance, not evidence that the later work uses every aspect of his output contract.

VecCISC: Improving Confidence-Informed Self-Consistency with Reasoning Trace Clustering and Candidate Answer Selection, from 2026, explicitly names reasoning-trace clustering as part of its subject. It combines that topic with confidence-informed self-consistency and candidate-answer selection. The citation connects Müllner’s algorithmic treatment to a later setting in which the objects being grouped are reasoning traces instead of the generic observations used in his experiments.

The title supports that broad description, but it does not establish the distance function, linkage rule, or selection mechanism. It also supplies no numerical result that can be attributed to Müllner’s algorithm. A careful account therefore distinguishes the later use of clustering as a component from any unverified claim that it adopts the generic procedure or inherits a particular runtime guarantee.

GS-Quant: Granular Semantic and Generative Structural Quantization for Knowledge Graph Completion, also from 2026, addresses semantic and structural quantization for knowledge graph completion. Its citation associates Müllner’s work with another setting where organizing related objects can support a larger computational method. The listing gives no implementation details that would identify a particular hierarchical clustering algorithm.

Across these later topics, the enduring contribution is a set of questions that remain useful whenever clustering becomes a component inside a larger system. What dissimilarities are supplied? Which update rule defines the intended groups? Does the consumer need a partition, a threshold hierarchy, or a legal merger history? Are ties and inversions possible? The paper shows that these choices determine both what counts as a correct answer and which efficient procedure can produce it.

Cite

Cite as Daniel Müllner. 2011. Modern hierarchical, agglomerative clustering algorithms. arXiv (Cornell University).

The paper itself, not this page. BibTeX from the library's record of the work. DOI 10.48550/arxiv.1109.2378 · arXiv 1109.2378

@misc{mullner2011modern,
  title = {{Modern hierarchical, agglomerative clustering algorithms}},
  author = {Daniel Müllner},
  year = {2011},
  doi = {10.48550/arxiv.1109.2378},
  eprint = {1109.2378},
  archivePrefix = {arXiv},
  url = {https://doi.org/10.48550/arxiv.1109.2378}
}

↑ back to top

This page in Markdown https://md.research.elamur.ai/free/en/papers/mullner-2011-modern-hierarchical-agglomerative-clustering-algorithms/

References

31 references, from the paper's own bibliography.

  1. NumPy: Scientific computing tools for Python. Available at http://numpy.scipy.org/. OpenAlex ↗ · Scholar ↗
  2. Michael R. Anderberg. Cluster analysis for applications. Academic Press, New York, 1973. ISBN 0120576503. OpenAlex ↗ · Scholar ↗
  3. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. MIT Press, 3rd edition, 2009. OpenAlex ↗ · Scholar ↗
  4. William H. E. Day. Complexity theory: an introduction for practitioners of classification. In Clustering and classification, pages 199–233. World Scientific Publishing, River Edge, NJ, 1996. OpenAlex ↗ · Scholar ↗
  5. William H. E. Day and Herbert Edelsbrunner. Efficient algorithms for agglomerative hierarchical clustering methods. Journal of Classification, 10 (1):0 7–24, 1984. . OpenAlex ↗ · Scholar ↗
  6. Daniel Defays. An efficient algorithm for a complete link method. The Computer Journal, 200 (4):0 364–366, 1977. . OpenAlex ↗ · Scholar ↗
  7. Damian Eads. Hierarchical clustering (scipy.cluster.hierarchy), 2007. Package for SciPy version 0.9.0. Available at http://www.scipy.org. OpenAlex ↗ · Scholar ↗
  8. Brian S. Everitt, Sabine Landau, Morven Leese, and Daniel Stahl. Cluster Analysis. John Wiley & Sons, 5th edition, 2011. . OpenAlex ↗ · Scholar ↗
  9. Allan D. Gordon. A review of hierarchical classification. Journal of the Royal Statistical Society. Series A (General), 1500 (2):0 119–137, 1987. . OpenAlex ↗ · Scholar ↗
  10. John C. Gower and G. J. S. Ross. Minimum spanning trees and single linkage cluster analysis. Journal of the Royal Statistical Society. Series C (Applied Statistics), 180 (1):0 54–64, 1969. . OpenAlex ↗ · Scholar ↗
  11. Pierre Hansen and Brigitte Jaumard. Cluster analysis and mathematical programming. Mathematical Programming, 790 (1–3):0 191–215, 1997. . OpenAlex ↗ · Scholar ↗
  12. Scott Huddleston and Kurt Mehlhorn. A new data structure for representing sorted lists. Acta Informatica, 170 (2):0 157–184, 1982. . OpenAlex ↗ · Scholar ↗
  13. Anil K. Jain and Richard C. Dubes. Algorithms for Clustering Data. Prentice Hall, Englewood Cliffs, NJ, 1988. OpenAlex ↗ · Scholar ↗
  14. Stephen C. Johnson. Hierarchical clustering schemes. Psychometrika, 320 (3):0 241–254, 1967. . OpenAlex ↗ · Scholar ↗
  15. Eric Jones, Travis Oliphant, Pearu Peterson, et al. SciPy: Open source scientific tools for Python, 2001. http://www.scipy.org. OpenAlex ↗ · Scholar ↗
  16. Leonard Kaufman and Peter J. Rousseeuw. Finding groups in data: An introduction to cluster analysis. John Wiley & Sons, New York, 1990. . OpenAlex ↗ · Scholar ↗
  17. Mirko Křivánek. Connected admissible hierarchical clustering. KAM series, 0 (90-189), 1990. Department of Applied Mathematics, Charles University, Prague (CZ). Available at http://kam.mff.cuni.cz/~kamserie/serie/clanky/1990/s189.pdf. OpenAlex ↗ · Scholar ↗
  18. G. N. Lance and W. T. Williams. A general theory of classificatory sorting strategies. Computer Journal, 90 (4):0 373–380, 1967. . OpenAlex ↗ · Scholar ↗
  19. Kurt Mehlhorn and Athanasios Tsakalidis. Data structures. In Handbook of theoretical computer science, Vol. A, pages 301–341. Elsevier, Amsterdam, 1990. Available at http://www.mpi-sb.mpg.de/~mehlhorn/ftp/DataStructures.pdf. OpenAlex ↗ · Scholar ↗
  20. Fionn Murtagh. A survey of recent advances in hierarchical clustering algorithms. Computer Journal, 260 (4):0 354–359, 1983. . OpenAlex ↗ · Scholar ↗
  21. Fionn Murtagh. Complexities of hierarchic clustering algorithms: State of the art. Computational Statistics Quarterly, 10 (2):0 101–113, 1984. Available at http://thames.cs.rhul.ac.uk/~fionn/old-articles/complexities/. OpenAlex ↗ · Scholar ↗
  22. Fionn Murtagh. Multidimensional clustering algorithms, volume 4 of Compstat Lectures. Physica-Verlag, Würzburg/ Wien, 1985. ISBN 3-7051-0008-4. Available at http://www.classification-society.org/csna/mda-sw/. OpenAlex ↗ · Scholar ↗
  23. Daniel Müllner. fastcluster: Fast hierarchical, agglomerative clustering routines for R and Python. Preprint, 2011. Will be available at http://math.stanford.edu/~muellner. OpenAlex ↗ · Scholar ↗
  24. R Development Core Team. R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria, 2011. http://www.R-project.org. OpenAlex ↗ · Scholar ↗
  25. F. James Rohlf. Hierarchical clustering using the minimum spanning tree. Comput. Journal, 16:0 93–95, 1973. Available at http://life.bio.sunysb.edu/ee/rohlf/reprints.html. OpenAlex ↗ · Scholar ↗
  26. F. James Rohlf. Single-link clustering algorithms. In P.R. Krishnaiah and L.N. Kanal, editors, Classification Pattern Recognition and Reduction of Dimensionality, volume 2 of Handbook of Statistics, pages 267–284. Elsevier, 1982. . OpenAlex ↗ · Scholar ↗
  27. R. Sibson. SLINK: an optimally efficient algorithm for the single-link cluster method. Comput. Journal, 16:0 30–34, 1973. . OpenAlex ↗ · Scholar ↗
  28. Peter H. A. Sneath and Robert R. Sokal. Numerical taxonomy. W. H. Freeman, San Francisco, 1973. OpenAlex ↗ · Scholar ↗
  29. The MathWorks, Inc. MATLAB, 2011. http://www.mathworks.com. OpenAlex ↗ · Scholar ↗
  30. Guido van Rossum et al. Python programming language. Available at http://www.python.org. OpenAlex ↗ · Scholar ↗
  31. Wolfram Research, Inc. Mathematica, 2010. http://www.wolfram.com. OpenAlex ↗ · Scholar ↗