Code for Johnson's algorithm to find directed cycles in a directed graph.