add requirement of directed graph for cycle testing and topological sort.