How to find parent vertex?

Hi, I am finding it difficult to solve this problem, can anyone tell me how to solve this problem, or which algo to use? I understood the problem, and i think we need to find the vertex which connects all other vertex, but how to do this, i tried solving this by counting the no the no of in vertices, ie if no of in vertices == 0, it means it is parent vertex, but i got WA. submission