Clear Filters
Clear Filters

How to calculate euclidean distance to each point/node in directed graph?

6 views (last 30 days)
I want to find euclidean distance of each point in directed graph that i already made. Can someone show me the efficient and an easy to understand way to do it? thank you..
this is my graph :
s = [ 1 2 2 3 4 4 5 6 6 7 8 8 9 10]
t = [ 2 3 4 11 5 6 11 7 8 11 9 10 11 11]
X = digraph(s, t)

Accepted Answer

Steven Lord
Steven Lord on 30 Sep 2016
I think what you're looking for is the distances method. If instead you've plotted the digraph using its plot method, you can obtain the coordinates of the vertices from the object plot returns and use those to set weights (lengths) on the edges on the digraph object then call distances.
I'm assuming that you want the distances between the nodes along the edges (as the car drives) rather the straight line distance between two nodes that are not connected (as the crow flies.)

More Answers (0)

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!