Tree decomposition 159023 222906003 2008-07-01T18:04:17Z SanderEvers 4746657 added reference for definition of tree decomposition [[Image:Tree decomposition.svg|thumb|240px|A graph with eight vertices, and a tree decomposition of it onto a tree with six nodes. Each graph edge connects two vertices that are listed together at some tree node, and each graph vertex is listed at the nodes of a contiguous subtree of the tree. Each tree node lists at most three vertices, so the width of this decomposition is two.]] In [[graph theory]], a '''tree decomposition''' is a mapping of a [[graph (mathematics)|graph]] into a [[tree (graph theory)|tree]] that can be used to speed up solving certain problems on the original graph. The '''treewidth''' measures the number of graph vertices mapped onto any tree node in an optimal tree decomposition. While it is [[NP-hard]] to determine the treewidth of a graph, many [[NP-hard]] combinatorial problems on graphs are solvable in polynomial time when restricted to graphs of bounded treewidth. In [[machine learning]], tree decompositions are also called '''junction trees''', '''clique trees''', or '''join trees'''; they play an important role in problems like [[belief propagation|probabilistic inference]], [[constraint satisfaction]], [[query optimization]], and [[matrix decomposition]]. The concept of tree decompositions and treewidth was introduced by {{harvtxt|Robertson|Seymour|1984}} and has since been studied by many other authors. ==Definition== Intuitively, a tree decomposition represents the vertices of the given graph as subtrees of a tree, in such a way that vertices are adjacent only when the corresponding subtrees intersect. Thus, the graph forms a [[subgraph]] of the [[intersection graph]] of the subtrees. The full intersection graph is a [[chordal graph]]. Each subtree associates a graph vertex with a set of tree nodes. To define this formally, we represent each tree node as the set of vertices associated with it. Thus, given a graph ''G'' = (''V'', ''E''), a tree decomposition is a pair (''X'', ''T''), where ''X'' = {''X''<sub>1</sub>, ..., ''X''<sub>''n''</sub>} is a family of subsets of ''V'', and ''T'' is a tree whose nodes are the subsets ''X''<sub>''i''</sub>, satisfying the following properties<ref>{{harvtxt|Diestel}} section 12.3</ref>: # The union of all sets ''X''<sub>''i''</sub> equals ''V''. That is, each graph vertex is associated with at least one tree node. # For every edge (''v'', ''w'') in the graph, there is a subset ''X''<sub>''i''</sub> that contains both ''v'' and ''w''. That is, vertices are adjacent in the graph only when the corresponding subtrees have a node in common. # If ''X''<sub>''i''</sub> and ''X''<sub>''j''</sub> both contain a vertex ''v'', then all nodes ''X''<sub>''z''</sub> of the tree in the (unique) path between ''X''<sub>''i''</sub> and ''X''<sub>''j''</sub> contain ''v'' as well. That is, the nodes associated with vertex ''v'' form a connected subset of ''T''. The tree decomposition of a graph is far from unique; for example, a trivial tree decomposition contains all vertices of the graph in its single root node. ==Treewidth== The ''width'' of a tree decomposition is the size of its largest set ''X''<sub>''i''</sub> minus one. The '''treewidth''' tw(''G'') of a graph ''G'' is the minimum width among all possible tree decompositions of ''G''. In this definition, the size of the largest set is diminished by one in order to make the treewidth of a tree equal to one. Equivalently, the treewidth of ''G'' is one less than the size of the largest [[clique (graph theory)|clique]] in any [[chordal graph]] containing ''G''. Treewidth can also be characterized in terms of certain [[pursuit-evasion]] games on the graph.<ref>{{harvtxt|Seymour|Thomas|1993}}.</ref> The graphs with treewidth at most ''k'' are also called '''partial ''k''-trees'''. It is NP-complete to determine whether a given graph ''G'' has treewidth at most a given variable ''k''.<ref>{{harvtxt|Arnborg|Corneil|Proskurowski|1987}}.</ref> However, when ''k'' is any fixed constant, the graphs with treewidth ''k'' can be recognized, and a width ''k'' tree decomposition constructed for them, in linear time.<ref name="b96">{{harvtxt|Bodlaender|1996}}.</ref> The time dependence of this algorithm on ''k'' is exponential. ==Graph minors== [[Image:Partial 3-tree forbidden minors.svg|thumb|Forbidden minors for partial 3-trees]] For any fixed constant ''k'', the partial ''k''-trees are closed under the operation of [[graph minor]]s, and therefore, by the [[Robertson–Seymour theorem]], this family can be characterized in terms of a finite set of [[Forbidden graph characterization|forbidden minors]]. For partial 1-trees (that is, forests), the single forbidden minor is a triangle, and for the partial 2-trees the single forbidden minor is the [[complete graph]] on four vertices. However, the number of forbidden minors increases for larger values of ''k'': for partial 3-trees there are four forbidden minors, the complete graph on five vertices, the [[octahedron|octahedral graph]] with six vertices, the [[Möbius ladder]] with eight vertices, and the [[pentagonal prism]] with ten vertices.<ref name="b98">{{harvtxt|Bodlaender|1998}}.</ref> The [[planar graph]]s do not have bounded treewidth, because the ''n'' &times; ''n'' [[grid graph]] is a planar graph with treewidth ''n''. Therefore, if ''F'' is a minor-closed graph family with bounded treewidth, it cannot include all planar graphs. Conversely, if some planar graph cannot occur as a minor for graphs in family ''F'', then there is a constant ''k'' such that all graphs in ''F'' have treewidth at most ''k''. That is, the following three conditions are equivalent to each other:<ref>{{harvtxt|Robertson|Seymour|1986}}.</ref> #''F'' is a minor-closed family of bounded-treewidth graphs; #One of the finitely many forbidden minors characterizing ''F'' is planar; #''F'' is a minor-closed graph family that does not include all planar graphs. Families of graphs with bounded treewidth include the [[cactus graph]]s, [[pseudoforest]]s, [[series-parallel graph]]s, [[outerplanar graph]]s, and [[Halin graph]]s.<ref name="b98"/> The [[control flow graph]]s arising in the [[compiler|compilation]] of [[Structured programming|structured programs]] also have bounded treewidth, which allows certain tasks such as [[register allocation]] to be performed efficiently on them.<ref>{{harvtxt|Thorup|1998}}.</ref> ==Dynamic programming== As several authors independently observed in the late 1980s,<ref>{{harvtxt|Arnborg|Proskurowski|1989}}; {{harvtxt|Bern|Lawler|Wong|1987}}; {{harvtxt|Bodlaender|1988}}.</ref> many algorithmic problems that are [[NP-completeness|NP-complete]] for arbitrary graphs may be solved efficiently by [[dynamic programming]] for graphs of bounded treewidth, using the tree-decompositions of these graphs. As an example, consider the problem of finding the [[maximum independent set]] in a graph of treewidth ''k''. To solve this problem, first choose one of the nodes of the tree decomposition to be the root, arbitrarily. For a node ''X<sub>i</sub>'' of the tree decomposition, let ''D<sub>i</sub>'' be the union of the sets ''X<sub>j</sub>'' descending from ''X<sub>i</sub>''. Let ''A''(''S'',''i''), for an independent set ''S''&nbsp;&sub;&nbsp;''X<sub>i</sub>'', denote the size of the largest independent subset ''I'' of ''D<sub>i</sub>'' such that ''I''&nbsp;&cap;&nbsp;''X<sub>i</sub>''&nbsp;=&nbsp;''S''. Similarly, for an adjacent pair of nodes ''X<sub>i</sub>'' and ''X<sub>j</sub>'', with ''X<sub>i</sub>'' farther from the root of the tree than ''X<sub>j</sub>'', and an independent set ''S''&nbsp;&sub;&nbsp;''X<sub>i</sub>''&nbsp;&cap;&nbsp;''X<sub>j</sub>'', let ''B''(''S'',''i'',''j'') denote the size of the largest independent subset ''I'' of ''D<sub>i</sub>'' such that ''I''&nbsp;&cap;&nbsp;''X<sub>i</sub>''&nbsp;&cap;&nbsp;''X<sub>j</sub>''&nbsp;=&nbsp;''S''. We may calculate these ''A'' and ''B'' values by a bottom-up traversal of the tree: :<math>A(S,i)=|S| + \sum_{j} \left(B(S\cap X_j, j,i) - |S\cap X_j|\right)</math> :<math>B(S,i,j)=\max_{S'\subset X_i\atop S=S'\cap X_j} A(S',i)</math> where the sum in the calculation of <math>A(S,i)</math> is over the children of node <math>X_i</math>. At each node or edge, there are at most 2<sup>''k''</sup> sets ''S'' for which we need to calculate these values, so if ''k'' is a constant then the whole calculation takes constant time per edge or node. The size of the maximum independent set is the largest value stored at the root node, and the maximum independent set itself can be found (as is standard in dynamic programming algorithms) by backtracking through these stored values starting from this largest value. Thus, in graphs of bounded treewidth, the maximum independent set problem may be solved in linear time. Similar algorithms apply to many other graph problems. This dynamic programming approach is used in [[machine learning]] via the [[junction tree algorithm]] for [[belief propagation]] in graphs of bounded treewidth. It also plays a key role in algorithms for computing the treewidth and constructing tree decompositions: typically, such algorithms have a first step that [[approximation algorithm|approximates]] the treewidth, constructing a tree decomposition with this approximate width, and then a second step that performs dynamic programming in the approximate tree decomposition to compute the exact value of the treewidth.<ref name="b96"/> ==Treewidth of cliques== In any tree decomposition <math>(T, X)</math> of a graph containing a [[Clique (graph theory)|clique]] there is a node ''i'' in ''T'' such that <math>X_i</math> contains all the nodes of the clique. This is shown by [[mathematical induction|induction]] on the size of the clique. The base cases are cliques of size 1 and 2, which follow from the conditions 1 and 2 on a tree decomposition. The inductive case is a graph containing a clique of size ''k''+1, where ''k'' is 2 or greater. Let ''C'' be the set of nodes in the clique. Since <math>k+1 \geq 3</math>, there are at least three nodes in the clique, call them ''x'', ''y'' and ''z''. We know from the induction hypothesis that there are nodes ''a'', ''b'' and ''c'' in the tree decomposition where :<math>X_a \supseteq C-\{x\}</math>, <math>X_b \supseteq C-\{y\}</math>, <math>X_c \supseteq C-\{z\}</math>. In a [[Tree (graph theory)|tree]] there is exactly one path between any two nodes. A second property of trees is that the three paths between a, b and c have a non-empty intersection. Let v be a node in this intersection. From condition 3 on a tree decomposition we get that :<math>X_v \supseteq X_a \cap X_b \supseteq C - \{ x, y \}</math> :<math>X_v \supseteq X_b \cap X_c \supseteq C - \{ y, z \}</math> :<math>X_v \supseteq X_a \cap X_c \supseteq C - \{ x, z \}</math> This implies that <math>X_v \supseteq C</math>. It follows from this that the treewidth of a ''k''-clique is ''k''-1. ==Treewidth of trees== A graph has treewidth 1 if and only if it is a tree. This can be shown in two steps, first that a tree has treewidth 1, second, that a graph with treewidth 1 is a tree. To show the former, use [[mathematical induction|induction]] on the number of nodes in the tree to show that it has a tree decomposition with no bag with size larger than two. The base cases are trees with one or two nodes, in which case the tree decomposition with one single node is sufficient. The inductive case is a tree <math>G</math> with <math>k+1</math> nodes, where <math>k</math> is any integer greater than <math>1</math>. If we remove a [[leaf]] <math>v</math> from the graph, we get a tree of size <math>k</math>. From the induction hypothesis we can create a tree decomposition <math>(T, X)</math> of width 1 of this graph. Let <math>u</math> be the unique neighbour of <math>v</math> in <math>G</math> and <math>i</math> some node in <math>T</math> such that <math>u</math> is in <math>X_i</math>. Let <math>T_1</math> be <math>T</math> added a node <math>j</math> with <math>i</math> as its only neighbour and let <math>X'</math> be <math>X</math> with the addition that <math>X'_j = \{ i, j \} </math>. Now <math>(T_1, X')</math> is a tree decomposition of <math>G</math> with width 1. Now it remains to show that a graph with treewidth 1 is a tree. The [[contrapositive]] statement is that a graph with a cycle does not have treewidth 1. A graph with a cycle has the 3-clique as a minor, which from the statement in the previous section has treewidth 2. Since the partial 2-trees are closed under minors, the graph therefore has treewidth 2 or greater. ==See also== *[[Clique-width]] ==Notes== {{reflist|2}} ==References== *{{citation | last1 = Arnborg | first1 = S. | last2 = Corneil | first2 = D. | last3 = Proskurowski | first3 = A. | title = Complexity of finding embeddings in a ''k''-tree | journal = SIAM Journal on Matrix Analysis and Applications | volume = 8 | issue = 2 | year = 1987 | pages = 277–284 | doi = 10.1137/0608024}}. *{{citation | last1 = Arnborg | first1 = S. | last2 = Proskurowski | first2 = A. | title = Linear time algorithms for NP-hard problems restricted to partial ''k''-trees | journal = Discrete Applied Mathematics | volume = 23 | issue = 1 | year = 1989 | pages = 11–24 | doi = 10.1016/0166-218X(89)90031-0}}. *{{citation | last1 = Bern | first1 = M. W. | last2 = Lawler | first2 = E. L. | last3 = Wong | first3 = A. L. | title = Linear-time computation of optimal subgraphs of decomposable graphs | journal = Journal of Algorithms | volume = 8 | issue = 2 | year = 1987 | pages = 216–235 | doi = 10.1016/0196-6774(87)90039-3}}. *{{citation | last = Bodlaender | first = Hans L. | contribution = Dynamic programming on graphs of bounded treewidth | title = Proc. 15th International Colloquium on Automata, Languages and Programming | publisher = Springer-Verlag | series = Lecture Notes in Computer Science | volume = 317 | year = 1988 | pages = 105–118}}. *{{citation | last = Bodlaender | first = Hans L. | title = A linear time algorithm for finding tree-decompositions of small treewidth | journal = SIAM Journal on Computing | volume = 25 | issue = 6 | year = 1996 | pages = 1305–1317 | doi = 10.1137/S0097539793251219}}. *{{citation | last = Bodlaender | first = Hans L. | title = A partial ''k''-arboretum of graphs with bounded treewidth | journal = Theoretical Computer Science | volume = 209 | issue = 1–2 | pages = 1–45 | year = 1998 | doi = 10.1016/S0304-3975(97)00228-4}}. *{{citation | last = Diestel | first = Reinhard | title = Graph Theory | url = http://www.math.uni-hamburg.de/home/diestel/books/graph.theory/GraphTheoryIII.pdf}} *{{citation | last1 = Robertson | first1 = Neil | authorlink1 = Neil Robertson (mathematician) | last2 = Seymour | first2 = Paul D. | authorlink2 = Paul Seymour (mathematician) | title = Graph minors III: Planar tree-width | journal = Journal of Combinatorial Theory, Series B | volume = 36 | year = 1984 | pages = 49–64}}. *{{citation | last1 = Robertson | first1 = Neil | authorlink1 = Neil Robertson (mathematician) | last2 = Seymour | first2 = Paul D. | authorlink2 = Paul Seymour (mathematician) | title = Graph minors V: Excluding a planar graph | journal = Journal of Combinatorial Theory, Series B | volume = 41 | issue = 1 | year = 1986 | pages = 92–114 | doi = 10.1016/0095-8956(86)90030-4}}. *{{citation | last1 = Seymour | first1 = Paul D. | authorlink1 = Paul Seymour (mathematician) | last2 = Thomas | first2 = Robin | title = Graph Searching and a Min-Max Theorem for Tree-Width. | journal = Journal of Combinatorial Theory, Series B | volume = 58 | issue = 1 | pages = 22–33 | doi = 10.1006/jctb.1993.1027}}. *{{citation | last = Thorup | first = Mikkel | title = All structured programs have small tree width and good register allocation | journal = Information and Computation | volume = 142 | issue = 2 | year = 1998 | pages = 159–181 | doi = 10.1006/inco.1997.2697}}. [[fr:Décomposition arborescente]] [[de:Baumweite]] [[Category:Trees (graph theory)]] [[Category:Graph operations]]