哨向 Mika & Lelush 2

Ci值是网络中节点的聚类系数,可以用以下Matlab代码计算: ```matlab function [C, Cn] = clustering_coef_bu(A) %CLUSTERING_COEF_BU Clustering coefficient % % C = clustering_coef_bu(A); % [C,CN] = clustering_coef_bu(A); % % The clustering coefficient is the fraction of triangles around a node % (equiv. the fraction of node's neighbors that are neighbors of each other). % % Input: A, binary undirected or directed connection matrix % (note: will be treated as undirected) % % Output: C, clustering coefficient vector % Cn, average clustering coefficient % % Notes: % The clustering coefficient measures the connectedness of nodes and % is defined here as the fraction of all possible triangles in the % graph that actually exist. Note that triangles are weighted equally % here, whereas in some formulations of the clustering coefficient, % triangles on edges that are part of larger cliques are weighted more % strongly. % % Reference: Watts and Strogatz (1998) Nature 393:440-442. % % Mika Rubinov, UNSW/U-Cambridge, 2007-2012 % Modification History: % Jul 2007: Original (contributed by Michael Breakspear) % Mar 2008: Addressed some minor issues and improved documentation. % (Thanks to Cosimo Lacava) % May 2008: Output Cn added. % May 2012: Addressed some minor issues in the documentation. % (Thanks to Noam Peled) % ensure binary and symmetrical A = double(A~=0); A = A + A.'; N = size(A,1); % number of triangles = trace(A^3)/2 A3 = A^3; triangles = trace(A3)/2; % number of connected triples = K*(K-1)/2 K = sum(A,1).'; if isempty(K) warning('Empty graph: clustering coefficients undefined.'); C = NaN(N,1); Cn = NaN; return end connected_triplets = sum(K.*(K-1))/2; % calculate clustering coefficient if triangles==0 % according to definition, when no triangles exist, C=0 C = zeros(N,1); else C = triangles./connected_triplets; end % calculate average clustering coefficient Cn = nanmean(C); ``` 使用方法: 1. 输入一个二进制的无向连接矩阵A。 2. 返回节点的聚类系数C,以及平均聚类系数Cn。 注意:该函数仅适用于无向图。如果你有一个有向图,你可以使用`clustering_coef_wd`函数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值