A tree decomposition represents a graph by arranging overlapping sets of vertices along a tree.
The purpose is to describe a graph that may contain cycles by using a tree-like structure. The graph itself may be complicated, but its vertices are grouped into bags, and the bags are organized as nodes of a tree. If the bags are small, many hard graph problems become easier.
Tree decompositions are important in structural graph theory, dynamic programming, constraint satisfaction, probabilistic inference, database query optimization, and algorithms on graphs of bounded treewidth. A standard definition uses three conditions: every graph vertex appears in some bag, every graph edge appears inside some bag, and the bags containing a fixed vertex form a connected subtree.
34.1 Motivation
Trees are simpler than general graphs.
A tree has no cycles. Between any two vertices there is exactly one simple path. Many problems that are hard on general graphs are easy on trees because information can be passed from leaves toward a root.
A general graph may contain many cycles. These cycles create dependencies that prevent simple recursive methods. A tree decomposition handles this by grouping vertices into bags. Each bag stores a local part of the graph. The tree structure describes how these local parts are connected.
The guiding idea is this:
A graph is close to a tree if it can be decomposed into small overlapping pieces arranged as a tree.
The size of the largest bag measures how far the graph is from being tree-like.
34.2 Definition
Let
be an undirected graph.
A tree decomposition of is a pair
where is a tree and
is a family of subsets of , one subset for each node of .
Each set is called a bag.
The following three conditions must hold.
First, every vertex of appears in at least one bag:
Second, every edge of is contained in some bag. That is, for every edge
there exists a node such that
Third, for every vertex , the set of nodes
forms a connected subtree of .
The third condition is called the connectedness condition or running intersection property. It prevents a vertex from disappearing and then reappearing in unrelated parts of the decomposition.
34.3 Bags and the Decomposition Tree
There are two graphs involved in a tree decomposition.
The original graph is
Its vertices are the objects we want to study.
The decomposition tree is
Its nodes are not vertices of . Instead, each node of carries a bag, and each bag is a subset of vertices of .
This distinction is important. To avoid confusion, one often says vertex for an element of , and node for an element of .
A bag may contain one vertex, two vertices, or many vertices. Adjacent bags in usually overlap. The overlaps are where information is passed between parts of the decomposition.
34.4 A Simple Example
Let be the path graph
One tree decomposition has three bags:
Let the decomposition tree be the path
Every graph vertex appears in some bag. Every graph edge appears inside a bag:
The bags containing vertex form the connected set
The bags containing vertex form the connected set
Vertices and each appear in one bag. Thus all three conditions hold.
This example shows that a tree is already tree-like. Its decomposition can use bags of size .
34.5 A Cycle Example
Consider the cycle graph
This graph is not a tree, but it has a small tree decomposition.
Take the bags
Let the decomposition tree consist of one edge:
Every vertex appears in some bag. The edges are covered:
The bags containing vertex are and , which are adjacent. The bags containing vertex are also and . The other vertices appear once.
Thus the cycle has a tree decomposition with bags of size .
The cycle cannot be decomposed with only bags of size , because a cycle has more dependency than a tree. This difference is measured by treewidth.
34.6 Width
The width of a tree decomposition is one less than the size of its largest bag:
The subtraction by is conventional. With this convention, a tree has treewidth , not , because it can be decomposed into bags of size .
A decomposition with small width is better for many algorithms, because the amount of local state often grows exponentially in the bag size.
For example:
| Largest bag size | Width |
|---|---|
34.7 Treewidth
The treewidth of a graph , written
is the minimum width over all tree decompositions of :
Treewidth measures how close a graph is to a tree.
A graph has treewidth exactly when it has no edges. A forest has treewidth at most . Any nonempty forest has treewidth exactly . A cycle has treewidth . Complete graphs have large treewidth.
For the complete graph , every pair of vertices is adjacent. In any tree decomposition, all vertices must appear together in some bag. Therefore
34.8 Why the Connectedness Condition Matters
The first two conditions alone are not enough.
Suppose a vertex appears in two distant bags but not in the bags between them. Then the decomposition treats as if it belongs to two separate regions. This breaks dynamic programming, because information about could become inconsistent.
The connectedness condition ensures that all appearances of form one contiguous region of the decomposition tree.
If appears in bag and bag , then must appear in every bag on the unique path between and in .
This condition is what makes the decomposition behave like a coherent tree-structured representation.
34.9 Separators from Tree Decompositions
Tree decompositions encode separators.
Let be an edge of the decomposition tree . Removing this edge splits into two components. These two components correspond to two collections of bags.
Let
Then acts as a separator between the parts of represented on the two sides.
Any path in from a vertex that appears only on one side to a vertex that appears only on the other side must pass through a vertex in .
This separator view explains why tree decompositions support divide-and-conquer algorithms. The graph can be separated into parts that interact through small boundary sets.
34.10 Trivial Decomposition
Every graph has a tree decomposition.
The simplest one uses a single bag:
The decomposition tree has one node carrying this bag.
All conditions are immediate. Every vertex appears in the bag. Every edge has both endpoints in the bag. The connectedness condition holds because each vertex appears in a one-node subtree.
The width of this decomposition is
This decomposition is usually not useful, but it proves that treewidth is always defined for finite graphs.
34.11 Tree Decomposition of a Tree
Let itself be a tree.
For every edge
create a bag
Arrange these bags in a tree structure corresponding to the original tree.
One way is to root , then connect bags for adjacent edges when the corresponding edges share a vertex and lie next to each other in the rooted structure.
Every edge of is contained in its own bag. Every vertex appears in the bags corresponding to edges incident with . These bags form a connected subtree.
Thus every tree with at least one edge has a decomposition of width .
Since a graph of treewidth has no edges, every nontrivial tree has treewidth .
34.12 Complete Graphs
Complete graphs have large treewidth.
Let
In a complete graph, every pair of vertices is adjacent.
For any tree decomposition of , there must be a bag containing every vertex of . This follows from the Helly property for subtrees of a tree: if every pair of connected subtrees intersects, then all of them have a common intersection.
For each vertex , the bags containing form a connected subtree of the decomposition tree. Since every pair of vertices is adjacent, each pair of these subtrees intersects in some bag. Hence all subtrees share a common node. The bag at that node contains all vertices.
Therefore the largest bag has size at least , and
34.13 Dynamic Programming on Tree Decompositions
Tree decompositions are algorithmically useful because they reduce global graph problems to local computations on bags.
A typical dynamic programming algorithm proceeds as follows:
- Root the decomposition tree.
- Process bags from leaves toward the root.
- For each bag, store partial solutions indexed by the vertices in that bag.
- Combine information from child bags through their intersections with the parent bag.
- Read the final answer at the root.
The running time is often exponential in the treewidth but polynomial in the number of vertices.
A common form is
where is the treewidth and . The function may be exponential, but if is small, the algorithm can be efficient.
This is the main reason bounded-treewidth graphs are important.
34.14 Example: Independent Set
An independent set is a set of vertices no two of which are adjacent.
On a general graph, finding a maximum independent set is computationally hard. On a graph with small treewidth, it can be solved by dynamic programming over a tree decomposition.
For each bag , one considers all subsets
Only subsets that are independent inside the bag are allowed. The algorithm records the best partial solution below consistent with choosing inside .
The number of subsets of a bag is
Thus small bags make the computation feasible.
This illustrates the general pattern: treewidth controls the number of boundary configurations.
34.15 Nice Tree Decompositions
For algorithmic purposes, tree decompositions are often converted into nice tree decompositions.
A nice tree decomposition is rooted and has restricted node types. Common types are:
| Node type | Meaning |
|---|---|
| Leaf | Starts a computation |
| Introduce vertex | Adds one vertex to the bag |
| Forget vertex | Removes one vertex from the bag |
| Introduce edge | Accounts for one graph edge |
| Join | Combines two child computations |
Nice decompositions simplify dynamic programming because each step changes the bag in a controlled way.
They do not change the essential width. They mainly provide a convenient normal form.
34.16 Chordal Graph View
Tree decompositions are closely related to chordal graphs.
A chordal graph is a graph in which every cycle of length at least four has a chord. A chord is an edge connecting two nonconsecutive vertices of the cycle.
One may view a tree decomposition as embedding the original graph into a chordal supergraph whose maximal cliques correspond to bags.
From this viewpoint, treewidth is one less than the minimum possible clique size in such a chordal completion.
This connection links tree decompositions with elimination orderings, sparse matrix factorization, and graphical models.
34.17 Elimination Orderings
An elimination ordering is an ordering of vertices
Eliminating a vertex means making its remaining neighbors into a clique, then removing the vertex.
The width of an elimination ordering is the maximum number of later neighbors any vertex has at the moment it is eliminated.
The treewidth of a graph equals the minimum width over all elimination orderings.
This gives another way to understand treewidth. A graph has small treewidth if its vertices can be eliminated while keeping small remaining neighborhoods.
34.18 Applications
Tree decompositions appear in several areas.
| Area | Role of tree decomposition |
|---|---|
| Graph algorithms | Dynamic programming over bags |
| Constraint satisfaction | Variables in bags, constraints across bags |
| Probabilistic inference | Junction tree methods |
| Database systems | Join trees and acyclic query plans |
| Sparse linear algebra | Fill-in and elimination |
| Structural graph theory | Measuring tree-like structure |
| Logic | Efficient model checking on bounded treewidth |
The common theme is controlled interaction. A large structure is decomposed into parts whose overlap is small.
34.19 Limitations
Tree decompositions are powerful when the width is small.
They become less useful when the treewidth is large. A graph may have many vertices but small treewidth, or it may have moderate size and large treewidth. Dense graphs often have large treewidth because many vertices must appear together in bags.
Finding an optimal tree decomposition is itself computationally difficult in general. In practice, algorithms often use heuristics or approximation methods to find decompositions that are good enough.
Thus tree decomposition is most effective when the input graph has natural sparsity, locality, or separator structure.
34.20 Summary
A tree decomposition represents a graph by assigning subsets of graph vertices, called bags, to the nodes of a tree.
The bags must cover all vertices, cover all edges, and satisfy the connectedness condition for each vertex.
The width of a decomposition is the largest bag size minus one. The treewidth of a graph is the minimum possible width.
Small treewidth means that the graph is structurally close to a tree. This enables dynamic programming and separator-based reasoning. Tree decompositions therefore form a bridge between graph structure and efficient algorithms.