Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to obtain the resistance distance matrix of a graph?

I tried to compute resistance distance matrix of a graph g by first evaluating the Moore-Penrose inverse of the Laplacian matrix, but the result is not accurate, the entries are slightly different. I tried with the following algorithm.

L=g.laplacian_matrix() from scipy import linalg M=matrix(linalg.pinv(L)) R=matrix(QQ, g.order()) for i in range(g.order()): for j in range(g.order()): if i!=j: R[i,j]=M[i,i]+M[j,j] -M[i,j]-M[j,i]

How to obtain the resistance distance matrix of a graph?

I tried to compute resistance distance matrix of a graph g by first evaluating the Moore-Penrose inverse of the Laplacian matrix, but the result is not accurate, the entries are slightly different. I tried with the following algorithm.

L=g.laplacian_matrix()
from scipy import linalg
M=matrix(linalg.pinv(L))
R=matrix(QQ, g.order())
for i in range(g.order()):
    for j in range(g.order()):
        if i!=j:
            R[i,j]=M[i,i]+M[j,j] -M[i,j]-M[j,i]

-M[i,j]-M[j,i]