Clear Filters
Clear Filters

shortestpath for mesh nodes

3 views (last 30 days)
skysky2000
skysky2000 on 22 Jun 2016
Commented: skysky2000 on 23 Jun 2016
hello guys, how can i get shortestpath for mesh nodes, i have 50 nodes and i want to calculate the shortest path between all those nodes help please.

Answers (3)

Walter Roberson
Walter Roberson on 22 Jun 2016
If you have R2015b or later, convert your mesh to a weighted graph and loop over all of the nodes in your graph using http://www.mathworks.com/help/matlab/ref/graph.shortestpathtree.html each time.
This will give you 50 trees, each with 49 paths, and each of the 49 paths could be as long as 49 elements (but probably would not be more than 14 elements if you have a square mesh.) A quick estimate is that it could be over 30000 pieces of information. I wonder if you actually need that information?
Ah yes, checking your other questions I see that you are doing WSN, in which case you would generally not hold on to that information. Depending on which routing protocol you are using, what each node needs to know is not the exact path to send to each other node, but instead just which of its neighbours it needs to send the packet to in order for the packet to reach the destination. WSN is not infrequently used in a situation where links go into and out of use, or might even move, so a pre-computed static routing table is not typically used.

skysky2000
skysky2000 on 22 Jun 2016
Thanks Walter, I tried your solution but unfortunately my version 2015a doesn't support graph function. any other solution please?

skysky2000
skysky2000 on 23 Jun 2016
thanks walter, i had this link, but the problem with this i have to connect my nodes manual .
  3 Comments
Walter Roberson
Walter Roberson on 23 Jun 2016
To connect the nodes by program, you need to define your geometry and your distance function. What information do you have available? x and y coordinates and you want to use Euclidean distance? Is there a cutoff beyond which two nodes are to be considered to not be directly connected?
skysky2000
skysky2000 on 23 Jun 2016
thank you very much... I am gonna work with it

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!