Code for cycle detection in directed graph.
Code for topological sort.
Code for strongly connected components.