matlab计算平均路径长度,复杂网络聚类系数和平均路径长度计算的matlab源代码

41528d3028836879cd698677c3999917.gif复杂网络聚类系数和平均路径长度计算的matlab源代码

复杂网络聚类系数和平均路径长度计算的MATLAB 源代码 申明:文章来自百度用户carrot_hy 复杂网络的代码总共是三个m文件,复制如下: 第一个文件,CCM_ClusteringCoef.m function [Cp_Global, Cp_Nodal] = CCM_ClusteringCoef(gMatrix, Types) % CCM_ClusteringCoef calculates clustering coefficients. % : % gMatrix adjacency matrix % Types type of graph: binary , weighted , directed , all (default). % Usage: % [Cp_Global, Cp_Nodal] = CCM_ClusteringCoef(gMatrix, Types) returns % clustering coefficients for all nodes “Cp_Nodal“ and average clustering % coefficient of network “Cp_Global“. % Example: % G = CCM_TestGraph1( nograph ); % [Cp_Global, Cp_Nodal] = CCM_ClusteringCoef(G); % Note: % 1) one node have vaule 0, while which only has a neighbour or none. % 2) The dircted network termed triplets that fulfill the follow condition % as non-vacuous: j->i->k and k->i-j,if don t satisfy with that as % vacuous, just like: j->i,k->i and i->j,i->k. and the closed triplets % only j->i->k == j->k and k->i->j == k->j. % 3) ALL type network code from Mika Rubinov s BCT toolkit. % Refer: % [1] Barrat et al. (2004) The architecture of the complex weighted networks. % [2] Wasserman,S.,Faust,K.(1994) Social Network Analysis: s and % Applications. % [3] Tore Opsahl and Pietro Panzarasa (2009). “Clustering in Weighted % Networks“. Social Networks31(2). % See also CCM_Transitivity % Written by Yong Liu, Oct,2007 % Center for Computational Medicine (CCM), % National Laboratory of Pattern Recognition (NLPR), % Institute of Automation,Chinese Academy of Sciences (IACAS), China. % Revise by Hu Yong, Nov, 2010 % E-mail: % based on Matlab 2006a % $Revision: 1.0, Copywrite (c) 2007error(nargchk(1,2,nargin, struct )); if(nargin 0);%Ensure binary networkfor i = 1:Nneighbor = (gMatrix(i,:) > 0);Num = sum(neighbor);%number of neighbor nodestemp = gMatrix(neighbor, neighbor);if(Num > 1), Cp_Nodal(i) = sum(temp(:))/Num/(Num-1); endendcase WEIGHTED % Weighted network -- arithmetic meanfor i = 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_weight ;n_weight = n_weight.*(gMatrix(neighbor, neighbor) > 0);Cp_Nodal(i) = sum(n_weight(:))/(2*Si*(Num-1));endend%case WEIGHTED % Weighted network -- geometric mean % A = (gMatrix~= 0); % G3 = diag((gMatrix.^(1/3) )^3);) % A(A == 0) = inf; %close-triplet no exist,let CpNode=0 (A=inf) % CpNode = G3./(A.*(A-1)); case DIRECTED , % Directed networkfor i = 1:Ninset = (gMatrix(:,i) > 0); %in-nodes setoutset = (gMatrix(i,:) > 0) ; %out-nodes setif(any(inset % Ensure aji*aik > 0,j belongs to inset,and k belongs to outsettotal = sum(inset)*sum(outset) - sum(allset);

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值