How to find distance between two nodes? including the nodes.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
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.
0 个评论
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.
1 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dijkstra algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!