TExcelTAD
Home › Parameterized & Fine-Grained Complexity › Parameters, FPT and XP

Parameters, FPT and XP

Classical complexity measures running time by one number, the input length nn. Parameterized complexity adds a second number kk, the parameter, which describes some aspect of the instance that we expect to be small: the size of the solution, the treewidth of a graph, the number of variables, the maximum degree. The question is then not "polynomial or not?" but "how does the running time depend on nn and kk together?".

Parameterized problems

A parameterized problem is a language L⊆Σ∗×NL \subseteq \Sigma^* \times \mathbb{N}: each instance is a pair (x,k)(x, k). The same underlying question gives different parameterized problems for different parameters:

Problem Parameter kk Status
VERTEX COVER: cover of size at most kk? solution size kk FPT, O(1.2738k+kn)O(1.2738^k + kn) (Chen, Kanj and Xia, 2010)
INDEPENDENT SET: independent set of size kk? solution size kk W[1]-hard, in XP
CLIQUE: clique of size kk? solution size kk W[1]-hard, in XP
CLIQUE maximum degree Δ\Delta FPT, O(2ΔΔ2n)O(2^{\Delta} \Delta^2 n)
kk-COLORING number of colors kk NP-hard already for k=3k = 3, so not in XP unless P = NP
any graph problem expressible in MSO treewidth FPT (Courcelle, 1990)

The table shows why the choice of parameter matters. Clique with the solution size as parameter is hard in a precise sense (Parameterized Reductions and W[1]-Hardness), but the same problem is easy on graphs of small maximum degree.

FPT and XP

FPT:decidable in time f(k)⋅nc for a computable f and a constant c,XP:decidable in time f(k)⋅ng(k) for computable f,g.\begin{aligned} \text{FPT} &: \text{decidable in time } f(k) \cdot n^{c} \text{ for a computable } f \text{ and a constant } c, \\ \text{XP} &: \text{decidable in time } f(k) \cdot n^{g(k)} \text{ for computable } f, g. \end{aligned}

In FPT the degree of the polynomial does not depend on kk; in XP it may. Every FPT problem is in XP (take gg constant). Clique with parameter kk is in XP by brute force over all (nk)\binom{n}{k} vertex sets, and the central working hypothesis of the area, FPT ≠\ne W[1], says it is not in FPT.

Two equivalent forms of the definition are useful:

  • Product or sum. A running time f(k)⋅ncf(k) \cdot n^c is at most f(k)2+n2cf(k)^2 + n^{2c}, because ab≤a2+b2ab \le a^2 + b^2. So FPT is also "time g(k)+nO(1)g(k) + n^{O(1)}": the exponential part and the polynomial part can be separated. Kernelization makes this separation explicit.
  • The function ff. Nothing restricts ff beyond computability. In practice f(k)=ckf(k) = c^k for a small constant cc is the goal, and much of the research on a single problem is about lowering cc, written O∗(ck)O^*(c^k) when polynomial factors are dropped.

What "efficient" means in numbers:

python · try it yourself
import math

def show(n, k):
    fpt = 2 ** k * n
    better = 1.2738 ** k * n
    xp = n ** k
    print(f"n = {n:>9,}  k = {k:2}:  2^k n = {fpt:.1e}   1.2738^k n = {better:.1e}   n^k = {xp:.1e}")

for n in [1000, 1_000_000]:
    for k in [10, 20, 40]:
        show(n, k)
n =     1,000  k = 10:  2^k n = 1.0e+06   1.2738^k n = 1.1e+04   n^k = 1.0e+30
n =     1,000  k = 20:  2^k n = 1.0e+09   1.2738^k n = 1.3e+05   n^k = 1.0e+60
n =     1,000  k = 40:  2^k n = 1.1e+15   1.2738^k n = 1.6e+07   n^k = 1.0e+120
n = 1,000,000  k = 10:  2^k n = 1.0e+09   1.2738^k n = 1.1e+07   n^k = 1.0e+60
n = 1,000,000  k = 20:  2^k n = 1.0e+12   1.2738^k n = 1.3e+08   n^k = 1.0e+120
n = 1,000,000  k = 40:  2^k n = 1.1e+18   1.2738^k n = 1.6e+10   n^k = 1.0e+240

At about 10910^9 simple steps per second, every entry in the middle column takes at most seconds, the first column is fine up to kk around 30, and the last column is hopeless already for k=10k = 10.

Example: clique parameterized by the maximum degree

Every clique containing a vertex vv lies inside N[v]={v}∪N(v)N[v] = \{v\} \cup N(v), a set of at most Δ+1\Delta + 1 vertices. So try every vertex and every subset of its neighbourhood:

text
CLIQUE-BY-DEGREE(G, k)
1  for each vertex v
2      for each subset S of N(v) with |S| = k - 1
3          if S is a clique                 // v is adjacent to all of S already
4              return YES
5  return NO

There are at most n⋅2Δn \cdot 2^{\Delta} pairs (v,S)(v, S) and each check costs O(Δ2)O(\Delta^2), so the time is O(2ΔΔ2n)O(2^{\Delta} \Delta^2 n): FPT in Δ\Delta, linear in nn. The same instance through brute force over kk-sets costs (nk)\binom{n}{k} checks. The program compares the two on random graphs of bounded degree, built by joining each vertex to a few nearby vertices on a ring.

python · try it yourself
import random
from itertools import combinations

def ring_graph(n, reach, p, seed):
    rng = random.Random(seed)
    adj = [set() for _ in range(n)]
    for u in range(n):
        for d in range(1, reach + 1):
            if rng.random() < p:
                v = (u + d) % n
                adj[u].add(v); adj[v].add(u)
    return adj

def is_clique(adj, S):
    return all(b in adj[a] for a, b in combinations(S, 2))

def by_degree(adj, k):
    checks = 0
    for v in range(len(adj)):
        for S in combinations(sorted(adj[v]), k - 1):
            checks += 1
            if is_clique(adj, S):
                return (v,) + S, checks
    return None, checks

def brute(adj, k):
    checks = 0
    for S in combinations(range(len(adj)), k):
        checks += 1
        if is_clique(adj, S):
            return S, checks
    return None, checks

print("  n  max deg  k  by-degree checks  brute-force checks  same answer")
for n in [16, 24, 32]:
    adj = ring_graph(n, 3, 0.8, seed=n)
    delta = max(len(a) for a in adj)
    for k in [4, 5]:
        a, c1 = by_degree(adj, k)
        b, c2 = brute(adj, k)
        print(f"{n:3} {delta:8} {k:2} {c1:17} {c2:19}  {(a is None) == (b is None)}")
  n  max deg  k  by-degree checks  brute-force checks  same answer
 16        6  4                 1                   1  True
 16        6  5               118                4368  True
 24        6  4                 9                3312  True
 24        6  5                96               42504  True
 32        6  4                 6                 435  True
 32        6  5               158              201376  True

When there is no clique of size kk, brute force must try all (nk)\binom{n}{k} sets, and that number explodes with nn; the degree-based search grows linearly in nn because the exponential part depends only on Δ\Delta.

In C++

The same search with neighbourhoods as bit masks: a subset of N(v)N(v) is a clique if every member's neighbourhood contains the rest.

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

int main() {
    const int n = 60, reach = 3;
    std::vector<std::vector<int>> nb(n);
    std::vector<std::vector<bool>> adj(n, std::vector<bool>(n, false));
    unsigned s = 7;
    for (int u = 0; u < n; u++)
        for (int d = 1; d <= reach; d++) {
            s = s * 1103515245u + 12345u;
            if ((s >> 16) % 10 < 8) {
                int v = (u + d) % n;
                if (!adj[u][v]) { adj[u][v] = adj[v][u] = true; nb[u].push_back(v); nb[v].push_back(u); }
            }
        }
    for (int k = 3; k <= 5; k++) {
        long checks = 0;
        int found = -1;
        for (int v = 0; v < n && found < 0; v++) {
            int d = nb[v].size();
            for (int mask = 0; mask < (1 << d); mask++) {
                if (__builtin_popcount(mask) != k - 1) continue;
                checks++;
                bool ok = true;
                for (int i = 0; i < d && ok; i++)
                    for (int j = i + 1; j < d && ok; j++)
                        if ((mask >> i & 1) && (mask >> j & 1) && !adj[nb[v][i]][nb[v][j]]) ok = false;
                if (ok) { found = v; break; }
            }
        }
        std::printf("k = %d: %s after %ld subset checks\n", k, found >= 0 ? "clique found" : "no clique", checks);
    }
}
k = 3: clique found after 1 subset checks
k = 4: clique found after 1 subset checks
k = 5: no clique after 323 subset checks

Where the parameter comes from

A parameter is useful when it is small on the instances that matter and when an algorithm can exploit it. Common choices:

  • Solution size: covers, hitting sets, edit distances to a graph class. Most of the first two sections of this course.
  • Structure of the input: treewidth, maximum degree, the size of a vertex cover of the input graph. These are often small for road networks, compiler control-flow graphs or chemical structures, and they power the treewidth section.
  • Above a guarantee: every graph with mm edges has a cut of size at least m2\frac{m}{2}, so for max-cut the interesting parameter is how far above m2\frac{m}{2} the target lies.
  • Combined parameters: k+Δk + \Delta, or kk plus the alphabet size. A problem can be hard for each parameter alone and FPT for their sum.

A problem that stays NP-hard for one fixed value of the parameter, like 3-coloring, is called para-NP-hard: it is not in XP unless P = NP. Problems such as clique sit in between: polynomial for each fixed kk, but apparently not with a uniform exponent. That middle ground is what the W hierarchy measures.

Test yourself

What separates FPT from XP?

  1. FPT allows randomization
  2. In FPT the exponent of nn is a constant independent of kk; in XP it may grow with kk
  3. XP problems are NP-hard
  4. FPT requires f(k)f(k) to be polynomial

Why is 3-coloring, parameterized by the number of colors, not in XP unless P = NP?

  1. Because it has no kernel
  2. Because an XP algorithm would run in polynomial time f(3)ng(3)f(3) n^{g(3)} for k=3k = 3, where the problem is NP-hard
  3. Because coloring is W[1]-hard
  4. Because the parameter is unbounded

Why does a running time f(k)⋅ncf(k) \cdot n^c imply a running time of the form g(k)+nO(1)g(k) + n^{O(1)}?

  1. Because f(k)f(k) is always small
  2. Because ab≤a2+b2ab \le a^2 + b^2, so f(k)nc≤f(k)2+n2cf(k) n^c \le f(k)^2 + n^{2c}
  3. Because n≤kn \le k
  4. It does not

Clique parameterized by the maximum degree Δ\Delta is solvable in time O(2ΔΔ2n)O(2^{\Delta} \Delta^2 n). What fact makes this work?

  1. Every clique has at most kk vertices
  2. Every clique containing vv lies inside vv's closed neighbourhood, which has at most Δ+1\Delta + 1 vertices
  3. Graphs of bounded degree are bipartite
  4. Cliques can be found greedily