MATLAB Answers

remove nodes without changing the numbering of nodes

4 ビュー (過去 30 日間)
Arpit Dua
Arpit Dua 2020 年 7 月 9 日
回答済み: Akira Agata 2020 年 7 月 10 日
I have a graph from which I want to remove nodes but want to keep the labels or the numbering of the nodes as the same before removing nodes. Is that possible with some option?

回答 (1 件)

Akira Agata
Akira Agata 2020 年 7 月 10 日
How about setting a nodelabel for each node?
The following is an example:
s = [1 1 1 2 2 3];
t = [2 3 4 3 4 4];
% Create a graph G with nodelabel '1',...,'4'
G = graph(s,t,[],{'1','2','3','4'});
% Remove the node 1
G = rmnode(G,1);
% Plot the graph
figure
plot(G)

Community Treasure Hunt

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

Start Hunting!

Translated by