integrate dfs into sparse_graph