private void visit(Color[] color, int i, List<Integer> sorted) throws Exception {
		if(color[i] == Color.GREY) throw new Exception("Cycle found!");
		if(color[i] == Color.BLACK) return;
		color[i] = Color.GREY;
		for(Node n : list[i]) {
			int id = n.getId();
			visit(color, id, sorted);
		}
		color[i] = Color.BLACK;
		sorted.add(0, i);
	}