-
Notifications
You must be signed in to change notification settings - Fork 0
/
findCoreNodesByDegree.m
48 lines (42 loc) · 1.53 KB
/
findCoreNodesByDegree.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
function coreNodes = findCoreNodesByDegree(AdjMatrix,degree,avgDegree)
degree2 = degree;
% %%与核心点直接相连接的不考虑
% adj_core_index = (sum(AdjMatrix(coreNodes,:)==1)>0);
% %%核心点本身不再考虑
% adj_core_index(:,coreNodes) = true;
% degree2(1,adj_core_index) = -1;
%%度小于平均度的不考虑
degree2(degree2<=(avgDegree)) = -1;
candidateCoreNodeNum = sum(degree2>0);
[~,degree_index] = sort(degree2,'descend');%%去除核心点之后的度排序
degree_index = degree_index(1,1:candidateCoreNodeNum);
% coresNode = degree_index(1);
% degree_index(1) = [];
coreNodes = [];
while ~isempty(degree_index)
coreNodes = [coreNodes degree_index(1)];
degree_index(1) = [];
if isempty(degree_index)
break;
end
adj = degree_index(AdjMatrix(coreNodes(end),degree_index)>0);
for i = 1:length(adj)
aaa = find(adj(i) == degree_index);
if ~isempty(aaa)
degree_index(aaa) = [];
end
end
% if find(find(AdjMatrix(coresNode(end),degree_index)>0) == degree_index)
%
% end
end
%
% [~,index_AA] = sort(top_degree_nodes_coreNodes_distance(:,end),'descend');
% if ceil(e)>length(index_AA)
% len = length(index_AA);
% else
% len =ceil(e);
% end
% moreCoreNodes = degree_index(1,index_AA(1:len,:)');
% coreNodes = [coreNodes moreCoreNodes];
end