I am looking for the solution to a problem where Perl script could detect all the cyclic nodes in a directed graph? For example, I have following graph:
A<-N<-G<-L<- A<-B<-C<-D<-E<-F<-A Be a Graph with cyclic edges.
use strict;
use warnings;
my @graphNodes=(A,N,G,L, A,B,C,D,E,F,A );
my depEdges= dependBy(); #Let dependBy be hypothetical function that return immediate dependents.
In rest of code, I need logical help to collect all the nodes which are involved in cyclic dependencies. For instance, in my case, on node 'A', there are cyclic dependencies. How can I recursively implement dependBy function to find cyclic edges or dependencies?