-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSuperSetRemoval.java
More file actions
68 lines (59 loc) · 1.63 KB
/
Copy pathSuperSetRemoval.java
File metadata and controls
68 lines (59 loc) · 1.63 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
68
package main;
import java.io.File;
import java.util.*;
public class SuperSetRemoval {
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
long startTime = System.nanoTime();
ArrayList<Long> temp = new ArrayList<>();
File f = new File("to_send_to_java.txt");
Scanner fileReader = new Scanner(f);
int n = 0;
while(fileReader.hasNextLine()) {
n++;
temp.add(Long.parseLong(fileReader.nextLine(), 2));
}
Long arr[] = temp.toArray(new Long[n]);
fileReader.close();
boolean removed[] = new boolean[n];
int reds = 0;
int supers = 0;
int MCSs = 0;
for (int i=0; i<n; i++) {
if((i>>16)<<16==i) {
System.err.printf("\n%.2f",((float)i/n)*((float)i/n)*100 );
System.err.println("% completed \nseconds passed: " + (System.nanoTime() - startTime)/1000000000);
System.err.println(reds);
System.err.println(supers);
}
if (removed[i])
continue;
for(int j=0; j<i; j++) {
if (removed[j])
continue;
if (arr[i]==arr[j]) {
reds++;
removed[j] = true;
continue;
}
if ((arr[i]&arr[j])==arr[i]) {
supers++;
removed[j] = true;
continue;
}
if ((arr[i]&arr[j])==arr[j]) {
supers++;
removed[i] = true;
break;
}
}
if (!removed[i])
MCSs++;
}
long endTime = System.nanoTime();
System.err.println("number of repeated MCSs: "+reds);
System.err.println("number of non-MCSs(Super set of a MCS a.k.a cut-sets)" + supers);
System.out.println("duration of the post-processing: " + (endTime - startTime)/1000000 + " miliseconds");
System.out.println("Total MCSs: " + MCSs);
}
}