public List<T> getTopologicalSort(Comparator<T> tieBreaker) {

		List<T> order = new ArrayList<T>();
		DirectedGraph<T> g = new DirectedGraph<T>(this);

		while (true) {

			Set<T> nodes = g.getNodes();

			if (nodes.isEmpty())
				return order;

			List<T> noInbound = new ArrayList<T>();

			for (T node : nodes) {
				if (g.getInboundNodes(node).isEmpty())
					noInbound.add(node);
			}

			if (noInbound.isEmpty())
				throw new IllegalStateException("cycle");

			if (tieBreaker != null)
				Collections.sort(noInbound, tieBreaker);

			T node = noInbound.get(0);
			order.add(node);
			g.removeNode(node);
		}
	}