MATLAB: How to get Matlab to display a graph type data structure with decreasing weights

graphgraph theoryMATLABsort

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.

Best Answer

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