graph theory

Problem link : https://www.codechef.com/problems/SEAGRP

I applied algorithm for which i am not able to find the test case for which my algo is failing .Can anybody help?

Algorithm :

  1. consider all edges , for each edge there are three things related- (vertex1),(vertex2) and (sum=degree(vertex1)+degree(vertex2))

  2. Now sort the edges based on the sum.

  3. Pick the edges sorted wise and check if degree of both vertices which are associated with this edge is greater than 1 then remove this edge else don’t remove.

4.Now check if degree of all vertices is 1 then Yes else No.

//