I would like to be able to get a "reverse" topological ordering from lexicographical_topological_sort and TopologicalSorter in the sense of "a topological order if all the edges reversed direction" - it'd be helpful on Qiskit in a few places where we want to find final operations. For our purposes, we don't need topological_sort to offer the same functionality, which might be easier since that one calls out to petgraph within rustworkx at the moment.
The logic is very straightforward - we just swap which of Direction::Outgoing and Direction::Incoming we use in a couple of places in the sorters. I can provide a PR if it's an acceptable feature.
What is the expected enhancement?
I would like to be able to get a "reverse" topological ordering from
lexicographical_topological_sort
andTopologicalSorter
in the sense of "a topological order if all the edges reversed direction" - it'd be helpful on Qiskit in a few places where we want to find final operations. For our purposes, we don't needtopological_sort
to offer the same functionality, which might be easier since that one calls out topetgraph
withinrustworkx
at the moment.The logic is very straightforward - we just swap which of
Direction::Outgoing
andDirection::Incoming
we use in a couple of places in the sorters. I can provide a PR if it's an acceptable feature.