This is where navigation should be.


GSP_RESISTANCE_DISTANCES - : Compute the resitance distances of a graph

Usage

rd = gsp_resistance_distances(G);
rd = gsp_resistance_distances(L);

Input parameters

G Graph structure or Laplacian matrix (L)
param optional parameters

Output parameters

rd distance matrix

Description

This function compute the resistance distances between all vertices in a graph. The distance between two nodes is defined as the inverse of the weight matrix. For example the distance matrix:

dist = [0, 3, 1;...
        3, 0, 2;...
        1, 2, 0];

corresponds to the weight matrix:

W = [0, 1/3, 1/1;...
     1/3, 0, 1/2;...
     1/1, 1/2, 0];

The function will compute the resistance distance following Kirshoff's law. In the our example it is:

rd2 = [0, 3/2, 5/6;...
       3/2, 0, 4/3;...
       5/6, 4/3, 0]

In matlab, you can reproduce this example using:

% The weight
dist = [0, 3, 1;...
        3, 0, 2;...
        1, 2, 0];
% The weight is the inverse of the distance...
W = dist.^(-1);
% Fix the diagonal
W([1,5,9])=0;
G = gsp_graph(W);
rd = gsp_resistance_distance(G)
% Resitance computed by hand
rd2 = [0, 3/2, 5/6;...
       3/2, 0, 4/3;...
       5/6, 4/3, 0]

This code produces the following output:

rd =

         0    1.5000    0.8333
    1.5000         0    1.3333
    0.8333    1.3333         0


rd2 =

         0    1.5000    0.8333
    1.5000         0    1.3333
    0.8333    1.3333         0

param is an optional structure that contains the following field

  • param.verbose: display parameter - 0 no log - 1 display warnings (default 1)

References:

D. J. Klein and M. Randić. Resistance distance. Journal of Mathematical Chemistry, 12(1):81--95, 1993.