Examples for 'igraph::scg_semi_proj'


Semi-Projectors

Aliases: scg_semi_proj scgSemiProjectors

Keywords:

### ** Examples


library(Matrix)
# compute the semi-projectors and projector for the partition
# provided by a community detection method
g <- sample_pa(20, m = 1.5, directed = FALSE)
eb <- cluster_edge_betweenness(g)
memb <- membership(eb)
lr <- scg_semi_proj(memb)
#In the symmetric case L = R
tcrossprod(lr$R)  # same as lr$R %*% t(lr$R)
5 x 5 sparse Matrix of class "dsCMatrix"
              
[1,] 1 . . . .
[2,] . 1 . . .
[3,] . . 1 . .
[4,] . . . 1 .
[5,] . . . . 1
P <- crossprod(lr$R)  # same as t(lr$R) %*% lr$R
#P is an orthogonal projector
isSymmetric(P)
[1] TRUE
sum( (P %*% P-P)^2 )
[1] 2.904302e-31
## use L and R to coarse-grain the graph Laplacian
lr <- scg_semi_proj(memb, mtype="laplacian")
L <- laplacian_matrix(g)
Lt <- lr$L %*% L %*% t(lr$R)
## or better lr$L %*% tcrossprod(L,lr$R)
rowSums(Lt)
[1] 5.551115e-17 0.000000e+00 1.110223e-16 5.551115e-17 0.000000e+00

[Package igraph version 1.3.1 Index]