Depth-First Search, Topological Sort, implementation tests