spectralClustering {anocva}R Documentation

Spectral clustering

Description

Unnormalized spectral clustering function. Uses Partitioning Around Medoids clustering instead of K-means.

Usage

spectralClustering(W, k)

Arguments

W

NxN similarity matrix

k

Number of clusters

Value

Cluster labels

References

Von Luxburg, U (2007) A tutorial on spectral clustering. Statistics and computing 17:395–416.

Ng A, Jordan M, Weiss Y (2002) On spectral clustering: analysis and an algorithm. In: Advances in Neural Information Processing Systems. Dietterich T, Becker S, Ghahramani Z (Eds.), vol. 14. MIT Press, (pp. 849–856).

Examples

# Install igraph if necessary
# install.packages('igraph')
# install.packages('cluster')

library(anocva)

set.seed(2000)

if (requireNamespace("igraph", quietly = TRUE)) {

  # Create a tree graph
  treeGraph = igraph::make_tree(80, children = 4, mode = "undirected")

  # Visualize the tree graph
  plot(treeGraph, vertex.size = 10, vertex.label = NA)

  # Get the adjacency matrix of the tree graph
  adj = as.matrix(igraph::get.adjacency(treeGraph))

  # Cluster the tree graph in to four clusters
  cluster = spectralClustering(adj, 4)

  # See the result clustering
  plot(treeGraph, vertex.size=10, vertex.color = cluster, vertex.label = NA)
}


[Package anocva version 0.1.1 Index]