algorithmsequenceswapinversionpartial-ordering

Reorder a sequence with minimum number of swaps to fulfil partial order constraints


Input: An array of elements and a partial order on a subset of those elements, seen as a constraint set.

Output: An array (or any ordered sequence) fulfilling the partial order.

The Problem: How can one achieve the reordering efficiently? The number of introduced inversions (or swaps) compared to the original input sequence should be as small as possible. Note, that the partial order can be defined for any amount of elements (some elements may are not part of it).

The context: It arises from a situation in 2-layer graph crossing reduction: After a crossing reduction phase, I want to reorder some of the nodes (thus, the partial order may contain only a small subset).

In general, I had the idea to weaken this a little bit and solve the problem only for the elements being part of the partial order (though I think, that this could lead to non-optimal results). Thus, if I have a sequence A B C D E and the partial order only contains A, B and E, then C and D will stay at the same place. It somehow reminds me of the Kemeny Score, but I couldn't yet turn that into an algorithm.

Just to be sure: I am not searching for a topological sort. This would probably introduce a lot more inversions than required.

Edit 1:


Solution

  • I found a paper, which looks promising: "A Fast and Simple Heuristic for Constrained Two-Level Crossing Reduction" by Michael Foster. Together with the comments below my question, it is answered. Thanks again, @j_random_hacker!