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

1 visualizzazione (ultimi 30 giorni)
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);

Risposta accettata

Jinal
Jinal il 17 Mar 2023
Modificato: Jinal il 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.

Più risposte (0)

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by