detect cyclic in undirected graph, good