資源簡介
有關復雜網絡無標度網絡的冪律分布MATLAB仿真程序,希望對大家有幫助!

代碼片段和文件信息
function?Nodes=Powerlaw_with_Expected_Exponent(Nmgamanode_attribution)
%This?program?generates?a?power?law?degree?distribution?graph?with?expected?gama
%Ref[Universal?behavior?of?load?distribution?in?Scale?free?networksPRL?V87200112]
%Input:
%N--the?number?of?nodes
%m--the?mean?degree?=2m
%gama--the?expected?exponentblong?to?(2infinit)whose?corelation?with?the?control
%??????parameter?alfa?is:?gama=1+1/alfawhere?alfa?is?[01)
%node_attribution--if?node_attribution==1Nodes?is?adjacent?matrix;?if
%???????????????????node_attribution=2Nodes?is?adjacent?list.
%Output
%Nodes--return?the?adjacent?matrix?if?node_attribution=1.the?adjacent?list
%???????if?node_attribution=2
%
if?node_attribution==1
????Nodes=zeros(NN);
????p=zeros(N1);
????pp=zeros(N1);
????node_1_Len=zeros(N1);
????node_2_Len=zeros(N1);
????alfa=1/(gama-1);
????edge_num=N*m;
????
????%1.get?nodes‘?weight
????for?i=1:N
????????p(i)=1/(i^alfa);????????
????end
????%2.normalized?node?weights
????sum_p=sum(p);
????pp(1)=p(1)/sum_p;
????for?i=2:N
????????pp(i)=pp(i-1)+p(i)/sum_p;????????
????end
????
????%3.add?edge
????for?i=1:edge_num
???????%i
???????ADD_ONE_EDGE=0;
???????while?ADD_ONE_EDGE==0
????????????node_1_Len=find(pp>rand(1));?
????????????node_1=node_1_Len(1);
????????????node_2_Len=find(pp>rand(1));
????????????node_2=node_2_Len(1);
????????????while?node_2==node_1%avoid?self-loop
????????????????node_2_Len=find(pp>rand(1));
????????????????node_2=node_2_Len(1);
????????????end
????????????if?Nodes(node_1node_2)==0
????????????????Nodes(node_1node_2)=1;
????????????????Nodes(node_2node_1)=1;
????????????????ADD_ONE_EDGE=1;
????????????else
????????????????ADD_ONE_EDGE=0;
????????????end%Nodes(node_1node_2)
???????end%while?ADD_ONE_EDGE==0
????end%?for?i=1:edge_num????
end%node_attribution
if?TEST==1
????t=toc
????for?i=1:N
????????Degree(i)=nnz(Nodes(i:));
????end
????plot_distribution(DegreeLine_color1);
????fname=[‘PLRG‘num2str(N)‘k‘num2str(m)‘gama‘num2str(gama)];
????Write_Sparse_Matrix(Nodes[fname‘.adj‘]);
????Write_into_Pajek(Nodes[fname‘.net‘]);
end
return
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2180??2008-07-24?23:15??Powerlaw_with_Expected_Exponent.m
-----------?---------??----------?-----??----
?????????????????2180????????????????????1
- 上一篇:FIR高通/低通/帶通/帶阻濾波器設計
- 下一篇:mgpc 多變量預測控制
評論
共有 條評論