ArticleslgStudy

computer science

Single-linkage clustering

Single-linkage clustering is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Single-linkage clustering rather than just read about it. In short: In statistics, single-linkage clustering is one of several methods of hierarchical clustering. It is based on grouping clusters in bottom-up fashion (agglomerative clustering), at each step combining two clusters that contain the closest pair of elements not yet belonging to the same cluster as each other.

Single-linkage clustering — main illustration
Single-linkage clustering — illustration

Key takeaways

  • Single-linkage clustering belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Single-linkage clustering to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Single-linkage clustering from memory before moving on to harder problems.

Reference excerpt

In statistics, single-linkage clustering is one of several methods of hierarchical clustering. It is based on grouping clusters in bottom-up fashion (agglomerative clustering), at each step combining two clusters that contain the closest pair of elements not yet belonging to the same cluster as each other. This method tends to produce long thin clusters in which nearby elements of the same cluster have small distances, but elements at opposite ends of a cluster may be much farther from each other than two elements of other clusters. For some classes of data, this may lead to difficulties in defining classes that could usefully subdivide the data. However, it is popular in astronomy for analyzing galaxy clusters, which may often involve long strings of matter; in this application, it is also known as the friends-of-friends algorithm.

Overview of agglomerative clustering methods In the beginning of the agglomerative clustering process, each element is in a cluster of its own. The clusters are then sequentially combined into larger clusters, until all elements end up being in the same cluster. At each step, the two clusters separated by the shortest distance are combined. The function used to determine the distance between two clusters, known as the linkage function, is what differentiates the agglomerative clustering methods. In single-linkage clustering, the distance between two clusters is determined by a single pair of elements: those two elements (one in each cluster) that are closest to each other. The shortest of these pairwise distances that remain at any step causes the two clusters whose elements are involved to be merged. The method is also known as nearest neighbour clustering. The result of the clustering can be visualized as a dendrogram, which shows the sequence in which clusters were merged and the distance at which each merge took place. Mathematically, the linkage function – the distance D(X,Y) between clusters X and Y – is described by the expression

D(X,Y)=minx∈X,y∈Yd(x,y), where X and Y are any two sets of elements considered as clusters, and d(x,y) denotes the distance between the two elements x and y.

Naive algorithm The following algorithm is an agglomerative scheme that erases rows and columns in a proximity matrix as old clusters are merged into new ones. The N×N proximity matrix D contains all distances d(i,j). The clusterings are assigned sequence numbers 0,1,…,n−1 and L(k) is the level of the k-th clustering. A cluster with sequence number m is denoted (m) and the proximity between clusters (r) and (s) is denoted d[(r),(s)]. The single linkage algorithm is composed of the following steps:

Begin with the disjoint clustering having level L(0)=0 and sequence number m=0. Find the most similar pair of clusters in the current clustering, say pair (r),(s), according to d[(r),(s)]=min⁡d[(i),(j)]where the minimum is over all pairs of clusters in the current clustering. Increment the sequence number: m=m+1. Merge clusters (r) and (s) into a single cluster to form the next clustering m. Set the level of this clustering to L(m)=d[(r),(s)] Update the proximity matrix, D, by deleting the rows and columns corresponding to clusters (r) and (s) and adding a row and column corresponding to the newly formed cluster. The proximity between the new cluster, denoted (r,s) and an old cluster (k) is defined as d[(r,s),(k)]=min⁡{d[(k),(r)],d[(k),(s)]}. If all objects are in one cluster, stop. Else, go to step 2.

Working example This working example is based on a JC69 genetic distance matrix computed from the 5S ribosomal RNA sequence alignment of five bacteria: Bacillus subtilis (a), Bacillus stearothermophilus (b), Lactobacillus viridescens (c), Acholeplasma modicum (d), and Micrococcus luteus (e).

First step First clustering Let us assume that we have five elements (a,b,c,d,e) and the following matrix D1 of pairwise distances between them:

In this example, D1(a,b)=17 is the lowest value of D1, so we cluster elements a and b.

First branch length estimation Let u denote the node to which a and b are now connected. Setting δ(a,u)=δ(b,u)=D1(a,b)/2 ensures that elements a and b are equidistant from u. This corresponds to the expectation of the ultrametricity hypothesis. The branches joining a and b to u then have lengths δ(a,u)=δ(b,u)=17/2=8.5 (see the final dendrogram)

First distance matrix update We then proceed to update the initial proximity matrix D1 into a new proximity matrix D2 (see below), reduced in size by one row and one column because of the clustering of a with b. Bold values in D2 correspond to the new distances, calculated by retaining the minimum distance between each element of the first cluster (a,b) and each of the remaining elements:

D2((a,b),c)=min⁡(D1(a,c),D1(b,c))=min⁡(21,30)=21D2((a,b),d)=min⁡(D1(a,d),D1(b,d))=min⁡(31,34)=31D2((a,b),e)=min⁡(D1(a,e),D1(b,e))=min⁡(23,21)=21 Italicized values in D2 are not affected by the matrix update as they correspond to distances between elements not involved in the first cluster.

Second step Second clustering We now reiterate the three previous actions, starting from the new distance matrix D2 :

Here, D2((a,b),c)=21 and D2((a,b),e)=21 are the lowest values of D2, so we join cluster (a,b) with element c and with element e.

Second branch length estimation Let v denote the node to which (a,b), c and e are now connected. Because of the ultrametricity constraint, the branches joining a or b to v, and c to v, and also e to v are equal and have the following total length:

δ(a,v)=δ(b,v)=δ(c,v)=δ(e,v)=21/2=10.5 We deduce the missing branch length:

δ(u,v)=δ(c,v)−δ(a,u)=δ(c,v)−δ(b,u)=10.5−8.5=2 (see the final dendrogram) Second distance matrix update We then proceed to update the D2 matrix into a new distance matrix D3 (see below), reduced in size by two rows and two columns because of the clustering of (a,b) with c and with e :

D3(((a,b),c,e),d)=min⁡(D2((a,b),d),D2(c,d),D2(e,d))=min⁡(31,28,43)=28

Final step The final D3 matrix is:

So we join clusters ((a,b),c,e) and d. Let r denote the (root) node to which ((a,b),c,e) and d are now connected. The branches joining ((a,b),c,e) and d to r then have lengths: δ(((a,b),c,e),r)=δ(d,r)=28/2=14 We deduce the remaining branch length: δ(v,r)=δ(a,r)−δ(a,v)=δ(b,r)−δ(b,v)=δ(c,r)−δ(c,v)=δ(e,r)−δ(e,v)=14−10.5=3.5

The single-linkage dendrogram

… excerpt ends here. Continue reading the full article.

Illustrations

Single-linkage clustering illustration
Single-linkage clustering illustration
Single-linkage clustering illustration

Worked examples

Example 1 — a first encounter with Single-linkage clustering

Start with the simplest possible case. Write down what Single-linkage clustering claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Single-linkage clustering before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Single-linkage clustering ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Single-linkage clustering

In research
Single-linkage clustering appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Single-linkage clustering in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Single-linkage clustering is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cluster analysis algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Single-linkage clustering outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Single-linkage clustering” →

How to study Single-linkage clustering in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Single-linkage clustering means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Single-linkage clustering out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Single-linkage clustering in simple terms?

In statistics, single-linkage clustering is one of several methods of hierarchical clustering. It is based on grouping clusters in bottom-up fashion (agglomerative clustering), at each step combining two clusters that contain the closest pair of elements not yet belonging to the same cluster as eac…

Why does Single-linkage clustering matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Single-linkage clustering?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Single-linkage clustering.

Tags

  • Cluster analysis algorithms

Keep exploring