Skip to content
Related Articles

Related Articles

Improve Article

Difference between Tree edge and Back edge in graph

  • Difficulty Level : Easy
  • Last Updated : 13 Jan, 2021

Tree Edge: It is an edge that is present in the tree obtained after performing DFS on the graph. All the Green edges are tree edges as shown in the below image. 

Back Edge: It is an edge (u, v) such that v is an ancestor of node u but not part of the DFS Traversal of the tree. Edge from 5 to 4 is a back edge. The presence of a back edge indicates a cycle in a directed graph.

Consider an undirected graph is given below, the DFS of the below graph is 3 1 2 4 6 5. In the below diagram, if the DFS is applied to this graph, a tree is obtained which is connected using green edges.

Tabular between the back Edge and tree Edge:

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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

In case you wish to attend live classes with experts, please refer DSA Live Classes for Working Professionals and Competitive Programming Live for Students.

My Personal Notes arrow_drop_up
Recommended Articles
Page :