o node1
node 2 o o node 3
if the above figure three nodes are present. how to calculate distance between these nodes.

답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 7월 5일

1 개 추천

Can you figure out the coordinates of those three dots? If so that the distance is defined as d=sqrt((x1-x2)^2+(y1-y2)^2)). Here (x1, y1) and (x2, y2) are the coordinates of the dots.

댓글 수: 1

ankanna
ankanna 2021년 7월 5일
n = 3;
source = 1;
destination = 3;
Link=(n*(n-1))/2;
c=2^Link;
NN = toeplitz(Link+1:-1:2)
mask = logical(fliplr(diag(ones(1,Link-1),-1)));
NN(mask) = 1;
for c = 0:2^Link-1
l = bitget(c, NN)
end
Edges = Link
for c = 0:2^Link-1
l = bitget(c, NN)
G = graph(l~=0)
G.Edges
path = shortestpath(G,source,destination)
end
for example distance between any two nodes is 1m. i want distance between nodes and shortest distance also.please help me to generate this.

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

카테고리

도움말 센터File Exchange에서 Live Scripts and Functions에 대해 자세히 알아보기

제품

릴리스

R2016a

질문:

2021년 7월 5일

댓글:

2021년 7월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by