Parameters, FPT and XP
Classical complexity measures running time by one number, the input length . Parameterized complexity adds a second number , 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 and together?".
Parameterized problems
A parameterized problem is a language : each instance is a pair . The same underlying question gives different parameterized problems for different parameters:
| Problem | Parameter | Status |
|---|---|---|
| VERTEX COVER: cover of size at most ? | solution size | FPT, (Chen, Kanj and Xia, 2010) |
| INDEPENDENT SET: independent set of size ? | solution size | W[1]-hard, in XP |
| CLIQUE: clique of size ? | solution size | W[1]-hard, in XP |
| CLIQUE | maximum degree | FPT, |
| -COLORING | number of colors | NP-hard already for , 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
In FPT the degree of the polynomial does not depend on ; in XP it may. Every FPT problem is in XP (take constant). Clique with parameter is in XP by brute force over all vertex sets, and the central working hypothesis of the area, FPT W[1], says it is not in FPT.
Two equivalent forms of the definition are useful:
- Product or sum. A running time is at most , because . So FPT is also "time ": the exponential part and the polynomial part can be separated. Kernelization makes this separation explicit.
- The function . Nothing restricts beyond computability. In practice for a small constant is the goal, and much of the research on a single problem is about lowering , written when polynomial factors are dropped.
What "efficient" means in numbers:
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 simple steps per second, every entry in the middle column takes at most seconds, the first column is fine up to around 30, and the last column is hopeless already for .
Example: clique parameterized by the maximum degree
Every clique containing a vertex lies inside , a set of at most vertices. So try every vertex and every subset of its neighbourhood:
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 NOThere are at most pairs and each check costs , so the time is : FPT in , linear in . The same instance through brute force over -sets costs 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.
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 , brute force must try all sets, and that number explodes with ; the degree-based search grows linearly in because the exponential part depends only on .
In C++
The same search with neighbourhoods as bit masks: a subset of is a clique if every member's neighbourhood contains the rest.
#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 edges has a cut of size at least , so for max-cut the interesting parameter is how far above the target lies.
- Combined parameters: , or 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 , but apparently not with a uniform exponent. That middle ground is what the W hierarchy measures.
Test yourself
What separates FPT from XP?
- FPT allows randomization
- In FPT the exponent of is a constant independent of ; in XP it may grow with
- XP problems are NP-hard
- FPT requires to be polynomial
Why is 3-coloring, parameterized by the number of colors, not in XP unless P = NP?
- Because it has no kernel
- Because an XP algorithm would run in polynomial time for , where the problem is NP-hard
- Because coloring is W[1]-hard
- Because the parameter is unbounded
Why does a running time imply a running time of the form ?
- Because is always small
- Because , so
- Because
- It does not
Clique parameterized by the maximum degree is solvable in time . What fact makes this work?
- Every clique has at most vertices
- Every clique containing lies inside 's closed neighbourhood, which has at most vertices
- Graphs of bounded degree are bipartite
- Cliques can be found greedily