Amazon interview question

Write a function to detect if a graph is cyclic.