Algorithm to count number of cycles in a directed Graph ..?

  algorithm, c++, data-structures, graph

This question has been asked before on StackOverflow but I don’t find any genuine solution so I am posting it again.

I came across a problem recently where it was asked to count the number of cycles in a directed Graph ?
I did it using DFS but it didn’t pass all the cases. I want to know how we can solve this problem ?

Example,
Example 1
Example 2

Source: Windows Questions C++

LEAVE A COMMENT