我有这个部分可以在组中创建一些随机链接。我可以让它更有效率吗?任何想法?
谢谢。
n=[10 ;10 ;10];
no_of_groups=size(n,1);
for k=1:no_of_groups
if k==1
m{k,1}=randi(n(1), n(1),2);%random links between nodes of group1
m1=rand(n(1),1)/2+0.5;%random weight to edges
c{k,1} = cat(2,m{1},m1);
else
m{k,1}=randi([((k-1)*n(k-1)+1) (k*n(k))],n(k),2););%random links between nodes of group k
m1=rand(n(k),1)/2+0.5;
c{k,1} = cat(2,m{k,1},m1);
end
end
c=cat(1,c{:});