课程首页 | 课程简介 | 课程大纲 | 课程讲义 | 授课教师 | 网络可视化 | 课程建设动态 | 课程资讯 | 线上课程 | 头条推荐 
   
 

代码参考 | 格子网络(Matlab)
2022-01-15 19:31  

function A=buildlattice(N,K)

%Builds ring lattice with N nodes.  K is the number of neighbours TO EACH SIDE (i.e. half the average degree).

%K must be less than (N-1)/2

%Usage: A=buildlattice(N,K)


A=sparse([],[],[],N,N,2*(N*K));

B=repmat(1,N,2*K);

d=[[-(N-1):-(N-K)] [1:K]];

A=spdiags(B,d,N,N);

A=A+A'; %could do it directed not symetric


Close Window
  读取内容中,请等待...

版权所有:Research Centre of Nonlinear Science 邮政编码:430073
E-mail:liujie@wtu.edu.cn 备案序号:鄂ICP备15000386号 鄂公网安备 42011102000704号