find cycle in undirected graph