def to_mlab_linkage(Z):
    Z = np.asarray(Z, order='c', dtype=np.double)
    Zs = Z.shape
    if len(Zs) == 0 or (len(Zs) == 1 and Zs[0] == 0):
        return Z.copy()
    is_valid_linkage(Z, throw=True, name='Z')

    ZP = Z[:, 0:3].copy()
    ZP[:, 0:2] += 1.0

    return ZP
Converts a linkage matrix to a MATLAB(TM) compatible one.
dataset/ETHPy150Open scipy/scipy/scipy/cluster/hierarchy.py/to_mlab_linkage