### Question:
MaxWeightClosure { public static int solve(List<Vertex> vertices, Set<Vertex> ans) { return 0; }  static int solve(List<Vertex> vertices, Set<Vertex> ans);  }### Answer:
@Test public void basicTest() { Vertex vertex0 = new Vertex(0, 8); Vertex vertex1 = new Vertex(1, -9); Vertex vertex2 = new Vertex(2, -20); Vertex vertex3 = new Vertex(3, 12); Vertex vertex4 = new Vertex(4, -10); Vertex vertex5 = new Vertex(5, 5); vertex0.addEdge(vertex1); vertex0.addEdge(vertex3); vertex1.addEdge(vertex4); vertex1.addEdge(vertex5); vertex3.addEdge(vertex4); vertex2.addEdge(vertex3); List<Vertex> vertices = Arrays.asList(vertex0, vertex1, vertex2, vertex3, vertex4, vertex5); Set<Vertex> ans = new HashSet<>(); Assert.assertEquals(7, MaxWeightClosure.solve(vertices, ans)); System.out.println(ans); }
@Test public void randomTest() { int V = 4; for (int i = 0; i < 150; i++) { if (i % 10 == 9) V++; List<Vertex> vertices = buildRandom(V); int expect = bruteForce(vertices); Set<Vertex> ans = new HashSet<>(); assertEquals(expect, MaxWeightClosure.solve(vertices, ans)); assertEquals(expect, check(ans, vertices)); System.out.println(ans); } }