graph.kmeans {statGraph}R Documentation

K-means for Graphs

Description

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

Usage

graph.kmeans(Graphs, k, nstart = 2, dist = "JS", ...)

Arguments

Graphs

a list of undirected graphs. If each graph has the attribute eigenvalues containing its eigenvalues , such values will be used to compute their spectral density.

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.

dist

string indicating if you want to use the 'JS' (default), 'L1' or 'L2' distances. 'JS' means Jensen-Shannon divergence.

...

Other relevant parameters for graph.spectral.density.

Value

A list with class 'statGraph' containing the following components:

method:

a string indicating the used method.

info:

a string showing details about the method.

data.name:

a string with the data's name(s).

cluster:

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

set.seed(1)
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


[Package statGraph version 1.0.3 Index]