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.
0 件のコメント
採用された回答
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 Center および File Exchange で Directed Graphs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!