def local_graph_weight_sum(G, list_of_coord):
    """
    This script computes the local weight of a graph inside a member of the partition whose location is given by
    list_of_coord.
    Edges with both endpoints included in the element of the part. contribute totally to the overall weight
    Edges with exactly one endpoint included in the elem of the part. contribute half weight to the overall weight
    Edges with no endpoints in the elem. don't contribute to the sum.
    :param G: Graph.
    :param list_of_coord: coordinates of an element of the partition.
    :return:
        localW: local weight of G.
    """
    localW=0
    x1_cell=list_of_coord[0][0]
    x2_cell=list_of_coord[3][0]
    y1_cell=list_of_coord[0][1]
    y2_cell=list_of_coord[1][1]
    for edge in G.edges():
        v=edge[0]
        w=edge[1]
        vx=G.nodes[v]['pos'][0]
        vy=G.nodes[v]['pos'][1]
        wx=G.nodes[w]['pos'][0]
        wy=G.nodes[w]['pos'][1]
        bool_membership=[ x1_cell <= vx <= x2_cell and  y1_cell <= vy <= y2_cell,
                         x1_cell <= wx <= x2_cell and  y1_cell <= wy <= y2_cell ]

        w_edge = G.edges[v,w]['weight']
        delta_edge=1/2*sum(bool_membership)
        localW=localW+delta_edge*w_edge
    return localW