(merges, n=None)
return [x for x in tuple_repr if x is not None]
Converts the matrix representation of a clustering to a tuple
        representation.

        @param merges: the matrix representation of the clustering
        @return: the tuple representation of the clustering
Converts the matrix representation of a clustering to a tuple
        representation.
Converts the matrix representation of a clustering to a tuple representation .
def _convert_matrix_to_tuple_repr(merges, n=None):
        """Converts the matrix representation of a clustering to a tuple
        representation.

        @param merges: the matrix representation of the clustering
        @return: the tuple representation of the clustering
        """
        if n is None:
            n = len(merges) + 1
        tuple_repr = range(n)
        idxs = range(n)
        for rowidx, row in enumerate(merges):
            i, j = row
            try:
                idxi, idxj = idxs[i], idxs[j]
                tuple_repr[idxi] = (tuple_repr[idxi], tuple_repr[idxj])
                tuple_repr[idxj] = None
            except IndexError:
                raise ValueError(
                    "malformed matrix, subgroup referenced "
                    + "before being created in step %d" % rowidx
                )
            idxs.append(j)
        return [x for x in tuple_repr if x is not None]
def _convert_matrix_to_tuple_repr ( merges , n = None ) : if n is None : n = len ( merges ) + 1 tuple_repr = range ( n ) idxs = range ( n ) for rowidx , row in enumerate ( merges ) : i , j = row try : idxi , idxj = idxs [ i ] , idxs [ j ] tuple_repr [ idxi ] = ( tuple_repr [ idxi ] , tuple_repr [ idxj ] ) tuple_repr [ idxj ] = None except IndexError : raise ValueError ( "malformed matrix, subgroup referenced " + "before being created in step %d" % rowidx ) idxs . append ( j ) return [ x for x in tuple_repr if x is not None ]