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 Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

질문:

2019년 4월 25일

편집:

2019년 5월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by