-
Notifications
You must be signed in to change notification settings - Fork 1
/
globalLink.m
71 lines (53 loc) · 1.77 KB
/
globalLink.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function [dotLink,cmLinkC,cmLinkW] = globalLink(Cmty,NodeMatrix)
%GLOBALWEIGHT 此处显示有关此函数的摘要
% 此处显示详细说明
% 输入:社团检测的输出(鲁文)
% :网络矩阵
% 输出:以社团为点的网络矩阵,值为社团间的权值
% CmtyNum = tabulate(Cmty);
comNum = max(Cmty);
%% 社团整体对外的连接
cmtyWeight = [];%
cmtyCount = [];
for i = 1:1:comNum % 第一个社团开始
inodeIdx = find(Cmty(:,:)==i);
for j = i+1:1:comNum % 与其他社团(不重复)
jnodeIdx = find(Cmty(:,:)==j);
outaction = NodeMatrix(jnodeIdx,inodeIdx);
iNodeAllWeight = sum(outaction,1);
iNodeAllCount = sum(outaction~=0,1);
cmtyWeight = [cmtyWeight, sum(iNodeAllWeight)];
cmtyCount = [cmtyCount, sum(iNodeAllCount)];
end
end
%% 确定社团中点对外的连接
nodeweight = zeros(size(Cmty));
nodecount = zeros(size(Cmty));
for i = 1:1:comNum % 第一个社团开始
inodeIdx = find(Cmty(:,:)==i);
inner = 1:1:comNum;
inner(inner==i) = [];
for j = inner % 与其他社团
jnodeIdx = find(Cmty(:,:)==j);
outaction = NodeMatrix(jnodeIdx,inodeIdx);
iNodeAllWeight = sum(outaction,1);
iNodeAllCount = sum(outaction~=0,1);
for k = 1:1:size(inodeIdx,2)
nodeweight(inodeIdx(k)) = nodeweight(inodeIdx(k))+iNodeAllWeight(k);
nodecount(inodeIdx(k)) = nodecount(inodeIdx(k))+iNodeAllCount(k);
end
end
end
dotLink = [Cmty;nodeweight;nodecount];
% ZZ = [];
% for i = unique(GWeight(1,:))
% e = dotLink(3,dotLink(1,:)==i);
% ZZ(i,:) = [i,sum(e)];
% end
% ZZ
% squareform(cmtyCount)
% cmLinkW = squareform(cmtyWeight);
% cmLinkC = squareform(cmtyCount);
cmLinkW = cmtyWeight;
cmLinkC = cmtyCount;
end