This question appears to be very Googleable. For example, youYou may be interested in the algorithm presented in this paper:
Finding all the elementary circuits of a directed graph. Donald B. Johnson. SIAM J. COMPUT. Vol. 4, No. 1, March 1975
Abstract. An algorithm is presented which finds all the elementary circuits-of a directed graph in time bounded by
O((n + e)(c + 1))
and space bounded byO(n + e)
, where there aren
vertices,e
edges andc
elementary circuits in the graph. The algorithm resembles algorithms by Tiernan and Tarjan, but is faster because it considers each edge at most twice between any one circuit and the next in the output sequence.
The paper contains a complete algorithm.