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

1 visualización (últimos 30 días)
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)

Respuesta aceptada

Steven Lord
Steven Lord el 30 de Sept. de 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.)

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by