Qiskit / rustworkx

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

Move `lexicographical_topological_sort()` functionality to rustworkx-core #1165

Closed mtreinish closed 4 months ago

mtreinish commented 5 months ago

The lexicographical_topological_sort() function is only exposed via a Python interface currently:

https://github.com/Qiskit/rustworkx/blob/ab93329be6d8aaccb6c090f4b3ab6f9540ee8114/src/dag_algo/mod.rs#L347-L485

We should port it to rustworkx-core, so that rust users can leverage the function.

One tweak that probably makes sense for the rustworkx-core version is that instead of returning a PyList (realistically a Vec<N>) of node weights we should have it return of an iterator of node ids. This would be more flexible and performant for rust space users and for the python side of rustworkx we can just consume the iterator to build the pylist return there (for api compatibility).

hunterkemeny commented 5 months ago

Self-assigning this.

mtreinish commented 4 months ago

There was a bit more urgency behind this as I had a few direct requests to have this implemented in rustworkx-core. So I hope you don't mind that I pushed up a PR to implement this here: #1197.