Modified DFS.
Added topological sort.
Added test for topological sort.