版權(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 幼兒想象力繪畫(huà)課程設(shè)計(jì)
- 板栗酒工廠(chǎng)設(shè)計(jì)課程設(shè)計(jì)
- 托管班課程設(shè)計(jì)
- 機(jī)電控制課程設(shè)計(jì)
- 2024年期戰(zhàn)略供應(yīng)商批量采購(gòu)協(xié)議版
- 學(xué)前心理學(xué) 課程設(shè)計(jì)
- 2024年礦權(quán)交易居間配合協(xié)議
- 早教美味的食物課程設(shè)計(jì)
- 《Operations,Logistics and Supply Chain Management(節(jié)選)漢譯實(shí)踐報(bào)告》
- 2024年度物權(quán)擔(dān)保期限跨境交易合同3篇
- 非新生兒破傷風(fēng)診療
- 建筑施工企業(yè)八大員繼續(xù)教育模擬考試題庫(kù)500題(含標(biāo)準(zhǔn)答案)
- 實(shí)驗(yàn)室組織機(jī)構(gòu)圖
- 眾創(chuàng)空間運(yùn)營(yíng)管理實(shí)施方案
- 2024智慧城市數(shù)據(jù)采集標(biāo)準(zhǔn)規(guī)范
- 2024年中國(guó)電子財(cái)務(wù)公司春季校園招聘3人高頻難、易錯(cuò)點(diǎn)500題模擬試題附帶答案詳解
- 寒假作業(yè)一年級(jí)上冊(cè)《數(shù)學(xué)每日一練》30次打卡
- 云南省2022年中考道德與法治真題試卷
- 業(yè)委會(huì)解除小區(qū)物業(yè)服務(wù)合同的函
- 食堂食材配送項(xiàng)目投標(biāo)方案(技術(shù)方案)
- 2024-2025學(xué)年北京市海淀區(qū)數(shù)學(xué)三上期末教學(xué)質(zhì)量檢測(cè)試題含解析
評(píng)論
0/150
提交評(píng)論