(self, *objects)
Find the sets containing the objects and merge them all.
Find the sets containing the objects and merge them all.
Find the sets containing the objects and merge them all .
def union(self, *objects):
        """Find the sets containing the objects and merge them all."""
        roots = [self[x] for x in objects]
        heaviest = max((self.weights[r], r) for r in roots)[1]
        for r in roots:
            if r != heaviest:
                self.weights[heaviest] += self.weights[r]
                self.parents[r] = heaviest
def union ( self , * objects ) : roots = [ self [ x ] for x in objects ] heaviest = max ( ( self . weights [ r ] , r ) for r in roots ) [ 1 ] for r in roots : if r != heaviest : self . weights [ heaviest ] += self . weights [ r ] self . parents [ r ] = heaviest