Document Open Access Logo

A Contraction-Recursive Algorithm for Treewidth

Author Hisao Tamaki

Thumbnail PDF


  • Filesize: 0.86 MB
  • 15 pages

Document Identifiers

Author Details

Hisao Tamaki
  • Meiji University, Kawasaki, Japan

Cite AsGet BibTex

Hisao Tamaki. A Contraction-Recursive Algorithm for Treewidth. In 18th International Symposium on Parameterized and Exact Computation (IPEC 2023). Leibniz International Proceedings in Informatics (LIPIcs), Volume 285, pp. 34:1-34:15, Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2023)


Let tw(G) denote the treewidth of graph G. Given a graph G and a positive integer k such that tw(G) ≤ k + 1, we are to decide if tw(G) ≤ k. We give a certifying algorithm RTW ("R" for recursive) for this task: it returns one or more tree-decompositions of G of width ≤ k if the answer is YES and a minimal contraction H of G such that tw(H) > k otherwise. Starting from a greedy upper bound on tw(G) and repeatedly improving the upper bound by this algorithm, we obtain tw(G) with certificates. RTW uses a heuristic variant of Tamaki’s PID algorithm for treewidth (ESA2017), which we call HPID. Informally speaking, PID builds potential subtrees of tree-decompositions of width ≤ k in a bottom up manner, until such a tree-decomposition is constructed or the set of potential subtrees is exhausted without success. HPID uses the same method of generating a new subtree from existing ones but with a different generation order which is not intended for exhaustion but for quick generation of a full tree-decomposition when possible. RTW, given G and k, interleaves the execution of HPID with recursive calls on G /e for edges e of G, where G / e denotes the graph obtained from G by contracting edge e. If we find that tw(G / e) > k, then we have tw(G) > k with the same certificate. If we find that tw(G / e) ≤ k, we "uncontract" the bags of the certifying tree-decompositions of G / e into bags of G and feed them to HPID to help progress. If the question is not resolved after the recursive calls are made for all edges, we finish HPID in an exhaustive mode. If it turns out that tw(G) > k, then G is a certificate for tw(G') > k for every G' of which G is a contraction, because we have found tw(G / e) ≤ k for every edge e of G. This final round of HPID guarantees the correctness of the algorithm, while its practical efficiency derives from our methods of "uncontracting" bags of tree-decompositions of G / e to useful bags of G, as well as of exploiting those bags in HPID. Experiments show that our algorithm drastically extends the scope of practically solvable instances. In particular, when applied to the 100 instances in the PACE 2017 bonus set, the number of instances solved by our implementation on a typical laptop, with the timeout of 100, 1000, and 10000 seconds per instance, are 72, 92, and 98 respectively, while these numbers are 11, 38, and 68 for Tamaki’s PID solver and 65, 82, and 85 for his new solver (SEA 2022).

Subject Classification

ACM Subject Classification
  • Theory of computation → Graph algorithms analysis
  • graph algorithm
  • treewidth
  • exact computation
  • BT dynamic programming
  • contraction
  • certifying algorithms


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Ernst Althaus, Daniela Schnurbusch, Julian Wüschner, and Sarah Ziegler. On tamaki’s algorithm to compute treewidths. In 19th International Symposium on Experimental Algorithms (SEA 2021). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 2021. Google Scholar
  2. Stefan Arnborg, Derek G Corneil, and Andrzej Proskurowski. Complexity of finding embeddings in a k-tree. SIAM Journal on Algebraic Discrete Methods, 8(2):277-284, 1987. Google Scholar
  3. Jean RS Blair, Pinar Heggernes, and Jan Arne Telle. A practical algorithm for making filled graphs minimal. Theoretical Computer Science, 250(1-2):125-141, 2001. Google Scholar
  4. Hans L Bodlaender. A linear-time algorithm for finding tree-decompositions of small treewidth. SIAM Journal on computing, 25(6):1305-1317, 1996. Google Scholar
  5. Hans L Bodlaender, Fedor V Fomin, Arie MCA Koster, Dieter Kratsch, and Dimitrios M Thilikos. On exact algorithms for treewidth. In Algorithms-ESA 2006: 14th Annual European Symposium, Zurich, Switzerland, September 11-13, 2006. Proceedings, pages 672-683. Springer, 2006. Google Scholar
  6. Hans L Bodlaender and Arie MCA Koster. Safe separators for treewidth. Discrete Mathematics, 306(3):337-350, 2006. Google Scholar
  7. Hans L Bodlaender and Arie MCA Koster. Treewidth computations i. upper bounds. Information and Computation, 208(3):259-275, 2010. Google Scholar
  8. Hans L Bodlaender and Arie MCA Koster. Treewidth computations ii. lower bounds. Information and Computation, 209(7):1103-1119, 2011. Google Scholar
  9. Vincent Bouchitté and Ioan Todinca. Treewidth and minimum fill-in: Grouping the minimal separators. SIAM Journal on Computing, 31(1):212-232, 2001. Google Scholar
  10. Marek Cygan, Fedor V Fomin, Łukasz Kowalik, Daniel Lokshtanov, Dániel Marx, Marcin Pilipczuk, Michał Pilipczuk, and Saket Saurabh. Parameterized algorithms. Springer, 2015. Google Scholar
  11. Holger Dell, Christian Komusiewicz, Nimrod Talmon, and Mathias Weller. The pace 2017 parameterized algorithms and computational experiments challenge: The second iteration. In 12th International Symposium on Parameterized and Exact Computation (IPEC 2017). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 2018. Google Scholar
  12. Fedor V Fomin and Yngve Villanger. Treewidth computation and extremal combinatorics. Combinatorica, 32(3):289-308, 2012. Google Scholar
  13. Pinar Heggernes. Minimal triangulations of graphs: A survey. Discrete Mathematics, 306(3):297-317, 2006. Google Scholar
  14. Neil Robertson and Paul D. Seymour. Graph minors. ii. algorithmic aspects of tree-width. Journal of algorithms, 7(3):309-322, 1986. Google Scholar
  15. Hisao Tamaki. PID., 2017. [github repository].
  16. Hisao Tamaki. Computing treewidth via exact and heuristic lists of minimal separators. In International Symposium on Experimental Algorithms, pages 219-236. Springer, 2019. Google Scholar
  17. Hisao Tamaki. A heuristic use of dynamic programming to upperbound treewidth. arXiv preprint arXiv:1909.07647, 2019. Google Scholar
  18. Hisao Tamaki. Positive-instance driven dynamic programming for treewidth. Journal of Combinatorial Optimization, 37(4):1283-1311, 2019. Google Scholar
  19. Hisao Tamaki. A heuristic for listing almost-clique minimal separators of a graph. arXiv preprint arXiv:2108.07551, 2021. Google Scholar
  20. Hisao Tamaki. Heuristic Computation of Exact Treewidth. In Christian Schulz and Bora Uçar, editors, 20th International Symposium on Experimental Algorithms (SEA 2022), volume 233 of Leibniz International Proceedings in Informatics (LIPIcs), pages 17:1-17:16, Dagstuhl, Germany, 2022. Schloss Dagstuhl - Leibniz-Zentrum für Informatik. URL:
  21. Hisao Tamaki. twalgor/tw., 2022. [github repository].
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail