netneurotools.metrics._graph_laplacian

netneurotools.metrics._graph_laplacian(W)[source]

Compute the graph Laplacian of a weighted adjacency matrix.

Graph Laplacian is defined as the degree matrix minus the adjacency matrix \(L = D - W\), where \(D\) is the degree matrix and is defined as \(D_{ii} = \sum_j W_{ij}\).

The graph Laplacian matrix \(L\) has the form of

\[\begin{split}L = \begin{bmatrix} d_1 & -w_{12} & \cdots & -w_{1n} \\ -w_{21} & d_2 & \cdots & -w_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ -w_{n1} & -w_{n2} & \cdots & d_n \end{bmatrix}\end{split}\]
Parameters:

W ((N, N) array_like) – Weighted, directed/undirected connection weight/length array

Returns:

L – Graph Laplacian of W

Return type:

(N, N) numpy.ndarray