How to list all isolated vertices and remove it from the graph?
27 ビュー (過去 30 日間)
古いコメントを表示
I have a Graph with several isolated vertices. I want to deleted these from the generated output.
0 件のコメント
採用された回答
Steven Lord
2021 年 12 月 17 日
rng default
A = sprandsym(10, (5/100));
G = graph(A, string(1:10)); % Give the nodes names
plot(G)
isolatedNodes = degree(G) == 0;
G2 = rmnode(G, find(isolatedNodes));
figure
plot(G2)
2 件のコメント
Steven Lord
2021 年 12 月 17 日
Note how I explicitly gave the nodes names rather than using the default numerical IDs.
G = graph(A, string(1:10)); % Give the nodes names
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Directed Graphs についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!