depth first search acyclic and cyclic tested