TExcelTAD
Home › Parameterized & Fine-Grained Complexity › Branching Vectors and a Faster Vertex Cover

Branching Vectors and a Faster Vertex Cover

The 2k2^k bound of Bounded Search Trees for Vertex Cover comes from two branches that each lower kk by only one. If some branch lowers kk by more, the tree is smaller. This lesson develops the arithmetic for such unequal branchings and uses it to bring vertex cover down to O∗(1.4656k)O^*(1.4656^k) with one extra observation.

Branching vectors and branching numbers

Suppose every node of a search tree with parameter kk branches into rr children with parameters k−t1,…,k−trk - t_1, \ldots, k - t_r, where all ti≥1t_i \ge 1. The vector (t1,…,tr)(t_1, \ldots, t_r) is the branching vector. The number of leaves T(k)T(k) satisfies

T(k)≤T(k−t1)+T(k−t2)+⋯+T(k−tr),T(k)=1 for k≤0.T(k) \le T(k - t_1) + T(k - t_2) + \cdots + T(k - t_r), \qquad T(k) = 1 \text{ for } k \le 0.

Lemma. T(k)=O(ck)T(k) = O(c^k), where c>1c > 1 is the unique positive root of

1=x−t1+x−t2+⋯+x−tr.1 = x^{-t_1} + x^{-t_2} + \cdots + x^{-t_r}.

cc is the branching number of the vector.

Proof. The right-hand side is strictly decreasing in x>0x > 0, goes to r≥2r \ge 2 near x=1x = 1 and to 0 as x→∞x \to \infty, so the root exists and is unique. By induction, T(k)≤ckT(k) \le c^{k} for k≥0k \ge 0 (base cases are ≤1≤ck\le 1 \le c^k): T(k)≤∑ick−ti=ck∑ic−ti=ckT(k) \le \sum_i c^{k - t_i} = c^k \sum_i c^{-t_i} = c^k. □\square

Some values, computed by bisection:

python · try it yourself
def branching_number(vec):
    lo, hi = 1.0, 10.0
    for _ in range(100):
        mid = (lo + hi) / 2
        if sum(mid ** -t for t in vec) > 1:
            lo = mid
        else:
            hi = mid
    return hi

for vec in [(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (1, 1, 1), (1, 2, 2), (3, 3, 3)]:
    print(f"{str(vec):10} -> {branching_number(vec):.4f}")
(1, 1)     -> 2.0000
(1, 2)     -> 1.6180
(1, 3)     -> 1.4656
(1, 4)     -> 1.3803
(2, 2)     -> 1.4142
(2, 3)     -> 1.3247
(1, 1, 1)  -> 3.0000
(1, 2, 2)  -> 2.0000
(3, 3, 3)  -> 1.4422

The vector (1,2)(1, 2) gives the golden ratio 1.6181.618; (1,3)(1, 3) gives 1.46561.4656. A balanced vector is better than an unbalanced one with the same sum: (2,2)(2, 2) gives 2≈1.414\sqrt{2} \approx 1.414, below (1,3)(1, 3).

Branching on a high-degree vertex

For a vertex vv, every vertex cover CC either contains vv, or does not; in the second case it must contain all neighbours of vv, since each edge vwvw needs an endpoint. So we may branch:

text
VC-DEGREE(G, k)
0  if k < 0:           return NO                // line 7 may overshoot the budget
1  if G has no edges:  return YES
2  if k = 0:           return NO
3  if every vertex has degree <= 2:
4      return YES if the exact cover of the paths and cycles has size <= k
5  pick a vertex v of degree d >= 3
6  if VC-DEGREE(G - v, k - 1) = YES:  return YES
7  return VC-DEGREE(G - N[v], k - d)            // N(v) goes into the cover

Line 4 is polynomial: a graph of maximum degree 2 is a disjoint union of paths and cycles, a path on pp vertices needs ⌊p/2⌋\lfloor p/2 \rfloor cover vertices and a cycle on cc vertices needs ⌈c/2⌉\lceil c/2 \rceil. Line 7 removes vv as well, since all its edges are covered. The branching vector is (1,d)(1, d) with d≥3d \ge 3, and (1,d)(1, d) is never worse than (1,3)(1, 3), so the tree has O(1.4656k)O(1.4656^k) leaves and the algorithm runs in O(1.4656k(n+m))O(1.4656^k (n + m)) time.

python · try it yourself
import random
from itertools import combinations

def random_graph(n, p, seed):
    rng = random.Random(seed)
    adj = {v: set() for v in range(n)}
    for u in range(n):
        for v in range(u + 1, n):
            if rng.random() < p:
                adj[u].add(v); adj[v].add(u)
    return adj

def delete(adj, S):
    return {v: nb - S for v, nb in adj.items() if v not in S}

def cover_max_deg2(adj):
    seen, total = set(), 0
    for s in adj:
        if s in seen or not adj[s]:
            continue
        comp, stack = [], [s]                     # collect the component
        seen.add(s)
        while stack:
            x = stack.pop(); comp.append(x)
            for y in adj[x]:
                if y not in seen:
                    seen.add(y); stack.append(y)
        edges = sum(len(adj[x]) for x in comp) // 2
        total += (len(comp) + 1) // 2 if edges == len(comp) else len(comp) // 2
    return total

def plain(adj, k, st):
    st[0] += 1
    e = next(((u, v) for u in adj for v in adj[u]), None)
    if e is None:
        return True
    if k <= 0:
        return False
    return plain(delete(adj, {e[0]}), k - 1, st) or plain(delete(adj, {e[1]}), k - 1, st)

def by_degree(adj, k, st):
    st[0] += 1
    if k < 0:
        return False
    if all(not nb for nb in adj.values()):
        return True
    if k <= 0:
        return False
    v = max(adj, key=lambda x: (len(adj[x]), -x))
    if len(adj[v]) <= 2:
        return cover_max_deg2(adj) <= k
    return by_degree(delete(adj, {v}), k - 1, st) or by_degree(delete(adj, adj[v] | {v}), k - len(adj[v]), st)

def brute_opt(adj):
    E = [(u, v) for u in adj for v in adj[u] if u < v]
    for s in range(len(adj) + 1):
        for S in combinations(adj, s):
            S = set(S)
            if all(u in S or v in S for u, v in E):
                return s

print(" n  OPT  nodes(edge branching)  nodes(degree branching)  agree")
for seed in range(5):
    G = random_graph(16, 0.25, seed)
    opt = brute_opt(G)
    a, b = [0], [0]
    ra = [plain(G, k, a) for k in (opt - 1, opt)]
    rb = [by_degree(G, k, b) for k in (opt - 1, opt)]
    print(f"16 {opt:4} {a[0]:22} {b[0]:24}  {ra == rb == [False, True]}")
 n  OPT  nodes(edge branching)  nodes(degree branching)  agree
16    7                    363                       18  True
16    9                    606                       21  True
16    9                    626                       20  True
16    8                    751                       16  True
16    9                   1023                       25  True

Each row runs both algorithms for k=OPT−1k = \text{OPT} - 1 (a NO instance, where the whole tree is explored) and k=OPTk = \text{OPT}, and checks both answers against brute force.

In C++

The degree-branching algorithm with adjacency bitmasks (up to 64 vertices): G−SG - S is one mask operation, the degree of vv is a population count, and the max-degree-2 base case walks each component.

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

int n;
std::vector<uint64_t> adj;
long nodes = 0;

int deg(int v, uint64_t alive) { return std::popcount(adj[v] & alive); }

int cover_deg2(uint64_t alive) {
    int total = 0;
    uint64_t seen = 0;
    for (int s = 0; s < n; s++) {
        if (!(alive >> s & 1) || (seen >> s & 1) || deg(s, alive) == 0) continue;
        uint64_t comp = 0, frontier = 1ULL << s;
        while (frontier) {
            int x = std::countr_zero(frontier);
            frontier &= frontier - 1;
            if (comp >> x & 1) continue;
            comp |= 1ULL << x;
            frontier |= adj[x] & alive & ~comp;
        }
        seen |= comp;
        int vs = std::popcount(comp), es = 0;
        for (uint64_t c = comp; c; c &= c - 1) es += deg(std::countr_zero(c), alive);
        es /= 2;
        total += (es == vs) ? (vs + 1) / 2 : vs / 2;
    }
    return total;
}

bool solve(uint64_t alive, int k) {
    nodes++;
    if (k < 0) return false;
    int best = -1, bd = 0;
    for (int v = 0; v < n; v++)
        if ((alive >> v & 1) && deg(v, alive) > bd) { bd = deg(v, alive); best = v; }
    if (bd == 0) return true;
    if (k <= 0) return false;
    if (bd <= 2) return cover_deg2(alive) <= k;
    if (solve(alive & ~(1ULL << best), k - 1)) return true;
    return solve(alive & ~(adj[best] | (1ULL << best)), k - bd);
}

int main() {
    n = 40;
    adj.assign(n, 0);
    unsigned s = 5;
    for (int u = 0; u < n; u++)
        for (int v = u + 1; v < n; v++) {
            s = s * 1103515245u + 12345u;
            if ((s >> 16) % 100 < 10) { adj[u] |= 1ULL << v; adj[v] |= 1ULL << u; }
        }
    uint64_t all = (n == 64) ? ~0ULL : ((1ULL << n) - 1);
    long total = 0;
    for (int k = 0;; k++) {
        nodes = 0;
        bool ok = solve(all, k);
        total += nodes;
        if (ok) { std::printf("minimum cover %d, %ld nodes over all k, last call %ld\n", k, total, nodes); break; }
    }
}
minimum cover 23, 4040 nodes over all k, last call 17

How far this goes

Refining the case analysis (branching differently on vertices of degree 3, 4 and 5, using reduction rules for degree-1 and degree-2 vertices, and measuring progress by more than kk) has lowered the base steadily:

Bound Authors
O∗(2k)O^*(2^k) folklore
O∗(1.4656k)O^*(1.4656^k) branching on a vertex of degree at least 3, as above
O∗(1.2852k)O^*(1.2852^k) Chen, Kanj and Jia (2001)
O(1.2738k+kn)O(1.2738^k + kn) Chen, Kanj and Xia (2010)

The last bound combines branching with the kernel of The Nemhauser-Trotter LP Kernel, so the exponential part runs on a graph with at most 2k2k vertices. Results of this kind are theorems about worst-case trees. On real instances, good reduction rules usually matter more than a smaller base.

Note: Branching numbers multiply cleanly with polynomial factors only when every node does polynomial work. A branching step that itself takes exponential time, such as trying all subsets of a neighbourhood, needs its own accounting.

Test yourself

What is the branching number of the vector (1,3)(1, 3)?

  1. 2
  2. About 1.4656, the positive root of 1=x−1+x−31 = x^{-1} + x^{-3}
  3. About 1.618
  4. 3

When VC-DEGREE does not put vv in the cover, why may it put all of N(v)N(v) in?

  1. Because N(v)N(v) is an independent set
  2. Because each edge vwvw must be covered and vv is not in the cover, so every neighbour ww must be
  3. Because neighbours have higher degree
  4. Because it is a heuristic

Why does VC-DEGREE need a separate base case for graphs of maximum degree at most 2?

  1. Because such graphs have no vertex cover
  2. Because branching on a degree-2 vertex gives vector (1,2)(1, 2), which would raise the base to 1.618; and such graphs are paths and cycles, solvable exactly in polynomial time
  3. Because the recursion would not terminate
  4. Because kk becomes negative

Which vector gives the smaller search tree: (2,2)(2, 2) or (1,3)(1, 3)?

  1. (1,3)(1, 3)
  2. (2,2)(2, 2), with branching number 2≈1.414\sqrt{2} \approx 1.414 against 1.4656
  3. They are equal because the sums are equal
  4. It depends on nn