code: def subgraph_from_edges(G, edge_list, ref_back=True):
      sub_nodes = list({y for x in edge_list for y in x[0:2]})
      multi_edge_list = [edge[0:3] for edge in edge_list]
      if ref_back:
          G_sub = G.subgraph(sub_nodes)
          for edge in G_sub.edges(keys=True):
              if edge not in multi_edge_list:
                  G_sub.remove_edge(*edge)
      else:
          G_sub = G.subgraph(sub_nodes).copy()
          for edge in G_sub.edges(keys=True):
              if edge not in multi_edge_list:
                  G_sub.remove_edge(*edge)
      return G_sub