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)]=mind[(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.



