Java Topological Sort