void () { TestNode nA = new TestNode("A"); TestNode nB = new TestNode("B"); TestNode nC = new TestNode("C"); TestNode nD = new TestNode("D"); TestNode[] allNodes = {nA, nB, nC, nD}; Map<TestNode, TestNode[]> map = new HashMap<>(); map.put(nA, new TestNode[]{nC}); map.put(nB, new TestNode[]{nA}); map.put(nC, new TestNode[]{nB}); map.put(nD, new TestNode[]{nB}); Graph<TestNode> graph = graphByNodes(allNodes, map); DFSTBuilder<TestNode> builder = new DFSTBuilder<>(graph); assertFalse(builder.isAcyclic()); Comparator<TestNode> comparator = builder.comparator(); assertTrue(comparator.compare(nA, nD) < 0); assertTrue(comparator.compare(nB, nD) < 0); assertTrue(comparator.compare(nC, nD) < 0); }