TExcelTAD
Home › Parameterized & Fine-Grained Complexity › Kernels and Buss's Rule for Vertex Cover

Kernels and Buss's Rule for Vertex Cover

Real solvers for hard problems rarely start with the exponential search. They first run cheap preprocessing that shrinks the instance, and only then search. Kernelization is the theory of preprocessing with a guarantee: after polynomial time, the instance that remains has size bounded by a function of the parameter alone, however large the input was.

Reduction rules and kernels

A reduction rule for a parameterized problem maps an instance (x,k)(x, k) to an instance (x′,k′)(x', k') in polynomial time. It is safe if (x,k)(x, k) is a YES instance exactly when (x′,k′)(x', k') is. The rules in Bounded Search Trees for Vertex Cover for degree-0 and degree-1 vertices are safe rules.

Definition. A kernelization (or kernel) for a parameterized problem is a polynomial-time algorithm that maps (x,k)(x, k) to an equivalent instance (x′,k′)(x', k') with

∣x′∣≤g(k)andk′≤g(k)\lvert x' \rvert \le g(k) \quad \text{and} \quad k' \le g(k)

for a computable function gg, the size of the kernel. A kernel is polynomial if gg is a polynomial.

Theorem. A decidable parameterized problem is FPT if and only if it has a kernel.

Proof. If there is a kernel, run it, then solve the instance of size at most g(k)g(k) by any algorithm: the total time is polynomial plus a function of kk. Conversely, suppose an algorithm decides the problem in time f(k)⋅ncf(k) \cdot n^c. Given (x,k)(x, k) with n=∣x∣n = \lvert x \rvert: if n≥f(k)n \ge f(k), the algorithm runs in time at most nc+1n^{c+1}, which is polynomial, so run it and output a fixed small YES or NO instance accordingly. Otherwise n<f(k)n < f(k) and (x,k)(x, k) itself is a kernel of size f(k)f(k). □\square

The theorem says kernels exist exactly where FPT algorithms do, but the kernel it builds has the same exponential size as ff. The interesting question is therefore how small a kernel can be: linear, quadratic, polynomial? The last lesson of this section shows that some FPT problems have no polynomial kernel unless the polynomial hierarchy collapses.

Buss's kernel for vertex cover

The key observation (Buss and Goldsmith, 1993): a vertex of degree more than kk must be in every cover of size at most kk. If it were not, all its more than kk neighbours would be.

text
BUSS-KERNEL(G, k)
1  repeat until nothing changes
2      delete every isolated vertex
3      if some vertex v has degree > k:
4          delete v;  k = k - 1                  // v is in every small cover
5          if k < 0: return a trivial NO instance
6  if G has more than k^2 edges:  return a trivial NO instance
7  return (G, k)

Lemma. If no vertex has degree more than kk and GG has a cover of size at most kk, then GG has at most k2k^2 edges.

Proof. Each of the at most kk cover vertices covers at most kk edges, and every edge is covered. □\square

So the reduced graph has at most k2k^2 edges, and since no vertex is isolated, at most 2k22k^2 vertices (a sharper count gives k2+kk^2 + k: the cover's kk vertices plus at most k2k^2 neighbours). Every rule runs in polynomial time and is safe, so this is a kernel with O(k2)O(k^2) edges and vertices. Followed by the O(2k)O(2^k) search tree on the kernel, it decides vertex cover in O(kn+2kk2)O(kn + 2^k k^2) time, where knkn pays for the reduction.

The program applies the rules to random graphs that have a planted cover of size kk, with a few hubs of high degree inside the cover, and reports how much is left.

python · try it yourself
import random

def planted(n, k, hubs, seed):
    rng = random.Random(seed)
    C = rng.sample(range(n), k)
    E = set()
    for i, c in enumerate(C):
        deg = rng.randint(30, 60) if i < hubs else rng.randint(2, 6)   # a few hubs, the rest low
        for v in rng.sample(range(n), deg):
            if v != c:
                E.add((min(c, v), max(c, v)))
    return E

def buss(E, k):
    E, forced = set(E), []
    while True:
        deg = {}
        for u, v in E:
            deg[u] = deg.get(u, 0) + 1
            deg[v] = deg.get(v, 0) + 1
        high = [v for v in sorted(deg) if deg[v] > k]
        if not high:
            break
        v = high[0]
        forced.append(v)
        E = {e for e in E if v not in e}
        k -= 1
        if k < 0:
            return None, None, forced
    if len(E) > k * k:
        return None, None, forced
    return E, k, forced

for seed in range(4):
    n, k = 2000, 12
    E = planted(n, k, hubs=4, seed=seed)
    K, k2, forced = buss(E, k)
    verts = {v for e in K for v in e}
    print(f"input: {n} vertices, {len(E)} edges, k = {k}  ->  kernel: {len(verts)} vertices, {len(K)} edges,"
          f" k' = {k2}  (forced {len(forced)}; bound k'^2 = {k2 * k2})")
print("same graph with budget k = 3:", "NO" if buss(planted(2000, 12, 4, 0), 3)[0] is None else "?")
input: 2000 vertices, 185 edges, k = 12  ->  kernel: 39 vertices, 31 edges, k' = 8  (forced 4; bound k'^2 = 64)
input: 2000 vertices, 211 edges, k = 12  ->  kernel: 37 vertices, 29 edges, k' = 8  (forced 4; bound k'^2 = 64)
input: 2000 vertices, 234 edges, k = 12  ->  kernel: 40 vertices, 32 edges, k' = 8  (forced 4; bound k'^2 = 64)
input: 2000 vertices, 215 edges, k = 12  ->  kernel: 43 vertices, 35 edges, k' = 8  (forced 4; bound k'^2 = 64)
same graph with budget k = 3: NO

From 2000 vertices only a few dozen remain, independent of nn. When the budget is too small, the rules notice it (here the fourth forced vertex makes kk negative) and answer NO without any search.

Kernel plus branching

The kernel and the search tree combine naturally, and the reduction can also be repeated at every node of the search tree (interleaving, Niedermeier and Rossmanith, 2000), which keeps the instances small as kk drops. The program compares the number of search-tree nodes and the total edge scans with and without the kernel on large sparse graphs.

python · try it yourself
import random

def planted(n, k, seed):
    rng = random.Random(seed)
    C = rng.sample(range(n), k)
    E = set()
    for i, c in enumerate(C):
        for v in rng.sample(range(n), n // 40 if i < 3 else 3):
            if v != c:
                E.add((min(c, v), max(c, v)))
    return sorted(E)

def buss(E, k):
    while True:
        deg = {}
        for u, v in E:
            deg[u] = deg.get(u, 0) + 1
            deg[v] = deg.get(v, 0) + 1
        high = next((v for v in sorted(deg) if deg[v] > k), None)
        if high is None:
            return (E, k) if len(E) <= k * k else (None, k)
        E = [e for e in E if high not in e]
        k -= 1
        if k < 0:
            return None, k

def branch(E, k, st):
    st["nodes"] += 1
    st["scans"] += len(E)
    if not E:
        return True
    if k == 0:
        return False
    u, v = E[0]
    return any(branch([e for e in E if w not in e], k - 1, st) for w in (u, v))

print("     n    |E|  k   plain: nodes     scans   kernel: |E'|  nodes  scans")
for n in [1000, 4000, 16000]:
    E = planted(n, 10, seed=n)
    a = {"nodes": 0, "scans": 0}
    r1 = branch(E, 10, a)
    K, k2 = buss(E, 10)
    b = {"nodes": 0, "scans": 0}
    r2 = K is not None and branch(K, k2, b)
    assert r1 == r2
    print(f"{n:6} {len(E):6} 10 {a['nodes']:13} {a['scans']:9} {len(K):14} {b['nodes']:6} {b['scans']:6}")
     n    |E|  k   plain: nodes     scans   kernel: |E'|  nodes  scans
  1000     96 10          2016     65783             21    224   2273
  4000    321 10          2047    122326             21    255   2435
 16000   1221 10          1984    151974             21    192   1865

Without the kernel each search-tree node rescans the whole edge list, so the cost grows with nn. With it, the search runs on a graph of at most k′2k'^2 edges and its cost no longer depends on nn at all; the reduction itself is a few linear passes.

In C++

Buss's rules with degree counters: when a vertex of degree more than kk is removed, the degrees of its neighbours drop, and isolated vertices disappear from the count automatically.

cpp · try it yourself
#include <cstdio>
#include <set>
#include <utility>
#include <vector>

int main() {
    const int n = 5000;
    int k = 15;
    std::vector<std::set<int>> adj(n);
    unsigned s = 99;
    auto rnd = [&](int m) { s = s * 1103515245u + 12345u; return int((s >> 8) % m); };
    for (int i = 0; i < 15; i++) {                  // a planted cover {0, ..., 14}
        int deg = i < 5 ? 60 : 6;
        for (int j = 0; j < deg; j++) {
            int v = rnd(n);
            if (v != i) { adj[i].insert(v); adj[v].insert(i); }
        }
    }
    long m = 0;
    for (auto& a : adj) m += a.size();
    std::printf("input: %d vertices, %ld edges, k = %d\n", n, m / 2, k);
    bool changed = true;
    while (changed && k >= 0) {
        changed = false;
        for (int v = 0; v < n; v++)
            if ((int)adj[v].size() > k) {
                for (int u : adj[v]) adj[u].erase(v);
                adj[v].clear();
                k--;
                changed = true;
                std::printf("forced vertex %d, k = %d\n", v, k);
                if (k < 0) break;
            }
    }
    long edges = 0, verts = 0;
    for (auto& a : adj) { edges += a.size(); verts += !a.empty(); }
    edges /= 2;
    if (k < 0 || edges > (long)k * k) std::printf("NO instance\n");
    else std::printf("kernel: %ld vertices, %ld edges, k' = %d (edge bound %d)\n", verts, edges, k, k * k);
}
input: 5000 vertices, 358 edges, k = 15
forced vertex 0, k = 14
forced vertex 1, k = 13
forced vertex 2, k = 12
forced vertex 3, k = 11
forced vertex 4, k = 10
kernel: 70 vertices, 60 edges, k' = 10 (edge bound 100)

Test yourself

Why must a vertex of degree more than kk belong to every vertex cover of size at most kk?

  1. Because it is adjacent to every other vertex
  2. Because leaving it out forces all of its more than kk neighbours into the cover
  3. Because it lies on a cycle
  4. Because high-degree vertices are always optimal

After Buss's rules, a YES instance has at most how many edges?

  1. kk
  2. k2k^2
  3. 2k2^k
  4. nn

Which statement about kernels is a theorem?

  1. Every NP-hard problem has a polynomial kernel
  2. A decidable parameterized problem is FPT exactly when it has a kernel
  3. Kernels always have linear size
  4. Kernels require randomness

Why does running the search tree on the kernel make its cost independent of nn?

  1. Because the kernel has at most k2k^2 edges, so each node of the tree does work bounded by a function of kk
  2. Because the kernel has no edges
  3. Because the search tree has fewer than kk nodes
  4. Because the kernel is a tree