Given an undirected Graph G(V,E) and provided we can remove edges from the graph. I have to tell is it possible to partition the graph so that each component contains exactly 2 vertices with one edge.
My Approach is this: as each component contains exactly 2 vertices so we can rule out the possibility of Graph containing odd vertices. Further more figuring out whether or not the graph contains a perfect matching can tell us the answer...
Am I going on the right path, or there's some other easy way to find the same. I want the algorithm which I can implement.
The algorithm you want to use is described here: Edmond's matching algorithm This runs in $|V(G)|^4$. I think this algorithm is not that hard (to understand and implement) and easier algorithms will probably have even worse (a lot worse) runtimes. The problem is that you can't tell whether a matching exists or not without finding one (usually). Of course there are cases where it is trivial a matching exists, like the complete graph and 'almost' complete graphs.