(cluster)
return depths
Return a dictionary mapping :class:`Tree` instances to their depth.

    :param Tree cluster: Root cluster
    :rtype: class:`dict`
Return a dictionary mapping :class:`Tree` instances to their depth.
Return a dictionary mapping : class : Tree instances to their depth .
def cluster_depths(cluster):
    """
    Return a dictionary mapping :class:`Tree` instances to their depth.

    :param Tree cluster: Root cluster
    :rtype: class:`dict`

    """
    depths = {}
    depths[cluster] = 0
    for cluster in preorder(cluster):
        cl_depth = depths[cluster]
        depths.update(dict.fromkeys(cluster.branches, cl_depth + 1))
    return depths
def cluster_depths ( cluster ) : depths = { } depths [ cluster ] = 0 for cluster in preorder ( cluster ) : cl_depth = depths [ cluster ] depths . update ( dict . fromkeys ( cluster . branches , cl_depth + 1 ) ) return depths