-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolveISet.java
More file actions
28 lines (24 loc) · 892 Bytes
/
solveISet.java
File metadata and controls
28 lines (24 loc) · 892 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
package npc;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class solveISet {
public static void main (String[] args) {
String filename = args[0];
List<Graph> graphs = Graph.makeAllGraphsFromFile(filename);
System.out.println("* Max Independent Sets in graphs in " + filename);
System.out.println("\t(|V|,|E|) Independent Set (size, ms used)");
for (Graph graph: graphs) {
//Graph graph = graphs.get(6);
//graph.debug(true);
String origGraph = graph.toString();
long start = System.currentTimeMillis();
Set<Integer> maxClique = graph.invertGraph().findLargestClique();
System.out.println(
origGraph + " {" + maxClique.stream().map(v -> v.toString()).collect(Collectors.joining(", ")) +
"} (size=" + maxClique.size() + ", " + (System.currentTimeMillis() - start) + " ms)"
);
//graph.debug();
}
}
}