nigsp.operations.laplacian.compute_laplacian

nigsp.operations.laplacian.compute_laplacian(mtx, negval='absolute', selfloops=False)[source]

Compute Laplacian (L) matrix from a square matrix.

mtx is supposed to be a connectivity matrix - its diagonal will be removed. L is obtained by subtracting the adjacency matrix from the degree matrix.

Parameters:
mtxnumpy.ndarray

A square matrix

negval“absolute”, “remove”, or “rescale”

The intended behaviour to deal with negative values in matrix: - “absolute” will take absolute values of the matrix - “remove” will set all negative elements to 0 - “rescale” will rescale the matrix between 0 and 1. Default is “absolute”.

selfloops“degree”, bool, or numpy.ndarray

Allow or remove self-loops in input matrix. A numpy array can be used to specify particular loops directly in the adjacency matrix. The degree matrix of the Adjacency matrix can also be used instead. In the last two cases, the degree matrix will be updated accordingly. Default is to remove self loops (False).

Returns:
numpy.ndarray

The laplacian of mtx

numpy.ndarray

The degree matrix of mtx as a (mtx.ndim-1)D array, updated with selfloops in case.

Raises:
NotImplementedError

If negval is not “absolute”, “remove”, or “rescale” If selfloop

Notes

https://en.wikipedia.org/wiki/Laplacian_matrix