Thus, to determine, in linear time, if a digraph has a cycle it suffices to do a DFS and check for the presence of back edges. If you find a back edge, it is easy to find a cycle containing it (using the tree edges). If there is no back edge, then there is no cycle. |