Abstract 1 Introduction 2 Universal Graph for Two Forests 3 Universal Graph for Three Forests 4 Conclusion and Open Question References

Isometric-Universal Graphs for Trees

Edgar Baucher ORCID LaBRI, University of Bordeaux, CNRS, Talence, France François Dross ORCID LaBRI, University of Bordeaux, CNRS, Talence, France Cyril Gavoille ORCID LaBRI, University of Bordeaux, CNRS, Talence, France
Abstract

We consider the problem of finding the smallest graph that contains two input trees each with at most n vertices preserving their distances. In other words, we look for an isometric-universal graph with the minimum number of vertices for two given trees. We prove that this problem can be solved in time O(n5/2logn). We extend this result to forests instead of trees, and propose an algorithm with running time O(n7/2logn). As a key ingredient, we show that a smallest isometric-universal graph of two trees essentially is a tree. Furthermore, we prove that these results cannot be extended. Firstly, we show that deciding whether there exists an isometric-universal graph with t vertices for three forests is NP-complete. Secondly, we show that any smallest isometric-universal graph cannot be a tree for some families of three trees. This latter result has implications for greedy strategies solving the smallest isometric-universal graph problem.

Keywords and phrases:
tree, forest, isometric subgraph, universal graph, distance-preserving
Copyright and License:
[Uncaptioned image] © Edgar Baucher, François Dross, and Cyril Gavoille; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Design and analysis of algorithms
Related Version:
Full Version: http://arxiv.org/abs/2506.11704 [3]
Editors:
Paweł Gawrychowski, Filip Mazowiecki, and Michał Skrzypczak

1 Introduction

Trees are one of the most natural and basic graph classes that can be studied. Studying problems on trees is thus natural, and is at the crux of the intersection between Graph Theory and Computer Science. Even for a general problem such as “finding a graph that contains two input trees”, there are a multitude of variants. To cite few of them, there is the case where the final graph is constrained to be a tree, where “containing” can be either as a subgraph or as a topological embedding [17]. There is also the more general case where the input is two graphs instead of two trees [1, 2, 8], or where the input is composed of more than two trees contained as minors [5, 16].

In this paper, we consider the problem of constructing a graph containing as isometric subgraphs two given trees (or forests) with the aim of minimizing its number of vertices. An isometric subgraph of a graph G is a subgraph H in which the distances between all the vertices of H are preserved in G. This is equivalent to the notion of distance-preserving embedding used by Winkler [19], and then reworded as distance-preservers [6, 7, 10] with important applications to spanners and distance labeling schemes.

This basic problem can be extended in many ways. First of all, one can consider a family of graphs as input rather than two trees. This leads to the notion of universal graphs, a notion that has been widely studied. More precisely, a graph 𝒰 is isometric-universal for a graph family if every graph of appears as an isometric subgraph in 𝒰. In this line of research, 𝒰 and are often constrained. For instance, if 𝒰 and are limited to caterpillars111A tree whose vertices of degree at least two induce a path., Chung, Graham, and Shearer [9] proved that n-vertex caterpillars have an isometric-universal caterpillar with O(n2/logn) vertices, which is tight. And, for the family of all n-vertex graphs, Esperet, Gavoille, and Groenland [12] showed that there exists an isometric-universal graph with at most 3n+O(log2n) vertices, and with a lower bound of 2(n1)/2.

The notion of isometric subgraph can also be extended to k-isometric subgraphs as follows. A subgraph H of G is called k-isometric if the distances between all the vertices of H at distance at most k in G are preserved in H. This definition generalizes several classical notions of graph containment. Indeed, a subgraph is simply a 0-isometric subgraph, an induced subgraph is a 1-isometric subgraph, and a distance-preserving embedding or isometric subgraph is an -isometric subgraph. This leads to the notion of k-isometric-universal graphs for a given family of graphs. Note that sparse universal graphs (k=0) and small induced-universal graphs (k=1) are well-studied topics in Graph Theory, see for instance [4, 11, 13] and the references therein. Thus, the initial problem we consider in this paper corresponds to the case where k= and is composed of two trees, and more generally two forests.

1.1 Our contribution

On the positive side, we prove that constructing a minimum isometric-universal graph for two forests, each with at most n vertices, can be done in time O(n7/2logn). On the negative side, we show that this result cannot be extended to three forests by proving that the associated decision problem is NP-complete.

More precisely, in Section 2, we demonstrate that a minimum isometric-universal graph for two trees can be constructed in time O(n5/2logn) thanks to an algorithm due to Gupta and Nishimura [17]. Additionally, we show how to reduce the problem for two forests from the Assignment Problem, a variant of the maximum matching of maximum weight problem in bipartite graphs, with an O(n) slow-down factor in time complexity. As a key ingredient, we show that two trees always admit a minimum isometric-universal graph that is a tree. We believe that this nice property for two trees is an important technical contribution of the paper.

On the other hand, in Section 3, we show that these positive results cannot be extended in at least two ways. First, we show that deciding whether there exists an isometric-universal graph with t vertices for three forests is NP-complete. This is achieved by a technical reduction from the 3D-Matching Problem. Second, we exhibit an infinite family of triples of trees having no minimum isometric-universal graph that is a tree. Implications to approximation algorithms are discussed in Section 3.2. In particular, we demonstrate that no greedy strategy can build a minimum isometric-universal graph, even with access to an optimal oracle for a pair of graphs. Finally, we show that the property used for two trees cannot be extended to minimum k-isometric-universal graphs if k<(n8)/3.

1.2 Preliminaries and definitions

We consider finite and undirected graphs with no loops and no multi-edges. The union graph of two graphs X,Y, denoted by XY, is defined by V(XY)=V(X)V(Y) and E(XY)=E(X)E(Y). Similarly, the intersection graph of X,Y, denoted by XY, is defined by V(XY)=V(X)V(Y) and E(XY)=E(X)E(Y). The disjoint union is denoted by XΓY.

Given a graph G, and two vertices u,v of G, we denote by distG(u,v) the minimum number of edges of a path connecting u to v in G, if it exists, and we set distG(u,v)= otherwise, i.e., if u and v are in different connected components of G.

A subgraph H of G is k-isometric if, for all vertices u,v of H, distH(u,v)=distG(u,v) if distG(u,v)k. Note that, in that case, if distH(u,v)>k, then distG(u,v)>k. In particular, since H is a subgraph of G, if distH(u,v)=k+1, then distG(u,v)=k+1.

A k-isometric-universal graph for a given graph family is a graph 𝒰 such that every graph G of is isomorphic to a k-isometric subgraph of 𝒰. Moreover, 𝒰 is called minimum if it has the smallest possible number of vertices. 𝒰 is minimal if no proper subgraph of 𝒰 is a k-isometric-universal graph for . Note that if 𝒰 is minimal, then, for every k-isometric embedding φ from the graphs of to 𝒰, we have 𝒰=Gφ(G). Whenever k=, we rather use the term isometric-universal graph as introduced by Esperet et al. [12].

2 Universal Graph for Two Forests

Let us first remark that computing the minimum isometric-universal graph is hard in general, even for two graphs. More precisely, given two graphs G,H, and some number t, the k-Isometric-Universal Graph for Two Graphs Problem asks for finding a k-isometric-universal graph with t vertices for {G,H}, that is a t-vertex graph 𝒰 containing G and H as k-isometric subgraphs.

Indeed, the problem is NP-complete for each k and for two graphs with the same number of vertices. For k=0, this is simple reduction222It is easy to check that the problem is in NP, the certificate being composed of the universal graph and of the embedding from each graph to the universal graph, both can be described polynomially in the size of G,H. from Hamiltonian Path, and for k>0, this is a reduction from Clique of size p. Indeed, for a graph G with n vertices, set H to a path (if k=0) or to a clique (for k>0) with n vertices, and ask whether the there exists a k-isometric-universal graph for the family {G,H}, with respectively t=n vertices for k=0, or with t=2np vertices for k>0.

We will consider the variant where the pair {G,H} is composed of two forests. The problem is known to be NP-complete for k=0 , even if one of the two forests is a tree [14, Theorem 4.6, p. 105]. As shown by Gavoille and Jacques [15], this NP-completeness result can be extended to two trees of the same size for k=1. Nevertheless, as we will see in this section, the problem becomes polynomial for two forests if k=.

2.1 Connected components reduction

We start with the following result, that will allow us to reduce the problem of computing the minimum isometric-universal graph for a pair of graphs (possibly non-connected) to the case of their connected components. The reduction is based on a polynomial solution of the Assignment Problem whose goal is to optimally assign agents to individual tasks. For the purpose of the next statement, we say that a function f is superlinear if f(n)/n is non-decreasing. Typically, polynomials n1+c and exponentials 2cn for c>0 are superlinear functions.

Theorem 1.

Let G,H be two graphs with at most n vertices, composed respectively of s and r connected components. Let f(m) be any superlinear function bounding above the time complexity of computing a minimum isometric-universal graph for any pair of graphs with at most m vertices composed of a component of G and of H. Then, assuming sr, a minimum isometric-universal graph for {G,H} can be computed in time

O(rmin{f(2n),sf(n)}+smin{rslogn,rs+sloglogs}).

The proof is available in the full version [3].

2.2 The case of two trees

To compute the minimum isometric-universal graph of two forests in polynomial time, we will combine Theorem 1 and the next result about two trees.

Theorem 2.

Every minimum and minimal isometric-universal graph for two trees is a tree.

Before presenting its technical proof, we remark that both properties, minimum and minimal, are required. Indeed, the disjoint union of any pair of trees is isometric-universal for this pair, is minimal but not minimum (as implied by Theorem 2, the minimum one must be connected). Moreover, the graph composed of two pendant vertices attached to some vertex of a C4 (see Figure 1) is a minimum isometric-universal graph for the family {K1,4,K1,3+} composed of two 5-vertex trees, where K1,p+ denotes here the graph K1,p where one edge has been subdivided into two edges. However, it is not minimal: it contains K1,4+ as proper subgraph which is isometric-universal for {K1,4,K1,3+}. This example can be generalized to two trees with n vertices, for every n5.

Figure 1: A minimum isometric-universal graph for the 5-vertex tree family {K1,4,K1,3+}. From Theorem 2 it is not minimal (the edge e can be removed).

Proof of Theorem 2.

Let 𝒰 be any minimum and minimal isometric-universal graph for ={T1,T2} composed of two trees. We consider a given isometric embedding of T1 and T2 in 𝒰, and denote by A1 and A2 their corresponding embedded subgraphs in 𝒰. Since 𝒰 is minimal, 𝒰=A1A2. So, each vertex or edge of 𝒰, belongs either to A1A2, A2A1, or to A1A2.

For convenience, let us denote by d(x,y)=dist𝒰(x,y), and by |P| the length of path P, i.e., its number of edges. We will often use the property that every path of P of Ai, for some i{1,2}, satisfies |P|=distAi(u,v)=d(u,v), where u,v are the extremities of P. This is because every path of a tree is a shortest path in this tree, and because Ai is an isometric subgraph of 𝒰.

𝒰 must be connected, otherwise we could merge two connected components of 𝒰 by a vertex, and this without modifying any distance in A1 or A2 which are finite. This would contradicting the fact that 𝒰 is minimum. If 𝒰 is a tree, we are done. It remains to show that if 𝒰 has a cycle, then 𝒰 is not minimum. Consider the shortest cycle C in 𝒰. Let us show that:

Claim 3.

The edges of C can be partitioned into two paths P1 and P2 such that (see Figure 2 on the left):

  • P1P2={u,v} with u,vA1A2

  • P1P2A1A2

  • P2P1A2A1

Proof.

Consider the connected components of A1A2. Obviously, such components are trees. In particular, CA1A2 is impossible. It is also clear that C intersects at least two such components. Indeed, first, if it intersects no components, then C is wholly contained in A1 or in A2, contradicting they are trees. Secondly, if it intersects only one, then C is wholly contained in A1 or in A2 as well, since the part of C outside the component exists and belongs to one tree, and the part inside the component belongs to both trees.

Define u and v as any two vertices of C that belong to two different components of A1A2, and such that distC(u,v) is minimum. Let P1 be a path of C realizing this distance. By construction, the only vertices of P1 that are in A1A2 are precisely its extremities u,v. Indeed, if P1{u,v} contains a vertex w in A1A2, then both distC(u,w) and distC(v,w) would be less than distC(u,v), which is not possible by the choice of u,vC. Thus, P1{u,v} contains only vertices and edges of a same tree Ai, because if two consecutive edges belong to different trees, their common vertex must be in the intersection. W.l.o.g., assume that P1A1. Note that we have distC(u,v)=dA1(u,v)=d(u,v)=|P1| because P1 is a path of A1. We set P2 to be the path of C induced by the edges of C not in P1.

Clearly, the first two points hold: P1P2={u,v} and u,vA1A2, and we have seen that P1{u,v}A1A2, and thus P1P2A1A2.

For the third point, by way of contradiction, assume that P2{u,v} contains a vertex of wA1A2. We have |P1|=distA1(u,v)=d(u,v). By the choice of u and v on C, we must have |P1|+|P2|2d(u,v), i.e., |P2|d(u,v). On the other hand, let us consider the path P between u and v in A2. We have |P|=distA2(u,v)=d(u,v). So, P1P creates a cycle of length at most 2d(u,v). By minimality of C, this implies that |P2|=d(u,v). But, if wP2{u,v}, then both distC(u,w) and distC(v,w) would be less than |P2|=d(u,v)=distC(u,v): a contradiction with the choice of u,vA1A2 that minimizes the distance on C. So, P2P1 has no vertex in A1A2. Thus, P2P1 contains only vertices and edges of a same tree Ai. Clearly, P2P1A1 is not possible, since otherwise C would be wholly contained in A1. So, P2P1A2A1 as required.

Let u,v,P1,P2 be as in Claim 3. Note that d(u,v)>1. Indeed, we have seen that the size of C is |P1|+|P2|=2d(u,v), and d(u,v)=1 is not possible since C is a cycle. Then, we can define wi to be the neighbor of u in Pi, for each i{1,2}. See Figure 2 on the left. And, consider the graph 𝒰 obtained from 𝒰 by identifying w1 and w2 into a new vertex w, and by removing double edges created. We call this operation on 𝒰 a contraction, since it corresponds to a classical edge-contraction if w1 and w2 are adjacent. See Figure 2.

Figure 2: Cycle C=P1P2. Contracting w1 and w2 in 𝒰. Green vertices and edges are in A1A2, red vertices and edges are in A2A1, and black vertices and edges are in A1A2.

We will show that 𝒰 is still isometric-universal for , contradicting the fact that 𝒰 has the minimum number of vertices. This will prove that C does not exist in 𝒰, and so 𝒰 is a tree.

Let us show that A1 and A2 are isometric subgraphs of 𝒰. We have to prove that the contraction of w1 and w2 does not change any distance between any pair of vertices that belong to a same tree Ai, for each i{1,2}.

First we remark that Ai is a subgraph of 𝒰. Indeed, w1 and w2 belong to different trees, and thus the edge uwi of Ai in 𝒰, after contraction, is in A1A2 in 𝒰. So, the distances between vertices taken in Ai can only decrease in 𝒰.

We proceed by way of contradiction. Assume there are two vertices x and y at distance d in 𝒰 that both belong to Ai, for some i, and such that dist𝒰(x,y)<d. We consider only the case Ai=A1, the case Ai=A2 being symmetric.

Let us show that:

Claim 4.

There exists a path P between x and y in 𝒰 of length |P|d+1 that passes through the path w1uw2 or the path w2uw1.

Proof.

For every path Q in 𝒰, we denote by Q^, its contraction, i.e., the path obtained by contracting all the edges of the subpath of Q between w1 and w2. If w1 or w2 is not in Q, we set Q^=Q. Note that Q^ is a path of 𝒰.

Let P be a shortest path in 𝒰 between x and y. By hypothesis on x,y, |P^|<d. Let us show that there exists a path P in 𝒰 such that P=P^ and |P|d+1. If P does not contain w, then P=P=P^. Otherwise, wP. There are two cases: (1) if P contain uw, then we can set P as the path P where w is replaced w1 or w2 (depending on the other edge incident to w in P); (2) if P does not contain uw, then since P is a shortest path, it cannot contain u. We can set P as the path P where w is replaced by the path w1uw2 or w2uw1. We check that in both cases, P^=P, and |P||Q^|+2<d+2, that implies |P|d+1.

Let P be a path as in Claim 4. Note that P is a witness for dist𝒰(x,y)<d, i.e., a path connecting x to y and such that after contracting w1 and w2, its length decreases by 2 in 𝒰, and becomes less than d. W.l.o.g. we will assume that P visits w1uw2 in this order when going from x to y. If not, we can exchange the role of x and y.

Now, let us define the vertices a,b,z as follows (see Figure 3):

  • Vertex b is the last vertex of P, when going from u to y, that belongs to P2. Note that b is between w2 and y on P, possibly with b=w2. See Figure 3 on the left.

  • Vertex z is the first vertex of P, when going from b to y, that belongs to A1, possibly with z=y. Note that zb. See Figure 3 on the right.

  • Vertex a is the last vertex of the path between u to z in A1, when going from u to z, that belongs to P1, possibly with a{u,w1,v}. See Figure 3 on the right.

Figure 3: Path P between x and y, and vertices a,b,z.

Since P passes successively through vertices x,w1,u,w2,b,z,y, we have:

d(x,w1)+d(w1,u)+d(u,w2)+d(w2,b)+d(b,z)+d(z,y)|P|.

The quantity d(w1,u)+d(u,w2) is equal to 2, since w1,u,w2 are consecutive in P. On the other hand, |P|d+1 by definition of P. By the triangle inequality between x and y, d=d(x,y)d(x,w1)+d(w1,a)+d(a,z)+d(z,y). Therefore:

d(x,w1)+2+d(w2,b)+d(b,z)+d(z,y) d(x,w1)+d(w1,a)+d(a,z)+d(z,y)+1
1+d(w2,b)+d(b,z) d(w1,a)+d(a,z) (1)

In fact, we will show that:

Claim 5.

d(w1,a)+d(a,z)d(w2,b)+d(b,z).

Before presenting its proof, observe that the inequality of Claim 5 contradicts Equation 1, and the fact that some distance between two vertices of the same tree, namely x and y, is shortened in 𝒰. So 𝒰 is universal-isometric for {A1,A2}, and thus 𝒰 cannot be minimum, and thus does not contain any cycle.

Proof.

We will actually prove a stronger statement which is:

d(w1,a)=d(w2,b)andd(a,z)=d(b,z).

We first remark that vertex zA1A2. Indeed, we have zA1. If zA2, then the edge zz on the path P from z to b is not in A2. So, zzA1, which implies zA1: a contradiction with the fact that z is the first vertex on P from b to y that is in P1. So zA1A2.

As a preliminary step, let us show that d(u,a)=d(u,b), cf. Equation 5 hereafter. Recall that u,v,zA1A2, and that distances in Ai coincide with distances in 𝒰.

By definition, a is on the path from u to z in A1. Thus

distA1(u,z) =distA1(u,a)+distA1(a,z)
d(u,z) =d(u,a)+d(a,z)

Similarly for b, which is on the path in A2 from u to z, we have d(u,z)=d(u,b)+d(b,z). Combining these two equations, we get:

d(u,a)+d(a,z)=d(u,b)+d(b,z) (2)

We use the following fact:

Fact.

For any three vertices in a tree, the three paths between them have exactly one vertex in common.

In particular, whenever applied to u,v and z in A1, pairwise connected by the three tree paths Puv,Pvz,Puz in A1, the fact implies the last vertex of Puz that is on Puv is also the last vertex of Pvz that is on Puv. From this, we deduce that a is on the path from v to z in A1. Thus d(v,z)=d(v,a)+d(a,z). With the same argument applied to the same vertices but in A2, we deduce that b is on the shortest path in A2 from v to z, we have d(v,z)=d(v,b)+d(b,z). Therefore:

d(v,a)+d(a,z)=d(v,b)+d(b,z) (3)

By subtracting Equation 3 from Equation 2, we have:

(d(u,a)+d(a,z))(d(v,a)+d(a,z)) =(d(u,b)+d(b,z))(d(v,b)+d(b,z))
d(u,a)d(v,a) =d(u,b)d(v,b) (4)

Note that P1 and P2 are paths of A1 and A2 respectively, thus they are shortest paths in 𝒰. Since a and b are on P1 and P2 respectively, we have d(u,v)=d(u,a)+d(a,v)=d(u,b)+d(b,v). And by adding to Equation 4, we get:

d(a,u)=d(b,u) (5)

as claimed.

We now show that:

d(a,w1)=d(b,w2) (6)

Indeed, either d(a,u)=d(b,u)=0, i.e., a=u=b, and thus d(a,w1)=d(u,w1)=1=d(u,w2)=d(b,w2). Or, d(a,u)=d(b,u)>0, and thus w1 is on the path from u to a on P1, and w2 is on the path from u to b on P2. This implies d(u,w1)+d(w1,a)=d(u,w2)+d(w2,b), and thus d(w1,a)=d(w2,b).

Furthermore, applying Equation 5 on Equation 2 gives that:

d(a,z)=d(b,z) (7)

Equation 6 and Equation 7 completes the proof of Claim 5. This completes the proof of Theorem 2.

This structural result allows us to predict that every minimum isometric-universal graph of two trees {T1,T2} either is a tree, or contains an isometric-universal graph for {T1,T2} as a subgraph (only by removing edges). However, as the proof of Theorem 6 will explain, if we can compute a tree that contains T1 and T2 as subgraphs, then we can compute a minimum isometric-universal graph for {T1,T2}. More precisely:

Theorem 6.

A minimum isometric-universal graph for a pair of trees with at most n vertices each can be computed in time O(n5/2logn).

Proof.

Let T1,T2 be two trees with at most n vertices. From Theorem 2, there always exists a minimum isometric-universal graph of two trees that is a tree itself. Thus, any algorithm that computes a minimum isometric-universal tree for {T1,T2} computes a minimum isometric-universal graph for {T1,T2} too.

In a tree there exists only one path connecting any pair of vertices. Thus, every tree that contains T1 and T2 as subgraphs (such a tree is called a supertree under graph isomorphism in [17]) is also an isometric-universal tree. According to Gupta and Nishimura [17, Theorem 9.6], a minimum supertree of two trees can be computed in time O(n5/2logn).

From the above discussion, the minimum supertree for T1,T2 is a minimum isometric-universal tree and also a minimum isometric-universal graph for {T1,T2}, which concludes the proof.

2.3 The case of two forests

Now we extend the previous result to forests instead of trees. The combination of Theorem 1 and Theorem 6 leads to the following result:

Theorem 7.

A minimum isometric-universal graph for a pair of forests with at most n vertices each can be computed in time O(n7/2logn).

Proof.

This is a direct application of Theorem 1 applied on two forests, composed respectively of s and r trees. In the complexity formula of Theorem 1, we can bound r, s, and f(n) as follows:

  • srn.

  • f(n)=Cn5/2log2n, for some constant C>0, since, from Theorem 6, the time complexity of finding a minimum isometric-universal graph of two trees is at most f(n). Note that f is superlinear.

We have:

rmin{f(2n),sf(n)}+smin{rslogn,rs+sloglogs}

rf(2n)+srslogn
= O(n7/2logn+n5/2logn)
= O(n7/2logn).

Applying Theorem 1, this completes the proof.

3 Universal Graph for Three Forests

3.1 Three trees and more

Unfortunately, Theorem 2 cannot be extended to three trees. Indeed, as we will show in Theorem 8, there are triples of trees with no minimum isometric-universal graph that is a tree. As we will see later in Section 3.2, this implies that no greedy strategy can build a minimum isometric-universal graph, even if equipped with an optimal oracle for isometric-universal graphs for a pair of graphs.

Theorem 8.

For every integer t9, there is a family of trees {T1,T2,T3}, each with 2t3+2 vertices and with pathwidth333The pathwidth of a graph G is the smallest integer p such that G is a subgraph of some interval graphs with maximum clique size p+1. two, for which every isometric-universal tree is not minimum.

The proof is available in the full version [3]. See Figure 4 and Figure 5 for an illustration of the construction.

T1 T2 T3

Figure 4: A tree family {T1,T2,T3} whose every minimum isometric-universal graph is not a tree.
Figure 5: A cyclic isometric-universal graph for that is smaller than any isometric-universal tree for .

The smallest example provided by Theorem 8, for t=9, consists of three trees of 293+2=1460 vertices. We suspect that this vertex amount can be lowered significantly, with perhaps more complex arguments.

3.2 Consequences for greedy strategies

As we will see, Theorem 2 and Theorem 8 imply that there exist graph families where no greedy strategies can build a minimum isometric-universal graph. Informally, a greedy strategy consists in starting with some initial graph of a given family , and then, at each step, picking a new graph of and computing a minimum isometric-universal graph for the pair composed of the current graph and this new graph, and updates the current graph with this new isometric-universal graph.

More formally, let A be any algorithm (considered as a black-box or oracle) computing an isometric-universal graph for a pair of graphs. A greedy strategy, parametrized by A, selects the graphs of a given family in some order, say G1,,G||, and builds the following sequence of graphs 𝒰1,,𝒰||:

𝒰i={G1if i=1A(𝒰i1,Gi)if i>1

By construction, 𝒰|| is an isometric-universal graph for , since, by induction, 𝒰i is an isometric-universal graph for {G1,,Gi}.

Unfortunately, no greedy strategies can determine the minimum isometric-universal graph for all families of trees, if the routine A constructs a minimum and minimal isometric-universal graph for any two graphs. (Recall that, for two general graphs, this is NP-hard.) This is due to the fact that, at every step i, A(𝒰i1,Gi) will return a tree, since, by Theorem 2, every minimum and minimal isometric-universal graph of two trees has to be a tree. In particular, the final graph 𝒰|| will be a tree.

Now, by Theorem 8, there is a family of trees whose minimum isometric-universal graph cannot be a tree. So, it implies that whatever the order of the trees chosen for the greedy strategy, the result cannot be a minimum isometric-universal graph.

Since by Theorem 2, A(𝒰i1,Gi) must be a tree, it is legitimate to ask whether, for tree families, greedy strategies can help in computing a minimum isometric-universal tree, rather than a minimum isometric-universal graph. Unfortunately, this will fail as well for the following reason.

Consider the family ={T1,T2,T3}, where Ti is composed of two copies of a K1,r, whose centers are connected by a path of length (i+2)s, where r and s=o(r) are large enough. See Figure 6 for an example.

Figure 6: A family {T1,T2,T3} of trees, here for r=5 and s=1, whose any greedy strategy designed for trees will fail.

It is not difficult to see that the minimum isometric-universal graph of {Ti,Tj}, i.e., A(Ti,Tj), must contain three stars, i.e., three copies of K1,r intersecting only within a constant number of vertices. Indeed, assuming444As A(Ti,Tj)=A(Tj,Ti), the order of the two first trees does not matter. i<j, A(Ti,Tj) must be composed of Tj where the center of a star of Ti belongs to the path of Tj, the other star being in common. In this universal tree, the distances between these three centers are (2+i)s, (2+j)s, and (ji)s. For instance, for i=1 and j=3, we have the distance set {3s,5s,2s}. The two other distance sets being {3s,4s,s} (for i,j=1,2) and {4s,5s,s} (for i,j=2,3).

Now, by adding the third tree Tk to A(Ti,Tj), by computing A(A(Ti,Tj),Tk), one obtain a universal tree that must contain four stars. Indeed, the only way to get three stars would be to share both stars of Tk with two out of the three stars already in A(Ti,Tj). Unfortunately, the distance (2+k)s between the two star centers of Tk does not belong to the distance set {(2+i)s,(2+j)s,(ji)s} of A(Ti,Tj).

The construction as depicted in Figure 7 shows that {T1,T2,T3} has an isometric-universal tree with only three stars, and thus with 3r+O(s) vertices, whereas the greedy strategy A(A(Ti,Tj),Tk) gives 4r+O(s) vertices, which is bigger for s=o(r) for instance.

Figure 7: An isometric-universal tree for {T1,T2,T3}, depicted in Figure 6, with only 3r+O(s) vertices.

To summarize the above discussion, we have shown:

Proposition 9.

Let A be any algorithm computing a minimum and minimal isometric-universal graph for a pair of graphs. Then, no greedy strategies based on A can compute a minimum isometric-universal graph (or tree) for all tree families.

We note that we have analyzed greedy strategies for its best-case running (and not its worst-case as usual), that is for best ordering of the graphs in the family. So, these greedy strategies fail in a strong sense (i.e. whatever the ordering is).

3.3 Extending Theorem 2 to 𝒌-isometric-universal trees

Another natural extension of Theorem 2 is to ask whether it holds for k-isometric-universal graphs, for k large enough and depending of n. More formally, we may ask what is the smallest function k(n) defined as:

For every kk(n), every minimum and minimal k-isometric-universal graph for a pair of trees each with at most n vertices is a tree.

Clearly, every graph 𝒰 containing an n-vertex tree T as an (n1)-isometric subgraph, also contains T as an isometric subgraph. Thus, by Theorem 2, k(n)n1 for all n1. On the other hand, as we will see hereafter in Theorem 10, there are pairs of n-vertex trees for which every minimum 1-isometric-universal graph is not a tree whenever n11. Thus, k(n)>1 for all n11.

We establish the following lower bound for k(n):

Theorem 10.

For every n8, k(n)>(n8)/3. In other words, there is a pair of trees, each with at most n vertices, for which every minimum (n8)/3-isometric-universal graph is not a tree.

The proof is available in the full version [3].

Despite Theorem 10 showing that k(n)n/3O(1), we suspect that k(n)=n/2+o(n), and we leave open to determine the right asymptotic value for k(n). On one side we believe that the above proof can be enhanced to reach k(n)n/2o(n). On the other hand, in the k(n)-isometric-universal graph, it seems far-fetched to have two disjoint paths of length >n/2.

3.4 NP-completeness

In this section we show that Theorem 7 cannot be extended to more than two forests (unless P = NP). In several decision problems, setting the input from 2 to 3 costs to pass from P to NP-C (for instance 2-SAT has a polynomial solution and 3-SAT is NP-complete, same for graph 2/3-coloring). We present here the same pattern with the problem of isometric-universal graph from 2 to 3 forests. As a byproduct of our proof, the NP-completeness holds if we restrict the isometric-universal graph to be a forest. This restriction has also been claimed by Rautenbach and Werner [18, Theorem 3].

Theorem 11.

Determining whether there exists an isometric-universal graph (or forest) with t vertices for three forests is NP-complete, even if the three forests have pathwidth at most two.

Proof.

It is not difficult to see that this problem is in NP. We use a reduction from the 3D-Matching problem that is NP-complete even if each element is contained in at most three sets (see [14, Problem SP1 in Appendix A.3.1]). This restriction can be seen as determining a perfect matching in a 3-partite sub-cubic hypergraph.

For the 3D-Matching problem, we are given three disjoint sets X,Y,Z of size n, and a set of triples TX×Y×Z. We ask whether there exists or not a subset of n triples of T that are pairwise independent. In other words, a solution for the problem, called matching, is a subset MT of size n such that no two triples of M agree in any coordinate.

In order to encode the 3D-Matching problem into our problem, consider a instance (X,Y,Z,T) where each element of X,Y, or Z is contained in two or three triples555Clearly, any element has to appear at least once in T, and if it appears only once, then we have to take it in any solution, and so reducing the instance. of T. We have |X|=|Y|=|Z|=n and |T|{2n,,3n}, so that the instance is of size O(n).

We construct a family ={FX,FY,FZ} composed of three forests, each with n trees, one tree for each element of X, Y, and Z. More precisely, for each set W{X,Y,Z}, the set of connected components of FW is denoted by {F(w):wW}, where F(w) is the tree associated with the element wW of the forest FW. Each tree F(w) will be described precisely hereafter.

For every w{1,,2n}, let S(w) be a subdivided star obtained from a K1,3w+3 whose three of its edges have been replaced by a path of length 2n+2w. Let 𝒮={S(1),,S(2n)} be the collection of all such stars that are pairwise non-isomorphic. See Figure 8 for examples of such stars.

Figure 8: The set 𝒮={S(1),,S(2n)} of subdivided stars for n=2.

It is easy to check that:

Claim 12.

Each S(w)𝒮 is a tree of pathwidth two with 3n+1 vertices, its center has degree 3w+3, 3w branches of length one, and three branches of length 2n+2w2.

The forests 𝑭𝒀 and 𝑭𝒁.

For convenience, we will assume that Y={1,,n} and Z={n+1,,2n}, so that YZ={1,,2n}. Actually, any one-to-one mapping from YZ to {1,,2n} is fine. For each wYZ, the tree F(w) is composed of a copy of the star S(w)𝒮 where is attached a claw, i.e., a copy of a K1,3. More precisely, the center of S(w) is merged with a leaf of the claw. The tree F(w) has |V(S(w))|+|V(K1,3)|1=3n+4 vertices, and pathwidth two. See Figure 9.

Figure 9: The tree F(w) associated with element wYZ={1,,2n} constructed from S(w)𝒮 and a claw K1,3 (in red).

The forest 𝑭𝑿.

Consider any xX, and define T(x)={(x,y,z)T} to be the set of triples of T containing element x. From the restriction of the input, |T(x)|{2,3}.

Let us denote by y1,,yt and z1,,zt the elements of Y and Z that are contained in the triples of T(x), where t=|T(x)|. The tree F(x) of the forest FX is obtained from the copies of the 2t stars S(y1),,S(yt),S(z1),,S(zt) where their centers are connected by a path in which each edge is alternatively replaced by a path of length two or three. Furthermore, along the path, the 2t star centers are encountered in the specific order S(y1)S(z1)S(z2)S(y2) if t=2 (dashes mean edges), and in the order S(y1)S(z1)S(z2)S(y2)S(y3)S(z3) if t=3. See Figure 10 with the notation therein.

Figure 10: The tree F(x) associated with the element xX. In this example, T(x)={(x1,y1,z1),(x2,y2,z2),(x3,y3,z3)}, and F(x) is composed of six distinct stars of 𝒮. Vertex c(w) is the center of the copy of S(w) in F(x), and p(w,w) with w<w is the unique vertex of the path between the centers c(w) and c(w), if (x,w,w)T(x).

Clearly, F(x) is a tree of pathwidth two. Since each star S(w) has 3n+1 vertices (cf. Claim 12), the number of vertices of F(x) is |V(F(x))|=2t(3n+1)+3t2=6tn+5t2{12n+8,18n+13} depending on t. By construction, we have |V(FX)|=xX|V(F(x))|.

An important property of F(x) is that if (x,y,z)T, then a copy of the stars S(y) and S(z) appears as an isometric subgraph of F(x). However, neither F(y) nor F(z) can appear in F(x) as an isometric subgraph because of their claws. Another important property is that if (x,y,z)T, then the stars S(y) and S(z) cannot appear consecutively in the main path of F(x) (if they appear). This is due to the specific order of the stars along the path. In that case, the distance between their centers is at least 5.

Let 𝒰 be any minimum isometric-universal graph for ={FX,FY,FZ}. We note that has polynomial size w.r.t. the instance (X,Y,Z,T), since each of the forests FX,FY,FZ is composed of n trees with O(n) vertices each.

Intuition behind the proof.

Each component of 𝒰 must contain the trees F(x), F(y) and F(z) for some elements x,y,z. In a favorable case, this component is composed of F(x) plus only one single vertex. Indeed, if y,z are both contained in T(x), then S(y) and S(z) each appears in F(x). It follows that F(y) and F(z) will almost fit in F(x) but for one vertex of their claw. The only way to pack in F(x) using one extra vertex is to share this vertex with their claw by being consecutive on the main path of F(x). This favorable situation will occur simultaneously on each F(x) if (X,Y,Z,T) has a solution, i.e., if T contains a matching for X×Y×Z. Unfortunately, if y or z are not in T(x), and still want to pack in F(x), then the resulting component would contain more than one vertex more as in F(x). This situation will necessarily occur if (X,Y,Z,T) has no solution. Overall, the number of vertices in 𝒰 will allow us to determine whether a solution exists or not for (X,Y,Z,T).

More formally, our goal is to prove the following claim:

Claim 13.

|V(𝒰)||V(FX)|+n if and only if (X,Y,Z,T) has a solution.

The proof of this claim is available in the full version [3].

4 Conclusion and Open Question

We have introduced the notion of k-isometric-universal graph, which captures several well-studied variants of universal graph, by taking different values for k, with k=0 (classical universal graphs), k=1 (induced-universal graphs), or k= (isometric-universal graphs). We have also considered limited families of graphs (by taking two graphs, two trees or forests, all n-vertex graphs, …).

We have mainly proved that, for k=, the problem of minimizing the number of vertices of a minimum k-isometric-universal graph is polynomial for two forests and NP-hard for three forests. The variants for k{0,1} are known to be NP-hard.

Along the way, we have proved that any minimum and minimal isometric-universal graph for two trees has to be a tree (Theorem 2). We propose two open questions, one about the structure of minimum isometric-universal graphs, and one about the complexity for two graphs. More precisely,

What is the arboricity of a minimum and minimal isometric-universal graph of t>2 trees? Is it t1?

Theorem 2 shows that this is indeed t1 for t=2. Note that Theorem 8 shows that for t=3 trees, arboricity 1 is not possible.

What is the complexity of finding a minimum isometric-universal graph for two outerplanar graphs? Or two graphs of bounded treewidth?

References

  • [1] Faisal N. Abu-Khzam. Maximum common induced subgraph parameterized by vertex cover. Information Processing Letters, 114(3):99–103, March 2014. doi:10.1016/j.ipl.2013.11.007.
  • [2] Faisal N. Abu-Khzam, Édouard Bonnet, and Florian Sikora. On the complexity of various parameterizations of common induced subgraph isomorphism. Theoretical Computer Science, 697:69–78, October 2017. doi:10.1016/j.tcs.2017.07.010.
  • [3] Edgar Baucher, François Dross, and Cyril Gavoille. Isometric-universal graphs for trees. Technical Report 2506.11704v1 [cs.DS], arXiv, June 2025. doi:10.48550/arXiv.2506.11704.
  • [4] Helena Bergold, Vesna Iršič, Robert Lauff, Joachim Orthaber, Manfred Scheucher, and Alexandra Wesolek. Subgraph-universal planar graphs for trees. Technical Report 2409.01678 [quant-ph], arXiv, September 2024. doi:10.48550/arXiv.2409.01678.
  • [5] Olivier Bodini. On the minimum size of a contraction-universal tree. In 28th International Workshop on Graph-Theoretic Concepts in Computer Science (WG), volume 2573 of Lecture Notes in Computer Science, pages 25–34. Springer, June 2002. doi:10.1007/3-540-36379-3_3.
  • [6] Gregory Bodwin. New results on linear size distance preservers. SIAM Journal on Computing, 50(2):662–673, January 2021. doi:10.1137/19M123662X.
  • [7] Béla Bollobás, Don Coppersmith, and Michael Elkin. Sparse distance preservers and additive spanners. SIAM Journal on Discrete Mathematics, 19(4):1029–1055, 2006. doi:10.1137/S0895480103431046.
  • [8] Horst Bunke, Xiaoyi Jiang, and Abraham Kandel. On the minimum common supergraph of two graphs. Computing, 65:13–25, July 2000. doi:10.1007/PL00021410.
  • [9] Fan R.K. Chung, Ronald Lewis Graham, and J. Shearer. Note: Universal caterpillars. Journal of Combinatorial Theory, Series B, 31(3):348–355, December 1981. doi:10.1016/0095-8956(81)90037-X.
  • [10] Don Coppersmith and Michael Elkin. Sparse source-wise and pair-wise distance preservers. SIAM Journal on Discrete Mathematics, 20(2):463–501, 2006. doi:10.1137/S0895480104445319.
  • [11] Vida Dujmović, Louis Esperet, Cyril Gavoille, Gwenaël Joret, Piotr Micek, and Pat Morin. Adjacency labelling for planar graphs (and beyond). Journal of the ACM, 68(6):Article No. 42, pp. 1–33, December 2021. doi:10.1145/3477542.
  • [12] Louis Esperet, Cyril Gavoille, and Carla Groenland. Isometric universal graphs. SIAM Journal on Discrete Mathematics, 5(2):1224–1237, 2021. doi:10.1137/21M1406155.
  • [13] Louis Esperet, Gwenaël Joret, and Pat Morin. Sparse universal graphs for planarity. Journal of the London Mathematical Society, 108(4):1333–1357, October 2023. doi:10.1112/jlms.12781.
  • [14] Michael R. Garey and David S. Johnson. Computers and Intractability - A Guide to the Theory of NP-Completeness. W.H. Freeman, 1979.
  • [15] Cyril Gavoille and Amaury Jacques. Compact universal graphs for small families of graphs, 2024. In preparation.
  • [16] Paweł Gawrychowski, Fabian Kuhn, Jakub Łopuszański, Konstantinos Panagiotou, and Pascal Su. Labeling schemes for nearest common ancestors through minor-universal trees. In 29th Symposium on Discrete Algorithms (SODA), pages 2604–2619. ACM-SIAM, 2018. doi:10.1137/1.9781611975031.166.
  • [17] Arvind Gupta and Naomi Nishimura. Finding largest subtrees and smallest supertrees. Algorithmica, 21(2):183–210, June 1998. doi:10.1007/PL00009212.
  • [18] Dieter Rautenbach and Florian Werner. Induced subforests and superforests. Technical Report 2403.14492v1 [cs.DS], arXiv, March 2024. doi:10.48550/arXiv.2403.14492.
  • [19] Peter Winkler. Proof of the squashed cube conjecture. Combinatorica, 3(1):135–139, March 1983. doi:10.1007/BF02579350.