?? nn_coupled_net.m
字號:
function A=NN_coupled_net()
%%% 產生有N個節點,每個節點有2K個鄰居節點的最近鄰耦合網絡
%% A ——————返回生成網絡的鄰接矩陣
disp('該程序生成最近鄰耦合網路:');
N=input('請輸入最近鄰耦合網絡中節點的總數N:');
K=input('請輸入最近鄰耦合網絡中每個節點的鄰居節點的個數的一半K:');
if K>floor(N/2)
disp('輸入的K值不合法')
return;
end
angle=0:2*pi/N:2*pi-2*pi/N; %%生成最近鄰耦合網絡的各節點坐標
x=100*sin(angle);
y=100*cos(angle);
plot(x,y,'ro','MarkerEdgeColor','g','MarkerFaceColor','r','markersize',8);
hold on;
A=zeros(N);
for i=1:N
for j=i+1:i+K
jj=j;
if j>N
jj=mod(j,N);
end
A(i,jj)=1; A(jj,i)=1; %%生成最近鄰耦合網絡的鄰接矩陣
end
end
for i=1:N
for j=i+1:N
if A(i,j)~=0
plot([x(i),x(j)],[y(i),y(j)],'linewidth',1.2);
hold on; %% 畫出最近鄰耦合網絡圖
end
end
end
axis equal;
hold off
[C,aver_C]=Clustering_Coefficient(A);
[DeD,aver_DeD]=Degree_Distribution(A);
[D,aver_D]=Aver_Path_Length(A);
disp(['該隨機圖的平均路徑長度為:',num2str(aver_D)]); %%輸出該網絡的特征參數
disp(['該隨機圖的聚類系數為:',num2str(aver_C)]);
disp(['該隨機圖的平均度為:',num2str(aver_DeD)]);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -