detect cycle in a directed graph, good