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:
- lapl
numpy.ndarray
A square matrix that is a Laplacian, or a stack of Laplacian matrices.
- degree
np.ndarray
orNone
, 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”, “randomwalk
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_zeros
bool
, optional Whether to change 0 elements in the degree matrix to 1 to avoid multiplying by 0. Default is to do so.
- lapl
- 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