-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvalidate.m
More file actions
67 lines (50 loc) · 1.21 KB
/
validate.m
File metadata and controls
67 lines (50 loc) · 1.21 KB
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
function mat = validate (A, mat, S)
com = community(mat);
nodes = length(mat);
temp = zeros(nodes,1);
for i=1:nodes
for j=1:com
temp(i,1) = temp(i,1) + mat(i,j);
end
end
invalid=0;
for i=1:nodes
if temp(i,1)~=1
mat(i,1:com)=0;
invalid = invalid+1;
end
end
%invalid;
mat;
invNodes = zeros(invalid,1);
temp2 = zeros(invalid,com);
inv=1;
for i=1:nodes
if temp(i,1)~=1
invNodes(inv) = i;
%temp2 = zeros(1,com);
for j=1:com
for k=1:nodes
if mat(k,j)==1
if A(i,k)==1
temp2(inv,j) = temp2(inv,j)+1;
end
end
end
end
inv=inv+1;
end
end
temp2;
invNodes;
for inv=1:invalid
[maxNeigh,X] = max(temp2(inv,:));
mat(invNodes(inv),X) = 1;
end
mat = gene_sort(S, mat);
for i=1:com
if sum(mat(:,i))==0
mat(:,i) = -1;
end
end
end