确定根节点是哪个。然后bfs或者dfs