fix the bug of graph traversal