-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticipation_coef.m
49 lines (43 loc) · 1.43 KB
/
participation_coef.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function P=participation_coef(W,Ci,flag)
%PARTICIPATION_COEF Participation coefficient
%
% P = participation_coef(W,Ci);
%
% Participation coefficient is a measure of diversity of intermodular
% connections of individual nodes.
%
% Inputs: W, binary/weighted, directed/undirected connection matrix
% Ci, community affiliation vector
% flag, 0, undirected graph (default)
% 1, directed graph: out-degree
% 2, directed graph: in-degree
%
% Output: P, participation coefficient
%
% Reference: Guimera R, Amaral L. Nature (2005) 433:895-900.
%
%
% 2008-2015
% Mika Rubinov, UNSW/U Cambridge
% Alex Fornito, University of Melbourne
% Modification History:
% Jul 2008: Original (Mika Rubinov)
% Mar 2011: Weighted-network bug fixes (Alex Fornito)
% Jan 2015: Generalized for in- and out-degree (Mika Rubinov)
if ~exist('flag','var')
flag=0;
end
switch flag
case 0 % no action required
case 1 % no action required
case 2; W=W.';
end
n=length(W); %number of vertices
Ko=sum(W,2); %degree
Gc=(W~=0)*diag(Ci); %neighbor community affiliation
Kc2=zeros(n,1); %community-specific neighbors
for i=1:max(Ci)
Kc2=Kc2+(sum(W.*(Gc==i),2).^2);
end
P=ones(n,1)-Kc2./(Ko.^2);
P(~Ko)=0; %P=0 if for nodes with no (out)neighbors