Skip to main content

matrix - Efficient Implementation of Resistance Distance for graphs?


Is there an implementation of the resistance distance matrix (or just resistance matrix) for graphs available in Mathematica?



Answer



Based on the definition from the Wikipedia article, this should give you the resistance distance matrix of the graph g:



With[{Γ = PseudoInverse[KirchhoffMatrix[g]]},
Outer[Plus, Diagonal[Γ], Diagonal[Γ]] - Γ - Transpose[Γ]
]

Comments