Compute Laplacian matrix for neighbor_graph object
Source:R/neighbor_graph.R
laplacian.neighbor_graph.RdCompute the Laplacian matrix of a neighbor_graph object.
Usage
# S3 method for class 'neighbor_graph'
laplacian(x, normalized = FALSE, ...)Details
The unnormalized Laplacian is computed as L = D - A where D is the degree matrix and A is the adjacency matrix. The normalized Laplacian is computed as L_sym = I - D^(-1/2) A D^(-1/2).
Examples
adj_matrix <- Matrix::Matrix(c(0, 1, 1, 0, 1, 0, 1, 0, 0),
nrow = 3, byrow = TRUE, sparse = TRUE)
ng <- neighbor_graph(adj_matrix)
L <- laplacian(ng)
L_norm <- laplacian(ng, normalized = TRUE)