Consider a directed graph given in below, DFS of the below graph is 1 2 4 6 3 5 7 8. In below diagram if DFS is applied on this graph a tree is obtained which is connected using green edges.
Tree Edge: It is an edge which is present in the tree obtained after applying DFS on the graph. All the Green edges are tree edges.
Forward Edge: It is an edge (u, v) such that v is descendant but not part of the DFS tree. Edge from 1 to 8 is a forward edge.
Back edge: It is an edge (u, v) such that v is ancestor of edge u but not part of DFS tree. Edge from 6 to 2 is a back edge. Presence of back edge indicates a cycle in directed graph.
Cross Edge: It is a edge which connects two node such that they do not have any ancestor and a descendant relationship between them. Edge from node 5 to 4 is cross edge.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Maximum Possible Edge Disjoint Spanning Tree From a Complete Graph
- Maximum number of edges to be added to a tree so that it stays a Bipartite graph
- Ways to Remove Edges from a Complete Graph to make Odd Edges
- Maximum number of edges that N-vertex graph can have such that graph is Triangle free | Mantel's Theorem
- Remove all outgoing edges except edge with minimum weight
- Edge Coloring of a Graph
- Check if removing a given edge disconnects a graph
- Program to Calculate the Edge Cover of a Graph
- Shortest Path in a weighted Graph where weight of an edge is 1 or 2
- Maximize number of nodes which are not part of any edge in a Graph
- Add and Remove Edge in Adjacency List representation of a Graph
- Find weight of MST in a complete graph with edge-weights either 0 or 1
- Maximum number of edges in Bipartite graph
- All vertex pairs connected with exactly k edges in a graph
- Minimum number of edges between two vertices of a Graph
- Minimum number of edges between two vertices of a graph using DFS
- Count number of edges in an undirected graph
- Number of Simple Graph with N Vertices and M Edges
- Path with minimum XOR sum of edges in a directed graph
- Find the maximum component size after addition of each edge to the graph
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.