Constrained sorting

48 Views Asked by At

The problem: Let $a=(x,y)$ be a 2-tuple, such that $x,y<2m$ and $x+y$ is odd. We are given $2n$ tuples, half have $x$ odd and the other half have $x$ even, we also know $n_{xy}$, the count of each $(x,y)$-tuple. In how many ways can those $2n$ tuples be sorted s.t. the second element of a tuple equals the first element in the subsequent tuple.

This feels like a count of graph bijections problem. I wonder if I am just blind and this maps to a known problem? Assuming $m$ is known.

1

There are 1 best solutions below

4
On BEST ANSWER

If you make a graph with all integers $< 2m$, where you connect $(x, y)$ by a number of directed edges equal to $n_{x, y}$, you get a (non-simple) graph. You are asking essentially: how many Hamiltonian paths are there in this graph?

You have a bipartite graph due to the condition that $x + y$ is always odd, but even then this problem is NP-hard, so unfortunately it does not help you. (In fact, this is kind of obvious: in any graph, you could subdivide each edge, giving you a bipartite graph whose Hamiltonian paths correspond one-to-one to the original graph's Hamiltonian paths.)