Docsity

NP-Completeness of Hamiltonian Circuit and Traveling Salesman Problem, Slides of Advanced Computational Complexity

Partial preview of the text

Download NP-Completeness of Hamiltonian Circuit and Traveling Salesman Problem and more Slides Advanced Computational Complexity in PDF only on Docsity!

Lecture 7: NP-completeness II

Matthew Johnson

[email protected]

NP-completeness of HAMILTONIAN CIRCUIT

HAMILTONIAN CIRCUIT

Instance : A graph G = (V , E) Question: Is there a Hamiltonian circuit in G, that is, a cycle passing through each vertex exactly once?

Step 1. The problem is in NP : a Hamiltonian circuit is the certificate. Step 2. To show completeness, reduce 3-SATISFIABILITY to HAMILTONIAN CIRCUIT. We will use the method of “component design”. The construction is from Papadimitriou, pp. 193–198.

The choice gadget

This gadget will allow the Hamiltonian circuit coming through it to pick either left or right edge, thus communicating the truth value.

The consistency gadget

It will be connected to the rest of the graph only via the black nodes. It can be traversed by a Hamiltonian circuit in exactly two ways.

Properties of gadgets

The choice gadget can be traversed in exactly two ways The internal vertices of the consistency gadget can be traversed in exactly two ways, so that exactly one pair of external (black) vertices is involved Any Hamiltonian circuit traverses at most two sides of the triangle in the constraint gadget.

Example construction

(x ∨ y ∨ z) ∧ (¬x ∨ ¬y ∨ ¬z) ∧ (¬x ∨ ¬y ∨ z)

The dotted circles denote vertices connected into one big clique.

Communicating truth value to several triangles

General construction

The graph G contains n copies of the choice gadget (one for each variable), connected in a series. Add vertices 1 and 2 and the two dotted vertices (on the right). G contains m triangles (one for each clause), with a side in the triangle identified with each literal in the clause. A side corresponding to literal xi is connected via the consistency gadget with the “true” side of the corresponding choice gadget; a side corresponding to ¬xi is connected to the “false” side. If an edge of some choice gadget is connected with several sides of (different) triangles then it is divided into several consecutive edges, each corresponding to a side of a triangle. This is to ensure that the same truth value is communicated to all occurrences of a literal. All 3m + 2 dotted nodes are connected into one big clique.

Assignment from circuit

Every Hamiltonian circuit must use the edge 1-2. From 2 via 1, it can only go up through all choice gadgets choosing one side (truth value) in each gadget and traversing the corresponding consistency gadgets on the way. Then it traverses all the triangles in some order and finish in vertex 2. Hence the circuit determines an assignment of truth values to the variables. Every triangle has a side which is not traversed. Hence the corresponding literal in the clause is TRUE, so all clauses are satisfied.

Assignment from circuit

Every Hamiltonian circuit must use the edge 1-2. From 2 via 1, it can only go up through all choice gadgets choosing one side (truth value) in each gadget and traversing the corresponding consistency gadgets on the way. Then it traverses all the triangles in some order and finish in vertex 2. Hence the circuit determines an assignment of truth values to the variables. Every triangle has a side which is not traversed. Hence the corresponding literal in the clause is TRUE, so all clauses are satisfied.

Assignment from circuit

Every Hamiltonian circuit must use the edge 1-2. From 2 via 1, it can only go up through all choice gadgets choosing one side (truth value) in each gadget and traversing the corresponding consistency gadgets on the way. Then it traverses all the triangles in some order and finish in vertex 2. Hence the circuit determines an assignment of truth values to the variables. Every triangle has a side which is not traversed. Hence the corresponding literal in the clause is TRUE, so all clauses are satisfied.

Circuit from assignment

Start from 2 to 1 and then go through all choice gadgets, each time picking the side corresponding to the truth value of the variable (in the assignment). Once this is done, you arrive at the dotted vertex (top of the choice gadget series). Now go through the triangles in arbitrary order, using the sides corresponding to true literals. (By doing so, you will also visit all unvisited vertices in the choice gadgets). Since all dotted vertices of the triangles are fully connected, it is possible to visit every vertex exactly once. Once this is done, move to the dotted vertex (bottom of the choice gadget series), and finish at vertex 2. This completes the Hamiltonian circuit.

Circuit from assignment

Start from 2 to 1 and then go through all choice gadgets, each time picking the side corresponding to the truth value of the variable (in the assignment). Once this is done, you arrive at the dotted vertex (top of the choice gadget series). Now go through the triangles in arbitrary order, using the sides corresponding to true literals. (By doing so, you will also visit all unvisited vertices in the choice gadgets). Since all dotted vertices of the triangles are fully connected, it is possible to visit every vertex exactly once. Once this is done, move to the dotted vertex (bottom of the choice gadget series), and finish at vertex 2. This completes the Hamiltonian circuit.

Circuit from assignment

Start from 2 to 1 and then go through all choice gadgets, each time picking the side corresponding to the truth value of the variable (in the assignment). Once this is done, you arrive at the dotted vertex (top of the choice gadget series). Now go through the triangles in arbitrary order, using the sides corresponding to true literals. (By doing so, you will also visit all unvisited vertices in the choice gadgets). Since all dotted vertices of the triangles are fully connected, it is possible to visit every vertex exactly once. Once this is done, move to the dotted vertex (bottom of the choice gadget series), and finish at vertex 2. This completes the Hamiltonian circuit.