Detecting Cycles In Directed Graphs