How to implement the following algorithm in MATLAB ?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
charu shree
le 31 Mar 2023
Commenté : charu shree
le 4 Avr 2023
Hello all, I am trying to implement MATLAB code for following statements of one of the algorithm which is as follows:
- We consider that there are multiple cellular towers. These towers are called as nodes, where node i and node j are neighbours of each others.
- We consider one of the towers among all the towers as the Macro tower (MT).
- Let the minimum number of hops from
tower to the MT be denoted as
.
After going through web, I understand that number of hops can be computed using Bellman ford algorithm.
My query is that how to implement the Bellman ford algorithm in this scenario.
Any help in this regard will be highly appreciated.
Réponse acceptée
Walter Roberson
le 1 Avr 2023
sr = [1 1 1 1 2 2 2 2 3 3 4 5 5 5 5 6 6 6 6 6]; % various possible sources
ta = [2 6 7 8 3 7 5 8 4 8 8 4 3 7 8 5 4 7 3 8]; % various possible targets
G = graph(sr,ta);
p = plot(G);
target = 8;
[TR, d] = shortestpathtree(G, 'all', target, 'outputform', 'cell')
3 commentaires
Walter Roberson
le 1 Avr 2023
Each cell in TR shows the exact path from one node to the target. d summarizes the cost of each path.
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!