GML#
Node ids#
A graph loaded from GML keeps each node’s id as the external id of its vertex,
as in MØD. The vertices themselves are renumbered, since a graph is stored in
canonical order, so look a vertex up by the id it was given with
molfoundry.Graph.getVertexFromExternalId():
g = mf.Graph.fromGMLString("""graph [
node [ id 10 label "O" ] node [ id 20 label "H" ] node [ id 30 label "C" ]
edge [ source 10 target 20 label "-" ] edge [ source 10 target 30 label "-" ]
]""")
v = g.getVertexFromExternalId(30)
print(v.id, v.stringLabel, v.externalId)
0 C 30
Graphs a derivation creates have no external ids. Depictions omit them unless
molfoundry.GraphPrinter.withExternalId is set:
printer = mf.GraphPrinter()
printer.withExternalId = True
g.print(printer)