code: def simplify_graph(graph):
      import utool as ut
      nodes = sorted(list(graph.nodes()))
      node_lookup = ut.make_index_lookup(nodes)
      if graph.is_multigraph():
          edges = list(graph.edges(keys=True))
      else:
          edges = list(graph.edges())
      new_nodes = ut.take(node_lookup, nodes)
      if graph.is_multigraph():
          new_edges = [(node_lookup[e[0]], node_lookup[e[1]], e[2], {}) for e in edges]
      else:
          new_edges = [(node_lookup[e[0]], node_lookup[e[1]]) for e in edges]
      cls = graph.__class__
      new_graph = cls()
      new_graph.add_nodes_from(new_nodes)
      new_graph.add_edges_from(new_edges)
      return new_graph