Skip to Main Content

Treewidth?

David Eppstein

The treewidth of a graph, a positive integer defined using a tree of sets of vertices, is central to graph structure theory and the parametrized complexity of algorithms. Its many areas of application include sparse numerical linear algebra, Bayesian inference, control theory, game theory, low-dimensional topology, network science, and algebraic geometry.

Definitions

A common definition of treewidth involves treedecompositions, of which the following is a special case. A graph is outerplanar if it can be drawn with its vertices on the boundary of a disk and its edges as noncrossing curves in the disk. Adding artificial edges, we can augment this drawing to a triangulation, a subdivision of the disk into triangles (Fig. 1), with the following properties:

1.

The edge-to-edge adjacencies of the triangles form a tree.

2.

Each graph vertex belongs to triangles forming a connected subtree.

3.

Each graph edge belongs to at least one triangle.

A tree-decomposition, then, consists of a tree (like the tree of triangles) whose nodes are associated with sets of graph vertices, called bags. In the outerplanar case, each bag contains the three corners of a triangle. More generally, tree-decompositions may have larger bags, but must satisfy properties (2) and (3): each graph vertex belongs to bags forming a connected subtree, and each graph edge has both endpoints in at least one bag. The width of a tree-decomposition is the size of the largest bag, minus one. The treewidth of any finite undirected graph is the smallest width of any of its tree-decompositions. The “minus one” adjustment ensures that trees have width one: root any tree arbitrarily, then use bags containing each vertex and its parent. The tree of triangles of an outerplanar graph has width two.

Figure 1.

An outerplanar graph (black) and a tree of triangles forming a tree-decomposition (gray).

Graphic without alt text

Treewidth has many equivalent definitions. It is the maximum clique size (minus one) in a chordal supergraph minimizing this size. It is the maximum number of cops that a robber can escape in a certain pursuit-evasion game, the maximum such that some function (called a haven) maps positions of cops to an unoccupied subgraph into which the robber can escape, and the maximum for which in some family of connected subgraphs, all touching each other (called a bramble), cops always leave an unoccupied subgraph into which the robber can escape ST93. Tree-decompositions and chordal supergraphs are in some sense dual to havens and brambles: a structure of the former type provides an upper bound on treewidth, whereas a haven or bramble provides a lower bound. Treewidth is the top element in a certain lattice of well-behaved functions from graphs to numbers Hal76. Many other graph parameters are both upper bounded and lower bounded by a function of treewidth HW17.

Structure

Tree-decompositions, with bag size replaced by other measures, play a central role in the work of Neil Robertson and Paul Seymour on families of graphs closed under minors, the results of edge contractions and vertex or edge deletions. In 23 papers published from 1983 to 2012, Robertson and Seymour found that the graphs in any minor-closed class have tree-decompositions in which each bag induces a torso, a graph of bounded genus with certain constrained embellishments, and in which adjacent bags share few vertices. This structural result was the key to their proof of Wagner’s conjecture, that every minor-closed family can be characterized by finitely many forbidden minors, in the same way that the planar graphs are exactly the graphs that do not have or as minors RS04.

Edge contraction and deletion cannot increase the treewidth of a graph: treewidth is minor-monotone. Thus, the graphs of treewidth have finitely many forbidden minors. As Robertson and Seymour also proved, every minor-closed family of graphs that has a planar forbidden minor has bounded treewidth. The planar graphs themselves have unbounded treewidth—an grid graph has treewidth —and every graph of sufficiently high treewidth contains an grid minor RS84DH08. It was in the context of this work on planar forbidden minors that Robertson and Seymour gave the name “treewidth” (or, as they wrote it, “tree-width”) to the concept we now study RS84, although it appeared earlier under other names BB72Hal76.

More recent work has shown that the graphs in any minor-closed family, and in some families that go beyond graph minors, have a different structure: each graph in the family is a subgraph of a strong product of graphs where has bounded treewidth and is a path. Here, the strong product has as vertex set the Cartesian product of the vertices of the two given graphs. It has an edge between two vertices, when, in each factor graph, the corresponding two vertices are adjacent or identical. This product structure, in turn, has been used to solve many old open problems in graph theory, on queue layouts of graphs, on non-repetitive and centered colorings of graphs, on implicit label schemes for graphs, and on universal graphs for families of graphs DHJ21.

Computation

The use of treewidth in graph algorithms can be illustrated by graph coloring, a problem that is -complete for arbitrary graphs but polynomial-time solvable for graphs of bounded treewidth. Any graph of treewidth can be colored with colors (not necessarily optimal) by choosing a root bag in a tree-decomposition, processing all bags in order by distance from the root, and assigning each uncolored vertex in each bag a color distinct from its neighbors in the same bag. Any other neighbors of such a vertex can only be in bags that come later in the processing order, so the resulting coloring is proper.

With this bound on the chromatic number in hand, an optimal coloring can be found by processing the bags in the opposite order, bottom-up from leaves to the root. At each bag, for each from 2 to , store a set of valid -colorings, assignments of colors to the vertices of the bag that are compatible with a proper coloring of the induced subgraph of all vertices in descendants of the bag. To find the valid -colorings, check for each color assignment whether it is a coloring of the induced subgraph of the bag and is consistent with an already-computed valid -coloring of each child bag. The whole graph is -colorable when there exists a valid -coloring at the root bag, as determined after processing all bags in this way.

Because this algorithm considers all color assignments within a bag, it takes super-exponential time (in the bag size) per bag. However, the number of bags in a tree-decomposition can be assumed to be linear in the number of vertices, so for any constant bound on width, this algorithm takes time linear in the graph size. This type of time bound, polynomial of fixed degree whenever some parameter such as treewidth is bounded, is called fixed-parameter tractable. Constructing optimal or approximately-optimal tree-decompositions is also fixed-parameter tractable KL23, so we need not assume that the tree-decomposition is given as input. Fixed-parameter tractable algorithms are the main topic of study in parametrized complexity theory.

The same sort of bottom-up processing of a tree-decomposition applies to many other problems. A powerful algorithmic meta-theorem known as Courcelle’s theorem provides a fixed-parameter tractable algorithm for testing whether a given graph models any quantified Boolean formula whose variables represent vertices, edges, sets of vertices, or sets of edges Cou90. Here, the parameters are the treewidth and the length of the formula. For instance, -coloring has a formula involving the existence of sets of vertices, one for each color class.

In a different direction, treewidth-based algorithms can often be extended beyond graphs of bounded treewidth. For instance, in planar graphs, one can find a bounded number of bounded-treewidth subgraphs that cover the whole graph with little overlap, or that cover most of the graph disjointly, and then use these systems of subgraphs for fast and accurate optimization algorithms for many hard graph problems Bak94. Another approach uses Robertson and Seymour’s grid-minor theorem: if a graph has a large grid minor one can use this somehow (perhaps either solving the problem directly or removing an irrelevant vertex from the middle of the grid), and if it does not, then one can apply algorithms that assume bounded treewidth. This combination of grids and treewidth in algorithm design has been formalized in the theory of bidimensionality DH08. Both Courcelle’s theorem and bidimensionality won their authors the Nerode Prize, an annual award for outstanding research in parametrized complexity, in 2022 and 2015, respectively.

An area of active research is the extension of treewidth to other related width parameters that can be bounded on dense graphs, apply to directed graphs, or characterize the graphs on which efficient testing of logically defined properties is possible. As well as longer-studied variants such as bandwidth, branchwidth, carving width, clique-width, cutwidth, and pathwidth, newer alternatives include twin-width, which characterizes the ordered graphs (graphs equipped with a total order on vertices) for which first-order model checking is efficient BKTW22, and flip-width, defined through a pursuit-evasion game like the cops-and-robbers game for treewidth, and conjectured to characterize the unordered graphs on which first-order model checking is efficient Tor23.

Applications

Graphs are a frequent abstraction in many other problem domains, and the strong relation between treewidth and algorithmic complexity is reflected in these domains. For instance:

In sparse numerical linear algebra, the method of generalized nested dissection allows for the fast solution of systems of linear equations defined on graphs of low or sublinear treewidth AY10.

The treewidth of a given belief network controls the complexity of junction tree algorithms for machine learning and Bayesian inference, and of algorithms for inferring the belief network when it is not given CG07. Similar methods can also be applied to stochastic optimal control problems KGO12.

In game theory, finding equilibria in certain coalition forming games is intractible in general, but becomes efficient when a graph underlying the game has bounded treewidth Pet16.

Extensions of Courcelle’s theorem to triangulated manifolds with low-treewidth dual graphs have been used to compute invariants in low-dimensional topology involving taut angle structures, discrete Morse theory, and Turaev–Viro invariants BD17.

In network science, low treewidth allows many types of queries on network databases to be answered more efficiently than otherwise. Although large real-world networks modeling roads and infrastructure, social interactions, biological subunits, and interrelated pieces of knowledge tend to have high treewidth, these networks can often be decomposed into smaller low-treewidth subnetworks to which these fast query techniques apply MSJ19.

The structural aspects of treewidth can also be reflected in other areas of mathematics that are less directly computational. As one example, in algebraic geometry and tropical geometry, the treewidth of certain graphs can be used as a lower bound for the gonality of these graphs, and hence for the gonality of Riemann surfaces and tropical curves associated to these graphs vDdBG20.

References

[AY10]
Noga Alon and Raphael Yuster, Solving linear systems through nested dissection, 2010 IEEE 51st Annual Symposium on Foundations of Computer Science—FOCS 2010, IEEE Computer Soc., Los Alamitos, CA, 2010, pp. 225–234. MR3024796,
Show rawAMSref \bib{MR3024796}{article}{ author={Alon, Noga}, author={Yuster, Raphael}, title={Solving linear systems through nested dissection}, conference={ title={2010 IEEE 51st Annual Symposium on Foundations of Computer Science---FOCS 2010}, }, book={ publisher={IEEE Computer Soc., Los Alamitos, CA}, }, date={2010}, pages={225--234}, review={\MR {3024796}}, }
[Bak94]
Brenda S. Baker, Approximation algorithms for NP-complete problems on planar graphs, J. Assoc. Comput. Mach. 41 (1994), no. 1, 153–180. MR1369197,
Show rawAMSref \bib{MR1369197}{article}{ author={Baker, Brenda~S.}, title={Approximation algorithms for {NP}-complete problems on planar graphs}, date={1994}, issn={0004-5411,1557-735X}, journal={J. Assoc. Comput. Mach.}, volume={41}, number={1}, pages={153\ndash 180}, url={https://doi.org/10.1145/174644.174650}, review={\MR {1369197}}, }
[BB72]
Umberto Bertelè and Francesco Brioschi, Nonserial dynamic programming, Mathematics in Science and Engineering, Vol. 91, Academic Press, New York-London, 1972. MR416607,
Show rawAMSref \bib{MR0416607}{book}{ author={Bertel\`e, Umberto}, author={Brioschi, Francesco}, title={Nonserial dynamic programming}, series={Mathematics in Science and Engineering, Vol. 91}, publisher={Academic Press, New York-London}, date={1972}, pages={xii+235}, review={\MR {416607}}, }
[BKTW22]
Édouard Bonnet, Eun Jung Kim, Stéphan Thomassé, and Rémi Watrigant, Twin-width I: Tractable FO model checking, J. ACM 69 (2022), no. 1, Art. 3, 46, DOI 10.1145/3486655. MR4402362,
Show rawAMSref \bib{MR4402362}{article}{ author={Bonnet, \'{E}douard}, author={Kim, Eun Jung}, author={Thomass\'{e}, St\'{e}phan}, author={Watrigant, R\'{e}mi}, title={Twin-width I: Tractable FO model checking}, journal={J. ACM}, volume={69}, date={2022}, number={1}, pages={Art. 3, 46}, issn={0004-5411}, review={\MR {4402362}}, doi={10.1145/3486655}, }
[BD17]
Benjamin A. Burton and Rodney G. Downey, Courcelle’s theorem for triangulations, J. Combin. Theory Ser. A 146 (2017), 264–294. MR3574232,
Show rawAMSref \bib{MR3574232}{article}{ author={Burton, Benjamin~A.}, author={Downey, Rodney~G.}, title={Courcelle's theorem for triangulations}, date={2017}, issn={0097-3165,1096-0899}, journal={J. Combin. Theory Ser. A}, volume={146}, pages={264\ndash 294}, url={https://doi.org/10.1016/j.jcta.2016.10.001}, review={\MR {3574232}}, }
[CG07]
Anton Chechetka and Carlos Guestrin, Efficient principled learning of thin junction trees, Advances in Neural Information Processing Systems 20, Proceedings of the Twenty-First Annual Conference on Neural Information Processing Systems, Vancouver, British Columbia, Canada, December 3–6, 2007, 2007, pp. 273–280, https://proceedings.neurips.cc/paper/2007/hash/0768281a05da9f27df178b5c39a51263-Abstract.html.,
Show rawAMSref \bib{DBLP:conf/nips/ChechetkaG07}{inproceedings}{ author={Chechetka, Anton}, author={Guestrin, Carlos}, title={Efficient principled learning of thin junction trees}, date={2007}, booktitle={{Advances in Neural Information Processing Systems 20, Proceedings of the Twenty-First Annual Conference on Neural Information Processing Systems, Vancouver, British Columbia, Canada, December 3--6, 2007}}, editor={Platt, John~C.}, editor={Koller, Daphne}, editor={Singer, Yoram}, editor={Roweis, Sam~T.}, publisher={Curran Associates, Inc.}, pages={273\ndash 280}, url={https://proceedings.neurips.cc/paper/2007/hash/0768281a05da9f27df178b5c39a51263-Abstract.html}, }
[Cou90]
Bruno Courcelle, The monadic second-order logic of graphs. I. Recognizable sets of finite graphs, Inform. and Comput. 85 (1990), no. 1, 12–75, DOI 10.1016/0890-5401(90)90043-H. MR1042649,
Show rawAMSref \bib{MR1042649}{article}{ author={Courcelle, Bruno}, title={The monadic second-order logic of graphs. I. Recognizable sets of finite graphs}, journal={Inform. and Comput.}, volume={85}, date={1990}, number={1}, pages={12--75}, issn={0890-5401}, review={\MR {1042649}}, doi={10.1016/0890-5401(90)90043-H}, }
[DH08]
Erik D. Demaine and Mohammadtaghi Hajiaghayi, Linearity of grid minors in treewidth with applications through bidimensionality, Combinatorica 28 (2008), no. 1, 19–36, DOI 10.1007/s00493-008-2140-4. MR2399006,
Show rawAMSref \bib{MR2399006}{article}{ author={Demaine, Erik D.}, author={Hajiaghayi, Mohammadtaghi}, title={Linearity of grid minors in treewidth with applications through bidimensionality}, journal={Combinatorica}, volume={28}, date={2008}, number={1}, pages={19--36}, issn={0209-9683}, review={\MR {2399006}}, doi={10.1007/s00493-008-2140-4}, }
[DHJ21]
Zdeněk Dvořák, Tony Huynh, Gwenaël Joret, Chun-Hung Liu, and David R. Wood, Notes on graph product structure theory, 2019–20 MATRIX annals, MATRIX Book Ser., vol. 4, Springer, Cham, 2021, pp. 513–533, DOI 10.1007/978-3-030-62497-2_32. MR4294791,
Show rawAMSref \bib{MR4294791}{article}{ author={Dvo\v {r}\'{a}k, Zden\v {e}k}, author={Huynh, Tony}, author={Joret, Gwena\"{e}l}, author={Liu, Chun-Hung}, author={Wood, David R.}, title={Notes on graph product structure theory}, conference={ title={2019--20 MATRIX annals}, }, book={ series={MATRIX Book Ser.}, volume={4}, publisher={Springer, Cham}, }, date={2021}, pages={513--533}, review={\MR {4294791}}, doi={10.1007/978-3-030-62497-2_32}, }
[Hal76]
Rudolf Halin, -functions for graphs, J. Geom. 8 (1976), no. 1-2, 171–186. MR444522,
Show rawAMSref \bib{MR0444522}{article}{ author={Halin, Rudolf}, title={{$S$}-functions for graphs}, date={1976}, issn={0047-2468,1420-8997}, journal={J. Geom.}, volume={8}, number={1-2}, pages={171\ndash 186}, url={https://doi.org/10.1007/BF01917434}, review={\MR {444522}}, }
[HW17]
Daniel J. Harvey and David R. Wood, Parameters tied to treewidth, J. Graph Theory 84 (2017), no. 4, 364–385, DOI 10.1002/jgt.22030. MR3623383,
Show rawAMSref \bib{MR3623383}{article}{ author={Harvey, Daniel J.}, author={Wood, David R.}, title={Parameters tied to treewidth}, journal={J. Graph Theory}, volume={84}, date={2017}, number={4}, pages={364--385}, issn={0364-9024}, review={\MR {3623383}}, doi={10.1002/jgt.22030}, }
[KGO12]
Hilbert J. Kappen, Vicenç Gómez, and Manfred Opper, Optimal control as a graphical model inference problem, Mach. Learn. 87 (2012), no. 2, 159–182. MR2914010,
Show rawAMSref \bib{MR2914010}{article}{ author={Kappen, Hilbert~J.}, author={G\'{o}mez, Vicen\c {c}}, author={Opper, Manfred}, title={Optimal control as a graphical model inference problem}, date={2012}, issn={0885-6125,1573-0565}, journal={Mach. Learn.}, volume={87}, number={2}, pages={159\ndash 182}, url={https://doi.org/10.1007/s10994-012-5278-7}, review={\MR {2914010}}, }
[KL23]
Tuukka Korhonen and Daniel Lokshtanov, An improved parameterized algorithm for treewidth, STOC’23—Proceedings of the 55th Annual ACM Symposium on Theory of Computing, ACM, New York, 2023, pp. 528–541, DOI 10.1145/3564246.3585245. MR4617406,
Show rawAMSref \bib{MR4617406}{article}{ author={Korhonen, Tuukka}, author={Lokshtanov, Daniel}, title={An improved parameterized algorithm for treewidth}, conference={ title={STOC'23---Proceedings of the 55th Annual ACM Symposium on Theory of Computing}, }, book={ publisher={ACM, New York}, }, date={2023}, pages={528--541}, review={\MR {4617406}}, doi={10.1145/3564246.3585245}, }
[MSJ19]
Silviu Maniu, Pierre Senellart, and Suraj Jog, An experimental study of the treewidth of real-world graph data, 22nd International Conference on Database Theory, LIPIcs. Leibniz Int. Proc. Inform., vol. 127, Schloss Dagstuhl. Leibniz-Zent. Inform., Wadern, 2019, pp. Art. No. 12, 18. MR3936362,
Show rawAMSref \bib{MR3936362}{article}{ author={Maniu, Silviu}, author={Senellart, Pierre}, author={Jog, Suraj}, title={An experimental study of the treewidth of real-world graph data}, conference={ title={22nd International Conference on Database Theory}, }, book={ series={LIPIcs. Leibniz Int. Proc. Inform.}, volume={127}, publisher={Schloss Dagstuhl. Leibniz-Zent. Inform., Wadern}, }, date={2019}, pages={Art. No. 12, 18}, review={\MR {3936362}}, }
[Pet16]
Dominik Peters, Graphical hedonic games of bounded treewidth, Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence, February 12–17, 2016, Phoenix, Arizona, USA, 2016, pp. 586–593, https://doi.org/10.1609/aaai.v30i1.10046.,
Show rawAMSref \bib{DBLP:conf/aaai/Peters16a}{inproceedings}{ author={Peters, Dominik}, title={Graphical hedonic games of bounded treewidth}, date={2016}, booktitle={{Proceedings of the Thirtieth {AAAI} Conference on Artificial Intelligence, February 12--17, 2016, Phoenix, Arizona, {USA}}}, editor={Schuurmans, Dale}, editor={Wellman, Michael~P.}, publisher={{AAAI} Press}, pages={586\ndash 593}, url={https://doi.org/10.1609/aaai.v30i1.10046}, }
[RS84]
Neil Robertson and P. D. Seymour, Graph minors. III. Planar tree-width, J. Combin. Theory Ser. B 36 (1984), no. 1, 49–64, DOI 10.1016/0095-8956(84)90013-3. MR742386,
Show rawAMSref \bib{MR0742386}{article}{ author={Robertson, Neil}, author={Seymour, P. D.}, title={Graph minors. III. Planar tree-width}, journal={J. Combin. Theory Ser. B}, volume={36}, date={1984}, number={1}, pages={49--64}, issn={0095-8956}, review={\MR {742386}}, doi={10.1016/0095-8956(84)90013-3}, }
[RS04]
Neil Robertson and P. D. Seymour, Graph minors. XX. Wagner’s conjecture, J. Combin. Theory Ser. B 92 (2004), no. 2, 325–357. MR2099147,
Show rawAMSref \bib{MR2099147}{article}{ author={Robertson, Neil}, author={Seymour, P.~D.}, title={Graph minors. {XX}. {W}agner's conjecture}, date={2004}, issn={0095-8956,1096-0902}, journal={J. Combin. Theory Ser. B}, volume={92}, number={2}, pages={325\ndash 357}, url={https://doi.org/10.1016/j.jctb.2004.08.001}, review={\MR {2099147}}, }
[ST93]
P. D. Seymour and Robin Thomas, Graph searching and a min-max theorem for tree-width, J. Combin. Theory Ser. B 58 (1993), no. 1, 22–33, DOI 10.1006/jctb.1993.1027. MR1214888,
Show rawAMSref \bib{MR1214888}{article}{ author={Seymour, P. D.}, author={Thomas, Robin}, title={Graph searching and a min-max theorem for tree-width}, journal={J. Combin. Theory Ser. B}, volume={58}, date={1993}, number={1}, pages={22--33}, issn={0095-8956}, review={\MR {1214888}}, doi={10.1006/jctb.1993.1027}, }
[Tor23]
Szymon Toruńczyk, Flip-width: cops and robber on dense graphs, 2023 IEEE 64th Annual Symposium on Foundations of Computer Science—FOCS 2023, IEEE Computer Soc., Los Alamitos, CA, 2023, pp. 663–700, DOI 10.1109/FOCS57990.2023.00045. MR4720287,
Show rawAMSref \bib{MR4720287}{article}{ author={Toru\'{n}czyk, Szymon}, title={Flip-width: cops and robber on dense graphs}, conference={ title={2023 IEEE 64th Annual Symposium on Foundations of Computer Science---FOCS 2023}, }, book={ publisher={IEEE Computer Soc., Los Alamitos, CA}, }, date={2023}, pages={663--700}, review={\MR {4720287}}, doi={10.1109/FOCS57990.2023.00045}, }
[vDdBG20]
Josse van Dobben de Bruyn and Dion Gijswijt, Treewidth is a lower bound on graph gonality, Algebr. Comb. 3 (2020), no. 4, 941–953, DOI 10.5802/alco.124. MR4145985,
Show rawAMSref \bib{MR4145985}{article}{ author={van Dobben de Bruyn, Josse}, author={Gijswijt, Dion}, title={Treewidth is a lower bound on graph gonality}, journal={Algebr. Comb.}, volume={3}, date={2020}, number={4}, pages={941--953}, review={\MR {4145985}}, doi={10.5802/alco.124}, }

Credits

Figure 1 is courtesy of David Eppstein.

Photo of David Eppstein is courtesy of Laurel Hungerford.