How do I get Matlab to display a graph type data structure with decreasing weights

1 次查看(过去 30 天)
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.

采纳的回答

Christine Tobler
Christine Tobler 2020-9-10
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Directed Graphs 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by