DEGraph (version 1.24.0)

laplacianFromA: Calculates the Laplacian associated to an adjacency matrix

Description

Calculates the Laplacian associated to an adjacency matrix.

Usage

laplacianFromA(A, k=1, ltype=c("meanInfluence", "normalized", "unnormalized", "totalInfluence"))

Arguments

A
The adjacency matrix of the graph.
k
...
ltype
A character value specifying the type of Laplacian to be calculated. Defaults to meanInfluence.

Value

A list containing the following components:
U
Eigenvectors of the graph Laplacian.
l
Eigenvalues of the graph Laplacian
kIdx
Multiplicity of '0' as eigenvalue.

Examples

Run this code
library("KEGGgraph")
library("rrcov")

## Create a random graph
graph <- randomWAMGraph(nnodes=5, nedges=7, verbose=TRUE)
plot(graph)

## Retrieve its adjacency matrix
A <- graph@adjMat

## write it to KGML file
grPathname <- "randomWAMGraph.xml"
writeAdjacencyMatrix2KGML(A, pathname=grPathname, verbose=TRUE, overwrite=TRUE)

## read it from file
gr <- parseKGML2Graph(grPathname)

## Two examples of Laplacians from the same graph
lapMI <- laplacianFromA(A, ltype="meanInfluence")
print(lapMI)

lapN <- laplacianFromA(A, ltype="normalized")
print(lapN)

U <- lapN$U
p <- nrow(A)
sigma <- diag(p)/sqrt(p)

X <- twoSampleFromGraph(100, 120, shiftM2=1, sigma, U=U, k=3)

## T2
t <- T2.test(X$X1,X$X2)
str(t)

tu <- graph.T2.test(X$X1, X$X2, lfA=lapMI, k=3)
str(tu)

Run the code above in your browser using DataLab