TopologicalSorting { public void sort() throws DeltaModellingException { boolean rootNode; Set<T> nodes = new HashSet<>(this.nodes); int currentSet = 0; while (nodes.size() > 0) { partition.add(new HashSet<>()); for (T node : nodes) { rootNode = true; for (T cn : nodes) { if (incidence.get(cn, node) == true) { rootNode = false; break; } } if (rootNode) partition.get(currentSet).add(node); } if (partition.get(currentSet).isEmpty()) throw new DeltaModellingException("Sorting: cycle detected among the following nodes: " + nodes.toString()); for (T node : partition.get(currentSet)) nodes.remove(node); currentSet++; } isSorted = true; } TopologicalSorting(Set<T> nodes); void addEdge(T high, T low); void sort(); List<T> getPreferredOrder(); List<T> getAnOrder(); List<Set<T>> getPartition();  }
@Test(expected=DeltaModellingException.class) public void test0_1() { TopologicalSorting<DeltaID> sorter = init0_1(); sorter.sort(); }