-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindMaxIndexOrder.m
More file actions
42 lines (32 loc) · 1017 Bytes
/
FindMaxIndexOrder.m
File metadata and controls
42 lines (32 loc) · 1017 Bytes
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
function[MaxIndexOrder] = FindMaxIndexOrder(Adj, q)
InfectedMatrix = zeros(length(Adj), length(Adj));
for i = 1:length(Adj)
InfectedMatrix(i, :) = DecBased(i, Adj, q);
end
disp(InfectedMatrix)
MaxIndex = 0;
MaxOfOnes = 0;
InfectedSetOr = zeros(1, length(Adj));
MaxIndexSet = zeros(1, length(Adj));
MaxIndexOrder = [];
for i = 1:length(Adj)
for j = 1:length(Adj)
if(MaxIndexSet(j) ~= 1)
NewInfectedSetOr = InfectedMatrix(j,:) | InfectedSetOr;
NumberOfOnes = sum(NewInfectedSetOr);
if NumberOfOnes > MaxOfOnes
MaxOfOnes = NumberOfOnes;
MaxIndex = j;
FinalInfectedSetOr = NewInfectedSetOr;
end
end
end
disp(MaxIndex)
disp(FinalInfectedSetOr)
InfectedSetOr = FinalInfectedSetOr;
MaxIndexSet(MaxIndex) = 1;
MaxIndexOrder = [MaxIndexOrder, MaxIndex];
if sum(FinalInfectedSetOr) == length(Adj)
break
end
end