Find cycle/loop in the graph – method 1

Find below algorithm to find loop/cycle in graph, Here in each stage I am checking for child node visited state. If any of the parent node has more than one child with visited state then it means graph has a loop. We can also use Disjoint Set (Or Union-Find) which I’ll show you in next article.

Algorithm to find cycle in graph

Find graph utility here
Find graph utility