rustworkx icon indicating copy to clipboard operation
rustworkx copied to clipboard

Add reverse topological ordering

Open jakelishman opened this issue 6 months ago • 0 comments

What is the expected enhancement?

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.

jakelishman avatar Feb 21 '24 13:02 jakelishman