How do I get Matlab to display a graph type data structure with decreasing weights
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Musashi Koyama
el 9 de Sept. de 2020
Comentada: Musashi Koyama
el 10 de Sept. de 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 comentarios
Respuesta aceptada
Christine Tobler
el 10 de Sept. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Directed Graphs en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!