In this section, by a graph we mean asimple graph: an undirected graph without multiple edges or loops. nis always the number of nodes. Unless we say otherwise, we assume that the graph is described by its adjacency matrix, which we consider as a string in{0,1}n2
. In this way, a graph property can be considered a language over{0,1}. We can thus ask whether a certain graph property is in NP. (Notice that describing a graph in one of the other usual ways, e.g. by giving a list of neighbors for each node, would not affect the membership of graph properties in NP. It is namely easy to compute these representations from each other in polynomial time.) The following graph properties are in NP.
Problem 6.4.1 Graph-connectivity Certificate: a set of ¡n2¢ paths, one for each pair of nodes.
Problem 6.4.2 Graph non-connectivity Certificate: a proper subset of the set of nodes that is not connected by any edge to the rest of the nodes.
Problem 6.4.3 Graph planarity The natural witness is a concrete diagram, though some analysis is needed to see that in case such a diagram exists then one exists in which the coordinates of every node are integers whose number of bits is polynomial inn.
It is interesting to remark the fact known in graph theory that this can be realized using single straight-line segments for the edges and thus, it is enough to specify the coordinates of the nodes. We must be careful, however, since the coordinates of the nodes used in the drawing may have too many bits, violating the requirement on the length of the witness. (It can be proved that every planar graph can be drawn in the plane in such a way that each edge is a straigh-line segment and the coordinates of every node are integers whose number of bits is polynomial inn.)
It is possible, however, to give a purely combinatorial way of drawing the graph. Let G
be a graph withnnodes andmedges which we assume for simplicity to be connected. After drawing it in the plane, the edges partition the plane into domains which we call “countries” (the unbounded domain is also a country). We need the following fact, called Euler’s formula: Theorem 6.4.1 A connected planar graph withnnodes andmedges hasn+m−2countries. Thus to specify the drawing we give a set of m−n+ 2 country names and for every country, we specify the sequence of edges forming its boundary. In this case, it is enough to check whether every edge is in exactly two boundaries.
6.4. EXAMPLES OF LANGUAGES IN NP 97 The fact that the existence of such a set of edge sequences is a necessary condition of planarity follows from Euler’s formula. The sufficiency of this condition requires somewhat harder tools from topology; we will not go into these details. (Specifying a set of edge sequences as country boundaries amounts to defining a two-dimensional surface with the graph drawn onto it. A theorem of topology says that if a connected graph drawn on that surface satisfies Euler’s formula then the surface is topologically equivalent (homeomorphic) to the plane.)
Problem 6.4.4 Non-planarity Let us review the following facts.
1. Let K5 be the graph obtained by connecting five nodes in every possible way. This
graph is also called a “complete pentagon”. Let K3
3 be the 6-node bipartite graph
containing two setsA, B of three nodes each, with every possible edge between Aand
B. This graph is also called “three houses, three wells” after a certain puzzle with a similar name. It is easy to see thatK5 andK33are nonplanar.
2. Given a graphG, we say that a graphG0 is a subdivisionofGif it is obtained fromG by replacing each edge ofGwith arbitrarily long non-intersecting paths. It is easy to see that ifGis nonplanar then any subdivision is nonplanar.
3. If a graph is nonplanar then, obviously, every graph containing it is also nonplanar. The following fundamental theorem of graph theory says that the nonplanar graphs are just the ones obtained by the above operations:
Theorem 6.4.2 (Kuratowski’s Theorem) A graph is nonplanar if and only if it contains a subgraph that is a topological version of eitherK5 orK33.
If the graph is nonplanar then the subgraph whose existence is stated by Kuratowski’s Theorem can serve as a certificate for this.
Problem 6.4.5 Existence of perfect matching A certificate is the perfect matching itself. Problem 6.4.6 Non-existence of a perfect matching Witnesses for the non-existence in case of bipartite graphs are based on a fundamental theorem. Let G be a bipartite graph G
consisting with bipartition classes U andW. Recall the following theorem:
Theorem 6.4.3 Frobenius’s Theorem A bipartite graphGhas a perfect matching if and only if |U|=|W| and for anyk, anyk nodes inW have at leastk neighbors inU.
Hence, if in some bipartite graph there is no perfect matching then this can be certified either by noting that U and W have different cardinality, or by a subset of W violating the conditions of the theorem.
Now letGbe an arbitrary graph. If there is a perfect matching then it is easy to see that for any k, if we delete any k nodes, there remain at most k connected components of odd size. The following fundamental (and deeper) theorem says that this condition is not only necessary for the existence of a perfect matching but also sufficient.
Theorem 6.4.4 Tutte’s Theorem A graph Ghas a perfect matching if and only if for any
k, if we delete any knodes, there remain at mostk connected components of odd size. This way, if there is no perfect matching in the graph then this can be certified by a set of nodes whose deletion creates too many odd components.
A Hamiltonian cycle of a graph is a cycle going through each node exactly once. Problem 6.4.7 Existence of a Hamiltonian cycle
Certificate: the Hamitonian cycle itself.
Acoloring of a graph is an assignment of some symbol called “color” to each node in such a way that neighboring nodes get different colors.
Problem 6.4.8 Colorability with three colors If a graph can be colored with three colors the coloring itself is a certificate. Of course, this is valid for any number of colors.
Most of the properties listed above, up to (and including) the non-existence of a perfect matching, can be solved in polynomial time (i.e., they are in P). For the Hamiltonian cycle problem and the three-colorability problem, no polynomial algorithm is known (we return to this later).