code: def freeze(G):
      
      G.add_node = frozen
      G.add_nodes_from = frozen
      G.remove_node = frozen
      G.remove_nodes_from = frozen
      G.add_edge = frozen
      G.add_edges_from = frozen
      G.remove_edge = frozen
      G.remove_edges_from = frozen
      G.clear = frozen
      G.frozen = True
      return G
docs: Modify graph to prevent further change by adding or removing nodes or edges.
  
          Node and edge data can still be modified.
  
          Parameters
          ----------
  
              G : graph
                  A NetworkX graph
  
  
          Notes
          -----
          To "unfreeze" a graph you must make a copy by creating a new graph object.
  
          See Also
          --------
          is_frozen