wikipedia has the good explaination about this. >A convenient description of a depth first search of a graph is in terms of a spanning tree of the vertices reached during the search. Based on this spanning tree, the edges of the original graph can be divided into three classes: forward edges, which point from a node of the tree to one of its descendants, back edges, which point from a node to one of its ancestors, and cross edges, which do neither. Sometimes tree edges, edges which belong to the spanning tree itself, are classified separately from forward edges. If the original graph is undirected then all of its edges are tree edges or back edges. ![tree][1] The four types of edges defined by a spanning tree In my opinion we use back & forward ages to make a fully spanning tree. In your graph N P M are Isolated nodes so to traverse these nodes we have to put back or forward ages (not sure about this). See this [answer][2] you will get a clear picture. [1]: https://i.sstatic.net/IYgiB.png [2]: https://cs.stackexchange.com/questions/11438/why-does-dfs-only-yield-tree-and-back-edges-on-undirected-connected-graphs?rq=1