Rename all nodes in a graph to a sequence of numbers

Would this work?

http://networkx.github.io/documentation/latest/reference/generated/networkx.relabel.convert_node_labels_to_integers.html

import networkx as nx
G = nx.Graph()
G.add_node(1)
G.add_nodes_from('spam')
print G.nodes()

returns:

['a', 1, 's', 'm', 'p']

now:

start = 1
G = nx.convert_node_labels_to_integers(G,first_label=start)
print G.nodes()

returns:

[1, 2, 3, 4, 5]

In case your interest is still relevant, there is networkx.relabel_nodes() which takes a mapping dictionary.