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.ndarrayorNone, 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”,
randomwalkinflow”, “rwi”, “randomwalkoutflow”, “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.ndarrayThe normalised laplacian
- Raises:
NotImplementedErrorIf lapl.ndim - degree.ndim > 1 If “norm” is not supported.
ValueErrorIf d in not a diagonal matrix or an array If d and mtx have different shapes.
Notes