adjcentmatrix - 复制.m
来自「该matlab程序可得到规则随机方形网络的邻接矩阵」· M 代码 · 共 24 行
M
24 行
clear;
p=0.5; %the probability of the bonds
N=50; %the number of nodes is N^2
%%%%%%%%%%%%%create the adjacency matrix of a percolation network
B=zeros(N^2);
for i=1:2:(2*N-1)
for j=2:N
if rand(1)+p>=1
B((i-1)*N/2+j-1,(i-1)*N/2+j)=1;
B((i-1)*N/2+j,(i-1)*N/2+j-1)=1;
end
end
end
for i=2:2:(2*N-2)
for j=1:N
if rand(1)+p>=1
B((i/2-1)*N+j,(i/2)*N+j)=1;
B((i/2)*N+j,(i/2-1)*N+j)=1;
end
end
end
%%%%%%%%%%%%%%end the creatation
P=length(find(B==1))/N^4
B=sparse(B); %transfer to sparse matrix to save memory
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?