Proofs: Constructing a tree decomposition
These are the human proofs of Constructing a tree decomposition, at full length.
DECOMPOSE returns a tree decomposition of width at most 4k + 4, or a true answer that the treewidth exceeds k full
This proof shows: correctness, termination.
Let be a simple graph with vertices, and . For , is the set of vertices outside with a neighbour in . A task has nonempty and connected, and .
Lemma 1 (edges). If , then .
Proof. Take a tree decomposition of width at most and remove bags that are subsets of a neighbouring bag; this keeps a decomposition. If , some leaf bag with neighbour has a vertex (or is the only bag). By the subtree condition, is in no other bag, so all neighbours of are in , and . Removing keeps the treewidth at most . By induction on , .
Lemma 2 (balanced separator). Let be a graph with and . There is a set of at most vertices such that every connected component of contains at most vertices of .
Proof. Take a tree decomposition of of width at most and root . For a node , let be the union of the bags in the subtree of . At the root, . Choose a node with such that every child of has ; it exists, by walking down from the root. Let , so . By the subtree condition, a vertex in for a child appears only in bags of the subtree of , and a vertex outside appears only outside the subtree of . Every edge lies in a bag, so an edge of cannot join two of the sets (for different children ) and . So each component of lies in one of these sets. If , then . If , then .
Lemma 3 (grouping). Let with and each . The indices can be split into two groups, each with sum at most .
Proof. If some , put alone in the first group: its sum is at most , and the rest sum to at most . Otherwise add indices to the first group one at a time until its sum is at least , or no index is left. Before the last addition the sum was below , and the last is below , so the first group sums to less than ; the second sums to at most , or to .
Lemma 4 (a split exists). Let be a task with , and . Then line L6 finds a split.
Proof. Apply Lemma 2 to , which has treewidth at most , and . Let be the set, , and . Each component of contains at most vertices of . By Lemma 3, with , the components can be grouped so that the vertices of in the two groups, and , number at most each, so at most each, being integers. No path in joins to , since they lie in different components, so meets every path from to in , and . Line L6 tries this split, and the flow finds a cut of the least size, which is at most .
Invariant. Every task on the stack satisfies: is nonempty and connected; ; ; is disjoint from all bags made so far; and the node , if any, has a bag that contains .
Initialization. At line L2, is a component, so .
Maintenance. Take a task and its bag , with . Let be a component of . It is nonempty, connected, and disjoint from and the older bags. A neighbour of a vertex of is either in , and then in , since is a whole component of ; or outside , and then in . So , the bag of the new node. For the size: if line L5 was used, . If line L8 was used, then is connected and avoids , and every vertex of outside is joined to by an edge. If met both and , there would be a path from to through that avoids and , against the choice of . So or , and .
Progress. Each task adds at least one vertex of to its bag. At line L5 this is clear. At line L8, , and , so both and are nonempty. If , then , and in the connected set is adjacent to every vertex of , since , which joins to , a contradiction. So contains a vertex of .
Termination. By the invariant and progress, the sets of all tasks taken from the stack contain distinct new vertices in their bags, and these vertices are never in a later . So there are at most tasks, and every loop of the algorithm is finite. The search of line L6 is finite.
Theorem. If DECOMPOSE returns "treewidth ", then . Otherwise it returns a tree decomposition of in which every bag has at most vertices. If , it does not return "treewidth ".
Proof. The answer "treewidth " comes from line L1, which is right by Lemma 1, or from line L7, which is right by Lemma 4. So if the decomposition is returned.
Suppose a decomposition is returned. The nodes form a forest, since each node except the first of a component is joined to an older node. Bag sizes: at line L5, ; at line L8, .
Each vertex is covered, and its bags are connected. Let . It lies in the first task's for its component. Follow the tasks whose contains : each next one is a child task of the last, until a task puts in its bag, which must happen since every task with either puts in its bag or passes it to exactly one child task, and there are finitely many tasks. After , is in no later . A later bag holds only through its boundary, as . A child task of a node with has , since , and its own node is joined to . So every bag that holds is joined, by a chain of nodes whose bags hold , to the node of ; these bags form a connected subtree.
Each edge is covered. Let , and let be the first task that puts or in its bag, say . At that moment is not in an older bag, so it is in , as and were together in each earlier (they are adjacent, and none of the earlier bags holds either). If , the edge is covered. Otherwise lies in a component of with , and the task for has . Repeat with this task: stays in the boundary, by the same argument, until a task puts in its bag, whose bag also contains as part of .
Running time. At most tasks; each tries at most splits, each with a flow of at most augmenting paths on a graph of size, and after line L1. So the time is .