import random


def create_networkcopy_with_missing_nodes(graph, list_missing_percentages):
    """
    Function to generate copies of a graph with varying proportion p of missing nodes given by a list P.
    The function returns a list of graphs, where each graph is a network copy with p% of the nodes missing.
        graph = true network
        list_missing_percentages = list that contains different values for p
    """
    lst = []
    for p in list_missing_percentages:
        # Generate copy of the graph, randomly remove p% of the nodes from the set and append to list
        G = graph.copy()
        G.remove_nodes_from(random.sample(list(G.nodes()), int(len(graph.nodes()) * p)))
        lst.append((G, p))
    return lst