@transformation<EOL>def random_by_edges(graph: BELGraph, percentage: Optional[float] = None) -> BELGraph:
percentage = percentage or <NUM_LIT><EOL>assert <NUM_LIT:0> < percentage <= <NUM_LIT:1><EOL>edges = graph.edges(keys=True)<EOL>n = int(graph.number_of_edges() * percentage)<EOL>subedges = random.sample(edges, n)<EOL>rv = graph.fresh_copy()<EOL>for u, v, k in subedges:<EOL><INDENT>safe_add_edge(rv, u, v, k, graph[u][v][k])<EOL><DEDENT>update_node_helper(graph, rv)<EOL>return rv<EOL>
Get a random graph by keeping a certain percentage of original edges.

    :param graph: A BEL graph
    :param percentage: What percentage of eges to take