def make_reverse_dict(in_dict, warn=True):
    """ Build a reverse dictionary from a cluster dictionary

    Parameters
    ----------
    in_dict : dict(int:[int,])    
        A dictionary of clusters.  Each cluster is a source index and
        the list of other source in the cluster.

    Returns
    -------
    out_dict : dict(int:int)    
       A single valued dictionary pointing from source index to
       cluster key for each source in a cluster.  Note that the key
       does not point to itself.
    """
    out_dict = {}
    for k, v in in_dict.items():
        for vv in v:
            if vv in out_dict:
                if warn:
                    print("Dictionary collision %i" % vv)
            out_dict[vv] = k
    return out_dict
Build a reverse dictionary from a cluster dictionary

    Parameters
    ----------
    in_dict : dict(int:[int,])    
        A dictionary of clusters.  Each cluster is a source index and
        the list of other source in the cluster.

    Returns
    -------
    out_dict : dict(int:int)    
       A single valued dictionary pointing from source index to
       cluster key for each source in a cluster.  Note that the key
       does not point to itself.