2

Let's say we have given unweighted directed graph with $N$ nodes and $M$ edges, and we want to find the $K$-th hamiltonian circuit, ordered in lexicographical order.

For example, if we have complete graph with $4$ nodes, and $12$ edges. The smallest hamiltonian circuit is $1 - 2 - 3 - 4$, the second one is $1 - 2 - 4 - 3$. Since finding hamiltonian circuit is NP Hard, what is the best complexity we can get this algorithm at?

Hamiltonian circuit is path that visits each node exactly once.

For the purpose of the problem, the circuit should begin in node $1$

What I think

If we have adjacent list of nodes connected to node $1$, sorted, then the permutations numbered from $[1, x]$ will pass in the first node, the on the second node the permutations numbered $[x, y]$ will pass the second node, etc..

Now our task is actually to find the $x, y...$ And we can solve for the second node (that we called from node $1$) for each of nodes adjacent to it, but this leads us to time complexity of $O(N!)$. Can we do it faster?

someone12321
  • 1,428
  • 15
  • 27

1 Answers1

1

Counting the number of Hamiltonian circuits in a graph is $\mathsf{\#P}$-hard (see for example this answer). Your problem is even harder, since we can use your problem together with binary search to count the number of Hamiltonian circuits in a given graph.

As an aside, let me mention that listing things in lexicographical order might be harder than listing them in any order. A case in point is the complexity of finding a [maximal independent set], which is an independent set which cannot be enlarged (but not necessarily one which has maximum size). A maximal independent set can easily be found by going over the vertices in some arbitrary order, putting the problem in the complexity class $\mathsf{P}$. This algorithm can be improved, and in fact a maximal independent set can be found in $\mathsf{NC^2}$. In contrast, finding the lexicographically first maximal independent set (that is, deciding whether a given vertex belongs to this set) is $\mathsf{P}$-complete.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514