MathWorks interview question

Detect cycle in a graph