I have a list of sets,
[set([0, 1, 2]),
set([3, 2]),
set([4, 1]),
set([5, 6]),
set([7, 8])]
and I need to unite all those that are intersecting, so that the result is the following:
[set([0, 1, 2, 3, 4]),
set([5, 6]),
set([7, 8])]
What's the most elegant way to do this? I can't think of anything better than n*n cycle.