topsort with dfs