フィルターのクリア

Remove nodes in a graph based on label name instead of index

1 回表示 (過去 30 日間)
IrisL
IrisL 2022 年 7 月 20 日
回答済み: Steven Lord 2022 年 7 月 20 日
I am fairly new to Matlab and trying to modify a network graph.
I want to remove nodes in a graph based on node's label name instead of the node's index. Using the screenshot as an example, I would like to remove node that has name of '12'(underline in blue) instead of node that has an index of 12(underline in red). Is there a way to do so?
I try
G = rmnode(G,G.Nodes.Name=='12')
But get error message: Operate '==' is not supported for operands of type 'cell'.
Thanks for any suggestions.

採用された回答

Steven Lord
Steven Lord 2022 年 7 月 20 日
B = graph(bucky, string(1:60)); % Use '1' through '60' as names
head(B.Nodes) % Show the first few node names
ans = 8×1 table
Name _____ {'1'} {'2'} {'3'} {'4'} {'5'} {'6'} {'7'} {'8'}
B2 = rmnode(B, '42');
B2.Nodes(40:45, :) % No node '42' in the modified graph's Nodes table
ans = 6×1 table
Name ______ {'40'} {'41'} {'43'} {'44'} {'45'} {'46'}

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by