Given edges and vertices, how do we decide which vertices form a polygon?

Hi! To all, here is what I meant.

Say I only have edges, and vertices(ids, coordinates), it’s very easy to tell by eye that 2-3-10-9 is a polyshape that can form a polygon(cycle), 0-11-9-2 can form a polygon, 0-2-6-5, 6-4-1-7, and so on.

How do we automate this process in python code?