nodes: 0, module; 1, function_definition; 2, function_name:simplify_graph; 3, parameters; 4, block; 5, identifier:graph; 6, expression_statement; 7, import_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, expression_statement; 15, expression_statement; 16, expression_statement; 17, return_statement; 18, comment:"""
      strips out everything but connectivity
  
      Args:
          graph (nx.Graph):
  
      Returns:
          nx.Graph: new_graph
  
      CommandLine:
          python3 -m utool.util_graph simplify_graph --show
          python2 -m utool.util_graph simplify_graph --show
  
          python2 -c "import networkx as nx; print(nx.__version__)"
          python3 -c "import networkx as nx; print(nx.__version__)"
  
      Example:
          >>> # ENABLE_DOCTEST
          >>> from utool.util_graph import *  # NOQA
          >>> import utool as ut
          >>> graph = nx.DiGraph([('a', 'b'), ('a', 'c'), ('a', 'e'),
  
          >>>                     ('a', 'd'), ('b', 'd'), ('c', 'e'),
          >>>                     ('d', 'e'), ('c', 'e'), ('c', 'd')])
          >>> new_graph = simplify_graph(graph)
          >>> result = ut.repr2(list(new_graph.edges()))
          >>> #adj_list = sorted(list(nx.generate_adjlist(new_graph)))
          >>> #result = ut.repr2(adj_list)
          >>> print(result)
          [(0, 1), (0, 2), (0, 3), (0, 4), (1, 3), (2, 3), (2, 4), (3, 4)]
  
          ['0 1 2 3 4', '1 3 4', '2 4', '3', '4 3']
      """; 19, aliased_import; 20, assignment; 21, assignment; 22, call; 23, block; 24, else_clause; 25, assignment; 26, call; 27, block; 28, else_clause; 29, assignment; 30, assignment; 31, call; 32, call; 33, identifier:new_graph; 34, dotted_name; 35, identifier:ut; 36, identifier:nodes; 37, call; 38, identifier:node_lookup; 39, call; 40, attribute; 41, argument_list; 42, expression_statement; 43, block; 44, identifier:new_nodes; 45, call; 46, attribute; 47, argument_list; 48, expression_statement; 49, block; 50, identifier:cls; 51, attribute; 52, identifier:new_graph; 53, call; 54, attribute; 55, argument_list; 56, attribute; 57, argument_list; 58, identifier:utool; 59, identifier:sorted; 60, argument_list; 61, attribute; 62, argument_list; 63, identifier:graph; 64, identifier:is_multigraph; 65, assignment; 66, expression_statement; 67, attribute; 68, argument_list; 69, identifier:graph; 70, identifier:is_multigraph; 71, assignment; 72, expression_statement; 73, identifier:graph; 74, identifier:__class__; 75, identifier:cls; 76, argument_list; 77, identifier:new_graph; 78, identifier:add_nodes_from; 79, identifier:new_nodes; 80, identifier:new_graph; 81, identifier:add_edges_from; 82, identifier:new_edges; 83, call; 84, identifier:ut; 85, identifier:make_index_lookup; 86, identifier:nodes; 87, identifier:edges; 88, call; 89, assignment; 90, identifier:ut; 91, identifier:take; 92, identifier:node_lookup; 93, identifier:nodes; 94, identifier:new_edges; 95, list_comprehension; 96, assignment; 97, identifier:list; 98, argument_list; 99, identifier:list; 100, argument_list; 101, identifier:edges; 102, call; 103, tuple; 104, for_in_clause; 105, identifier:new_edges; 106, list_comprehension; 107, call; 108, call; 109, identifier:list; 110, argument_list; 111, subscript; 112, subscript; 113, subscript; 114, dictionary; 115, identifier:e; 116, identifier:edges; 117, tuple; 118, for_in_clause; 119, attribute; 120, argument_list; 121, attribute; 122, argument_list; 123, call; 124, identifier:node_lookup; 125, subscript; 126, identifier:node_lookup; 127, subscript; 128, identifier:e; 129, integer:2; 130, subscript; 131, subscript; 132, identifier:e; 133, identifier:edges; 134, identifier:graph; 135, identifier:nodes; 136, identifier:graph; 137, identifier:edges; 138, keyword_argument; 139, attribute; 140, argument_list; 141, identifier:e; 142, integer:0; 143, identifier:e; 144, integer:1; 145, identifier:node_lookup; 146, subscript; 147, identifier:node_lookup; 148, subscript; 149, identifier:keys; 150, True; 151, identifier:graph; 152, identifier:edges; 153, identifier:e; 154, integer:0; 155, identifier:e; 156, integer:1
code: def simplify_graph(graph):
      """
      strips out everything but connectivity
  
      Args:
          graph (nx.Graph):
  
      Returns:
          nx.Graph: new_graph
  
      CommandLine:
          python3 -m utool.util_graph simplify_graph --show
          python2 -m utool.util_graph simplify_graph --show
  
          python2 -c "import networkx as nx; print(nx.__version__)"
          python3 -c "import networkx as nx; print(nx.__version__)"
  
      Example:
          >>> # ENABLE_DOCTEST
          >>> from utool.util_graph import *  # NOQA
          >>> import utool as ut
          >>> graph = nx.DiGraph([('a', 'b'), ('a', 'c'), ('a', 'e'),
  
          >>>                     ('a', 'd'), ('b', 'd'), ('c', 'e'),
          >>>                     ('d', 'e'), ('c', 'e'), ('c', 'd')])
          >>> new_graph = simplify_graph(graph)
          >>> result = ut.repr2(list(new_graph.edges()))
          >>> #adj_list = sorted(list(nx.generate_adjlist(new_graph)))
          >>> #result = ut.repr2(adj_list)
          >>> print(result)
          [(0, 1), (0, 2), (0, 3), (0, 4), (1, 3), (2, 3), (2, 4), (3, 4)]
  
          ['0 1 2 3 4', '1 3 4', '2 4', '3', '4 3']
      """
      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