필터 지우기
필터 지우기

Find the shortest distance in cluster group.

조회 수: 1 (최근 30일)
Asyran Abdullah
Asyran Abdullah 2018년 10월 9일
댓글: Walter Roberson 2018년 10월 10일
Hi, i have a group of cluster, and the information of source and destination node. How can i find the shortest distance to the destination node and display the result?
This is my result:
start id = 18
finish id = 2
Group: 1
Members:
2 7 18
start id = 24
finish id = 8
Group: 2
Members:
1 8 10 12 15 16 24
start id = 14
finish id = 9
Group: 3
Members:
3 9 11 14
Hope someone can help and advice me.
Thanks
  댓글 수: 4
Walter Roberson
Walter Roberson 2018년 10월 9일
Yes, dijkstra needs weights as well.
In some cases weights are all the same and can all be designated as 1, but probably not in your case: your weights are probably more like euclidean distances.
Asyran Abdullah
Asyran Abdullah 2018년 10월 9일
OK sir, i have explain my question in following comment. Hope u will give some suggestion.
Thanks

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

답변 (1개)

KSSV
KSSV 2018년 10월 9일
Read about pdist, pdist2 and knnsearch.
  댓글 수: 2
Asyran Abdullah
Asyran Abdullah 2018년 10월 9일
편집: Asyran Abdullah 2018년 10월 9일
Sir, The following is my code result.
disp(['start id = ' num2str(start_id)]);
disp(['finish id = ' num2str(finish_id)]);
disp(['distance = ' num2str(distance)]);
disp(['path = [' num2str(path) ']']);
disp(['Group: ',num2str(i)]);
disp('Members: ');
disp(save); save= 0;
Result:
start id = 90
finish id = 81
distance = 15.5563
path = [43 44 49 75 81 90]
Group: 13
Members:
43 44 49 75 81 90
start id = 94
finish id = 86
distance = 16.9706
path = [86 91 94]
Group: 14
Members:
86 91 94
start id = 100
finish id = 95
distance = 18.3848
path = [77 82 88 95 100]
Group: 15
Members:
77 82 88 95 100
I want to implement the shortestpath in each group. Then i implement this:
x = path;
w = rand;
g = graph(start_id,finish_id,w);
shortPath = shortestpath(g, start_id, finish_id);
However, it appear some error:
Error using graph/shortestpath (line 58)
Target must specify one node.
Error in map2 (line 356)
shortestpath(g, start_id, finish_id);
It that any way to solve it?
Thanks sir.
Walter Roberson
Walter Roberson 2018년 10월 10일
Distance between what and what? What does the path mean? If those are start and end node numbers then why do they appear beside each other in the first and third path, but not beside each other in the second path ?

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

카테고리

Help CenterFile Exchange에서 Dijkstra algorithm에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by