Строительный блокнот  Automata methods and madness 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 [ 151 ] 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175


Figure 10.10: Example of the Hamilton-circuit construction



10.4.5 Undirected Hamilton Circuits and the TSP

The proofs that the undirected Hamilton-circuit problem and the TVaveling Salesman problem are also NP-complete are relatively easy. We already saw in Section 10.1.4 that TSP is in AfP. HC is a special case of TSP, so it is also in MP. We must perform the reductions of DHC to HC and HC to TSP.

PROBLEM: Undirected Hamilton-Circuit Problem.

INPUT: An undirected graph G.

OUTPUT: Yes if and only if G has a Hamilton circuit. REDUCTION FROM: DHC.

Theorem 10.23 : HC is NP-complete.

PROOF: We reduce DHC to HC, as follows. Suppose we are given a directed graph С([, The undirected graph we construct will be called Gu- For every node v of Grf, there are three nodes v \ and v in G . The edges of G are;

1. For all nodes v of Gd, there are edges and (uf\u() in G .

2. If there is an arc и -> № in Grf, then there is an edge (иш ) in Gu-Figure 10.11 suggests the pattern of edges, including the edge for an arc v w.


Figure 10.11: Arcs in G arc replaced by edges in Gu that go from rank 2 to rank 0

Clearly the constniction of Gu from Gd can be performed in polynomial time. We must show that

Gu has a Hamilton circuit if and only if Gd has a directed Hamilton circuit.



10.4.6 Summary of NP-Complete Problems

Figure 10.12 indicates all the reductions we have made in this chapter. Notice that we have suggested reductions from all the specific problems, like TSP, to SAT. What happened was that we reduced the language of every polynomial-time, nondeterministic Turing machine to SAT in Theorem 10.9. Without mentioning it explicitly, these TMs included at least one that solves TSP, one that solves IS, and so on. Thus, all the NP-complete problems are polynomial-time reducible to one another, and are, in effect, difierent faces of the same problem.

(If) Suppose Vi,V2y ,Vn,V\ is a directed Hamilton circuit. Then surely

(0) Ji) .,(2) (0) -,(1) (2) (0) (0) (1) (2) (0)

is an undirected Hamilton circuit in Gu- That is, we go down each column, and then jump to the top of the next column to follow an arc of Grf.

{Only if) Observe that each node u of G has only two edges, and therefore must appear in a Hamilton circuit with one of v) and u its immediate predecessor, and the other its immediate successor. Thus, a Hamilton circuit in Gu must have superscripts on its nodes that vary in the pattern 0,1,2,0,1,2,... or its opposite, 2,1,0,2,1,0,.... Since these patterns correspond to traversing a cycle in the two different directions, we may as well assume the pattern is 0,1,2,0,1,2,.,.. Thus, if we look at the edges of the cycle that go from a node with superscript 2 to one with superscript 0, we know that these edges are arcs of Gd, and that each is followed in the direction in which the arc points. Thus, an undirected Hamilton circuit in Gu yields a directed Hamilton circuit in Grf. □

PROBLEM: Traveling Salesman Problem.

INPUT: An undirected graph G with integer weights on the edges, and a limit k.

OUTPUT: Yes if and only if there is a Hamilton circuit of G, such that the sum of the weights on the edges of the cycle is less than or equal to k.

REDUCTION PROM: HC.

Theorem 10.24: The Traveling Salesman Problem is NP-complete.

PROOF: The reduction from HC is as follows. Given a graph G, construct a weighted graph G whose nodes and edges are the same as the edges of G, with a weight of 1 on each edge, and a limit к that is equal to the number of nodes n of G. Then a Hamilton circuit of weight n exists in G if and only if there is a Hamilton circuit in G. □



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 [ 151 ] 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175