DFS ( Depth First Search ) is an algorithm of graph exploration that goes along each branch down to the last child node before backtracking. When trees T ( more specifically, acyclic connected graphs ) are considered, it runs rather straightforward, visiting all the nodes of the tree. Nevertheless, in the case of graphs with loops, it is essential to control which vertices were visited so as not to get stuck in infinite loops. Casewise, a particular order is used, such as pre-order, in-order, or post-order to carry out the traversals for DFS.