Chapter 11
■
hard problems and (lImIted) sloppIness
242
The reduction is straightforward enough.
Basically, a set of nodes is a vertex cover if
and only if the remaining
nodes form an independent set. Consider any pair of nodes that are not in the vertex cover. If there were an edge
between them, it would not have been covered (a contradiction), so there cannot be an edge between them. Because
this holds for any pair of nodes outside the cover, these nodes form an independent set. (A single node would work on
its own, of course.)
The implication goes the other way as well. Let’s say you have an independent set—do you see why the remaining
nodes must form a vertex cover? Of course, any edge not connected to the independent set will be covered by the
remaining nodes. But what if an edge is connected to one of your independent nodes? Well, its other end can’t be in
the independent set (those nodes aren’t connected), and that means that the edge is covered by an outside node.
In other words, the vertex cover problem is NP-complete (or NP-hard, in its optimization version).
Finally, we have the
set covering problem, which asks you to find a so-called set cover of size at most
k (or, in the
optimization version, to find the smallest one). Basically, you have a set
S and another set
F, consisting of subsets of
S.
The union of all the sets in
F is equal to
S. You’re trying to find a small subset of
F that covers all the elements of
S.
To get an intuitive understanding of this, you can think of it in terms of nodes and edges. If
S were the nodes of a
graph, and
F, the edges (that is, pairs of nodes), you’d be trying to find the smallest number of edges that would cover
(be incident to) all the nodes.
Caution
■
the example used here is the so-called edge cover problem. although it’s a useful illustration of the set
covering problem, you should not conclude that the edge cover problem is np-complete. It can, in fact, be solved in
polynomial time.
It should be easy enough to see that the set covering problem is NP-hard, because
the vertex cover problem
is basically a special case. Just let
S be the edges of a graph and
F consist of the neighbor sets for every node, and
you’re done.
Paths and Circuits
This is our final group of beasties—and we’re drawing near to the problem that started the book. This material mainly
has to do with navigating efficiently, when there are requirements on locations (or states) you have to pass through.
For example, you might try to work out movement patterns for an industrial robot, or the layout of some kinds of
electronic circuits. Once more you may have to settle for approximations or special cases. I’ve already shown how
finding a Hamilton cycle in general is a daunting prospect. Now let’s see if we can shake out some other hard path and
circuit-related problems from this knowledge.
First, let’s consider the issue of direction. The proof I gave that checking for Hamilton cycles was NP-complete
was based on using a directed graph (and, thus, finding a directed cycle). What about the undirected case? It might
seem we lose some information, and the earlier proof doesn’t hold here. However, with some widgetry, we can
simulate direction with an undirected graph!
The idea is to split every node in
the directed graph into three, basically replacing it by a length-two path.
Imagine coloring the nodes: You color the original node blue, but you add a red in-node and a green out-node.
All directed in-edges now become undirected edges linked to the red in-node, and the out-edges are linked to the
green out-node. Clearly, if the original graph had a Hamilton cycle, the new one will as well. The challenge is getting
the implication the other way—we need “if and only if” for the reduction to be valid.
Imagine that our new graph
does have a Hamilton cycle. The node colors of this cycle would be either
“… red, blue, green, red, blue, green …” or “… green, blue, red, green, blue, red …” In the first case, the blue nodes
will represent a directed Hamilton cycle in the original graph, as they are entered only through their in-nodes
(representing the original in-edges) and left through out-nodes. In the second case, the blue nodes will represent a
reverse directed Hamilton cycle—which also tells us what we need to know (that is, that
we have a usable directed
Hamilton cycle in the other direction).
Chapter 11
■
hard problems and (lImIted) sloppIness
243
So, now we know that directed and undirected Hamilton cycles are basically equivalent (see Exercise 11-8).
What about the so-called Hamilton
path problem? This is similar to the cycle problem, except you’re no longer required
to end up where you started. Seems like it might be a bit easier? Sorry. No dice. If you can find a Hamilton path, you can
use that to find a Hamilton cycle. Let’s consider the directed case (see Exercise 11-9 for the undirected case). Take any
node
v with both in- and out-edges. (If there is no such node, there can be no Hamilton cycle.) Split it into two nodes,
Do'stlaringiz bilan baham: