| mst.knn | R Documentation |
Performs the MST-kNN clustering algorithm which generates a clustering solution with automatic number-of-clusters determination by recursively intersecting the Minimum Spanning Tree (MST) and the k-Nearest Neighbor (kNN) graphs.
mst.knn(distance.matrix, suggested.k)
distance.matrix |
A numeric matrix or data.frame with equal numbers of rows and columns representing pairwise distances between objects. |
suggested.k |
Optional. A numeric value representing the suggested number of nearest neighbours. |
A list with elements cnumber, cluster,
partition, csize, network.
Mario Inostroza-Ponta, Jorge Parraga-Alava, Pablo Moscato
set.seed(1987)
n <- 100; m <- 15
x <- matrix(runif(n * m, min = -5, max = 10), nrow = n, ncol = m)
d <- base::as.matrix(stats::dist(x, method = "euclidean"))
library("mstknnclust")
results <- mst.knn(d)
library("igraph")
plot(results$network,
vertex.size = 8,
vertex.color = igraph::components(results$network)$membership,
layout = igraph::layout_with_fr(results$network, niter = 10000),
main = paste("MST-kNN | clusters =", results$cnumber))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.