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

digraphdistanceeuclideanMATLABpoints

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)

Best Answer

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.)
Related Question