def get_scc_from_tuples(constraints):
    """Given set of equivalences, return map of transitive equivalence classes.

    >> constraints = [(1,2), (2,3)]
    >> get_scc_from_tuples(constraints)
    {
        1: (1, 2, 3),
        2: (1, 2, 3),
        3: (1, 2, 3),
    }
    """
    classes = unionfind.classes(constraints)
    return dict((x, tuple(c)) for x, c in classes.iteritems())
def get_scc_from_tuples ( constraints ) : classes = unionfind . classes ( constraints ) return dict ( ( x , tuple ( c ) ) for x , c in classes . iteritems ( ) )
Given set of equivalences, return map of transitive equivalence classes.

    >> constraints = [(1,2), (2,3)]
    >> get_scc_from_tuples(constraints)
    {
        1: (1, 2, 3),
        2: (1, 2, 3),
        3: (1, 2, 3),
    }