We are given a simple un-directed graph G=(V,E) and a subset S of V.
We are told that all the vertices of S are making a simple cycle (of length |S|) in G.
Now, we are to find that exact cycle (or its any cyclic shift) (a sequence of all vertices of S). How can we find it ? Any approach ?
I tried DFS/BFS but it does not seem working fine.
For example: if we have 4 vertices A, B, C, D in G and edges are (A,C), (A,D), (B,C), (B,D). Let given S= {A, B, C, D}
Then our answer should be ADBCA (or BCADB or its any cyclic shift).