復(fù)雜網(wǎng)絡(luò)聚類(lèi)系數(shù)和平均路徑長(zhǎng)度計(jì)算的MATLAB源代碼_第1頁(yè)
復(fù)雜網(wǎng)絡(luò)聚類(lèi)系數(shù)和平均路徑長(zhǎng)度計(jì)算的MATLAB源代碼_第2頁(yè)
復(fù)雜網(wǎng)絡(luò)聚類(lèi)系數(shù)和平均路徑長(zhǎng)度計(jì)算的MATLAB源代碼_第3頁(yè)
復(fù)雜網(wǎng)絡(luò)聚類(lèi)系數(shù)和平均路徑長(zhǎng)度計(jì)算的MATLAB源代碼_第4頁(yè)
復(fù)雜網(wǎng)絡(luò)聚類(lèi)系數(shù)和平均路徑長(zhǎng)度計(jì)算的MATLAB源代碼_第5頁(yè)
已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、carrot_hy復(fù)雜網(wǎng)絡(luò)的代碼總共是三個(gè)m文件,復(fù)制如下:第一個(gè)文件,functionCp_Global,Cp_Nodal=CCM_ClusteringCoef(gMatrix,Types)%CCM_ClusteringCoefcalculatesclusteringcoefficients.%Input:%gMatrixadjacencymatrix%Typestypeofgraph:'binary','weighted','directed','all'(default).%Usage:%Cp_Global,Cp_Nodal

2、=CCM_ClusteringCoef(gMatrix,Types)returns%clusteringcoefficientsforallnodes"Cp_Nodal"andaverageclustering%coefficientofnetwork"Cp_Global".%Example:%G=CCM_TestGraph1('nograph');%Cp_Global,Cp_Nodal=CCM_ClusteringCoef(G);%Note:%1)onenodehavevaule0,whilewhichonlyhasaneighbour

3、ornone.%2)Thedirctednetworktermedtripletsthatfulfillthefollowcondition%asnon-vacuous:j->i->kandk->i-j,ifdon'tsatisfywiththatas%vacuous,justlike:j->i,k->iandi->j,i->k.andtheclosedtriplets%onlyj->i->k=j->kandk->i->j=k->j.%3)'ALL'typenetworkcodefromMik

4、aRubinov'sBCTtoolkit.%Refer:%1Barratetal.(2004)Thearchitectureofthecomplexweightednetworks.%2Wasserman,S.,Faust,K.(1994)SocialNetworkAnalysis:Methodsand%Applications.%3ToreOpsahlandPietroPanzarasa(2009)."ClusteringinWeighted%Networks".SocialNetworks31(2).%SeealsoCCM_Transitivity%Writte

5、nbyYongLiu,Oct,2007%CenterforComputationalMedicine(CCM),%NationalLaboratoryofPatternRecognition(NLPR),%InstituteofAutomation,ChineseAcademyofSciences(IACAS),China.%RevisebyHuYong,Nov,2010%E-mail:%basedonMatlab2006a%$Revision:,Copywrite(c)2007error(nargchk(1,2,nargin,'struct');if(nargin<2)

6、,Types='all'endN=length(gMatrix);gMatrix(1:(N+1):end)=0;%Clearself-edgesCp_Nodal=zeros(N,1);%Preallocateswitch(upper(Types)case'BINARY'%BinarynetworkgMatrix=double(gMatrix>0);%Ensurebinarynetworkfori=1:Nneighbor=(gMatrix(i,:)>0);Num=sum(neighbor);%numberofneighbornodestemp=gMat

7、rix(neighbor,neighbor);if(Num>1),Cp_Nodal(i)=sum(temp(:)/Num/(Num-1);endendcase'WEIGHTED'%Weightednetwork-arithmeticmeanfori=1:Nneighbor=(gMatrix(i,:)>0);n_weight=gMatrix(i,neighbor);Si=sum(n_weight);Num=sum(neighbor);if(Num>1),n_weight=ones(Num,1)*n_weight;n_weight=n_weight+n_weigh

8、t'neighbor) > 0);n_weight=n_weight.*(gMatrix(neighbor,Cp_Nodal(i)=sum(n_weight(:)/(2*Si*(Num-1);endend%case'WEIGHTED'%Weightednetwork-geometricmean%A=(gMatrix=0);%G3=diag(gMatrix.A(1/3)43);)%A(A=0)=inf;%close-tripletnoexist,letCpNode=0(A=inf)%CpNode=G3./(A.*(A-1);case'DIRECTED'

9、;,%Directednetworkfori=1:Ninset=(gMatrix(:,i)>0);%in-nodessetoutset=(gMatrix(i,:)>0)'%out-nodessetif(any(inset&outset)allset=and(inset,outset);%Ensureaji*aik>0,jbelongstoinset,andkbelongstooutsettotal=sum(inset)*sum(outset)-sum(allset);tri=sum(sum(gMatrix(inset,outset);Cp_Nodal(i)=t

10、ri./total;endend%case'DIRECTED',%Directednetwork-clarityformat(fromMikaRubinov,UNSW)%G=gMatrix+gMatrix'%symmetrized%D=sum(G,2);%totaldegree%g3=diag(GA3)/2;%numberoftriplet%D(g3=0)=inf;%3-cyclesnoexist,letCp=0%c3=D.*(D-1)-2*diag(gMatrixA2);%numberofallpossible3-cycles%Cp_Nodal=g3./c3;%Not

11、e:Directed&weightednetwork(fromMikaRubinov)case'ALL',%Alltype%adjacency matrix%total degree%number of triplet%3-cycles no exist,letA=(gMatrix=0);G=gMatrix.A(1/3)+(gMatrix.').A(1/3);D=sum(A+A.',2);g3=diag(GA3)/2;D(g3=0)=inf;Cp=0c3=D.*(D-1)-2*diag(AA2);Cp_Nodal=g3./c3;otherwise,%Eo

12、rrMsgerror('Typeonlyfour:"Binary","Weighted","Directed",and"All"');endCp_Global=sum(Cp_Nodal)/N;%第二個(gè)文件:functionD_Global,D_Nodal=CCM_AvgShortestPath(gMatrix,s,t)%CCM_AvgShortestPathgeneratestheshortestdistancematrixofsourcenodes%indicestothetargetnodesi

13、ndicet.%Input:%gMatrixsymmetrybinaryconnectmatrixorweightedconnectmatrix%ssourcenodes,defaultis1:N%ttargetnodes,defaultis1:N%Usage:%D_Global,D_Nodal=CCM_AvgShortestPath(gMatrix)returnsthemean%shortest-pathlengthofwholenetworkD_Global,andthemeanshortest-path%lengthofeachnodeinthenetwork%Example:%G=CC

14、M_TestGraph1('nograph');%D_Global,D_Nodal=CCM_AvgShortestPath(G);%Seealsodijk,MEAN,SUM%WrittenbyYongLiu,Oct,2007%ModifiedbyHuYong,Nov2010%CenterforComputationalMedicine(CCM),%BasedonMatlab2008a%$Revision:,Copywrite(c)2007%#Inputcheck#error(nargchk(1,3,nargin,'struct');N=length(gMatri

15、x);if(nargin<2|isempty(s),s=(1:N)'elses=s(:);endif(nargin<3|isempty(t),t=(1:N)'elset=t(:);end%Calculatetheshortest-pathfromstoallnodeD=dijk(gMatrix,s);%D(isinf(D)=0;D=D(:,t);%TotargetnodesD_Nodal=(sum(D,2)./sum(D>0,2);%D_Nodal(isnan(D_Nodal)=;D_Global=mean(D_Nodal);第三個(gè)文件:functionD=d

16、ijk(A,s,t)%DIJKShortestpathsfromnodes's'tonodes't'usingDijkstraalgorithm.%D=dijk(A,s,t)%A=nxnnode-nodeweightedadjacencymatrixofarclengths%(Note:A(i,j)=0=>Arc(i,j)doesnotexist;A(i,j)=NaN=>Arc(i,j)existswith0weight)%s=FROMnodeindices%=(default),pathsfromallnodes%t=TOnodeindices%=

17、(default),pathstoallnodes%D=|s|x|t|matrixofshortestpathdistancesfrom's'to't'%=D(i,j),whereD(i,j)=distancefromnode'i'tonode'j'%(IfAisatriangularmatrix,thencomputationallyintensivenode%selectionstepnotneededsincegraphisacyclic(triangularityisa%sufficient,butnotanecessar

18、y,conditionforagraphtobeacyclic)%andAcanhavenon-negativeelements)%(If|s|>>|t|,thenDIJKisfasterifDIJK(A',t,s)used,whereDisnow%transposedandPnowrepresentssuccessorindices)%(BasedonFig.4.6inAhuja,Magnanti,andOrlin,NetworkFlows,%Prentice-Hall,1993,p.109.)%Copyright(c)1998-2000byMichaelG.Kay%Ma

19、tlogVersion29-Aug-2000%ModifiedbyJBT,Dec2000,todeletepaths% Input Error Checking*error(nargchk(1,3,nargin,'struct');n,cA=size(A);ifnargin<2|isempty(s),s=(1:n)'elses=s(:);endifnargin<3|isempty(t),t=(1:n)'elset=t(:);endifany(any(tril(A)=0)%AisuppertriangularisAcyclic=1;elseifany(

20、any(triu(A)=0)%AislowertriangularisAcyclic=2;else%GraphmaynotbeacyclicisAcyclic=0;endifn=cAerror('Amustbeasquarematrix');elseifisAcyclic&any(any(A<0)error('Amustbenon-negative');elseifany(s<1|s>n)error('''s''mustbeanintegerbetween1and',num2str(n);elseifany(t<1|t>n)error('''t''mustbeanintegerbetween1and',num2str(n);end% End (Input Error Checking)*A=A'%Usetransposetospeed-upFINDforsparseAD

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論