필터 지우기
필터 지우기

Computing average path length

조회 수: 7 (최근 30일)
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 20일
편집: Walter Roberson 2018년 9월 20일
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
Walter Roberson
Walter Roberson 2018년 9월 20일
I would tend to think that average path length would include alternative paths, not just the shortest path.

댓글을 달려면 로그인하십시오.

채택된 답변

Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 20일
편집: Walter Roberson 2018년 9월 20일
size = nodesize;
x = [];
for c = 1:size
for dest=1:size
if(c~=dest)
[P,d] = shortestpath(G,c,dest);
x = [x, d];
end
end
answer = mean(x)

추가 답변 (1개)

KSSV
KSSV 2018년 9월 20일
편집: KSSV 2018년 9월 20일
nodesize = numnodes(G);
thesize = nodesize;
x = zeros(thesize,1);
for c = 1:size
[P,d] = shortestpath(G,c,nodesize);
x(C) = d ;
end
answer = mean(x)
  댓글 수: 7
KSSV
KSSV 2018년 9월 20일
YOu mean mean(x)?
Isaac Osei Agyemang
Isaac Osei Agyemang 2018년 9월 20일
편집: Walter Roberson 2018년 9월 20일
I've been able to work things out, thanks for your help.
size = nodesize;
x = [];
for c = 1:size
for dest=1:size
if(c~=dest)
[P,d] = shortestpath(G,c,dest);
x = [x, d];
end
end
answer = mean(x)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by