Description Usage Arguments Value Examples
View source: R/mstclustering.R
Run clustering using MST. Before calling this function, remove some edges from the MST, for example the k-1 heaviest.
1 | mst.cluster(child.list.mst, m, k)
|
child.list.mst |
The return value of the gen.child.list.mst() function with k-1 edges removed. |
m |
Number of nodes. |
k |
The number of clusters. |
A vector whose k-th element is the cluster the k-th point belongs to.
1 2 3 4 5 6 7 8 9 10 | iris.clean <- iris[,-5]
iris.dist <- as.matrix(dist(iris.clean))
iris.edge.list <- gen.edge.list(iris.dist)
m <- nrow(iris.dist)
iris.mst.edge.list <- kruskal(iris.edge.list, m)
k <- 3
n.edges <- nrow(iris.mst.edge.list)
iris.mst.edge.list <- iris.mst.edge.list[1:(n.edges - (k - 1)),]
iris.child.list.mst <- gen.child.list.mst(iris.mst.edge.list, m)
iris.clust.mst <- mst.cluster(iris.child.list.mst, m, k)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.