Modify the implementation of DFS && BFS

Test successful