필터 지우기
필터 지우기

How to find distance between two nodes? including the nodes.

조회 수: 1 (최근 30일)
Aswin Sandirakumaran
Aswin Sandirakumaran 2018년 7월 1일
댓글: navanit dubey 2020년 11월 17일
For example: In this graph i would like to find distance *between s1 and s3.
SO MY OUTPUT SHOULD LOOK LIKE : Distance = 7 (includes both edges and nodes)
  댓글 수: 2
Paolo
Paolo 2018년 7월 1일
Can you share the code with which the image was generated?
Aswin Sandirakumaran
Aswin Sandirakumaran 2018년 7월 1일
I just used addnode and addedge.

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

답변 (2개)

Anton Semechko
Anton Semechko 2018년 7월 1일
Download graph processing toolbox from FEX. Use Dijkstra's algorithm to get shortest path between pairs of nodes. Path length = distance between nodes = sum of edge weights along the path.

Walter Roberson
Walter Roberson 2018년 7월 2일
Call https://www.mathworks.com/help/matlab/ref/graph.shortestpath.html shortestpath() on the graph object to get the distances.

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by