How do I get Matlab to display a graph type data structure with decreasing weights
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Musashi Koyama
le 9 Sep 2020
Commenté : Musashi Koyama
le 10 Sep 2020
Hi all,I have the following graph from the following matrix L
L=[0 11 13 4; 11 0 9 8; 13 9 0 10; 4 8 10 0]
L=[0 11 13 4; 11 0 9 8; 13 9 0 10; 4 8 10 0]
G=graph(L)
disp(G.Edges)
Which has the following output
EndNodes Weight
________ ______
1 2 11
1 3 13
1 4 4
2 3 9
2 4 8
3 4 10
I want to know how I can get G.Edges to display the same information but with decreasing weights as opposed to increasing first end node. I know I can get the vector of decreasing weights by sort(G.Edges.Weight, 'descend') on its own, but I still want the End nodes to be attached to the corresponding weights. Any help is greatly appreciated.
0 commentaires
Réponse acceptée
Christine Tobler
le 10 Sep 2020
The Edges table attached to a digraph is always standardized so that its sorted by the EndNodes column. However, you can get a copy of the Edges table which is sorted by the weights, this will just not be attached to the G object anymore:
>> sortrows(G.Edges, 'Weight', 'descend')
ans =
6×2 table
EndNodes Weight
________ ______
1 3 13
1 2 11
3 4 10
2 3 9
2 4 8
1 4 4
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Directed Graphs 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!