graph: better test for dfs