'''Performs depth-first search with cycle detection for a directed (or undirected) unweighted graph represented as edgelist format.