how to find Shortest path from source to destination in wireless sensor networks using matlab?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
sindhu
il 16 Set 2014
Commentato: Walter Roberson
il 10 Set 2022
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 Commenti
Walter Roberson
il 10 Set 2022
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)
Risposta accettata
Walter Roberson
il 24 Mar 2018
First construct a connection matrix with distances between nodes. Then use graph() or digraph() to build a graph object. You can then use shortestpath() to find the route between nodes.
Note that if you use euclidian distances and your graph is fully connected, then the shortest path is always direct from source to destination. Shortest path algorithms are for the case of noneucludian costs or the case where the graph is not fully connected.
An example of a noneucludian cost would be if there is a partly transparent obstacle such as a tree in some path that causes the energy requirements for that path to rise faster than the square of the distance. A full blockage such as concrete would prevent a path from being used. Reflections off of metal can have odd effects and can even provide better than euclidian energy costs if the reflection acts to focus a spreading signal.
Pure Euclidean costs also assume that there is an indefinitely large energy budget to transmit with, or that there is an indefinitely sensitive receiver with no noise. If these are not true then the graph will not be fully connected and a shortest path algorithm helps.
0 Commenti
Più risposte (2)
Junaid Qadir
il 24 Mar 2018
You can use the Euclidean distance formula to find the nearest neighbor node.
1 Commento
Walter Roberson
il 24 Mar 2018
This is not sufficient to find shortest path on a network that forwards packets to nodes.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!