def _list2dict(list_partitions, number_nodes):
    """ Rearranges the `list_partitions' into a list of dictionaries.

    Parameters
    ----------
    list_partitions : list
        List of (number_nodes -1) lists got using `girvan_newman_partitions`.
        Each list contains the information about the partition of that level.

    number_nodes : integer
        number of nodes in the graph.

    Returns
    -------
    list
        List of dictionaries. The list has length (number_of_nodes - 1).
        The dictionary ith contains the information about the partition of the
        level ith and it has this form:
            - key: integer, label of the node;
            - value: integer, label of the community the node belongs to.
    """
    list_of_dict = [0]*(number_nodes-1)
    c = 0

    for part in list_partitions:
        # Transform to a dict
        tmp_dict = {}
        for i, part_i in enumerate(part):
            for j in part_i:
                tmp_dict[j] = i
        list_of_dict[c] = tmp_dict
        c += 1

    return list_of_dict