I have an algorithm to suggest, not tested yet, but seems to work on paper:
Here, a polygon is a set of edges and vertices (or nodes) all with the same id.
Each node can be marked as "visited", all are "non visited" by default.
Each Edge can have a value (integer), 0 by default.
Subtlety: Consider only the convex envelope of each polygon.
Note that the complexity is roughly quadratic, as you have to compare (a bit less than) each node with each other, then go through each edge once. The last step can be parallelized (the first one too but you may visit twice the same node).
Tell me if you have any trouble implementing it, or if you see any flaws.