📜  图中树边和后边的区别

📅  最后修改于: 2021-09-02 06:41:19             🧑  作者: Mango

树边对图进行DFS后得到的树中存在的边。所有绿色边缘都是树边缘,如下图所示。

Back Edge 它是一条边(u, v) ,使得v节点 u祖先,但不是树的DFS 遍历的一部分。从54的边是后边。后边的存在表示有向图中的循环

考虑下面给出的一个无向图,下图的 DFS 是3 1 2 4 6 5 。在下图中,如果将 DFS 应用于该图,将获得使用绿色边连接的树。

后边和树边之间的表格:

S.N. Tree Edge Back Edge
1 It connects the node to its descendants. It connects the node to its ancestors.
2 It is the path traversed during DFS. It is the path not visited during DFS.
3 They can form bridges. They can never form bridges.
4 If it is disconnected, the number of connected components may increase. Even if it is disconnected, the number of connected components remains the same.
5 It never creates a cycle. It can create a cycle.

如果您想与行业专家一起参加直播课程,请参阅Geeks Classes Live