-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrunerRoy
37 lines (30 loc) · 1.26 KB
/
PrunerRoy
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
public class Pruner {
/**
* @param adjMatrix the adj matrix
* @param cliqueSize the hypothetical lower bound computed witht the eigenvalues.
* @param degreeOrder the array that contains the amount of edges for each index
* @return another adj matrix, that will be pruned such that there wont be any vertices with less coneections then cliqueSize.
*/
public static int[][] prune(int[][] adjMatrix,int cliqueSize,int[] degreeOrder) {
for (int i = 0; i < adjMatrix.length; i++) {
int degrees = degreeOrder[i];
if(degrees < cliqueSize && degrees !=0 ){
for(int j =0;j<adjMatrix.length;j++){
adjMatrix[i][j] = 0;
adjMatrix[j][i] = 0;
}
}
}
int[] updatedDegrees = new int[adjMatrix.length];
for(int k = 0;k<updatedDegrees.length;k++) {
updatedDegrees[k] = ChromaticMethods.checkDegrees(adjMatrix, k);
}
for(int r =0;r<updatedDegrees.length;r++){
if(updatedDegrees[r] != 0 && updatedDegrees[r] <cliqueSize){
return prune(adjMatrix,cliqueSize,updatedDegrees);
}
}
System.out.println("pruning is done!");
return adjMatrix;
}
}