@VisibleForTesting
	static <T> List<T> topologicalSort(Graph<T> graph)
	{
		MutableGraph<T> graphCopy = Graphs.copyOf(graph);
		List<T> l = new ArrayList<>();
		Set<T> s = graphCopy.nodes().stream()
			.filter(node -> graphCopy.inDegree(node) == 0)
			.collect(Collectors.toSet());
		while (!s.isEmpty())
		{
			Iterator<T> it = s.iterator();
			T n = it.next();
			it.remove();

			l.add(n);

			for (T m : new HashSet<>(graphCopy.successors(n)))
			{
				graphCopy.removeEdge(n, m);
				if (graphCopy.inDegree(m) == 0)
				{
					s.add(m);
				}
			}
		}
		if (!graphCopy.edges().isEmpty())
		{
			throw new RuntimeException("Graph has at least one cycle");
		}
		return l;
	}
@Test
	public void testTopologicalSort()
	{
		MutableGraph<Integer> graph = GraphBuilder
			.directed()
			.build();

		graph.addNode(1);
		graph.addNode(2);
		graph.addNode(3);

		graph.putEdge(1, 2);
		graph.putEdge(1, 3);

		List<Integer> sorted = PluginManager.topologicalSort(graph);

		assertTrue(sorted.indexOf(1) < sorted.indexOf(2));
		assertTrue(sorted.indexOf(1) < sorted.indexOf(3));
	}