- Related Questions & Answers
- Depth First Search
- Depth-first search traversal in Javascript
- Depth First Search (DFS) for a Graph
- Depth First Search or DFS for a Graph
- Web crawling using Breadth First Search at a specified depth
- Python Program for Depth First Binary Tree Search using Recursion
- Comparison of Search Trees in Data Structure
- Dynamic Finger Search Trees in Data Structure
- Randomized Finger Search Trees in Data Structure
- Balanced binary search trees in Data Structure
- Python Program to Implement Depth First Search Traversal using Post Order
- Breadth First Search on Matrix in C++
- Breadth First Search on Matrix in Python
- Add and Search Word - Data structure design in C++
- Best First Search (Informed Search)

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

The Depth first search for graphs are similar. But for Digraphs or directed graphs, we can find some few types of edges. The DFS algorithm forms a tree called DFS tree. There are four types of edges called −

**Tree Edge (T)**− Those edges which are present in the DFS tree**Forward Edge (F)**− Parallel to a set of tree edges. (From smaller DFS number to larger DFS number, and Larger DFS completion number to Smaller DFS completion number)**Backward Edge (B)**− From larger DFS number to Smaller DFS number and Smaller DFS completion number to Larger DFS completion number.**Cross Edge (C)**− Larger DFS number to Smaller DFS number, and Larger DFS completion number to Smaller DFS completion number.

Suppose we have a graph like below −

Now we will perform DFS by taking A as initial vertex, and put the DFS number and DFS completion numbers. So the tree will be look like below −

So the DFS traversal is A, B, F, D, G, C, E

The Tree edges are − T = {(A, B), (B, F), (F, D), (F, G), (A, C), (C, E)}

The Forward edges are − F = {(A, G)}

The Backward edges are − B = {(G, B)}

The Cross edges are −C = {(G, D)}

Advertisements