but, trying
G=graph(EdgeTable)
plotgraph=plot(G,'EdgeLabel',EdgeName)
The Result is
The Nodes are correctly conected, but de EdgeNames are wrong.
am i doing something wrong, or the program just is plotting de edge names wrong?

 採用された回答

Adam Danz
Adam Danz 2019 年 5 月 5 日
編集済み: Adam Danz 2019 年 5 月 9 日

1 投票

Correct way to include labels
Following this example, you must include the edge labels when you construct the graph object by including the 'code' column in the EdgeTable table and then using the graph object output to specify the labels during plotting.
code = {'a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i'}'; %your SC-## strings
EdgeTable = table([1 2;3 4;6 7;4 8;9 10; 4 11; 12 13; 13 14; 4 14],code,'VariableNames', {'EndNodes','code'});
G = graph(EdgeTable);
plot(G,'EdgeLabel', G.Edges.code)
Why your method didn't work
If you look at the values stored in your graph object, you'll see that the edges have been rearranged from your input order. When you assigned the edge labels (in the original order) during plotting, they no longer corresponded to the order in the graph object table.
% Incorrect method of edge labeling
EdgeTable = table([1 2;3 4;6 7;4 8;9 10; 4 11; 12 13; 13 14; 4 14],'VariableNames', {'EndNodes'});
G=graph(EdgeTable)
G.Edges
ans =
9×1 table
EndNodes YOUR INPUTS
________ _____________
1 2 1 2
3 4 3 4
4 8 6 7
4 11 4 8
4 14 9 10
6 7 4 11
9 10 12 13
12 13 13 14
13 14 4 14

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by