How to generate the following Graph in MATLAB ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
charu shree
le 21 Avr 2023
Commenté : charu shree
le 21 Avr 2023
Hello all, I am trying to generate the following graph shown in image and compute the shortest distance between each nodes but not getting correctly. Specifically I am able to generate the graph with the code shown below but not able to compute shortest distance between each nodes.
sr = [1,2,2,2,3,3,3,4,5];
ta = [2,3,6,8,6,4,7,6,6];
G = graph(sr,ta);
plot(G)
Any help in this regard will be highly appreciated.
Réponse acceptée
Dyuman Joshi
le 21 Avr 2023
sr = [1,2,2,2,3,3,3,4,5];
ta = [2,3,6,8,6,4,7,6,6];
G = graph(sr,ta);
%The (i,j) elemenet is the shortest distance between node i and node j
d = distances(G)
plot(G)
2 commentaires
Plus de réponses (0)
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!