I'm creating graph using networkx library and also storing that graph as graphml file (using write_graphml function of networkx library).
In my graph, each node have 8 different attribute and edge have one attribute. (Total no of attributes = 9)
Problem is, each time I run code and generate graphml file. Graphml file structure have different ordering of node attributes.
For example, in first run,
<key attr.name="key" attr.type="long" for="edge" id="d8" />
<key attr.name="lemma" attr.type="string" for="node" id="d7" />
<key attr.name="cng" attr.type="long" for="node" id="d6" />
<key attr.name="chunk_no" attr.type="long" for="node" id="d5" />
<key attr.name="pre_verb" attr.type="string" for="node" id="d4" />
<key attr.name="length_word" attr.type="long" for="node" id="d3" />
<key attr.name="morph" attr.type="string" for="node" id="d2" />
<key attr.name="word" attr.type="string" for="node" id="d1" />
<key attr.name="position" attr.type="long" for="node" id="d0" />
<graph edgedefault="directed">
On second Run,
<key attr.name="key" attr.type="long" for="edge" id="d8" />
<key attr.name="length_word" attr.type="long" for="node" id="d7" />
<key attr.name="chunk_no" attr.type="long" for="node" id="d6" />
<key attr.name="cng" attr.type="long" for="node" id="d5" />
<key attr.name="position" attr.type="long" for="node" id="d4" />
<key attr.name="pre_verb" attr.type="string" for="node" id="d3" />
<key attr.name="lemma" attr.type="string" for="node" id="d2" />
<key attr.name="morph" attr.type="string" for="node" id="d1" />
<key attr.name="word" attr.type="string" for="node" id="d0" />
<graph edgedefault="directed">
As we can see, In first run of code I got id="d0" for node attribute "position" and for second run I got id="d0" for node attribute "word".
Can we make ordering of node attribute consistent in any way ?