## create three Gaussian clouds
cl1 <- cbind(rnorm(70, 0.2, 0.05), rnorm(70, 0.8, 0.06))
cl2 <- cbind(rnorm(50, 0.7, 0.08), rnorm(50, 0.3, 0.05))
cl3 <- cbind(rnorm(60, 0.8, 0.04), rnorm(60, 0.8, 0.05))
x <- rbind(cl1, cl2, cl3)
## create similarity matrix
sim <- negDistMat(x, r=2)
## run affinity propagation such that 3 clusters are obtained
apres <- apclusterK(sim, 3)
## show details of clustering results
show(apres)
## plot clustering result
plot(apres, x)
Run the code above in your browser using DataLab