Remove nodes in a graph based on label name instead of index
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
IrisL
el 20 de Jul. de 2022
Respondida: Steven Lord
el 20 de Jul. de 2022
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?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1072265/image.jpeg)
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.
0 comentarios
Respuesta aceptada
Steven Lord
el 20 de Jul. de 2022
B = graph(bucky, string(1:60)); % Use '1' through '60' as names
head(B.Nodes) % Show the first few node names
B2 = rmnode(B, '42');
B2.Nodes(40:45, :) % No node '42' in the modified graph's Nodes table
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Graph and Network Algorithms en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!