betaFeedback

WorksComputer Science

Metric Dimension is NP-complete on Graphs of Treewidth Two

Abstract

The metric dimension of a connected graph is the least number of vertices whose distance vectors distinguish all vertices. We show that deciding whether the metric dimension of a graph is at most a given integer is NP-complete on graphs of treewidth at most two, and even on two-connected two-terminal series-parallel graphs of pathwidth at most five. As the problem is polynomial on trees, the graphs of treewidth one, this settles the treewidth threshold of its hardness, which was known to lie between two and twenty-four. The reduction is from satisfiability of formulas in which every literal occurs at most twice. To such a formula with nn clauses and rr variables it associates a two-terminal series-parallel graph GφG_φ with O((n+r)2)O((n+r)^2) vertices and pathwidth at most five, whose metric dimension is 2(n+r)+72(n+r)+7 if the formula is satisfiable and 2(n+r)+82(n+r)+8 otherwise.

Introduction

The problem and the known results

For a connected graph GG, a vertex ww separates two vertices x,yx,y when d(w,x)≠d(w,y)d(w,x) \ne d(w,y), and a set W⊆V(G)W \subseteq V(G) resolves GG when every two distinct vertices are separated by a vertex of WW; the metric dimension md⁡(G)\operatorname{md}(G) is the least size of a resolving set (Definition 2.2). The decision problem Metric Dimension asks, for a connected graph GG and an integer k≥0k \ge0, whether md⁡(G)≤k\operatorname{md}(G) \le k. Resolving sets were introduced by Slater [28] and by Harary and Melter [21]. The problem is NP-complete in general; Garey and Johnson list it as problem GT61 of their book [20], and Khuller, Raghavachari and Rosenfeld [26] give a reduction from 3-SAT. On trees it is polynomial: the metric dimension of a tree that is not a path is the number of its leaves minus the number of its exterior major vertices [7, 21, 28], and Khuller et al. [26] compute a minimum resolving set of a tree in linear time.

Between these two poles, the problem has been placed on many classes. It stays NP-complete on planar graphs of maximum degree six [10], on split graphs, bipartite graphs, co-bipartite graphs and line graphs of bipartite graphs [14], on interval graphs of diameter two and on permutation graphs of diameter two [16], and on a subclass of unit disk graphs [23]. It is polynomial on outerplanar graphs [10], on cographs and, for every fixed kk, on trees with kk additional edges [14], on chain graphs [15], and, in linear time, on cactus block graphs [24]. In the parameterized setting the problem is W[2]\mathrm{W}[2]-hard with respect to the solution size kk, already on graphs of maximum degree three, and it cannot be approximated within a factor o(log⁡n)o(\log n) unless P=NP\mathrm{P} = \mathrm{NP} [22]. It is fixed-parameter tractable with respect to the vertex cover number [22], the max leaf number [13], the tree-length plus the maximum degree, and the modular width [2], and the distance to cluster or to co-cluster [19]. For the vertex cover number vc⁡\operatorname{vc}, Foucaud et al. [18] give an algorithm running in time 2O(vc⁡2)⋅nO(1)2^{O(\operatorname{vc}^{2})}\cdot n^{O(1)} and show that, unless the Exponential Time Hypothesis fails, no algorithm runs in time 2o(vc⁡2)⋅nO(1)2^{o(\operatorname{vc}^{2})}\cdot n^{O(1)}, even on graphs of bounded diameter.

The parameter treewidth resisted longest. Díaz et al. [10], Belmonte et al. [2] and Eppstein [13] asked for the complexity of the problem on graphs of bounded treewidth, and Hoffmann et al. [24] observed that the decision problem, for each fixed k≥2k \ge2, cannot be expressed in monadic second-order logic, so that Courcelle’s theorem does not apply. Bonnet and Purohit [5] proved that the problem is W[1]-hard parameterized by treewidth, even by pathwidth; Galby et al. [19] strengthened this to the feedback vertex set number plus the pathwidth. Li and Pilipczuk [27] then proved that the problem is NP-hard on graphs of treewidth, and even pathwidth, 24, and asked for the exact treewidth at which it becomes hard, the case of treewidth two being open. Bonnet and Purohit [5] and Bousquet, Deschamps and Parreau [6] ask the same question. On the positive side, Bousquet, Deschamps and Parreau prove that the problem is fixed-parameter tractable with respect to treewidth on chordal graphs; since kk-trees are chordal, the problem is polynomial on kk-trees for every fixed kk, and in particular on 2-trees, the maximal graphs of treewidth two. Foucaud et al. [17] give an algorithm running in time 2diam⁡O(tw⁡)⋅nO(1)2^{\operatorname{diam}^{O(\operatorname{tw})}}\cdot n^{O(1)}, so the problem is polynomial when both the treewidth and the diameter are bounded, and they show that this running time is essentially optimal under the Exponential Time Hypothesis.

The main theorem

Our result answers the question of the complexity on graphs of treewidth two.

Theorem 1.1 (main theorem). The following problem is NP-complete: given a two-connected two-terminal series–parallel graph (G;s,t)(G; s, t) of pathwidth at most five and an integer k≥0k \ge0, decide whether md⁡(G)≤k\operatorname{md}(G) \le k. Consequently the problem is NP-complete on connected graphs of treewidth at most two and pathwidth at most five.

Proof. This is Theorem 11.8 with Corollary 11.9.

The theorem rests on the following value theorem, with the restricted formulas of Definition 4.1 (formulas in conjunctive normal form with at most three literals per clause and every literal in at most two clauses) and the graph GφG_{\varphi} of Definition 4.6.

Theorem 1.2 (the value of md⁡(Gφ)\operatorname{md}(G_{\varphi})). Let φ\varphi be a restricted formula with nn clauses and rr variables, and m:=n+r+1m := n + r + 1. Then (Gφ;T1,T2)(G_{\varphi}; T_{1}, T_{2}) is two-terminal series–parallel, so GφG_{\varphi} has treewidth at most two; GφG_{\varphi} has pathwidth at most five; and

md⁡(Gφ)={2m+5if φ is satisfiable,2m+6otherwise.\operatorname{md}(G_{\varphi}) = \begin{cases} 2m + 5 & \text{if } \varphi\text{ is satisfiable},\\ 2m + 6 & \text{otherwise}. \end{cases}

Proof. This is Theorem 11.5 with Theorem 8.5(i),(ii) and Theorem 9.8.

With the results recalled above, the main theorem has the following consequences.

  • The treewidth threshold is two. Graphs of treewidth at most one are those without a K3K_3 minor [4 Theorem 17], that is, the forests, on which the problem is polynomial [26]; by the main theorem it is NP-complete at treewidth two. Thus, unless P=NP\mathrm{P} = \mathrm{NP}, the gap left by Li and Pilipczuk [27], between two and twenty-four, is closed, and in the terms of Bonnet and Purohit [5], Metric Dimension parameterized by treewidth is para-NP-hard at the first value where it can be.

  • The pathwidth threshold lies between two and five. Li and Pilipczuk [27] proved the hardness at pathwidth twenty-four. The graph GφG_\varphi has pathwidth at most five (Theorem 9.8), and the problem is polynomial at pathwidth one, where the graphs are forests, as the pathwidth of a graph is at least its treewidth (Definition 9.1). So, unless P=NP\mathrm{P} = \mathrm{NP}, the least pathwidth at which the problem is NP-complete lies between two and five.

  • Outerplanar graphs are the boundary. Outerplanar graphs have treewidth at most two [4], and the problem is polynomial on them [10]. The graphs GφG_\varphi are not outerplanar: they contain a subdivision of K2,3K_{2,3} (Lemma 10.1(i)). So, within treewidth two, the boundary between easy and hard runs between outerplanar graphs and graphs with a K2,3K_{2,3} minor.

  • Two-connected graphs. Two-connected graphs of treewidth two are the two-connected series–parallel graphs [4 Theorem 42]. The main theorem is stated on two-connected two-terminal series–parallel graphs of pathwidth at most five, which have treewidth at most two (Lemma 8.3(iii)); so the problem is NP-complete on two-connected graphs of treewidth two.

  • The diameter must grow. By the algorithm of Foucaud et al. [17], a hard family of bounded treewidth must have unbounded diameter unless P=NP\mathrm{P} = \mathrm{NP}; the diameter of GφG_\varphi is at least 4m+154m + 15 (Lemma 10.1(ii)).

  • Trees with kk additional edges. Epstein, Levin and Woeginger [14] solve the problem in polynomial time on trees with kk additional edges for every fixed kk, with a running time whose exponent grows with kk. The graph GφG_\varphi is a tree with at most 12m+912m + 9 additional edges (Lemma 10.1(iii)) and has O(m2)O(m^2) vertices (Lemma 4.12(iv)); so no algorithm for this class runs in time polynomial in both the number of vertices and kk, unless P=NP\mathrm{P} = \mathrm{NP}.

Overview of the reduction

The construction and the proof are described in full in Sections 3 to 11, with Sections 9 and 10 aside; this overview gives their shape, and every claim in it points to the statement that proves it.

The template. The building block is the template T(L,μ;E)\mathsf{T}(L,\mu;E) of Definition 3.1: a path, the spine, from a terminal ss to a terminal tt, with one tt-ear attached near tt and up to two crossings, ears (Definition 2.9, Figure 1) attached around the middle of the spine whose lengths are set by the list EE (Figure 2). Every vertex uu of a template has a profile (h(u),hˉ(u))(h(u),\bar{h}(u)), its distances to ss and to tt, and a skew κ(u)=hˉ(u)−h(u)\kappa(u)=\bar{h}(u)-h(u). The vertices whose skew equals the number σ=L−2μ\sigma=L-2\mu are the diagonal vertices: one on the spine and one on each crossing, at positions set by EE (Lemma 3.7(iii)); Figure 3 marks them on two examples. The first vertex of the tt-ear is the core, a vertex that is closer to every other member of the template than any path through ss or tt would make it (Lemma 5.3(iv)).

Two templates

Figure 3. Two templates (Definition 3.1), with s=v0s = v_0 on the left and t=vLt = v_L on the right. The core r1r_1 is the black square, with profile (L−μ+1,μ+1)(L-\mu+1,\mu+1) (Lemma 3.10). The circled vertices are the diagonal members, those with κ=hˉ−h=σ\kappa= \bar{h}-h=\sigma, labelled with their profiles (h,hˉ)(h,\bar{h}): in (a) v3v_3 and x30x^0_3, in (b) v4v_4, x20x^0_2 and x41x^1_4 (Lemma 3.7(iii)).

The graph GφG_\varphi. A restricted formula φ\varphi with nn clauses and rr variables has m=n+r+1m = n + r + 1 levels, one per clause, one per variable, and a last level, the idle level, each with three options: at the level of a clause, an option selects one of its literals; at the level of a variable, the option 1 sets it true and the options 2, 3 set it false; at the idle level the three options are alike (Definition 4.2). The graph GφG_\varphi (Definition 4.6; Figure 4(a)) has a frame, two paths T1,s1,…,smT_1, s_1, \ldots, s_m and tm,…,t1,z1,…,z7,T2t_m, \ldots, t_1, z_1, \ldots, z_7, T_2; at each level kk, three copies Uk,1,Uk,2,Uk,3U_{k,1}, U_{k,2}, U_{k,3} of a template between sks_k and tkt_k, one per option, nested inside one another along the levels (Figure 4(b)); a pair q,q′q, q' of vertices, each adjacent to tmt_m and to tm−1t_{m-1} (Figure 4(d)); and four arms, paths of length D=4m+15D = 4m + 15 from T1T_1 to T2T_2, each carrying one twin y~j\widetilde{y}_j of one of its vertices wjw_j (Figure 4(c)). The copies of one level differ only in their crossings: the crossing lengths of Uk,cU_{k,c} encode the cells of the option cc, integers attached to the occurrences of literals in φ\varphi, so that the diagonal vertices of Uk,cU_{k,c} lie at the distances 2m+4−k2m + 4 - k and the cells of cc from T1T_1 (Lemma 11.1). The cells are arranged so that two levels have a common cell exactly when one is a clause level, the other is the level of the variable of a literal of that clause, and the options chosen at the two levels select that literal and falsify it (Lemma 4.3(iv)).

References

  1. [1]Anthropic. Claude Fable 5.1, a large language model (claude-fable-5-1). https://www.anthropic.com/claude/fable, 2026. Accessed 15 October 2026.
  2. [2]R. Belmonte, F. V. Fomin, P. A. Golovach, and M. S. Ramanujan. Metric dimension of bounded tree-length graphs. SIAM J. Discrete Math., 31:1217–1243, 2017. https://doi.org/10.1137/16M1057383. Extended abstract in Proc. MFCS 2015, LNCS 9235, pp. 115–126, under the title “Metric dimension of bounded width graphs”.
  3. [3]T. Benoit and Claude (Anthropic). A Lean 4 formalisation of “Metric Dimension is NP-complete on Graphs of Treewidth Two”. Zenodo, 2026. https://doi.org/10.5281/zenodo.23382308.
  4. [4]H. L. Bodlaender. A partial k-arboretum of graphs with bounded treewidth. Theoret. Comput. Sci., 209:1–45, 1998. https://doi.org/10.1016/S0304-3975(97)00228-4.
  5. [5]É. Bonnet and N. Purohit. Metric dimension parameterized by treewidth. Algorithmica, 83:2606–2633, 2021. https://doi.org/10.1007/s00453-021-00808-9. Extended abstract in Proc. IPEC 2019, LIPIcs 148, 5:1–5:15.
  6. [6]N. Bousquet, Q. Deschamps, and A. Parreau. Metric dimension parameterized by treewidth in chordal graphs. In Proc. WG 2023, pages 130–142. Springer, 2023. https://doi.org/10.1007/978-3-031-43380-1_10. arXiv:2303.10646.
  7. [7]G. Chartrand, L. Eroh, M. A. Johnson, and O. R. Oellermann. Resolvability in graphs and the metric dimension of a graph. Discrete Appl. Math., 105:99–113, 2000. https://doi.org/10.1016/S0166-218X(00)00198-0.
  8. [8]S. A. Cook. The complexity of theorem-proving procedures. In Proc. 3rd ACM Symposium on Theory of Computing, pages 151–158. ACM, 1971. https://doi.org/10.1145/800157.805047.
  9. [9]L. de Moura and S. Ullrich. The Lean 4 theorem prover and programming language. In Automated Deduction – CADE 28, volume 12699 of Lecture Notes in Computer Science, pages 625–635. Springer, 2021. https://doi.org/10.1007/978-3-030-79876-5_37.
  10. [10]J. Díaz, O. Pottonen, M. J. Serna, and E. J. van Leeuwen. Complexity of metric dimension on planar graphs. J. Comput. System Sci., 83:132–158, 2017. https://doi.org/10.1016/j.jcss.2016.06.006. Extended abstract in Proc. ESA 2012, LNCS 7501, pp. 419–430, under the title “On the complexity of metric dimension”.
  11. [11]R. Diestel. Graph Theory, volume 173 of Graduate Texts in Mathematics. Springer, 5th edition, 2017. https://doi.org/10.1007/978-3-662-53622-3.
  12. [12]D. Eppstein. Parallel recognition of series-parallel graphs. Inform. and Comput., 98:41–55, 1992. https://doi.org/10.1016/0890-5401(92)90041-D.
  13. [13]D. Eppstein. Metric dimension parameterized by max leaf number. J. Graph Algorithms Appl., 19:313–323, 2015. https://doi.org/10.7155/jgaa.00360.
  14. [14]L. Epstein, A. Levin, and G. J. Woeginger. The (weighted) metric dimension of graphs: hard and easy cases. Algorithmica, 72:1130–1171, 2015. https://doi.org/10.1007/s00453-014-9896-2. Extended abstract in Proc. WG 2012, LNCS 7551, pp. 114–125.
  15. [15]H. Fernau, P. Heggernes, P. van ’t Hof, D. Meister, and R. Saei. Computing the metric dimension for chain graphs. Inform. Process. Lett., 115:671–676, 2015. https://doi.org/10.1016/j.ipl.2015.04.006.
  16. [16]F. Foucaud, G. B. Mertzios, R. Naserasr, A. Parreau, and P. Valicov. Identification, location-domination and metric dimension on interval and permutation graphs. II. Algorithms and complexity. Algorithmica, 78:914–944, 2017. https://doi.org/10.1007/s00453-016-0184-1. Extended abstract in Proc. WG 2015, LNCS 9224, pp. 456–471, under the title “Algorithms and complexity for metric dimension and location-domination on interval and permutation graphs”.
  17. [17]F. Foucaud, E. Galby, L. Khazaliya, S. Li, F. Mc Inerney, R. Sharma, and P. Tale. Problems in NP can admit double-exponential lower bounds when parameterized by treewidth or vertex cover. In Proc. ICALP 2024, volume 297 of LIPIcs, pages 66:1–66:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. https://doi.org/10.4230/LIPIcs.ICALP.2024.66. Full version: arXiv:2307.08149.
  18. [18]F. Foucaud, E. Galby, L. Khazaliya, S. Li, F. Mc Inerney, R. Sharma, and P. Tale. Metric dimension and geodetic set parameterized by vertex cover. J. Comput. System Sci., 164:103850, 2027. https://doi.org/10.1016/j.jcss.2026.103850. Extended abstract in Proc. STACS 2025, LIPIcs 327, 33:1–33:20.
  19. [19]E. Galby, L. Khazaliya, F. Mc Inerney, R. Sharma, and P. Tale. Metric dimension parameterized by feedback vertex set and other structural parameters. SIAM J. Discrete Math., 37:2241–2264, 2023. https://doi.org/10.1137/22M1510911. Extended abstract in Proc. MFCS 2022, LIPIcs 241, 51:1–51:15.
  20. [20]M. R. Garey and D. S. Johnson. Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, 1979.
  21. [21]F. Harary and R. A. Melter. On the metric dimension of a graph. Ars Combin., 2:191–195, 1976.
  22. [22]S. Hartung and A. Nicht­erlein. On the parameterized and approximation hardness of metric dimension. In Proc. 28th IEEE Conference on Computational Complexity (CCC 2013), pages 266–276. IEEE, 2013. https://doi.org/10.1109/CCC.2013.36.
  23. [23]S. Hoffmann and E. Wanke. Metric dimension for Gabriel unit disk graphs is NP-complete. In Proc. ALGO/SENSORS 2012, pages 90–92. Springer, 2012. https://doi.org/10.1007/978-3-642-36092-3_10.
  24. [24]S. Hoffmann, A. Elterman, and E. Wanke. A linear time algorithm for metric dimension of cactus block graphs. Theoret. Comput. Sci., 630:43–62, 2016. https://doi.org/10.1016/j.tcs.2016.03.024.
  25. [25]R. M. Karp. Reducibility among combinatorial problems. In Complexity of Computer Computations, pages 85–103. Plenum, 1972. https://doi.org/10.1007/978-1-4684-2001-2_9.
  26. [26]S. Khuller, B. Raghavachari, and A. Rosenfeld. Landmarks in graphs. Discrete Appl. Math., 70:217–229, 1996. https://doi.org/10.1016/0166-218X(95)00106-2.
  27. [27]S. Li and M. Pilipczuk. Hardness of metric dimension in graphs of constant treewidth. Algorithmica, 84:3110–3155, 2022. https://doi.org/10.1007/s00453-022-01005-y. Extended abstract in Proc. IPEC 2021, LIPIcs 214, 24:1–24:13.
  28. [28]P. J. Slater. Leaves of trees. Congr. Numer., 14:549–559, 1975.
  29. [29]The mathlib Community. The Lean mathematical library. In Proc. 9th ACM SIGPLAN International Conference on Certified Programs and Proofs (CPP 2020), pages 367–381. ACM, 2020. https://doi.org/10.1145/3372885.3373824.
  30. [30]C. A. Tovey. A simplified NP-complete satisfiability problem. Discrete Appl. Math., 8:85–89, 1984. https://doi.org/10.1016/0166-218X(84)90081-7.

Paper details

vlnc:W_4pqcwta5
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Claude Code

View statement
Looking for related papers…
Contents