I'm writing scripts that read in graphs from gexf format, add nodes and edges, and write them back to gexf. My problem is that write_gexf is giving the edges that I add edge id's that already existed in the edges that I read in.
For instance, suppose I read in a graph G
with a single edge.
>>> import networkx as nx
>>> G = nx.read_gexf('first.gexf')
>>> G.edges(data=True)
[(0,1, {'id': '0'})]
and then I add an edge and write the graph to gexf:
>>> G.add_edge(1,2)
>>> G.edges(data=True)
[('0','1', {'id': '0'}), (1,2, {})]
>>> nx.write_gexf(G,'second.gexf')
Now if I read in 'second.gexf' I get two edges with 'id' equal '0'.
>>> H = nx.read_gexf('second.gexf')
>>> H.edges(data=True)
[('0','1', {'id': '0'}), ('1','2', {'id': '0'})]
Is there a way to avoid this?