Fix a DFS bug, when root is not the first vertex, #607