Adding topological sort and breadth-first sort.