Qiskit / rustworkx

A high performance Python graph library implemented in Rust.
https://www.rustworkx.org
Apache License 2.0
1.03k stars 145 forks source link

Support for "long" attribute type in GraphML #1140

Closed jamesdbaker closed 5 months ago

jamesdbaker commented 5 months ago

The GraphML spec (http://graphml.graphdrawing.org/xmlns/1.0rc/graphml-attributes.xsd) states that the allowed attribute types are:

However, loading a GraphML file with an attribute type of long (e.g. <key id="d0" for="edge" attr.name="weight" attr.type="long"/> fails with:

Exception: Invalid 'attr.type' attribute in key with id=d0.

The issue seems to be that the Type enum doesn't have a Long type. Could this be added?

https://github.com/Qiskit/rustworkx/blob/af0d36caa3d3b3488bdb0297b2014e5f3154f994/src/graphml.rs#L118-L124

IvanIsCoding commented 5 months ago

Yeah we should handle this case. In the meantime, can you try swapping long for int? I don’t think it will overflow with the current implementation

IvanIsCoding commented 5 months ago

Indeed we will probably map them to isize https://github.com/Qiskit/rustworkx/blob/af0d36caa3d3b3488bdb0297b2014e5f3154f994/src/graphml.rs#L129 likes we already do with int