I was wondering if there's an efficient way to find all cycles of a graph of length <= 5 in a directed graph. I've read up on Johnson's algorithm that takes O((|V|+|E|)(c+1))
time to find all cycles of any length (where c is the total number of cycles), but that might be overkill considering I only need cycles of length at most 5. Is there a more efficient way to do this? The input graph can be pretty large with |V| = 600
and Johnson's algorithm seems to take too long!
P.S: I found this StackOverflow link too, but the answer has 0 upvotes, so I'm not quite sure.