how to find Shortest path from source to destination in wireless sensor networks using matlab?
Show older comments
Among all the paths available from source to destination, I need to find the shortest path between source and destination....For example,in an area of 500*500 i have deployed 10 nodes randomly.considering 1st node as source and 10th node as destination now,I need matlab code for finding the optimized route from node1 to node10..can anyone please help??
3 Comments
Lakshmipriya M
on 8 Mar 2017
same doubt for above question kindly pls answer for this anyone
Tagore Pattela
on 9 Sep 2022
did u have code for this answer
I described the process https://www.mathworks.com/matlabcentral/answers/155009-how-to-find-shortest-path-from-source-to-destination-in-wireless-sensor-networks-using-matlab#answer_311668
x = randi(500, 1, 10);
y = randi(500, 1, 10);
xy = [x; y].'
D = squareform(pdist(xy))
G = graph(D)
p = shortestpath(G, 1, 10)
Shortest path is just to go directly from the beginning to the end.
This will always be the case unless:
- you have range limitations; or
- you have blocked paths; or
- you have non-euclidean paths: due to reflections and different materials, direct paths might lead to traversing paths with slower signal transmission rates, and indirect paths might hypothetically travel routes that have higher signal transmission rates
%range limit
D(D > 250) = 0;
G1 = graph(D)
p = shortestpath(G1, 1, 10)
Accepted Answer
More Answers (2)
Matt J
on 16 Sep 2014
0 votes
Junaid Qadir
on 24 Mar 2018
0 votes
You can use the Euclidean distance formula to find the nearest neighbor node.
1 Comment
Walter Roberson
on 24 Mar 2018
This is not sufficient to find shortest path on a network that forwards packets to nodes.
Categories
Find more on Dijkstra algorithm 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!