Effacer les filtres
Effacer les filtres

MATLAB can relabel graph node table columns but not edge table columns.

2 vues (au cours des 30 derniers jours)
Roy Goodman
Roy Goodman le 16 Mar 2023
Modifié(e) : Jinal le 17 Mar 2023
It seems that I can rename a column in the Nodes table of a graph but trying to do so for the Edges table returns an error. (This is a minimal example. It has come up in a method I'm trying to write for a user-defined class.)
g=digraph([1 2],[2 2]);
g.Nodes.label={'A';'B'}
g =
digraph with properties: Edges: [2×1 table] Nodes: [2×1 table]
g.Nodes = renamevars(g.Nodes,'label','Label')
g =
digraph with properties: Edges: [2×1 table] Nodes: [2×1 table]
g.Edges.label={'A';'B'}
g =
digraph with properties: Edges: [2×2 table] Nodes: [2×1 table]
g.Edges = renamevars(g.Edges,'label','Label')
Error using digraph/subsasgn>assignToEdges
Direct editing of edges not supported. Use addedge or rmedge instead.

Error in indexing (line 14)
G = assignToEdges(G, S, V);

Réponse acceptée

Jinal
Jinal le 17 Mar 2023
Modifié(e) : Jinal le 17 Mar 2023
Hi Roy,
I understand that you are facing issues while using ‘renamevars’ to rename a column in 'g.Edges'.
You can use the following command to rename the column.
g.Edges.Properties.VariableNames("label") = "Label";
Please refer this page for more information.
Hope this helps.

Plus de réponses (0)

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by