def _rename_node(graph, node_id, copy_id):
 graph._add_node_silent(copy_id)
 graph.node[copy_id] = graph.node[node_id]
 for nbr in graph.neighbors(node_id):
  wt = graph[node_id][nbr]['weight']
  graph.add_edge(nbr, copy_id, {'weight': wt})
 graph.remove_node(node_id)

def _rename_node ( graph , node_id , copy_id ) : graph . _add_node_silent ( copy_id ) graph . node [ copy_id ] = graph . node [ node_id ] for nbr in graph . neighbors ( node_id ) : wt = graph [ node_id ] [ nbr ] [ 'weight' ] graph . add_edge ( nbr , copy_id , { 'weight' : wt } ) graph . remove_node ( node_id )
rename node_id in graph to copy_id .