nigsp.operations.laplacian.normalisation

nigsp.operations.laplacian.normalisation(lapl, degree, norm='symmetric', fix_zeros=True)[source]

Normalise a Laplacian (L) matrix using either symmetric or random walk normalisation.

Parameters:
laplnumpy.ndarray

A square matrix that is a Laplacian, or a stack of Laplacian matrices.

degreenp.ndarray or None, optional

An array, a diagonal matrix, or a stack of either. This will be used as the the degree matrix for the normalisation. It’s assumed that degree.ndim == lapl.ndim or degree.ndim == lapl.ndim-1.

norm[“symmetric”, “symm”, “random walk”, “rw”, random walk inflow”, “rwi”, “random walk outflow”, “rwo”], str, optional

The type of normalisation to perform. Default to symmetric. - “symmetric”: D^(-1/2) @ L @ ^(-1/2), a.k.a. symmetric laplacian normalisation - “random walk”, “random walk inflow”: D^(-1) @ L, a.k.a. random walk

It normalises the inflow, i.e. it is row-optimised (each row = 0). Normally used in e.g. consensus networks.

  • “random walk outflow”: L @ D^(-1) It normalises the outflow, i.e. it is column-optimised (each column = 0). Normally used in e.g. physical distribution networks.

fix_zerosbool, optional

Whether to change 0 elements in the degree matrix to 1 to avoid multiplying by 0. Default is to do so.

Returns:
numpy.ndarray

The normalised laplacian

Raises:
NotImplementedError

If lapl.ndim - degree.ndim > 1 If “norm” is not supported.

ValueError

If d in not a diagonal matrix or an array If d and mtx have different shapes.

Notes

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