Finding a directed cycle