This is the problem:
I have n points (p1, p2, p3, .. pn), each of them can connect to any other with a determined cost x.
Each point belongs to one of a set of p
Hope this is clear.
This solution is not particularly efficient, but clearly polynomial.