フィルターのクリア

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

2 ビュー (過去 30 日間)
Roy Goodman
Roy Goodman 2023 年 3 月 16 日
編集済み: Jinal 2023 年 3 月 17 日
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);

採用された回答

Jinal
Jinal 2023 年 3 月 17 日
編集済み: Jinal 2023 年 3 月 17 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by