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?

 Akzeptierte Antwort

Adam Danz
Adam Danz am 5 Mai 2019
Bearbeitet: Adam Danz am 9 Mai 2019

1 Stimme

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

Weitere Antworten (0)

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by