### Question:
EulerCycle { public static List<Integer> solveUndirectGraph(List<Integer>[] graph) { return null; }  static List<Integer> solveUndirectGraph(List<Integer>[] graph);  }### Answer:
@Test public void basicTest1() { List<Integer>[] gra = new List[3]; for (int i = 0; i < 3; i++) { gra[i] = new ArrayList<>(); } for (int i = 0; i < 3; i++) { gra[i].add((i + 1) % 3); gra[(i + 1) % 3].add(i); } Assert.assertEquals("[0, 1, 2, 0]", EulerCycle.solveUndirectGraph(gra).toString()); }
@Test public void basicTest2() { List<Integer>[] gra = new List[2]; for (int i = 0; i < 2; i++) { gra[i] = new ArrayList<>(); } gra[0].add(1); gra[1].add(0); Assert.assertEquals("[]", EulerCycle.solveUndirectGraph(gra).toString()); }
@Test public void basicTest3() { List<Integer>[] gra = new List[0]; Assert.assertEquals("[]", EulerCycle.solveUndirectGraph(gra).toString()); }
@Test public void randomTest() { long timecost1 = 0, timecost2 = 0; for (int i = 5; i < 1000; i += 50) { List<Integer>[] graph = GraphBuilder.buildEulerCycle(i); for (List<Integer> j : graph) { Collections.sort(j); } long st = System.nanoTime(); List<Integer> expect = fleury(graph); timecost1 += System.nanoTime() - st; st = System.nanoTime(); List<Integer> test = EulerCycle.solveUndirectGraph(graph); timecost2 += System.nanoTime() - st; Assert.assertEquals(expect, test); } Assert.assertTrue(timecost1 + "," + timecost2, timecost1 > 90 * timecost2); }