graph.kmeans: K-means for Graphs

Description Usage Arguments Value References Examples

View source: R/statGraph.R

Description

graph.kmeans clusters graphs following a k-means algorithm based on the Jensen-Shannon divergence between the spectral densities of the graphs.

Usage

1
graph.kmeans(x, k, nstart = 2)

Arguments

x

a list containing the graphs or their adjacency matrices to be clustered.

k

an integer specifying the number of clusters.

nstart

the number of trials of k-means clusterizations. The algorithm returns the clusterization with the best silhouette.

Value

a vector of the same length of x containing the clusterization labels.

References

MacQueen, James. "Some methods for classification and analysis of multivariate observations." Proceedings of the fifth Berkeley symposium on mathematical statistics and probability. Vol. 1. No. 14. 1967.

Lloyd, Stuart. "Least squares quantization in PCM." IEEE transactions on information theory 28.2 (1982): 129-137.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(42)
g <- list()
for(i in 1:5){
  g[[i]] <- igraph::sample_gnp(30, p=0.2)
}
for(i in 6:10){
  g[[i]] <- igraph::sample_gnp(30, p=0.5)
}
res <- graph.kmeans(g, k=2, nstart=2)
res

statGraph documentation built on May 19, 2021, 9:11 a.m.