Error ploting a graph with EdgeTable

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?

 Respuesta aceptada

Adam Danz
Adam Danz el 5 de Mayo de 2019
Editada: Adam Danz el 9 de Mayo de 2019
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

Más respuestas (0)

Categorías

Más información sobre Graph and Network Algorithms en Centro de ayuda y File Exchange.

Preguntada:

el 25 de Abr. de 2019

Editada:

el 9 de Mayo de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by