get dfs and bfs work