資源簡介
用matlab編程實現無標度度網絡算法
代碼片段和文件信息
%???This?is?the?BA_Scale?Model?by?Fan?Jin.
%???At?first?there?are?only?m?nodes?and?no?edge?then?the?m+1st?node?is
%???connected?with?the?above?m?nodes
%???usage:?Nodes?=?BA(Nm)
%???the?parameter:N----network?size
%?????????????????m----a?new?node?with?m?new?edges
%???can?randomly?initialize?the?N?and?the?m?by?yourself
%???the??diagonal?elements?of?the?matrix?also?equal?to?-degree
%???Nodes----the?final?coupling?matrix
%???The?following?message(s)?may?not?be?displayed?correctly?for?they?contain?Chinese?charactors.
%???list----生成的一個輔助向量,該向量中的元素為每條邊端點的節點。for?example?假設網絡中節點4的度為7,則在list向量中會存在7個4,而這7個4的位置不一定是連續在一起的。
%???preferential?attachment體現在隨機的從list向量中選取元素,選中哪個元素,該元素表示的節點即被選中。由于list向量中每個節點的個數與它的度有關,因此,度越大的點被選中的概率越大。
function?[NodesCii]=BA(Nm)
%?N=10m=3;
Nodes=zeros(N);
Cii=zeros(1N);
t=zeros(1N);
%Nodes=sparse(N);
for?i=1:m
????Nodes(im+1)=1;
????Nodes(m+1i)=1;
????A(i)=i;
end
for?i=m+1:2*m
????A(i)=m+1;
end
for?n=m+2:N???
評論
共有 條評論