**Depth First Search (DFS)**algorithm.

We made a

*graph class*that can represent a graph in the previous article of this series. Lets add another function to this class

*DFSSearch(i,j).*This function is an implementation of Depth first search where the search algorithm begins at root node and explores the first successor of the node then again its first successor and so on until it finds the goal or it reaches the leaf node (i.e nodes without any successors). Then the search backs off to the previous node which is still to be expanded and so on. The algorithm of DFS is similar to that of BFS but the only difference is the use of Stack instead of Queue.

Here is a simple algorithm