Depth First Search and Cycle test.