Learn R Programming

MMOC (version 0.1.1.0)

Lapprox: Compute a rank k approximation of a graph Laplacian

Description

This function calculates the rank-k approximation of a graph Laplacian (or any symmetric matrix). This function performs eigen decomposition on the given matrix L and reconstructs it using only the LAST k eigenvectors and eigenvalues.

Usage

Lapprox(LapList, k, laplacian = c("shift", "Ng", "sym", "rw"), plots = TRUE)

Value

An n\(\times\)n matrix

Arguments

LapList

A list of Laplacian matrices

k

A vector indicating how many eigenvectors to take from each Laplacian, i.e., the number of clusters in each view

laplacian

One of "shift", "Ng", "rw" or "sym". Should be the same type used to calculate your Laplacians

plots

Whether or not to plot the eigenvalues from the rank approximated Laplacians

Examples

Run this code

## Generating data with 2 and 3 distinct clusters
## Note that 'clustStruct' returns a list
n=120; k <- c(2,3)
set.seed(23)
dd <- clustStruct(n=n, p=30, k=k, noiseDat='random')

## Laplacians
L_list <- lapply(dd, kernelLaplacian, kernel="Spectrum",
 laplacian='shift', plots=FALSE, verbose=FALSE)

trueGroups(n,k)

La <- Lapprox(L_list, k=k, plots=FALSE)

kmeans(La$vectors[,1:4], centers=4)

Run the code above in your browser using DataLab