This is O(n^2) -- you're rebuilding the nodes list for each node and you're copying the whole graph at the start as well.

Instead make the look do the following:

`for node_index, node in enumerate(graph.nodes_iter()):
    mapping_to_int[node]= node_index
    mapping_to_orig[node_index] = node`