@uni_in_place_transformation<EOL>def expand_periphery(universe: BELGraph,<EOL>graph: BELGraph,<EOL>node_predicates: NodePredicates = None,<EOL>edge_predicates: EdgePredicates = None,<EOL>threshold: int = <NUM_LIT:2>,<EOL>) -> None:
nd = get_subgraph_peripheral_nodes(universe, graph, node_predicates=node_predicates,<EOL>edge_predicates=edge_predicates)<EOL>for node, dd in nd.items():<EOL><INDENT>pred_d = dd['<STR_LIT>']<EOL>succ_d = dd['<STR_LIT>']<EOL>in_subgraph_connections = set(pred_d) | set(succ_d)<EOL>if threshold > len(in_subgraph_connections):<EOL><INDENT>continue<EOL><DEDENT>graph.add_node(node, attr_dict=universe[node])<EOL>for u, edges in pred_d.items():<EOL><INDENT>for k, d in edges:<EOL><INDENT>safe_add_edge(graph, u, node, k, d)<EOL><DEDENT><DEDENT>for v, edges in succ_d.items():<EOL><INDENT>for k, d in edges:<EOL><INDENT>safe_add_edge(graph, node, v, k, d)<EOL><DEDENT><DEDENT><DEDENT>
Iterates over all possible edges, peripheral to a given subgraph, that could be added from the given graph.
    Edges could be added if they go to nodes that are involved in relationships that occur with more than the
    threshold (default 2) number of nodes in the subgraph.

    :param universe: The universe of BEL knowledge
    :param graph: The (sub)graph to expand
    :param threshold: Minimum frequency of betweenness occurrence to add a gap node

    A reasonable edge filter to use is :func:`pybel_tools.filters.keep_causal_edges` because this function can allow
    for huge expansions if there happen to be hub nodes.