Computing average path length
6 views (last 30 days)
Show older comments
Isaac Osei Agyemang
on 20 Sep 2018
Edited: Walter Roberson
on 20 Sep 2018
I'm using karate.gml dataset, from two visualization software gephi and SocNetV both gives me an average path length of 2.408. I want to compute the average path length in matlab using the same dataset, but mine gives me 1.76. My matlab procedure is below:
I add the distance {d} returned by the shortestpath function {[P,d] = shortestpath(G,c,nodesize);} to an array I've declared and afterwards find the mean. Not sure what I'm doing wrong.
size = nodesize;
x = [];
for c = 1:size
[P,d] = shortestpath(G,c,nodesize);
x = [x, d];
end
answer = mean(x)
1 Comment
Walter Roberson
on 20 Sep 2018
I would tend to think that average path length would include alternative paths, not just the shortest path.
Accepted Answer
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!