netneurotools.stats.effective_resistance

netneurotools.stats.effective_resistance(W, directed=True)[source]

Calculate effective resistance matrix.

The effective resistance between two nodes in a graph, often used in the context of electrical networks, is a measure that stems from the inverse of the Laplacian matrix of the graph.

Warning

Test before use.

Parameters:
  • W ((N, N) array_like) – Weight matrix.

  • directed (bool, optional) – Whether the graph is directed. This is used to determine whether to turn on the hermitian=True option in numpy.linalg.pinv(). When you are using a symmetric weight matrix (while real-valued implying hermitian), you can set this to False for better performance. Default: True

Returns:

R_eff – Effective resistance matrix

Return type:

(N, N) numpy.ndarray

Notes

The effective resistance between two nodes \(i\) and \(j\) is defined as

\[R_{ij} = (e_i - e_j)^T Q^* (e_i - e_j)\]

where \(Q^*\) is the Moore-Penrose pseudoinverse of the Laplacian matrix \(L\) of the graph, and \(e_i\) is the \(i\)-th standard basis vector.

References