Keywords

1 Introduction

A graph completion problem asks whether it is possible to add edges to a given graph in order to make it satisfy some target property. There are two different ways of defining the optimization measure for such problems. The first, and most common, is the number of edges to be added, while the second is the value of some graph invariant on the resulting graph. Problems of the first type are Hamiltonian Completion [14], Interval Graph Completion [16], Proper Interval Graph Completion [15, 20], Chordal Graph Completion [20, 24], and Strongly Chordal Graph Completion [20].

We focus our attention on the second category of problems where, for some given parameterized graph property \(\mathcal{P}_{k}\), the problem asks, given a graph G and an integer k, whether it is possible to add edges to G such that the resulting graph belongs to \(\mathcal{P}_{k}\). Usually \(\mathcal{P}_{k}\) is a parameterized graph class whose graphs are typically required (for every k) to satisfy some sparsity condition. There are few problems of this type in the bibliography. Such a completion problem is the Planar Disjoint Paths Completion problem that asks, given a plane graph and a collection of k pairs of terminals, whether it is possible to add edges such that the resulting graph remains plane and contains k vertex-disjoint paths between the pairs of terminals. While this problem is trivially NP-complete, it has been studied from the point of view of parameterized complexity [1]. In particular, when all edges should be added in the same face, it can be solved in \(f(k)\cdot n^{2}\) steps [1], i.e., it is fixed parameter tractable (FPT in short; for details about fixed parameter tractability, refer to the monographs [10, 12, 21]).

Perhaps the most challenging problem of the second category is the Planar Diameter Improvement problem (PDI in short), which was first mentioned by Dejter and Fellows [7] (and made an explicit open problem in [10]). Here we are given a planar graph G and we ask for the minimum integer D such that some completion (by addition of edges) of G is a planar graph with diameter at most D. Note that according to the general formalism, all planar graphs with diameter at most D verify this parameterized property \(\mathcal{P}_{D}\). The computational complexity of Planar Diameter Improvement is open, as it is not even known whether it is an NP-complete problem, even in the case where the embedding is part of the input. Interestingly, Planar Diameter Improvement is known to be FPT: it is easy to verify that, for every D, its Yes-instances are closed under taking minorsFootnote 1 which, according to the meta-algorithmic consequence of the Graph Minors series of Robertson and Seymour [22, 23], implies that Planar Diameter Improvement is FPT. Unfortunately, this implication only proves the existence of such an algorithm for each D, while it does not give any way to construct it. Whether this problem is uniformly FPT Footnote 2 remains as one of the most intriguing open questions in parameterized algorithm design. To our knowledge, when it comes to explicit algorithms, it is not even clear how to get an \(O(n^{f(D)})\)-algorithm for this problem (in parameterized complexity terminology, such an algorithm is called an XP-algorithm).

Notice that, in both aforementioned problems of the second type, the planarity of the graphs in \(\mathcal{P}_{D}\) is an important restriction, as it is essential for generating a non-trivial problem; otherwise, one could immediately turn a graph into a clique that trivially belongs to \(\mathcal{P}_{1}\). For practical purposes, such problems are relevant where instead of generating few additional links, we mostly care about maintaining the network topology. The algorithmic and graph-theoretic study on diameter improvement problems has focused both on the case of minimizing the number (or weight) of added edges [24, 9, 11, 17], as well as on the case of minimizing the diameter [3, 13]. In contrast, the network topology, such as acyclicity or planarity, as a constraint to be preserved has received little attention in the context of complementing a graph; see for example [11]. See also [18, 19] for other completion problems in outerplanar graphs, where the objective is to add edges in order to achieve a prescribed connectivity.

In this paper we study the Outerplanar Diameter Improvement problem, or OPDI in short. An instance of OPDI consists of an outerplanar graph \(G=(V,E)\) and a positive integer D, and we are asked to add a set F of missing edges to G so that the resulting graph \(G'=(V,E\cup F)\) has diameter at most D, while \(G'\) remains outerplanar. Note that we are allowed to add arbitrarily many edges as long as the new graph is outerplanar. Given a graph \(G=(V,E)\), we call \(G'=(V,E\cup F)\) a completion of G.

It appears that the combinatorics of OPDI demonstrate some interesting parallelisms with the notorious PDI problem. We denote by \(\mathbf{opdi}(G)\) (resp. \(\mathbf{pdi}(G)\)) the minimum diameter of an outerplanar (resp. planar) completion of G. It can be easily seen that the treewidth of a graph with bounded \(\mathbf{pdi}(G)\) is bounded, while the pathwidth of a graph with bounded \(\mathbf{opdi}(G)\) is also bounded. In that sense, the OPDI can be seen as the “linear counterpart” of PDI. We stress that the same “small pathwidth” behavior of OPDI holds even if, instead of outerplanar graphs, we consider any class of graphs with bounded outerplanarity. Note also that both \(\mathbf{pdi}(G)\) and \(\mathbf{opdi}(G)\) are trivially 2-approximable in the particular case where the embedding is given. To see this, let \(G'\) be a triangulation of a plane (resp. outerplane) embedding of G where, in every face of G, all edges added to it have a common endpoint. Then, for each edge uv in each shortest path in an optimal completion of G, a u-v-path of length at most two exists in \(G'\). Thus, for both graph invariants, the diameter of \(G'\) does not exceed twice the optimal value.

Our Results. In this work, we show that Outerplanar Diameter Improvement is polynomial-time solvable. Our algorithm, described in Sect. 2, is based on dynamic programming and works in full generality, even when the input graph may be disconnected. Also, our algorithm does not assume that the input comes with some specific embedding (in the case of an embedded input, the problem becomes considerably easier to solve).

2 Description of the Algorithm

The aim of this section is to describe a polynomial-time dynamic program that, given an outerplanar graph G and an integer D, decides whether G admits an outerplanar completion with diameter at most D, denoted diameter- D outerplanar completion for simplicity. By repeated use of this algorithm, we can thus determine in polynomial time the smallest integer D such that G admits a diameter-D outerplanar completion.

Before describing the algorithm, we show some properties of outerplanar completions. In particular, Subsect. 2.1 handles the case where the input outerplanar graph has cut vertices. Its objective is to prove that we can apply a reduction rule to such a graph which is safe for the OPDI problem. In Subsect. 2.2 we deal with 2-vertex separators, and in Subsect. 2.3 we present a polynomial-time algorithm for connected input graphs. Finally, we present the algorithm for disconnected input graphs in Subsect. 2.4.

Some Notation. We use standard graph-theoretic notation, see for instance [8]. It is well known that a graph is outerplanar if and only if it excludes \(K_4\) and \(K_{2,3}\) as a minor. An outerplanar graph is triangulated if all its inner faces (in an outerplanar embedding) are triangles. An outerplanar graph is maximal if it is 2-connected and triangulated. Note that, when solving the OPDI problem, we may always assume that the completed graph \(G'\) is maximal.

2.1 Reducing the Input Graph When There Are Cut Vertices

Given a graph G, let the eccentricity of a vertex u be \({\text {ecc}}(u,G) = \max _{v\in V(G)}{\text {dist}}_{G}(u,v)\). Given an outerplanar graph G, a vertex \(u\in V(G)\), and an integer D, let us define \({\text {ecc}}_D^*(u,G)\) as \(\min _{H} {\text {ecc}}(u,H)\) over all the diameter-D outerplanar completions H of G. We set this value to \(+\infty \) if no such completion of G exists. Unless said otherwise, we assume henceforth that D is a fixed given integer, so we may just write \({\text {ecc}}^*(u,G)\) instead of \({\text {ecc}}_D^*(u,G)\). (The value of D will change only in the description of the algorithm at the end of Subsect. 2.3, and in that case we will make the notation explicit).

As admitting an outerplanar completion with bounded eccentricity (for a fixed vertex u) is a minor-closed property, let us observe the following:

Lemma 1

(\(\star \))Footnote 3 For any connected outerplanar graph G, any vertex \(v\in V(G)\), and any connected subgraph H of G with \(v\in V(H)\), we have that \({\text {ecc}}^*(v,H) \le {\text {ecc}}^*(v,G)\).

Consider a connected graph G with a cut vertex v, and let \(C_1,\ldots ,C_t\) be the vertex sets of the connected components of \(G\setminus \{v\}\). For \(1\le i\le t\), we call the vertex set \(B_i = C_i\cup \{v\}\) a branch of G at v. To shorten notations, we abbreviate \(B_i\cup \ldots \cup B_j=:B_{i\ldots j}\). Also, when referring to the eccentricity, we simply write \(B_i\) to denote the subgraph of G that is induced by \(B_i\) (i.e. \(G[B_i]\)). Thus, the value \({\text {ecc}}^*(v,B_{1\ldots i})\) refers to the minimum eccentricity with respect to v that a diameter-D outerplanar completion of the graph \(G[B_{1\ldots i}]\) can have. The following lemma, crucial in our polynomial-time algorithm, implies that it is safe to ignore most of the branches of G at a cut vertex v.

Lemma 2

(\(\star \)) Consider a connected outerplanar graph G with a cut vertex v that belongs to at least 7 branches. Denote these branches \(B_1,\ldots ,B_t\) with \(t\ge 7\), in such a way that \({\text {ecc}}^*(v,B_1) \ge \ldots \ge {\text {ecc}}^*(v,B_t)\). The graph G has an outerplanar completion with diameter at most D if and only if \({\text {ecc}}^*(v,B_{1\ldots 6}) + {\text {ecc}}^*(v,B_7) \le D\).

Our algorithm computes the minimal eccentricity of a given “root” vertex r in a diameter-D outerplanar completion of G, i.e. \({\text {ecc}}^*(r,G)\). Then, however, the branch containing the root (\(B_0\) in Algorithm 1, Subsect. 2.3) should not be removed. Therefore, although Lemma 2 already implies that G has a diameter-D outerplanar completion if and only if \(G[B_{1\ldots 7}]\) does, we instead use the following corollary to identify removable branches.

Corollary 1

(\(\star \)) Let G be a connected outerplanar graph with a cut vertex v that belongs to at least 8 branches. Denote these branches \(B_1,\ldots ,B_t\), with \(t\ge 8\), in such a way that \({\text {ecc}}^*(v,B_1) \ge \ldots \ge {\text {ecc}}^*(v,B_t)\). For each \(8\le i\le t\), the graph \(G_i = \bigcup _{j\in \{1,\ldots ,7,i\}} B_j\) has a diameter-D outerplanar completion if and only if G does.

2.2 Dealing with 2-Vertex Separators

In this subsection, we extend the definition of eccentricity to the pairs (uv) such that \(uv\in E(G)\). Namely, \({\text {ecc}}(u,v,G)\) is defined as the set of pairs obtained by taking the maximal elements of the set \(\{({\text {dist}}_{G}(u,w),{\text {dist}}_{G}(v,w))\ |\ w\in V(G)\}\). The pairs are ordered such that \((d_1,d_2) \le (d'_1,d'_2)\) if and only if \(d_1\le d'_1\) and \(d_2\le d'_2\). As u and v are adjacent, note that \({\text {dist}}_{G}(u,w)\) and \({\text {dist}}_{G}(v,w)\) differ by at most one. Hence, \({\text {ecc}}(u,v,G)\) is equal to one of \(\{(d,d)\}\), \(\{(d,d+1)\}\), \(\{(d+1,d)\}\), and \(\{(d,d+1),(d+1,d)\}\), for some positive integer d. As before, we abbreviate \({\text {ecc}}(u,v,G[X])\) by \({\text {ecc}}(u,v,X)\). Given a graph G and a subset \(S \subseteq V(G)\), we denote by \(\partial (S)\) the set of vertices in S that have at least one neighbor in \(V(G) \setminus S\).

Lemma 3

(\(\star \)) Consider a connected graph G with \(V(G)=: X \) and a triangle uvw and two sets \(X_u, X_v \subseteq X\) such that \(X_u \cup X_v = X\), \(X_u \cap X_v = \{w\}\), \(\partial (X_u) \subseteq \{u,w\}\), and \(\partial (X_v) \subseteq \{v,w\}\). Then \({\text {ecc}}(u,v,G)\) equals the maximal elements of the set

$$\begin{aligned} \{(d_u,\min \{d_u+1,d_w+1\}) \ |\ (d_u,d_w)\in {\text {ecc}}(u,w,X_u)\}&\cup \\ \{(\min \{d_w+1,d_v+1\},d_v) \ |\ (d_w,d_v)\in {\text {ecc}}(w,v,X_v)\}.&\end{aligned}$$

Given a connected outerplanar graph G, for any two vertices \(u,v\in V(G)\) and any vertex set \(X\subseteq V(G)\) with \(u,v \in X\) such that \(\partial (X) \subseteq \{u,v\}\), let us define \({\text {ecc}}^*_D(u,v,X)\) (or \({\text {ecc}}^*(u,v,X)\)) as the minimal elements of the set

$$\begin{aligned} \left\{ {\text {ecc}}(u,v,H) \ \left| \begin{array}{l}H\text { is a diameter-}D\text { outerplanar completion of }G[X]\text { such }\\ \text {that }uv \in E(H)\text { and such that }uv\text { lies on the outer face.}\end{array}\right. \right\} \end{aligned}$$

If this set is empty, we set \({\text {ecc}}^*_D(u,v,X)\) to \(\{\{(\infty ,\infty )\}\}\). Here, \({\text {ecc}}(u,v,H) \le {\text {ecc}}(u,v,H')\) if and only if for any \((d_1,d_2)\in {\text {ecc}}(u,v,H)\) there exists \((d'_1,d'_2)\in {\text {ecc}}(u,v,H')\) such that \((d_1,d_2) \le (d'_1,d'_2)\). According to the possible forms of \({\text {ecc}}(u,v,H)\), we have that \({\text {ecc}}^*(u,v,X)\) is of one of the following five forms (for some positive integer d):

  • \(\{\{(d,d)\}\}\),

  • \(\{\{(d,d+1)\}\}\),

  • \(\{\{(d+1,d)\}\}\),

  • \(\{\{(d,d+1),(d+1,d)\}\}\), or

  • \(\{\{(d,d+1)\},\{(d+1,d)\}\}\) (when the minima come from different values of H)

Considering \({\text {ecc}}^*(u,X)\) for some u and X, note that u has at least one incident edge uv on the outer face in an outerplanar completion achieving \({\text {ecc}}^*(u,X)\). Thus, we can observe the following.

Observation 1

\({\text {ecc}}^*(u,X) = \min _{v\in X}\min _{S\in {\text {ecc}}^*(u,v,X)}\max _{(d_u,d_v)\in S} d_u\).

2.3 The Algorithm for Connected Outerplanar Graphs

We now proceed to describe a polynomial-time algorithm that solves Outerplanar Diameter Improvement when the input outerplanar graph is connected. In Subsect. 2.4 we will deal with the disconnected case. In a graph, a block is either a maximal 2-vertex-connected component or a bridge. Before proceeding to the formal description of the algorithm, let us provide a high-level sketch.

Algorithm 1 described below receives a connected outerplanar graph G, an arbitrary non-cut vertex r of G, called the root (such a vertex is easily seen to exist in any graph), and a positive integer D. In order to decide whether G admits a diameter-D outerplanar completion, we compute in polynomial time the value of \({\text {ecc}}^*_D(r,G)\), which by definition is finite if and only if G admits a diameter-D outerplanar completion.

In order to compute \({\text {ecc}}^*_D(r,G)\), the algorithm proceeds as follows. In the first step (lines 1–9), we consider an arbitrary block B of G containing r (line 1), and in order to reduce the input graph G, we consider all cut vertices v of G in B. For each such cut vertex v, we order its corresponding branches according to their eccentricity w.r.t. v (line 8), and by Corollary 1 it is safe to keep just a constant number of them, namely 8 (line 9). For computing the eccentricity of the branches not containing the root (lines 5–7), the algorithm calls itself recursively, by considering the branch as input graph, and vertex v as the new root.

In the second step of the algorithm (lines 10–17), we try all 2-vertex separators uv in the eventual completed graph \(G'\) (note that \(G'\) cannot be 3-connected, as otherwise it would contain a \(K_{2,3}\)-minor or a \(K_4\)-minor), together with a set X consisting of a subset of the connected components of \(G' \setminus \{u,v\}\), not containing the root r. For each such triple (uvX), our objective is to compute the value of \({\text {ecc}}^*_D(u,v,X)\). To this end, after initializing its value (lines 11–12), we consider all possible triples \(w, X_u, X_v\) chosen as in Lemma 3 after adding the triangle uvw to G[X] (line 13), for which we already know the values of \({\text {ecc}}^*_D(u,w,X_u)\) and \({\text {ecc}}^*_D(w,v,X_v)\), since the sets X are processed by increasing size. Among all choices of one element in \({\text {ecc}}^*_D(u,w,X_u)\) and another in \({\text {ecc}}^*_D(w,v,X_v)\) (line 14), only those whose corresponding completion achieves diameter at most D are considered for updating the value of \({\text {ecc}}^*_D(u,v,X)\) (line 15). For updating \({\text {ecc}}^*_D(u,v,X)\) (line 17), we first compute \({\text {ecc}}_D(u,v,X)\) using Lemma 3 (line 16).

Finally, once we have computed all values of \({\text {ecc}}^*_D(u,v,X)\), we can easily compute the value of \({\text {ecc}}^*_D(u,X)\) by using Observation 1 (line 18). The formal description of the algorithm can be found in Fig. 1.

Fig. 1.
figure 1

The algorithm OPDI-Connected

The correctness of Algorithm 1 follows from the results proved in Subsects. 2.1 and 2.2, and the following fact (whose proof is straightforward), which guarantees that the value of \({\text {ecc}}_D^*(u,v,X)\) can indeed be computed as done in lines 13–17.

Fact 1

There exists an outerplanar completion H of G[X] with the edge uv on the outer boundary if and only if there is \(w\in X\) and two sets \(X_u, X_v\) such that:

  1. (a)

    \(X_u\cup X_v=X\), \(X_u\cap X_v=\{w\}\),

  2. (b)

    \(\partial _G(X_u)\subseteq \{u,w\}\) and \(\partial _G(X_v)\subseteq \{v,w\}\), and

  3. (c)

    there exists an outerplanar completion \(H_u\) of \(G[X_u]\) with the edge uw on the outer boundary, and an outerplanar completion \(H_v\) of \(G[X_v]\) with the edge vw on the outer boundary.

It remains to analyze the running time of the algorithm.

Running Time Analysis of Algorithm 1. Note that at line 6 each \(B_i\) is recursively replaced by an equivalent (by Corollary 1) subgraph such that its cut vertices have at most 8 branches attached.

Let us first focus on the second step of the algorithm, that is, on lines 10–17. The algorithm considers in line 10 at most \(O(n^2)\) pairs \(\{u,v\}\). As each of u and v has at most 7 attached branches avoiding the root, and \(G \setminus \{u,v\}\) has at most 2 connected components with vertices adjacent to both u and v (as otherwise G would contain a \(K_{2,3}\)-minor), there are at most \(2^{7} \cdot 2^{7} \cdot 2^{2} = 2^{16}\) possible choices for assigning these branches or components to X or not. In line 13, the algorithm considers O(n) vertices w. Similarly, as w belongs to at most 7 branches not containing u nor v, there are at most \(2^7\) choices for assigning these branches to \(X_u\) or \(X_v\). In lines 14–17, the algorithm uses values that have been already computed in previous iterations, as the sets X are considered by increasing order. Note that each of \({\text {ecc}}^*_D(u,w,X_u)\) and \({\text {ecc}}^*_D(w,v,X_v)\) contains at most 2 elements, so at most 4 choices are considered in line 14. Again, at most 4 choices are considered in line 15. Therefore, lines 14–17 are executed in constant time.

As for the first step of the algorithm (lines 1–9), the algorithm calls itself recursively. The number of recursive calls is bounded by the number of blocks of G, as by construction of the algorithm each block is assigned a single root. Therefore, the number of recursive calls is O(n). Once the algorithm calls itself and the corresponding branch has no cut vertex other than the root, the algorithm enters in lines 10–17, whose time complexity has already been accounted above. (Note that each triple (uvX) is considered only once, and the value of \({\text {ecc}}^*_D(u,v,X)\) is stored in the tables.)

Finally, in line 18, the algorithm considers O(n) vertices, and for each of them it chooses among constantly many numbers. Summarizing, we have that the algorithm has overall complexity \(O(n^3)\).

It is worth mentioning that Algorithm 1 can also compute the actual completion achieving diameter at most D, if any, within the same time bound. Indeed, it suffices to keep track of which edges have been added to G when considering the guessed triangles uvw (recall that we may assume that the completed graph is triangulated).

Theorem 1

Algorithm 1 solves Outerplanar Diameter Improvement for connected input graphs in time \(O(n^3)\).

Note that we can compute \(\mathbf{opdi}(G)\) by calling Algorithm 1 with an arbitrary root \(r\in V(G)\) (such that \(G \setminus \{r\}\) is connected) for increasing values of D, or even binary search on these values.

Corollary 2

Let G be a connected outerplanar graph. Then, \(\mathbf{opdi}(G)\) can be computed in time \(O(n^3\log {n})\).

2.4 The Algorithm for Disconnected Outerplanar Graphs

In this subsection we will focus on the case where the input outerplanar graph is disconnected. The radius of a graph is defined as the eccentricity of a “central” vertex, that is, the minimum eccentricity of any of its vertices.

Lemma 4

([6], Theorem 3 ). Let G be a maximal outerplanar graph of diameter D and radius r. Then, \(r\le \lfloor D/2\rfloor +1\).

In the following, we denote the minimum radius of a diameter-D outerplanar completion of a graph or connected component G by \(r^*({G})\). If G has no diameter-D outerplanar completion, then let \(r^*({G}) = \infty \).

Definition 1

Let G be a connected graph and let D be an integer. Let \(G'\) be the graph resulting from G by adding an isolated vertex v. Let \(G^*\) be a diameter-D outerplanar completion of \(G'\) that minimizes the eccentricity of v. Then, \(G^*\) is called escalated completion of (GD) with respect to v and the eccentricity \({\text {ecc}}(v,G^*)\), denoted by \(r^+({G})\), is called escalated eccentricity of (GD). Again, if such a \(G^*\) does not exist, let \(r^+({G}) = \infty \).

We will apply Definition 1 also to connected components of a graph and, if clear from context, we omit D. Note that we can compute \(r^+({G})\) by guessing an edge between the isolated vertex v and G and running OPDI-Connected, the algorithm for connected graphs. Hence this can be done in \(O(n^4)\) time. Also note that \(r^*({G})\le r^+({G})\le r^*({G})+1\).

Lemma 5

(\(\star \)) Given a graph G with a connected component C such that \(r^+({C}) < D/2\), then G has a diameter-D outerplanar completion if and only if \(G\setminus C\) does.

Observation 2

(\(\star \)) Let C be a connected component of G, let \(G'\) be an outerplanar completion of G and let \(C'\) be a connected component of \(G' \setminus C\). Then, there is a vertex \(v\in C\) at distance at least \(r^+({C})\) to each vertex of \(C'\) in \(G'\).

Observation 2 immediately implies that any cutset separating two connected components \(C_1\) and \(C_2\) of G in \(G'\) has distance at least \(r^+({C_1})\) and \(r^+({C_2})\) to some vertex in \(C_1\) and \(C_2\), respectively. Thus, these two vertices are at distance at least \(r^+({C_1})+r^+({C_2})\) in \(G'\).

Corollary 3

Let \(C_1\) and \(C_2\) be connected components of G such that \(r^+({C_1})+r^+({C_2})>D\) and let \(G'\) be a diameter-D outerplanar completion of G. Then, \(C_1\) and \(C_2\) are adjacent in \(G'\), i.e. \(G'\) has an edge with an end in \(C_1\) and an end in \(C_2\).

Corollary 3 allows us to conclude that all connected components C with \(r^+({C})> D/2\) have to be pairwise adjacent in any diameter-D outerplanar completion of G. Thus, there cannot be more than three such components.

Lemma 6

(\(\star \)) An outerplanar graph G with more than 3 connected components C such that \(r^+({C})> D/2\) has no diameter-D outerplanar completion. On the other hand, if G has no connected component C such that \(r^+({C})> D/2\), then G necessarily has a diameter-D outerplanar completion.

Hence, assume G has \(p=1,2\), or 3 connected components C such that \(r^+({C})> D/2\). By Corollary 3 these p components are pairwise adjacent in the desired completion. Note that with \(O(n^{2p-2})\) tries, we can guess \(p-1\) edges connecting all such components into one larger component. Thus, in the following, we assume that there is only one component C with \(r^+({C})> D/2\), denoted \(\mathcal {C}_{\text {max}}\).

Lemma 7

(\(\star \)) Consider an outerplanar graph G with exactly one connected components \(\mathcal {C}_{\text {max}}\) such that \(D/2 < r^+({\mathcal {C}_{\text {max}}}) < \infty \). If \(r^*({\mathcal {C}_{\text {max}}})\le D/2\), then G necessarily has a diameter-D outerplanar completion.

Let us now distinguish two cases according to the parity of D.

Lemma 8

(\(\star \)) For odd D, if an outerplanar graph G has at most one component \(\mathcal {C}_{\text {max}}\) such that \(D/2 < r^+({\mathcal {C}_{\text {max}}}) < \infty \), then G has a diameter-D outerplanar completion.

The case where D is even is more technical.

Lemma 9

(\(\star \)) For even D, Let p and q respectively denote the number of connected components C such that \(D/2 < r^+({C}) < \infty \) and \(r^+({C}) = D/2\), of an outerplanar graph G. If \(p\ge 2\) and \(p+q \ge 5\), then G has no diameter-D outerplanar completion.

Lemma 10

(\(\star \)) For even D, if an outerplanar graph G has one component, denoted \(\mathcal {C}_{\text {max}}\), such that \(D/2 < r^*({\mathcal {C}_{\text {max}}}) < \infty \), and at least 4 other components C such that \(D/2 \le r^+({C}) < \infty \), then G has no diameter-D outerplanar completion.

Hence, assume G has \(q=0,1,2\), or 3 connected components C such that \(r^+({C}) = D/2\). By Corollary 3 these q components are adjacent to each of the p components such that \(r^+({C}) > D/2\). Note that with \(O(n^{2q})\) tries, we can guess q edges connecting each of the q components to one of the p component. Then we are left with a connected graph, and we can call OPDI-Connected.

The Algorithm Itself. We now describe a polynomial-time algorithm that solves the Outerplanar Diameter Improvement problem when the input contains a disconnected outerplanar graph. Algorithm 2 described in Fig. 2 receives a (disconnected) outerplanar graph G, and a positive integer D.

Fig. 2.
figure 2

The algorithm OPDI-Disconnected.

At the beginning, the algorithm computes \(r^+({C})\) and \(r^*({C})\) for each connected component C of G. For computing \(r^+({C})\) the algorithm adds a vertex v, guessing (with O(n) tries) an edge connecting v to C, and then calls OPDI-Connected for this component and root v. For computing \(r^*({C})\) the algorithm guesses a root u (with O(n) tries), and then calls OPDI-Connected for C and root u.

If \(r^*({C})=\infty \) for some component C then, as \(r^*({G}) \ge r^*({C})\), G has no diameter-D outerplanar completion.

Then, as they could be added in a diameter-D outerplanar completion (by Lemma 5), the algorithm removes the components C with small escalated eccentricity, that is those such that \(r^+({C}) < D/2\).

Then the algorithm tests if there is no component C such that \(r^+({C}) > D/2\), or if there is only one component C such that \(r^+({C}) > D/2\), and if \(r^*({C}) \le D/2\). In both cases by Lemmas 6 and 7, G is a positive instance.

Then the algorithm tests if there are more than 3 components C such that \(r^+({C}) > D/2\). In this case, by Lemma 6, G is a negative instance. Otherwise, G has \(p=1\), 2, or 3 such connected components, and the algorithm guesses \(p-1\) edges (in time \(O(n^{2p-2})\)) to connect them (as they should be by Corollary 3). For each such graph we call algorithm OPDI-Connected to check that this graph has a diameter-D outerplanar completion.

Then the algorithm proceeds differently according to D’s parity. If D is odd, then G is a positive instance (By Lemma 8). If D is even, if G has (still) more than \(5-p\) connected components (by Lemmas 9 and 10), then G is a negative instance. Then we are left with a graph G with \(1+q\) connected components, and again the algorithm guesses q edges (in time \(O(n^{2q})\)), connecting G. For each of these graphs the algorithm calls OPDI-Connected(GvD) (for any v) to check whether this graph admits a diameter-D outerplanar completion.

Finally if none of these “guessed” connected graphs has a diameter-D outerplanar completion, then the algorithm concludes that G is a negative instance.

Theorem 2

(\(\star \)) Algorithm 2 solves Outerplanar Diameter Improvement for disconnected input graphs in polynomial time. For odd D the running time is \(O(n^7)\), while it is \(O(n^{9})\) for even D.

3 Conclusions and Further Research

Our algorithm for OPDI runs in time \(O(n^3)\) for connected input graphs, and in time \(O(n^{7})\) or \(O(n^{9})\) for disconnected input graphs, depending on whether D is odd or even, respectively. The main contribution of our work is to establish the computational complexity of OPDI and there is room for improvement of the running time.

We believe that our approach might be interesting for generalizations or variations of the OPDI problem, such as the one where we demand that the augmented graph has fixed outerplanarity or is series-parallel.

By the Graph Minors series of Robertson and Seymour [22, 23], we know that for each fixed integer D, the set of minor obstructions Footnote 4 of OPDI is finite. We have some preliminary results in this direction, but we managed to obtain a complete list only for small values of D. Namely, we obtained a partial list of forbidden substructures (not necessarily minimal), by using the notion of parallel matching. These partial results can be found in the arXiv version of this article, see [5].

Settling the computational complexity of PDI remains the main open problem in this area. An explicit FPT-algorithm, or even an XP-algorithm, would also be significant. The interested reader can find in the arXiv version [5] of this paper a NP-completeness result for a modified version of PDI involving edge weights.