The following code implements some of the concepts of the paper:

Michael Hahsler and Kurt Hornik. Dissimilarity plots: A visual exploration tool for partitional clustering. Journal of Computational and Graphical Statistics, 10(2):335–354, June 2011.

library(seriation)
set.seed(1234)

We use the Ruspini data set with 4 clusters

data("ruspini", package="cluster")
d <- dist(ruspini)

Original data (dissimilarity matrix shading)

Look for dark blocks (small distances) along the diagonal.

pimage(d)

Reorder using cluster labels (i.e., coarse seriation)

Ruspini has 4 clusters but we use incorrectly 10!

l <- kmeans(ruspini, 10)$cluster
dissplot(d, method = NA, labels = l)

With reordering

dissplot(d, labels = l)

Note that the plot reassembles the four clusters.

Using too few clusters

l <- kmeans(ruspini, 3)$cluster

dissplot(d, labels = l)

dissplot(d, labels = l, zlim= c(0,40))

Note that one cluster consists of 2 clusters (two dark blocks)!

Use different seriation methods (see ? seriate)

Linear Seriation Criterion

dissplot(d, labels= l, method = list(intra="ARSA", inter="ARSA"))

Hamiltonian path

dissplot(d, labels= l, method = list(intra="TSP", inter="TSP"))

Hierarchical clustering

dissplot(d, labels= l, method = list(intra="HC_average", inter="HC_average"))

dissplot(d, labels= l, method = list(intra="OLO", inter="OLO"))

Scaling and others

dissplot(d, labels= l, method = list(intra="MDS", inter="MDS"))

dissplot(d, labels= l, method = list(intra="Spectral", inter="Spectral"))

dissplot(d, labels= l, method = list(intra="QAP_2SUM", inter="QAP_2SUM"))

dissplot(d, labels= l, method = list(intra="R2E", inter="R2E"))

dissplot(d, labels= l, method = list(intra="Spin", inter="Spin"))