Exercises
Thirteen problems covering the whole course: FPT algorithms, kernels, treewidth, parameterized lower bounds and fine-grained reductions. Each has a short Answer and a full Solution; several solutions include a program that checks the result by brute force. Work each one on paper first.
Tip: For an FPT claim, name the parameter, the branching vector or kernel size, and the polynomial factor. For a lower bound, name the hypothesis and check that the reduction keeps the parameter (or the exponent) under control.
| # | Exercise | Practises |
|---|---|---|
| 1 | FPT, XP or neither? | definitions |
| 2 | Two branching vectors | branching numbers |
| 3 | Buss's rules by hand | kernels |
| 4 | Crowns in a star and a path | crown decompositions |
| 5 | Two LP solutions for a path | Nemhauser-Trotter |
| 6 | Find the sunflower | sunflower lemma |
| 7 | How many colorings? | color coding |
| 8 | Treewidth of a small graph | tree decompositions |
| 9 | Independent set on a cycle by DP | treewidth DP |
| 10 | Parameterized or not? | parameterized reductions |
| 11 | A fast 3-coloring algorithm? | ETH |
| 12 | Sizes in split and list | SETH, OV |
| 13 | A negative triangle by min-plus | APSP |
Exercise 1: FPT, XP or neither?
Classify each running time for a problem with parameter and input size : (a) ; (b) ; (c) ; (d) for every ; (e) .
Answer
(a) FPT; (b) XP, not FPT form; (c) FPT; (d) neither: not even polynomial for fixed ; (e) XP.
Solution
FPT means with a constant. (a) has , . (c) is , which is at most for . XP means : (b) and (e) have the parameter in the exponent of ; the factor in (e) does not help, the exponent still grows with . (d) does not depend on but is superpolynomial in for every fixed , so it is not XP either (Parameters, FPT and XP).
Exercise 2: Two branching vectors
A vertex cover algorithm branches on a vertex of degree at least 4 whenever one exists (vector ), and otherwise on a degree-3 vertex with a rule that gives the vector . What is the base of its running time?
Answer
: the running time is , assuming the remaining cases (max degree at most 2) are solved in polynomial time.
Solution
The tree size is governed by the worst branching vector that can occur (Branching Vectors and a Faster Vertex Cover). The roots of and :
def base(vec):
lo, hi = 1.0, 3.0
for _ in range(100):
mid = (lo + hi) / 2
lo, hi = (mid, hi) if sum(mid ** -t for t in vec) > 1 else (lo, mid)
return hi
for v in [(1, 4), (2, 3), (1, 3)]:
print(v, round(base(v), 4))(1, 4) 1.3803
(2, 3) 1.3247
(1, 3) 1.4656
The overall base is the larger one, 1.3803. (If degree-3 vertices had to use , the base would be 1.4656.)
Exercise 3: Buss's rules by hand
The graph is a star with centre and 10 leaves, plus a separate triangle . Apply Buss's rules with . What remains, and what is the answer?
Answer
is forced ( becomes 2); the leaves become isolated and are deleted; the triangle remains with , it has 3 edges , and the answer is YES ().
Solution
has degree , so it is in every cover of size at most 3: delete it, . The ten leaves are now isolated: delete them. The triangle's vertices have degree , so no more vertices are forced; the triangle has 3 edges and , so the instance passes the edge test. The kernel is , a YES instance since any two triangle vertices cover it (Kernels and Buss's Rule for Vertex Cover).
Exercise 4: Crowns in a star and a path
Give a crown decomposition of (a) the star and (b) the path . What does the crown rule do in each case?
Answer
(a) = the five leaves, = the centre, : the rule takes the centre and the graph disappears. (b) For example , , : take 2, leaving the path ; again , leaves the single vertex 3. Total cover , optimal.
Solution
In (a) the leaves are independent, their neighbourhood is the centre, and any one leaf-centre edge is a matching saturating . In (b) the pendant vertex 1 with its neighbour 2 is the degree-1 rule as a crown: independent, , matched by the edge 12, and no edge from 1 to . Larger crowns work too: , is a crown (independent, , matching , and 5 is adjacent only to 4), giving the same cover at once (Crown Decompositions).
Exercise 5: Two LP solutions for a path
For the path , give two optimal half-integral solutions of the vertex cover LP, one integral and one with every value . What kernel does each give?
Answer
and , both of value 2. The first gives an empty kernel with in the cover; the second leaves the whole path.
Solution
The LP value is at least 2 because edges and are disjoint and each needs total value 1. Both solutions reach 2. Nemhauser-Trotter applies to any optimal half-integral solution (The Nemhauser-Trotter LP Kernel), so the kernel depends on which one the solver returns; the theory only guarantees . Implementations prefer solutions with as few halves as possible: from any optimal solution one can compute in polynomial time one whose is minimal.
Exercise 6: Find the sunflower
In the family , find a sunflower with 3 petals. Is there one with 4 petals?
Answer
with core (and also ). With 4 petals: no.
Solution
The three sets containing 1 with otherwise disjoint elements form a sunflower with core . A 4-petal sunflower with core would need a fourth set through 1 disjoint from outside 1; the only other set with 1 is , which meets in . With an empty core we would need 4 pairwise disjoint sets, but at most one of them can contain 1 and only two sets avoid 1. Checking all triples and quadruples confirms this:
from itertools import combinations
F = [{1, 2, 3}, {1, 4, 5}, {1, 6, 7}, {2, 4, 6}, {3, 5, 7}, {1, 2, 8}]
def is_sunflower(sets):
core = set.intersection(*sets)
return all(a & b == core for a, b in combinations(sets, 2)), core
for p in [3, 4]:
found = [[sorted(A) for A in S] for S in combinations(F, p) if is_sunflower(list(S))[0]]
print(p, "petals:", found if found else "none")3 petals: [[[1, 2, 3], [1, 4, 5], [1, 6, 7]], [[1, 4, 5], [1, 6, 7], [1, 2, 8]]]
4 petals: none
Exercise 7: How many colorings?
Color coding for -PATH with : how many random colorings are needed so that a fixed 10-path is colorful in at least one of them with probability at least 0.99?
Answer
About 12,700 colorings: .
Solution
The probability of being colorful is (Color Coding and Long Paths). The failure probability after rounds is , which is at most when .
import math
p = math.factorial(10) / 10 ** 10
r = math.ceil(math.log(100) / p)
print(f"p = {p:.3e}, rounds = {r}, exact failure (1-p)^r = {(1 - p) ** r:.5f}")p = 3.629e-04, rounds = 12691, exact failure (1-p)^r = 0.00999
Exercise 8: Treewidth of a small graph
The graph has vertices and edges (two triangles and sharing the edge , plus the pendant edge ). Give a tree decomposition of minimum width and prove it is minimum.
Answer
Bags in a path; width 2. The treewidth is 2.
Solution
All edges lie in a bag ( in the first; in the second; in the third), and each vertex's bags are consecutive: 2 and 3 in the first two, 4 in the last two. The width is . It cannot be 1: the graph contains a triangle, and a clique must lie in one bag (Tree Decompositions and Treewidth).
Exercise 9: Independent set on a cycle by DP
Using the path decomposition , , of the cycle , run the independent set DP for with weights on vertices . What is the answer, and how many table entries does a bag have at most?
Answer
The maximum weight is 16 ( has ); a bag has at most 6 independent subsets of its 3 vertices (out of 8 subsets).
Solution
Every bag contains vertex 0, so the table splits into "0 in the set" and "0 not in the set"; it is the classical way of solving a cycle by fixing one vertex. The program runs the four rules on the path decomposition (as a sequence of introduce and forget steps) and compares with brute force.
from itertools import combinations
w = [3, 1, 4, 1, 5, 9, 2]
n = len(w)
adj = {v: {(v - 1) % n, (v + 1) % n} for v in range(n)}
bags = [[0, i, i + 1] for i in range(1, n - 1)]
table, bag, biggest = {frozenset(): 0}, set(), 1
for B in bags + [[]]:
for v in sorted(bag - set(B)): # forget
new = {}
for S, val in table.items():
new[S - {v}] = max(new.get(S - {v}, -1), val)
table, bag = new, bag - {v}
for v in [x for x in B if x not in bag]: # introduce
new = dict(table)
for S, val in table.items():
if not adj[v] & S:
new[S | {v}] = val + w[v]
table, bag = new, bag | {v}
biggest = max(biggest, len(table))
best = max(sum(w[v] for v in S) for r in range(n + 1) for S in combinations(range(n), r)
if all(b not in adj[a] for a, b in combinations(S, 2)))
print("DP:", table[frozenset()], " brute force:", best, " largest table:", biggest)DP: 16 brute force: 16 largest table: 6
The subsets of a bag that are independent in are , the three singletons, and and when those vertices are not neighbours of 0 ( is an edge), so at most 6 (Independent Set on Bounded Treewidth).
Exercise 10: Parameterized or not?
Which of these reductions are parameterized reductions? (a) DOMINATING SET to SET COVER: universe , one set per vertex, same . (b) VERTEX COVER to INDEPENDENT SET . (c) CLIQUE to CLIQUE where adds a universal vertex.
Answer
(a) yes; (b) no; (c) yes.
Solution
(a) A dominating set of size is exactly a choice of closed neighbourhoods covering ; the parameter is unchanged and the map is polynomial. (b) is correct as a reduction but the new parameter is not bounded by a function of (Parameterized Reductions and W[1]-Hardness). (c) A -clique plus the universal vertex is a -clique, and a -clique in minus the universal vertex (or minus any vertex, if it does not use it) is a -clique of ; .
Exercise 11: A fast 3-coloring algorithm?
Someone claims a algorithm for 3-COLORING of arbitrary graphs on vertices. Which hypothesis does that refute? Would it be surprising for planar graphs?
Answer
On general sparse graphs it refutes ETH. For planar graphs a algorithm exists, and ETH says that is optimal.
Solution
3-COLORING has a linear reduction from 3-SAT: a formula with variables and clauses (after sparsification) becomes a graph with vertices and edges. A algorithm would then solve 3-SAT in time (Tight Lower Bounds from ETH and SETH). Planar graphs have treewidth , so the coloring DP runs in ; the reduction to planar graphs has quadratic blow-up, which is exactly why the planar lower bound is rather than .
Exercise 12: Sizes in split and list
A CNF formula has 40 variables and 200 clauses. How many vectors and which dimension does the split-and-list reduction produce? How many pairs does the naive OV algorithm inspect in the worst case, and what OV running time would beat brute force by a factor of ?
Answer
vectors per side, dimension 200; pairs; an algorithm in time with and , that is , would take about steps.
Solution
Each half has 20 variables, so partial assignments per side, each a vector with one coordinate per clause (Orthogonal Vectors and the Split-and-List Reduction). The naive algorithm checks all pairs, as many as brute force has assignments. An algorithm costs ; to save a factor we need , . SETH predicts that no fixed works for all clause widths.
Exercise 13: A negative triangle by min-plus
The symmetric weight matrix of 4 vertices is below. Compute (over ) and use it to find a negative triangle.
0 1 2 3
0 - 5 -4 2
1 5 - 3 -6
2 -4 3 - 1
3 2 -6 1 -Answer
and ; but and : the triangle has weight . The triangle , of weight , is negative too.
Solution
The program computes all of and checks every pair, then confirms with brute force over triples (APSP, Negative Triangle and Subcubic Equivalence).
from itertools import combinations
W = [[0, 5, -4, 2], [5, 0, 3, -6], [-4, 3, 0, 1], [2, -6, 1, 0]]
n = 4
for i, j in combinations(range(n), 2):
k_best = min((k for k in range(n) if k not in (i, j)), key=lambda k: W[i][k] + W[k][j])
c = W[i][k_best] + W[k_best][j]
print(f"C[{i}][{j}] = {c:3} via {k_best}; C + w({j},{i}) = {c + W[j][i]:3}" + (" <- negative" if c + W[j][i] < 0 else ""))
print("negative triangles:", [t for t in combinations(range(n), 3) if W[t[0]][t[1]] + W[t[1]][t[2]] + W[t[2]][t[0]] < 0])C[0][1] = -4 via 3; C + w(1,0) = 1
C[0][2] = 3 via 3; C + w(2,0) = -1 <- negative
C[0][3] = -3 via 2; C + w(3,0) = -1 <- negative
C[1][2] = -5 via 3; C + w(2,1) = -2 <- negative
C[1][3] = 4 via 2; C + w(3,1) = -2 <- negative
C[2][3] = -3 via 1; C + w(3,2) = -2 <- negative
negative triangles: [(0, 2, 3), (1, 2, 3)]
Test yourself
A vertex cover algorithm uses the branching vectors and . What is its running time base?
- 1.3247
- 1.3803
- 1.4656
- 2
Which reduction is NOT parameterized?
- Dominating set to set cover with the same
- Vertex cover to independent set
- Clique to independent set in the complement with the same
- Clique to clique with a universal vertex added
What does a algorithm for 3-coloring all graphs on vertices refute?
- Nothing; such algorithms exist
- ETH
- P NP
- The 3SUM conjecture
In split and list, a formula with 40 variables gives OV instances with how many vectors per side?
- 40
- 200