def invert_dict_mapping_all(mapping_dictionary):
    """
    Args:
        mapping_dictionary: mapping from keys to values which is not necessarily
            injective, e.g., node_id to community_id mapping

    Returns: inverted mapping with unique values as keys and lists of former keys as
        values, e.g., community_id to node_id mapping

    """
    inverted = {v: [] for v in mapping_dictionary.values()}
    for k, v in mapping_dictionary.items():
        inverted[v].append(k)
    return inverted