use dfs detect cycle in undirected graph, good
use dfs to topological sort