void () { TestNode o = new TestNode("o"); TestNode a = new TestNode("a"); TestNode b = new TestNode("b"); TestNode c = new TestNode("c"); for (int oIndex = 0; oIndex < 4; oIndex++) { List<TestNode> list = new ArrayList<>(Arrays.asList(a, b, c)); list.add(oIndex, o); TestNode[] allNodes = list.toArray(new TestNode[0]); Map<TestNode, TestNode[]> mapIn = new HashMap<>(); mapIn.put(o, new TestNode[]{a, b, c}); DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graphByNodes(allNodes, mapIn)); assertTrue(builder.isAcyclic()); Comparator<TestNode> comparator = builder.comparator(); TestNode[] sorted = allNodes.clone(); Arrays.sort(sorted, comparator); assertEquals("All nodes: " + list, Arrays.asList(c, b, a, o), Arrays.asList(sorted)); } }