How can I find the Members of the largest component of a graph?

3 ビュー (過去 30 日間)
Waseem AL Aqqad
Waseem AL Aqqad 2021 年 1 月 29 日
コメント済み: Waseem AL Aqqad 2021 年 1 月 29 日
I'm trying to find the members of the largest component of a graph that I added names to it's nodes, however my code below doesn't show the members as the names I added. It shows numeric values.
Your help would be appreciated!
N=8;
s=[1 4 4 5 6 7 8 9 9 10 10 10 10 11];
t=[12 6 11 13 14 15 16 10 15 11 13 14 16 12];
GF=graph(s,t);
F_prime = subgraph(GF,N+1:N+N);
lh=N+1:N+N;
lh=arrayfun(@num2str,lh,'un',0);
F_prime.Nodes.Name=lh';
[bin,binsize]=conncomp(F_prime);
compF=length(binsize); % No. of components
m=mode(bin);
oF=find(bin==m); % members of largest component

採用された回答

Christine Tobler
Christine Tobler 2021 年 1 月 29 日
Use
oF = F_prime.Nodes.Name(bin==m);
instead of the find command to return node names instead of node numbers.
  1 件のコメント
Waseem AL Aqqad
Waseem AL Aqqad 2021 年 1 月 29 日
Thank you very much, Christine.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by