Amazon Interview Question

Write a function to detect if a graph is cyclic.