Tutorials › Graph Theory (Undergraduate) › Vertex Cover and Independent Set

Complexity of Graph Problems · Tutorial 742 of 799

Vertex Cover and Independent Set

See why complements exchange vertex covers and independent sets, and use that fact to establish the NP-completeness of Vertex Cover.

Advanced 10 min read

What You'll Learn

  • Define vertex covers and independent sets and distinguish their decision versions.
  • Prove that a set is a vertex cover exactly when its complement is independent.
  • Derive the relation between the minimum vertex cover size and maximum independent set size.
  • Construct the reduction from Independent Set to Vertex Cover and verify its direction.
  • Check that Vertex Cover has polynomially verifiable certificates and is NP-complete.

Two Complementary Ways to Describe Vertices

To cover every edge, a chosen set of vertices must meet each edge at one or both endpoints. An independent set instead avoids taking both endpoints of any edge. These conditions are complementary: every vertex not selected for a cover must be safe to select together, because no edge can have both endpoints outside the cover. This simple observation gives an exact relationship between the two decision problems and transfers computational hardness from one to the other.

All graphs in this tutorial are finite and simple. A set \(C\subseteq V(G)\) is a vertex cover if every edge of \(G\) has at least one endpoint in \(C\). A set \(I\subseteq V(G)\) is an independent set if no edge has both endpoints in \(I\). The minimum size of a vertex cover is the vertex cover number \(\tau(G)\), and the maximum size of an independent set is the independence number \(\alpha(G)\).

Definition: In the Vertex Cover decision problem, the input is a graph \(G\) and a nonnegative integer \(b\); the answer is yes exactly when \(G\) has a vertex cover of size at most \(b\). In the Independent Set decision problem, the input is \(G\) and a nonnegative integer \(k\); the answer is yes exactly when \(G\) has an independent set of size at least \(k\).

“At most” for a cover and “at least” for an independent set are important: these are decision versions of minimum and maximum problems. An empty set is a cover of an edgeless graph, and every subset of the vertices of an edgeless graph is independent. Isolated vertices create no edge constraint: they may be left out of a cover, and they may be included in an independent set.

The Complement Correspondence

Theorem: For every graph \(G=(V,E)\) and every subset \(C\subseteq V\), \(C\) is a vertex cover if and only if \(V\setminus C\) is an independent set.

Proof. Put \(I=V\setminus C\). Suppose first that \(C\) is a vertex cover. If \(I\) were not independent, some edge \(uv\in E\) would have both endpoints in \(I\). Neither endpoint would then belong to \(C\), contradicting that \(C\) meets every edge. Thus \(I\) is independent. Conversely, suppose \(I\) is independent and let \(C=V\setminus I\). If an edge \(uv\) had neither endpoint in \(C\), then both \(u\) and \(v\) would belong to \(I\), contradicting independence. Every edge therefore has an endpoint in \(C\), so \(C\) is a vertex cover. This argument also applies when \(V\) or \(E\) is empty. \(\square\)

Taking sizes in the correspondence gives \(|C|+|V\setminus C|=|V|\). It follows that the two extremal parameters satisfy

$$ \tau(G)+\alpha(G)=|V(G)|. $$

Indeed, if \(I\) is a largest independent set, then \(V\setminus I\) is a cover of size \(|V|-\alpha(G)\), so \(\tau(G)\le |V|-\alpha(G)\). If \(C\) is a smallest cover, then \(V\setminus C\) is independent of size \(|V|-\tau(G)\), so \(\alpha(G)\ge |V|-\tau(G)\). These inequalities give equality. No assumption that the graph is connected or has an edge is needed.

Worked Example: Turning an Independent Set into a Cover

Let \(G=(V,E)\) have \(V=\{1,2,3,4,5\}\) and \(E=\{12,23,34,45,15,13\}\). Take \(I=\{2,4\}\). Check each edge: \(12\) has endpoint \(1\notin I\); \(23\) has endpoint \(3\notin I\); \(34\) has endpoint \(3\notin I\); \(45\) has endpoint \(5\notin I\); \(15\) has both endpoints outside \(I\); and \(13\) has both endpoints outside \(I\). Thus no edge has both endpoints in \(I\), so \(I\) is independent.

Its complement is \(C=V\setminus I=\{1,3,5\}\), with \(|C|=3\). Check the edges in order: \(12\) meets \(C\) at \(1\); \(23\) at \(3\); \(34\) at \(3\); \(45\) at \(5\); \(15\) at both \(1\) and \(5\); and \(13\) at both \(1\) and \(3\). Therefore \(C\) is a vertex cover.

Check: \(|I|+|C|=2+3=5=|V|\), as required. The edge \(15\) is not a problem for independence: neither of its endpoints is in \(I\).

Reducing Independent Set to Vertex Cover

A polynomial-time many-one reduction converts each input of one decision problem into an input of another in polynomial time, preserving the yes-or-no answer. For an Independent Set instance \((G,k)\), let \(n=|V(G)|\). When \(0\le k\le n\), define the output instance to be \((G,n-k)\) for Vertex Cover. The graph is unchanged; only the bound is transformed.

Theorem: For a graph \(G\) on \(n\) vertices and an integer \(k\) with \(0\le k\le n\), \(G\) has an independent set of size at least \(k\) if and only if it has a vertex cover of size at most \(n-k\).

Proof. If \(I\) is independent with \(|I|\ge k\), then \(C=V(G)\setminus I\) is a vertex cover by the complement correspondence. Its size is \(|C|=n-|I|\le n-k\). Conversely, if \(C\) is a vertex cover with \(|C|\le n-k\), then \(I=V(G)\setminus C\) is independent and has size \(|I|=n-|C|\ge k\). Both implications use the same graph and the exact complement relation, so the reduction preserves yes and no answers. \(\square\)

The transformation calculates \(n-k\) and copies the graph, so its running time is polynomial in the input length. If the source convention allows \(k>n\), that case is always a no-instance of Independent Set and can be mapped to the fixed no-instance \((K_2,0)\) of Vertex Cover: the sole edge of \(K_2\) cannot be covered by a set of size zero. Thus the reduction can be made total under that convention as well. The usual source problem Independent Set is NP-complete; using the reduction above establishes NP-hardness of Vertex Cover.

Worked Example: Computing the Reduced Bound

Let \(G\) have \(V=\{1,2,3,4\}\) and \(E=\{12,23,34,41,13\}\), and consider the Independent Set bound \(k=2\). Here \(n=4\), so the output Vertex Cover bound is \(n-k=4-2=2\).

The set \(I=\{2,4\}\) is independent: none of the listed edges is \(24\), and no listed edge has both endpoints in \(\{2,4\}\). Its complement is \(C=\{1,3\}\), which meets \(12\) at \(1\), \(23\) at \(3\), \(34\) at \(3\), \(41\) at \(1\), and \(13\) at both endpoints. Hence the source answer and the output answer are both yes.

In fact, the cover bound is tight. The edges \(12\) and \(34\) have no common endpoint, so any cover must contain at least one endpoint of \(12\) and at least one endpoint of \(34\); these are distinct vertices. Thus every cover has size at least \(2\), and \(C=\{1,3\}\) shows a cover of size \(2\). The complement identity then gives \(\tau(G)=2\) and \(\alpha(G)=4-2=2\).

Check: Substituting the source bound gives \(n-k=4-2=2=\tau(G)\), and the independent set has size \(2\ge k=2\).

Why Vertex Cover Is in NP

A certificate for a yes-instance \((G,b)\) is a list or bit string specifying a candidate set \(C\subseteq V(G)\). A verifier checks that \(|C|\le b\), then checks every edge and accepts exactly when at least one endpoint of each edge belongs to \(C\). The size check takes polynomial time, and checking all \(m=|E(G)|\) edges takes polynomial time in a standard graph encoding. A yes-instance has such a certificate, and every accepted certificate really is a cover of the required size. Therefore Vertex Cover belongs to NP.

Worked Example: Verifying a Cover Certificate

Let \(G\) have \(V=\{a,b,c,d,e\}\) and \(E=\{ab,bc,cd,de,ea,ac\}\), with bound \(b=3\). Consider the certificate \(C=\{a,c,d\}\). Its size is \(|C|=3\le b=3\). Edge by edge, \(ab\) meets \(C\) at \(a\); \(bc\) at \(c\); \(cd\) at \(c\) and \(d\); \(de\) at \(d\); \(ea\) at \(a\); and \(ac\) at both endpoints. The verifier accepts, and the checks show directly that this is a valid cover.

For comparison, the smaller candidate \(C'=\{a,c\}\) has size \(|C'|=2\le3\), but it misses edge \(de\), since neither \(d\) nor \(e\) belongs to \(C'\). The verifier must reject it. A certificate is not accepted merely because its size meets the bound; it must also cover every edge.

Check: There are six listed edges, and all six were checked for \(C\). For \(C'\), the explicit uncovered edge \(de\) is enough to disprove that it is a cover.

NP-Completeness

Theorem: Vertex Cover is NP-complete.

Proof. Membership in NP follows from the certificate verifier above. For NP-hardness, reduce from Independent Set, which is NP-complete by the earlier material on that problem. Given an instance \((G,k)\) with \(0\le k\le |V(G)|\), output \((G,|V(G)|-k)\). The transformation is polynomial-time, and the proved equivalence shows that the input is yes exactly when the output is yes. Hence Independent Set reduces to Vertex Cover, so Vertex Cover is NP-hard. More explicitly, every problem in NP reduces to Independent Set; composing that reduction with this one gives a polynomial-time reduction to Vertex Cover. Together with membership in NP, this proves NP-completeness. \(\square\)

A Direction Pitfall

The numerical bound changes from \(k\) to \(n-k\), not to \(k\). For example, if \(n=4\) and \(k=2\), the correct cover bound is \(4-2=2\). A common wrong calculation is to leave the bound at \(2\) and claim it represents the complement correspondence in general. That happens to give the same number for this particular choice, so it does not test the formula. With \(n=5\) and \(k=2\), the correct output bound is \(5-2=3\), not \(2\): an independent set of size \(2\) has a complement of size \(3\). In general the proof requires \(|V\setminus I|=n-|I|\); reversing or omitting this subtraction can reverse the decision condition.

The correspondence also does not say that a particular independent set has minimum complement among all vertex covers unless the independent set is maximum. The identity \(\tau(G)+\alpha(G)=n\) compares the optimum sizes. For a decision reduction, however, no optimization algorithm is needed: the exact complement equivalence proves that the chosen thresholds preserve the answer.

Check Your Understanding

Use the definitions and complement correspondence to justify each answer.

  1. For \(V=\{1,2,3,4\}\) and \(E=\{12,23,34\}\), is \(I=\{1,3\}\) independent? If so, write its complementary cover and check every edge.
  2. In a graph with \(n=7\), what Vertex Cover bound corresponds to an Independent Set bound \(k=3\)? State the equivalence in both directions.
  3. Explain why an isolated vertex may belong to an independent set without forcing it into every vertex cover.
  4. Give a polynomial-time certificate verifier for a proposed cover \(C\) with bound \(b\), including the two checks it must perform.
  5. Why does a reduction from Independent Set prove NP-hardness of Vertex Cover when Independent Set is NP-complete?