• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / rustworkx / 15708458581
94%

Build:
DEFAULT BRANCH: main
Ran 17 Jun 2025 01:34PM UTC
Jobs 1
Files 109
Run time 27min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

17 Jun 2025 01:03PM UTC coverage: 95.201% (-0.08%) from 95.283%
15708458581

push

github

web-flow
Fix #840: Add GraphML serializer (#1464)

* Fix #840: Add GraphML serializer

This commit adds a GraphML serializer:

```python
def write_graphml(
    graphs: list[PyGraph | PyDiGraph],
    keys: list[tuple[str, Domain, str, Type, Any]],
    path: str,
    /,
    compression: str | None = ...,
) -> None: ...
```

`keys` is a list of tuples: id, domain, name of the key, type, and
default value. This commit also introduces the
`read_graphml_with_keys` function, which returns the key definitions
in the same format, along with the list of parsed graphs.

The implementation preserves the ids of graphs, nodes, and edges when
possible. If some ids conflict, fresh ids are generated in the written
GraphML file. The `read_graphml` function has also been updated to
store the graph id in the graph attributes, just like node and edge
ids are stored in the corresponding attributes.

The `write_graphml` function supports gzip compression, as does
`read_graphml`.

Note that the JSON node-link serializer (the other part of #840) was
already implemented in #1091.

Compared to #1462:

- Keys are passed explicitly instead of being inferred (which allows
to use the types `float` and `int`, and to use default values);

- Attributes for graphs, nodes, and edges are taken from the weight of elements, instead of relying on callbacks. This allows write_graphml to act as a proper reciprocal of read_graphml. Round-trip tests have been added.

- IDs are taken from attributes when possible, instead of being generated from indices.

- Multiple graphs can be written to the same file.

- Gzip compression is supported.

- Tests have been added.

Regarding @IvanIsCoding's
comment (https://github.com/Qiskit/rustworkx/pull/1462#issuecomment-2951935390),
about using https://github.com/jonasbb/petgraph-graphml:

- Rustworkx's `graphml.rs` introduces an internal `Graph` data
structure, which is used for `read_graphml`. It is natural to
have `write_graphml` rely on the same data structure.

... (continued)

447 of 487 new or added lines in 2 files covered. (91.79%)

19383 of 20360 relevant lines covered (95.2%)

1034380.47 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
40
93.53
-2.32% src/graphml.rs
Jobs
ID Job ID Ran Files Coverage
1 15708458581.1 17 Jun 2025 01:34PM UTC 109
95.2
GitHub Action Run
Source Files on build 15708458581
  • Tree
  • List 109
  • Changed 2
  • Source Changed 2
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #15708458581
  • fb530db6 on github
  • Prev Build on gh-readonly-queue/main/pr-1465-359757202a50e48c3745401ee879e8d6179c96c7 (#15670334722)
  • Next Build on main (#15799699615)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc