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 for a Vec of Vecs of node weights we should have it return of an iterator of Vecs of node ids. This would be more flexible and performant for rust space users and for the python side of rustworkx we can just collect the iterator to a pylist (for backwards compatibility).
The
layers()
function is only exposed via a Python interface currently:https://github.com/Qiskit/rustworkx/blob/ab93329be6d8aaccb6c090f4b3ab6f9540ee8114/src/dag_algo/mod.rs#L227-L345
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
for a Vec of Vecs of node weights we should have it return of an iterator of Vecs of node ids. This would be more flexible and performant for rust space users and for the python side of rustworkx we can just collect the iterator to a pylist (for backwards compatibility).