vertex name when exporting to graphml
The following code
import graph_tool as gt
graph = gt.Graph(directed=False)
graph.add_edge(0, 1)
graph.save('graph.gml')
graph.save('graph.graphml')
creates the following files:
graph.gml
:
graph [
node [
id 0
]
node [
id 1
]
edge [
id 0
source 0
target 1
]
]
graph.graphml
:
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<!-- property keys -->
<graph id="G" edgedefault="undirected" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst">
<!-- graph properties -->
<!-- vertices -->
<node id="n0">
</node>
<node id="n1">
</node>
<!-- edges -->
<edge id="e0" source="n0" target="n1">
</edge>
</graph>
</graphml>
While vertices and edges are named 0
and 1
in gml, they are named n0
, n1
, e0
in graphml.
I think that it would be better to use a single number everywhere for consistency.
Consistency across graph-tool, and with other tools (NetworkX set numeric ids by default).