laplacian_mat {gasper}R Documentation

Compute the Graph Laplacian Matrix

Description

laplacian_mat computes various forms of the graph Laplacian matrix for a given adjacency matrix W.

Usage

laplacian_mat(W, type = "unnormalized")

Arguments

W

Adjacency matrix (dense or sparseMatrix).

type

Character string, type of Laplacian matrix to compute. Can be "unnormalized" (default), "normalized", or "randomwalk".

Details

The function supports three types of Laplacian matrices:

Where:

The function supports both standard and sparse matrix representations of the adjacency matrix.

Value

L The graph Laplacian matrix.

References

Chung, F. R. (1997). Spectral graph theory (Vol. 92). American Mathematical Soc.

Examples

# Define the 3x3 adjacency matrix
W <- matrix(c(0, 1, 0,
              1, 0, 1,
              0, 1, 0), ncol=3)

# Non-sparse cases
laplacian_mat(W, "unnormalized")
laplacian_mat(W, "normalized")
laplacian_mat(W, "randomwalk")

# Convert W to a sparse matrix
W_sparse <- as(W, "sparseMatrix")

# Sparse cases
laplacian_mat(W_sparse, "unnormalized")
laplacian_mat(W_sparse, "normalized")
laplacian_mat(W_sparse, "randomwalk")

[Package gasper version 1.1.6 Index]