import random


def remove_nodes_random(G, remove_proportion, random_seed=None):
    """
    Remove some proportion of nodes (and attached edges) randomly.

    Parameters
    ----------
    G : NetworkX Graph structure
        Graph of the network.
    remove_proportion : float between 0 and 1
        proportion of nodes to be removed
    random_seed : int or None
        Random seed for removal. If None, the results will be different
        each time the functions is used
    
    Returns
    -------
    NetworkX Graph structure
    """

    random.seed(random_seed)
    G_new = G.copy()
    delete_nodes = random.sample(list(G.nodes), int(remove_proportion*len(G.nodes)))
    G_new.remove_nodes_from(delete_nodes)
    return G_new