How to rename all nodes in a graph?
If you want to change the node ids, you can use the function relabel_nodes
:
renaming_mapping = {}
for node, data in graph.nodes(data=True):
if condition:
renaming_mapping[node] = "new individual name"
graph_with_new_names = nx.relabel_nodes(graph, renaming_mapping)