Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can I get my minimum spanning tree to select only one edge?

조회 수: 1 (최근 30일)
AAS
AAS 2020년 4월 23일
마감: MATLAB Answer Bot 2021년 8월 20일
for each node, I have many edges how can I make it choose the shortest edge per node?

답변 (1개)

BobH
BobH 2020년 4월 23일
If this calculation is a smaller part of a larger problem like determining the shortest path between a pair of distant nodes, there is a function for the larger problem http://www.mathworks.com/help/bioinfo/ref/graphshortestpath.html
I am assuming "shorted edge" means the same as "lowest weight".
For a single node connected to multiple other nodes, for example node 1 connects to nodes 2-6 using weights of 4 6 8 10 12
s = [1 1 1 1 1];
t = [2 3 4 5 6];
w = [8 12 6 4 10];
R = sparse(s, t, w);
minw = min(R(1,[2:6])); % value of lowest weight for node 1, ignoring node 1
minwIx = find(R == minw); % index into R of the lowest weight. There may be more than one.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by