FPT algorithms for embedding into low complexity graphic metrics

The Metric Embedding problem takes as input two metric spaces $(X,D_X)$ and $(Y,D_Y)$, and a positive integer $d$. The objective is to determine whether there is an embedding $F:X \rightarrow Y$ such that $d_{F} \leq d$, where $d_{F}$ denotes the distortion of the map $F$. Such an embedding is called a distortion $d$ embedding. The bijective Metric Embedding problem is a special case of the Metric Embedding problem where $|X| = |Y|$. In parameterized complexity, the Metric Embedding problem, in full generality, is known to be W-hard and therefore, not expected to have an FPT algorithm. In this paper, we consider the Gen-Graph Metric Embedding problem, where the two metric spaces are graph metrics. We explore the extent of tractability of the problem in the parameterized complexity setting. We determine whether an unweighted graph metric $(G,D_G)$ can be embedded, or bijectively embedded, into another unweighted graph metric $(H,D_H)$, where the graph $H$ has low structural complexity. For example, $H$ is a cycle, or $H$ has bounded treewidth or bounded connected treewidth. The parameters for the algorithms are chosen from the upper bound $d$ on distortion, bound $\Delta$ on the maximum degree of $H$, treewidth $\alpha$ of $H$, and the connected treewidth $\alpha_{c}$ of $H$. Our general approach to these problems can be summarized as trying to understand the behavior of the shortest paths in $G$ under a low distortion embedding into $H$, and the structural relation the mapping of these paths has to shortest paths in $H$.

The central idea is, given an input metric space (X, D X ), we find an efficient small distortion embedding of (X, D X ) into a simpler metric space whose structure is well understood. For example, the metric space into which we intend to embed (X, D X ) could be a simple graphic metric like a path or a tree, or well-studied metric spaces like a Euclidean space etc. Examples of problems where this strategy has been successfully implemented include problems like Sparsest Cut, Approximate Nearest Neighbor Search, Clustering, Multicommodity Flow, Multicut, Low Diameter Decomposition, Small Balanced Separators etc. (See [LLR95,Ind01,GNRS04,ABN11,Mat13]).
The problem of finding a low distortion embedding of a metric space into a simple metric space has been extensively studied both in Mathematics and Computer Science. For example, any metric space with n points can be isometrically embedded into ℓ n ∞ [LLR95]. In [LLR95], Linial et al. showed that any unweighted n vertex tree with l leaves can be isometrically embedded into ℓ O(log l) ∞ . Bourgain [Bou85] showed that any metric space on n points can be embedded into ℓ p with distortion O(log n). Johnson and Lindenstrauss [JL84] showed that any n points can be embedded into ℓ O(log 2 n/ǫ 2 ) 2 with distortion at most (1+ǫ). Bartal [Bar96] and Fakcharoenphol et al. [FRT03] showed that any metric space on n points can be embedded into a distribution of trees with expected distortion O(log n).

Embedding into low complexity graphs
The need for getting small distortion embeddings into simpler spaces naturally led to the question of finding minimum distortion embedding of (X, D X ) into (Y, D Y ) when both the metric spaces come from shortest path metrics on graphs with positive weights, and (Y, D Y ) has a simple topology like paths, cycles, trees etc. Kenyon et al. [KRS10] showed that this problem is APX-hard even when both the graphs are unweighted, have the same number of vertices, and one of the graphs is a simple wheel graph. Kenyon et al.'s [KRS10] result implies that the problem is APX-hard even when we are looking for a bijective embedding and both the graphs are unweighted. Badoiu et al. [BDG + 05] also proved APX-hardness when both the graphs are unweighted and (Y, D Y ) is the metric space of a path. Badoiu et al. [BCIS05] showed that computing the minimum distortion is hard to approximate up to a factor polynomial in |X|, even when (X, D X ) is a weighted tree with polynomial spread and (Y, D Y ) is a path. Fellows et al. [FFL + 13] showed that the problem of embedding a weighted graph metric into a path with distortion at most d > 2 is NP-complete. Badoiu et al. [BDG + 05] gave the first algorithm for deciding if an unweighted graph metric has a non-contracting embedding into a path with distortion d. The running time of their algorithm was n 4d+2 · d O(1) , where n denotes the number of vertices in the graph. The study of small distortion embeddings through the lens of Parameterized Complexity [CFK + ] started with the work of Fellows et al. [FFL + 13]. They gave the first fixed parameter tractable(FPT) algorithm with running time O n d 4 (2d + 1) 2d for finding a non-contracting embedding of an n vertex unweighted graph metric into a path with distortion at most d (d is the parameter of the algorithm). Fellows et al. [FFL + 13] also showed that their FPT algorithm can be extended to get an FPT algorithm for the case of non-contracting embeddings for weighted graphs into paths, where the parameters to the algorithm are both the distortion and the maximum weight of an edge in the graph. Nayyeri et al. [NR15] gave improved exact algorithms for embedding weighted path metrics into weighted paths.
Results for embedding into paths have been extended to the case of trees. Kenyon et al. [KRS10] gave the first FPT algorithm for finding a bijective embedding f of an unweighted graph metric on n vertices into a tree with maximum degree bounded by ∆ in O n 2 · 2 ∆ µ 3 time, where µ = max {e f , c f }. Fellows et al. [FFL + 13] extended this result to give an algorithm for the problem of finding a non-contracting embedding of unweighted graphs into bounded degree trees with distortion at most d in O(n 2 · |V (T )|) · 2 O((5d) ∆ d+1 ·d) time, where V (T ) denotes the vertex set of the tree and where the maximum degree in T is bounded by ∆. In a follow-up paper, Nayyeri et al. [NR17] gave the first (1 + ǫ)-approximation algorithm to embed weighted graphs with spread Σ into graphs on m vertices with bounded treewidth α and doubling dimension λ in m O(1) · n O(α)·(doptΣ) α·(1/ǫ) λ+2 ·λ·(O(d opt )) 2λ time, where d opt denotes the minimum distortion.

Our contributions
In this paper, we further investigate the problem of embedding a general graph metric (G, D G ) into a low complexity graph metric (H, D H ) with distortion at most d. We will denote by n and N the number of vertices in graphs G and H, respectively. Also, we denote distortion by d, the maximum degree of H by ∆, and the length of a longest geodesic (or induced) cycle of H by ℓ g . We approach the metric embedding problem by trying to understand the behavior of the shortest paths in G under a low distortion embedding into H, and what relation the mapping of these paths has to shortest paths in H. Careful analysis of this connection helps us solve a number of problems in this area, in the parameterized setting. All the algorithmic results mentioned below are regarding non-contracting bounded distortion embeddings. However, all these results can be extended to find bounded distortion embeddings, without the assumption on non-contraction. For all the results, if the running time of the stated algorithm is T , then the running time of finding a bounded distortion embedding will be (nN ) O(1) · T . For more details, refer to Proposition 2.2 in Section 2.
(a) In Section 3, we find a non-contracting embedding of distortion d of G into H, when H is a cycle. We present an FPT algorithm, parameterized by d and with time complexity 2 O(d log d) · n O(1) . The techniques used for obtaining this algorithm involve a few different ideas from the ones used in the previous papers where H is either a path or a bounded degree tree. This is due to the existence of the large geodesic cycle that is the graph H. The technique of pushing embeddings, introduced in [FFL + 13] for embedding into paths, does not work and some new ideas are required to solve this problem. This resolves a question left open in [FFL + 13]. Moreover, our FPT algorithm can be extended to the weighted setting, where the input graph G has edge weights and we parameterize by the distortion d as well as the maximum edge weight in G. On the other hand, we show that when we do not take the maximum edge weight as a parameter, then the problem becomes NP-Complete for any distortion d > 2.
(b) Observe that the treewidth of a cycle is 2, but the connected treewidth of a cycle is Ω(n) (see the definitions of treewidth and connected treewidth in Section 2). These two parameters (treewidth and connected treewidth of graphs) play important roles in this paper.
-First, in Section 4, we find a non-contracting bijection of distortion d of G into H, which has constant treewidth α. Parameterized by d and ∆, the FPT algorithm has time complexity O(α 2 n α+3 ) · ∆ d+1 · (α∆ d+1 ) ∆ O(αd 2 ) . This is an extension of the result of Kenyon et al. [KRS10] for bijection into bounded degree trees. Even though our FPT algorithm is different from the algorithm in [KRS10], the fact that we are looking for bijective embeddings plays an important role in the analysis and the algorithm in [KRS10] also uses this fact crucially.
-Next, in Section 5, we find a non-contracting embedding of distortion d of G into H, which has treewidth α and length of longest geodesic cycle ℓ g . Parameterized by d, α, ℓ g and ∆, the FPT algorithm has time complexity O(n 2 · N ) · (µ · ∆ d+1 ) ∆ O(µ·d+d 2 ) · 2 O((4(µ+d)) µ 2 ·∆ d+1 + n O(1) , where µ = 4(α + α 2 (ℓ g (α − 2) − 1)). This result crucially uses the result in [DM17] that a graph has bounded connected treewidth if and only if the graph has bounded treewidth and no long geodesic cycle. It is to be noted that a wheel graph has constant connected treewidth, and by a result in [KRS10], embedding into wheel graphs is NP-hard even when the distortion d = 2. However, when the wheel graph has bounded degree, then the number of vertices in the wheel graph becomes bounded, and we obtain a trivial FPT algorithm parameterized by the degree and the distortion d. This motivated us to consider the above variant of metric embedding. Our FPT algorithm extends the result of Fellows et al. [FFL + 13] for embedding into trees with bounded degree. Controlling the behavior of shortest paths in the graph G under a low distortion embedding into the class of graphs with bounded degree and bounded connected treewidth is algorithmically considerably harder than the case of bounded degree trees. The algorithm given in [FFL + 13] remembers the information of one shortest path between two vertices in G but in our case we have to efficiently maintain information of a set of useful paths between two vertices.
(c) In Section 6, we consider generalized theta graphs: defined by the union of k paths all of which have common endpoints s and t. We find a noncontracting embedding of distortion d of G into H, which is a generalized theta graph. Parameterized by d and k, our FPT algorithm has running time O(N )+n 5 ·k 2k+1 ·(kd+1) (2d) O(kd) ·d O(d 2 ) . As mentioned earlier, it was shown in [DM17] that a graph has bounded connected treewidth if and only if the graph has bounded treewidth and no long geodesic cycle. In general, embedding into graphs with large geodesic cycles is not amenable to known algorithmic techniques in the parameterized settings. Intuitively, all known techniques for designing FPT algorithms in this area used the fact that if a low distortion embedding F exists, then the embedding of a shortest path between two vertices u, v ∈ V (G) and the shortest path in H between F (u) and F (v) are somewhat structurally related. With the presence of large geodesic cycles this structural relation may completely break down: although the two paths have similar lengths, structurally they could be completely different. This poses a problem for designing dynamic programming algorithms, a staple for FPT algorithms in this area. The class of generalized theta graphs has treewidth 2, but may have large geodesic cycles. Hence, these graphs are more general than cycles and have constant treewidth, but they do not have bounded connected treewidth. Even for this very structured graph class, by virtue of the graphs having long geodesic cycles, we needed to develop completely new ideas in order to find low distortion embeddings into generalized theta graphs via FPT algorithms. The problem arises from the fact that any two geodesic cycles of a generalized theta graph intersect at at least two vertices, and there are many pairs of geodesic cycles with large intersections. Our algorithm is still a dynamic programming algorithm, but a more involved one. The way to work around the apparent barriers is to investigate more closely the structural properties of an input graph G that can be embedded with small distortion into a generalized theta graph. Independently a generalization of this result was obtained in [CFL + 17].

General Notations
We denote {1, . . . , t} as [t]. For a set S, |S| denotes the number of elements present in S. Given a function f : U ′ → D ′ and a function F : U → D, where U ′ ⊆ U and D ′ ⊆ D, we say that F extends f if for all x ∈ U ′ , F (x) = f (x). A graph is denoted by G while its vertex set and edge set are denoted by V (G) and E(G), respectively. We denote the set of neighbours of a vertex v ∈ V (G) as N G (v). The degree of a vertex v ∈ V (G) is denoted as deg G (v). We also define ∆(G) = max and refer to is as an r-ball around v. For a subgraph }. An induced cycle in a graph is also called a geodesic cycle.
A generalized theta graph is the union of k paths P = {P 1 , P 2 , . . . P k } such that the endpoints of all the paths are two vertices s and t, while every pair of paths are internally vertex and edge disjoint. Such a graph will also be referred to as a generalized theta graph defined at s,t, and the family P is said to define the generalized theta graph.

Tree decompositions and treewidth
We define treewidth and tree decompositions.
has an assigned set of vertices X u ⊆ V (G) (called a bag) such that the following properties hold: • For any (x, y) ∈ E(G), there exists a u ∈ V (T ) such that x, y ∈ X u .
• If x ∈ X u and x ∈ X v , then x ∈ X w for all w on the path from u to v in T .
In short, we denote T = (T, {X u } u∈V (T ) ) as T .
The treewidth tw T of a tree decomposition T is the size of the largest bag of T minus one. A graph may have several distinct tree decompositions. The treewidth tw(G) of a graph G is defined as the minimum of treewidths over all possible tree decompositions of G. Note that for the tree T of a tree decomposition, we denote a vertex of V (T ) in bold font.
A tree decomposition T = (T, {X u } u∈V (T ) )) is called a nice tree decomposition if T is a tree rooted at some node r where X r = ∅, each node of T has at most two children, and each node is of one of the following kinds: • Introduce node: a node u that has only one child u ′ where X u ⊃ X u ′ and |X u | = |X u ′ | + 1.
• Forget vertex node: a node u that has only one child u ′ where X u ⊂ X u ′ and |X u | = |X u ′ | − 1.
• Join node: a node u with two children u 1 and u 2 such that X u = X u 1 = X u 2 .
• Leaf node: a node u that is a leaf of T , and X u = ∅.
One can show that a tree decomposition of width w can be transformed into a nice tree decomposition of the same width w and with O(w|V (G)|) nodes, see e.g. [CFK + ]. A connected tree decomposition is a tree decomposition where the vertices in every bag induce a connected subgraph of G [DM17]. The connected treewidth ctw(G) of a graph G is defined as the minimum of treewidths over all possible connected tree decompositions of G.

Parameterized Complexity
The instance of a parameterized problem/language is a pair containing the problem instance of size n and a positive integer k, which is called a parameter. The problem is said to be in FPT if there exists an algorithm that solves the problem in f (k)n O(1) time, where f is a computable function. Such an algorithm is called an FPT algorithm and the running time of such an algorithm is called FPT running time. There is also an accompanying theory of parameterized intractability using which one determines that a parameterized problem is unlikely to admit FPT algorithms. A parameterized problem is said to be in the class para-NP if it has a nondeterministic algorithm with FPT running time. To show that a problem is para-NP-hard we need to show that the problem is NP-hard for some constant value of the parameter. Readers are requested to refer [CFK + ] for more details on Parameterized Complexity.

Metric Embedding
Given a graph G, the function D G : V (G) × V (G) → R is the shortest distance function defined on G; for any pair u, v ∈ V (G), D G (u, v) is the length of the shortest path between u and v in the graph G. When the graph is unweighted, then note that the range of D G is Z ≥0 . When we talk of a graph metric, then we denote it as the tuple (G, D G ). In this paper, unless otherwise mentioned, a graph metric is that of an unweighted undirected graph.
A metric embedding of a graph metric (G, D G ) into a graph metric (H, D H ) is a function F : V (G) → V (H). When the graph metrics are clear, we also use the terminology that the metric embedding is that of G into H, or that G is embedded into H. We also denote (G, D G ) as the input metric space and (H, D H ) as the output metric space. The expansion of F is defined as Similarly, the contraction of F is defined as .
The metric embedding F is said to be of distortion d if d = e F ·c F . When F has the property that c F < 1, then the metric embedding is called a non-contracting embedding. In this case, a noncontracting distortion d metric embedding implies that the expansion is at most d. Therefore, for any pair u, v ∈ V (G), When d = 1, then the metric embedding is called an isometry.
The Gen-Graph Metric Embedding problem is defined below: Gen-Graph Metric Embedding Input: Two graph metrics (G, D G ) and (H, D H ), where G is a connected graph, and a positive integer d Question: Is there a distortion d metric embedding of (G, D G ) into (H, D H )?
A related problem is the Graph Metric Embedding problem, where we are only interested in finding a non-contracting distortion d metric embedding.

Graph Metric Embedding
Input: Two graph metrics (G, D G ) and (H, D H ), where G is a connected graph, and a positive integer d Question: Is there a non-contracting distortion d metric embedding of (G, D G ) into (H, D H )?
We also define the following restricted version of the problem.

Red-Blue Graph Metric Embedding
Input: Two graph metrics (G, D G ) and (H, D H ), where G is a connected graph and V (H) = R ⊎ B, and a positive integer d Question: Is there a metric embedding F : V (G) → R such that it is a non-contracting distortion d metric embedding of (G, D G ) into (H, D H )?
In Red-Blue Graph Metric Embedding, the objective is to find a non-contracting distortion d metric embedding that maps the vertices of V (G) only to the vertices in R ⊆ V (H). Now, we will explain the necessity of this restricted problem in the graph metric setting.
When (G, D G ) and (H, D H ) are graph metrics, then the contraction c F is a rational number p q . By a result of Nayyeri et al. [NR15], we can assume that F is a non-contracting distortion d metric embedding. We state a modified version of the result, tailored to our need.
Proposition 2.2. Let (G, D G ) and (H, D H ) be graph metrics with n and N vertices, respectively. Then the Gen-Graph Metric Embedding problem reduces to solving O(N 4 n 4 ) instances of the Red-Blue Graph Metric Embedding problem.
Proof. Let F be any metric embedding with distortion d. Let x, x ′ ∈ V (G) and y, y ′ ∈ V (H) realize the expansion e F and the contraction c F , respectively. Since we consider graph metrics, the contraction c F is a rational p q . We subdivide all the edges of H p times. This results in a new graph H ′ , where we mark all the original vertices of H with red and all the newly introduced subdivision vertices with blue. We define a bipartition of V (H ′ ) into the set R of red vertices and the set B of blue vertices. Now, the mapping F still is a distortion d embedding of G into H ′ . The extra property is that F is a non-contracting distortion d embedding of G into H ′ . Since the original vertices of H are remembered in the set R, we can derive a distortion d metric embedding of G into H from a non-contracting distortion d metric embedding of G into H ′ , where V (G) is mapped to R. Since we do not know the metric embedding F , we guess the vertices x, x ′ , F (x), F (x ′ ), y, y ′ , F −1 (y) and F −1 (y ′ ). There are O(N 4 n 4 ) choices for these values. Thus, if we solve O(N 4 n 4 ) instances of Red-Blue Graph Metric Embedding, we can solve Gen-Graph Metric Embedding.
The Gen-Graph Metric Embedding problem or the Graph Metric Embedding problem for a graph class G is a variant where the output metric space (H, D H ) is such that H ∈ G. In this paper, the graph classes we consider are the class of cycles, the class of generalized theta graphs and the class of graphs with treewidth α, for any constant α. All these classes are closed under the subdivision operation. Therefore, by Proposition 2.2 solving the Gen-Graph Metric Embedding for such a graph class is same as solving polynomially many instances of the Red-Blue Graph Metric Embedding problem for the graph class. In this paper, we present detailed FPT algorithms for the Graph Metric Embedding problem. All these algorithms are easily modified to solve the Red Blue Graph Metric Embedding problem, and therefore by Proposition 2.2, FPT algorithms for the Gen-Graph Metric Embedding problem can be designed.
The bijective Gen-Graph Metric Embedding problem takes the same input but aims to determine whether the distortion d embedding is a bijective function. The following result in [GKL03] is useful for us to reduce the problem to that of finding a non-contracting distortion d metric embedding.
Proposition 2.3. Let (G, D G ) and (H, D H ) be two graph metrics. Let F : V (G) → V (H) be a bijection. Then the expansion of F is achieved by an adjacent pair (x, x ′ ) ∈ E(G) and the contraction of F is achieved by an adjacent pair (y, y ′ ) ∈ E(H).
From the above proposition, we obtain the following result. Proof. By Proposition 2.3, for a bijective distortion d metric embedding F , an edge in H realizes the contraction c F . Therefore, c F ∈ N and c F ≤ d. From Proposition 2.2, it is enough to solve the Red-Blue Graph Metric Embedding problem where the output graph metric of each instance has had each of its edges subdivided at most d times. Therefore, in the new output graph metric any path of length d + 1 contains at least one internal red vertex. Also, a bijective mapping of the Gen-Graph Metric Embedding problem implies that in a reduced instance of Red-Blue Graph Metric Embedding we look for a bijection between the vertices of the input graph metric (G, D G ) and the red vertices R ′ of the output graph metric (H ′ , D H ′ ).
In Section 4, we describe an FPT algorithm for bijective Graph Metric Embedding for constant treewidth graphs. Using Lemma 2.4, it is possible to easily modify this algorithm to design an FPT algorithm for bijective Gen-Graph Metric Embedding.
The following Observation relates ∆(H) to ∆(G) when G can be embedded into H by a non-contracting distortion d embedding.
Observation 2.5. Given graph metrics (G, D G ) and (H, If there is a non-contracting distortion d embedding F of G into H, then without loss of generality we assume that F (x) = v. However, by non-contracting, F is an injective function. Since F has distortion d, every neighbour of x in G must be mapped to a vertex of B(v, d). However, since ∆(G) > Σ 0≤i≤d−1 ∆(H)(∆(H) − 1) i , this is not possible. Therefore, there cannot exist a non-contracting distortion d embedding of G into H.
The following observation is about non-contracting distortion d embeddings into lines or cycles.
Observation 2.6. Let F be a non-contracting distortion d embedding of a graph G, into H such that H is either a line or a cycle. Let P ′ be the maximal subpath of H such that Proof. For any two vertices x, y ∈ V (G), D G (x, y) ≤ n − 1. This implies D H (F (x), F (y)) ≤ d(n − 1). Let u ∈ V (H) be such that some vertex of G is mapped to it. Observe that any other vertex of H that has a vertex of G as its pre-image, must be within a distance of d(n − 1) from u in H. As the degree of u is at most 2, the result follows.

Graph Metric Embedding for cycles
In this Section, we are going to look at the parameterized complexity of the Graph Metric Embedding problem for cycles. Recall that this means that the output metric (C, D C ) is such that C is a cycle. First, we consider the problem of embedding unweighted graphs into cycles, parameterized by the distortion d. We show that the problem is in FPT. Next, we consider the input graph to have edge weights, while the parameters are the distortion d and the largest edge weight W . This problem also has an FPT algorithm, very similar to the one for unweighted graphs. However, in general the weights on the edges need not be reasonably bounded, and therefore, we consider the weighted problem with only distortion d as parameter. In this case, the problem becomes NP-hard for any distortion d > 2, where d is a rational number.

Embedding an unweighted graph into a cycle
In this part, we will present an FPT algorithm for embedding an input unweighted graph into a given cycle. Our algorithm is similar to the FPT algorithm for Graph Metric Embedding for lines, given in [FFL + 13]. We too try to build the metric embedding function by stitching together partial embeddings that we find locally. Similar to the definition in [FFL + 13], a partial embedding describes what a metric embedding could possibly look like when restricted to a small subpath of the given cycle. The main idea is to employ a dynamic programming strategy to build a solution metric embedding using a set of computed partial embeddings. We compute the set of partial embeddings by an FPT algorithm and the dynamic programming algorithm is also FPT. Thereby we find a metric embedding into the given cycle in FPT time. Now we formalize the ideas. In [FFL + 13], the algorithm searched for a special kind of embedding, called a pushing embedding, that always exists for embedding into lines. Such an embedding need not exist for embedding into cycles. Our algorithm does not require the assumption of a pushing embedding.
Let (G, D G ) be the input connected graph metric and (C, D C ) be the output graph metric such that C is a cycle. We denote the vertices of the cycle C as 0, . . . , N − 1 in the clockwise direction. Whenever we use u to denote a vertex of C in this section, consider the vertex to be numbered u mod N .
First, we make an observation about a property of a non-contracting distortion d embedding into a cycle.
Observation 3.1. Let F be a non-contracting distortion d embedding of G into C. Then there exists at most one maximal connected subgraph S of C such that the pre-image of V (S) is ∅ and |V (S)| ≥ 2d + 3.
Proof. We prove the observation by contradiction. The input graph G is connected. Let S 1 and S 2 be two maximal connected subgraph of C such that the pre-images of both V (S 1 ) and V (S 2 ) are ∅ and |V (S 1 )| , |V (S 2 )| ≥ 2d + 3. Without loss of generality, assume that the vertex set of S 1 is {1, . . . , i} and that of S 2 is {j, . . . , k}, where 2d + 3 ≤ i < j − 1 and j + 2d + 2 < k + 1 ≤ N . By definition of maximality, 0, i + 1, j − 1 and k + 1 have pre-images. Consider the setsŜ These subsets are nonempty and form a partition of V (G).
Now, D C (x, y) > d, for all x ∈ {i + 1, . . . , j − 1} and y ∈ {k + 1, . . . , N }. Consider any pair of vertices u, v ∈ V (G) such that u ∈Ŝ 1 and v ∈Ŝ 2 . Since D C (F (u), F (v)) > d and F is a non-contracting distortion d embedding of G, it is true that (u, v) / ∈ E(G). This implies the graph G is not connected, which is a contradiction.
From now on, we assume that if there is a non-contracting distortion d embedding of G into C, the pre-image of the vertex 0 ∈ V (C) is nonempty. Also, let us assume that if there is a subgraph S of C such that |V (S)| ≥ 2d + 3 and the pre-image of V (S) is ∅, then V (S) = {k, . . . , N − 1} for some k ≤ N − (2d + 3). This can be ensured by making a guess for the vertex of G that will be mapped to 0 ∈ V (C); there are polynomially many such guesses. For any ℓ ∈ {0, . . . , N − 1}, we define S ℓ = {ℓ − (d + 1), . . . , ℓ + (d + 1)}. We fix a function Ψ : W → S 0 , where Ψ is a non-contracting distortion d embedding of a vertex set W ∈ V (G). Since we are under the assumption that the preimage of the vertex 0 ∈ V (C) is nonempty, we also make sure that W = ∅. All of the following definitions are with respect to Ψ. First, we define the notion of a partial embedding at a vertex a ∈ V (C).
is a function f a : U → S a . Here, U is referred to as Dom fa and a is referred to as mid(f a ).
(ii) Dom   . L(f a ) (R(f a )) is the union of the vertex sets of connected components of V (G) \ (W ∪ U ) that have neighbours in Dom L fa (Dom R fa ). It is important to define the feasibility of a partial embedding. Since we ultimately want to use the partial embeddings to build a metric embedding of G into C, it is necessary that a feasible partial embedding behaves like a metric embedding locally.
Definition 3.3. Let f a : U → S a be a partial embedding with respect to Ψ, where U ⊆ V (G). Then f is said to be feasible with respect to Ψ, if it satisfies the following conditions.
(ii) f a is a non-contracting distortion d embedding of U .
(iii) For every pair u ∈ U and w ∈ W , D C (f a (u), Ψ(w)) is non-contracting and has expansion at most d, Next, we define the notion of succession from one partial embedding to another. This definition will help us put together many partial embeddings to get one metric embedding of G into C.
Definition 3.4. Let f a : U → S a be a feasible partial embedding of U with respect to Ψ. Let f b : U ′ → S b be a feasible partial embedding of U ′ with respect to Ψ. Then f b succeeds f a with respect to Ψ if the following conditions are satisfied.
While we are considering a partial embedding f , the sets L(f ) and R(f ) help us to have a view of the mapping of the rest of the graph G in terms of this partial embedding f . The next Lemma proves that our definition of succession implies that we have a consistent view of the mapping of the rest of G when we move from one partial embedding to another.
Lemma 3.5. Let f a : U → S a be a feasible partial embedding of U with respect to Ψ, and f b : U ′ → S b be a feasible partial embedding of U ′ with respect to Ψ. If f b succeeds f a with respect to Ψ, then the following properties hold.
Proof. We prove property (i), and property (ii) can be proved similarly. Note that f b succeeds f a . In the forward direction, we prove that Recall the definition of R(f a ). Since the two embeddings are feasible, L(f a )∩R(f a ) = ∅. This implies that Y does not contain any neighbour of Dom To complete the proof, in the backward direction, we prove that . Hence, we have proved property (i).
Finally, the following definitions help to establish the meaning of building a metric embedding using a sequence of partial embeddings.
Definition 3.7. A sequence of feasible partial embedding Φ 1 , . . . , Φ t with respect to Ψ is embeddable with respect to Ψ if it satisfies the following conditions.
We prove the relation between a non-contracting distortion d embedding of G into C and a sequence of feasible partial embeddings.
Lemma 3.8. A graph G has a non-contracting distortion d embedding into a cycle C if and only if there exist a W ⊆ V (G), a non-contracting distortion d partial embedding Ψ : W → S 0 and an embeddable sequence of feasible partial embeddings Φ 1 , . . . , Φ t with respect to Ψ.
Proof. First, we show that if F is a non-contracting distortion d embedding of G into C then there is an embeddable sequence of feasible partial embeddings Φ 1 , . . . , Φ t with respect to some Ψ. By Observation 3.1, there exists at most one connected subgraph S of C such that the pre-image of S under F is ∅ and |S| ≥ 2d + 3. If such a subgraph S exists, then without loss of generality assume that the vertices of S are {k, . . . , N − 1} for some k ≤ N − (2d + 3). Now, take W as the set of vertices that are mapped by F into S 0 . Take a function Ψ : Now, it is easy to verify that Φ 1 , . . . , Φ t are all embeddable with respect to Ψ.
Conversely, let {Φ 1 , . . . , Φ t } be a sequence of embeddable feasible partial embeddings with respect to Ψ : W → S 0 . We make the following claims about the sequence of embeddable feasible partial embeddings, which we prove later.
Claim 3.10. The following properties hold: We are done with the proof of the converse part by the following claims, which we will prove later.
Recall the definition of succession from Definition 3.4. The partial embedding Φ j cannot succeed Φ i as mid(Φ i ) and mid(Φ j ) are not adjacent. So, there must exist some This is not possible as Φ i ′ is a feasible partial embedding.
(b) The statement follows from part (a) and by using the definition of succession.
Proof of Claim 3.11. By Claim 3.9, Dom F = V (G). Consider any pair of vertices u, v ∈ V (G). We need to show the following statement.
We use the method of induction on D G (u, v). For now, assume that the statement is true for D G (u, v) = 1. We will prove it after the inductive step. Let the statement be true for all . Thus, we need to prove the base case of this induction hypothesis. Consider an edge (u, v) in G. We break the analysis into the following cases.
does not expand by a factor of more than d, due to condition (iii) of Definition 3.3. This implies D C (F (u), F (v)) ≤ d.
Proof of Claim 3.12. By Claim 3.9, We divide the proof into the following cases.
). Using the fact that u(v) is in the domain of some feasible partial embedding and recalling condition (iii) of This implies the path between F (u) and F (v) is non-contracting and has expansion of at most d due to condition (ii) of Definition 3.3.
Hence, we are done.
Thus, we have seen that finding a sequence of feasible partial embeddings is enough to find a non-contracting distortion d embedding of G into C. What remains to be proven is that the number of such sequences is bounded by an FPT function.
In the following observation, we describe the structure of a partial embedding.
Observation 3.13. Let f : U → S a be any feasible partial embedding with respect to Ψ. Then we can describe it by the following properties.
This implies the statement of the Observation.
Now, we are ready to bound the number of feasible partial embeddings possible.
Definition 3.14. Let x be a non-negative integer and N u 1 (x) be the number of sequences Proof. We prove the statement using induction on x. For x = 0, the statement is trivially true. Assume that the statement is true for every y < x. Let S i be the set of sequences such that By the induction hypothesis, Note that by Observation 2.5, if there is a non-contracting distortion d embedding of G into C, it must be true that ∆(G) ≤ 2d. This implies that |A u 1 (i)| ≤ 2 · (2d) i . So, Note that the above discussion is true for any u 1 ∈ V (G). Hence, Lemma 3.16. Let |V (G)| = n, |V (H)| = N . The total number of feasible partial embeddings with respect to a particular Ψ, is at most O N · n · (4d(2d + 2)) 2d+2 and the total number of possible Ψ : W → S 0 is O n · (4d(2d + 2)) 2d+2 .
Proof. By Observation 3.13 and Definition 3.14, we can have at most N (2d + 2 − x 1 ) feasible partial embeddings with respect to Ψ for a fixed integer a and fixed vertices u 1 ∈ V (G), where u 1 is mapped to a − (d + 1) + x 1 . Hence, the total number of feasible partial embeddings is at most Observe that a particular Ψ can be described by a vertex sequence u 1 . . . u p along with a sequence of non-negative integers x 0 , . . . , Hence, the stated bound on the total number of possible Ψ follows from Lemma 3.15.
Putting everything together, our algorithm tries to find a sequence of feasible partial embeddings in order to find a non-contracting distortion d embedding of G into C. The bound on feasible partial embeddings makes the algorithm run in FPT time.
Theorem 3.17. Given an undirected unweighted graph G on n vertices, a cycle C and a distortion parameter d, there exists an algorithm that either finds a non-contracting distortion d embedding of G into C or decides that there does not exist such an embedding in O n 3 · d 2d+3 · (4d(2d + 2)) 4d+4 time.
Proof. Suppose there exists a desired embedding F from G to C. By Observation 2.6, there exists a maximal subpath P of length 2dn of C such that F (x) ∈ V (P ) for all x ∈ V (G). If |V (C)| = N > 4dn, then consider an induced connected subgraph C ′ of C having 2dn vertices. Observe that C ′ is a line and G can be embedded into C if and only if G can be embedded into C ′ . We run the algorithm of embedding an unweighted graph into a line [FFL + 13], to find a possible embedding of G into C ′ . Note that the time complexity of the mentioned algorithm in [FFL + 13], is O(nd 4 (2d + 1) 2d ).
If N ≤ 4dn, then we do the following. Let F be a distortion d embedding of G into C, if one exists. We find ∆(G) in O(n) time. By Observation 2.5, if ∆(G) > 2d then we report no F exists. Otherwise, we try to find an embeddable sequence of partial embeddings, according to Lemma 3.8. We first fix Ψ : W → S 0 . Let F Ψ be the set of all possible partial embeddings with respect to Ψ from G to C. By Observation 3.13 and Definition 3.14, |F Ψ | ≤ O N · n · (4d(2d + 2)) 2d+2 . Then we make the following construction: (ii) Then we check for the existence of a directed path from S to D. This implies that there is a directed path from some Φ 1 ∈ F Ψ to some Φ t ∈ F Ψ in G such that conditions (ii) and (iii) of Definition 3.7 are satisfied. If such a path exists, then there exists an embeddable sequence, say Φ 1 , . . . , Φ t , of feasible partial embeddings with respect to Ψ. Report Φ Π as Otherwise, there does not exist an embeddable sequence of feasible partal embeddings with respect to Ψ.
If there does not exist an embeddable sequence of feasible partal embeddings with respect to Ψ, then we conclude that we cannot have a non-contracting and distortion d embedding of G into C. Observe that we execute the above procedure for all possible Ψ in the worst case. But, the total number of possible Ψ is at most O n · (4d(2d + 2)) 2d+2 by Lemma 3.16. The number of vertices in graph G is at most O N · n · (4d(2d + 2)) 2d+2 . Every vertex of G has outdegree at most O(d 2d ). This is because, if f b succeeds f a , then f b is determined by f a along with the condition (i) of Definition 3.4. Similar to [FFL + 13], we can test whether a partial embedding succeeds another using a prefix tree like data structure in O(d 2 ) time. So, the total running time of Step We can test the existence of a path of the mentioned type in Step-(ii), by running the DFS algorithm in O N · n · (4d(2d + 2)) 2d+2 time. Hence, our algorithm takes O d 2 · d 2d · N · n · (4d(2d + 2)) 2d+2 time for each Ψ and O N · n 2 · d 2d+2 · (4d(2d + 2)) 4d+4 in total. As N ≤ 2dn, the stated bound of the time complexity follows.
Our algorithm does not assume pushing embeddings and therefore will work even for embedding into lines, where the maps of certain vertices are already fixed. Specifically in this part, we mention two results which will be useful for us in Section 6. A line with N vertices can be thought to have vertices named {1, 2, . . . , N }.
Proof. Without loss of generality, assume that there exists a vertex of G mapped to 1 and N . If N > 2dn, then there exists an induced maximal subpath P of H such that all vertices of G are mapped into it and |V (P )| > 2dn. This is impossible by Observation 2.6. Hence, there does not exist a desired embedding if N > 2dn. Now assume that N ≤ 2dn. The algorithm is very similar to the algorithm for embedding into a cycle. As before, for any ℓ ∈ {1, 2, . . . , N }, S ℓ = {ℓ − (d + 1), . . . , ℓ + (d + 1)}. We explicitly define a feasible partial function.
Definition 3.19. (i) For an a ∈ V (H), a partial embedding of U ⊆ V (G), with respect to Ψ 1 and Ψ 2 , is a function f a : U → S a . As before, U is referred to as Dom fa and a is referred to as mid(f a ).
(ii) Dom Definition 3.20. Let f a : U → S a be a partial embedding with respect to Ψ 1 and Ψ 2 , where U ⊆ V (G). Then f is said to be feasible with respect to Ψ 1 and Ψ 2 , if it satisfies the following conditions.
(ii) f a is a non-contracting distortion d embedding of U .
(iii) For every pair u ∈ U and w ∈ U 1 , D H (f a (u), Ψ 1 (w)) is neither contracting nor expanding by a factor of more than d. A similar condition holds for every pair u ∈ U and w ∈ U 1 , The definition of succession of feasible partial embeddings and embeddability of a sequence of partial embeddings are analogous to Definitions 3.4 and 3.7. We can also state results analogous to Lemma 3.5 and 3.8.
What remains is to bound the number of partial embeddings. By Observation 2.5, ∆(G) ≤ 2d if G is embeddable into H. The structure of a partial embedding for embedding into lines is same as that described in Observation 3.13. Therefore, Lemma 3.15 is true in this case as well. Given Ψ 1 and Ψ 2 , analogous to Lemma 3.16, the total number of feasible partial embeddings with respect to Ψ 1 and Ψ 2 is O(N ·n(4d(2d+ 2)) 2d+2 ). Now, we design an algorithm similar to that given in Theorem 3.17. The correctness of the algorithm can be argued in a similar way as that in Theorem 3.17. The running time of the algorithm turns out to be O N · n · d 2d+2 · (4d(2d + 2)) 2d+2 . As N ≤ 2dn, the claimed bound of the time complexity holds. follows.
We also obtain the following corollary using similar analysis.
Corollary 3.21. Let (G, D G ) and (H, D H ) be two graph metrics on n and N vertices,respectively. Let a 1 be a positive integer such that a 1 ≤ N . Let Z 1 = {1, 2, . . . , a 1 }. Let Ψ 1 : U 1 → Z 1 be a fixed non-contracting distortion d embedding of U 1 ⊆ V (G). Also consider a fixed vertex v ∈ V (G). Then there is an FPT algorithm to determine whether there exists a non-contracting distortion d embedding F of G into H that extends Ψ 1 and where for all u ∈ V (G), F (u) ≤ F (v). The running time of the algorithm is O n 2 · d 2d+3 · (4d(2d + 2)) 2d+2 .
Proof. Without loss of generality, assume that there exists a vertex of G that is mapped to 1. Then, by Observation 2.6, there does not exist any vertex of G that is mapped to some j > 2dn. So, we delete all vertices of H that are at a distance more than 2dn from 1. Call the new graph H ′ . Observe that finding a required embedding of G into H is equivalent to finding a required embedding of G into H ′ . Let N ′ denote the number of vertices in H ′ . Note that N ′ ≤ 2dn.
The definition of feasible partial embeddings, succession of feasible partial embeddings, embeddability of a sequence of partial embeddings are similar to the definitions in Lemma 3.18. Similarly, we can also argue the correctness of finding an embeddable sequence of partial embeddings and a bound on the number of feasible partial embeddings. The FPT algorithm will be very similar to that of Lemma 3.18. The only change is that now there is an added condition that v is the last vertex that gets mapped in the line H. However, this can be ensured very easily, by making modifications in the directed graph G associated with partial embeddings, that was built for the algorithms of Theorem 3.17 and of Lemma 3.18. The running time of the algorithm is O N ′ · n · d 2d+2 · (4d(2d + 2)) 2d+2 . As N ′ ≤ 2dn, the claimed bound of the time complexity follows.
As mentioned earlier, these algorithms on embedding into the line will be useful to us in Section 6.

Embedding a weighted graph into a cycle
In this part, we consider embedding weighted graph metrics into cycles. Let G be a weighted graph and w : E(G) → R be the weight function. The objective is to either find a non-contracting distortion d embedding of G into C or decide that no such embedding exists. We will call this problem Weighted Graph Metric Embedding. In general this problem is NP-complete, which we show shortly. However, we first give an FPT algorithm by taking M = max e∈E(G) w(e) as a parameter along with d. The terminologies and the algorithm discussed in Section 3.1, can be extended to the an FPT algorithm for embedding of a weighted graph metric G into a cycle, parameterized by M and d.

FPT algorithm taking d and M as parameter
We have an observation analogous to Observation 3.1, with the change that |V (S)| ≥ (2d + 4)M . S ℓ = {ℓ − (dM + 1), . . . , ℓ + (dM + 1)}. We first fix a function Ψ : W → S 0 . We define a partial embedding as f a : U → S a , where U ⊆ V (G) and other terminologies in Definition 3.2 can be defined in a similar manner. We can define the notion of feasible partial embedding, how a feasible partial embedding succeeds another and what an embeddable sequence of feasible partial embeddings is similarly. We can also state results analogous to Lemma 3.5 and 3.8.
Analogous to Observation 2.5, we check whether ∆(G) ≤ 2dM . If this is false, we conclude that we cannot embed the given graph into the cycle C with distortion d. If the condition is true, we execute an algorithm similar to that explained in the proof of Theorem 3.17. By following similar analysis done in Lemma 3.15 and Lemma 3.16, the total number of feasible partial embeddings with respect to some Ψ can be bounded by O n · N · (4dM (2dM + 2)) 2dM +2 and the total number of possible Ψ can be bounded by O n · (4dM (2dM + 2)) 2dM +2 . One can easily go through the analogous steps explained in Theorem 3.17 and verify that the time complexity of our algorithm to embed a weighted graph into a cycle C is O n 2 · N · (dM ) 2dM +2 (4dM (2dM + 2)) 4dM +4 . Using Observation 2.6 and an arguement similar to that given in the first paragraph of the proof of Theorem 3.17, we can assume that N ≤ 4dM n. Hence, the time complexity of our algorithm to embed a weighted graph into a cycle C is O n 3 (dM ) 2dM +3 (4dM (2dM + 2)) 4dM +4 . w(e), and C be a cycle. Then there exists an algorithm that either finds a non-contracting distortion d embedding of G into C or concludes that there does not exist such an embedding. The running time of the algorithm is O n 3 (dM ) 2dM +3 (4dM (2dM + 2)) 4dM +4 .

Hardness proof
Consider the Weighted Graph Metric Embedding problem where the input metric (G, D G ) has an associated weight function w : E(G) → R ≥0 and the distortion is d > 2. We use the notation W (G) to denote maximum weight over all edges of the graph G. In this section, we prove the following Theorem. Proof. For any two vertices x, y ∈ V (G), D G (x, y) ≤ M (n − 1). This implies D H (F (x), F (y)) ≤ dM (n − 1). Let u ∈ V (H) be such that some vertex of G is mapped to it. Observe that any other vertex of H that has a vertex of G as its pre-image, must be within a distance of dM (n − 1) from u in H. As the degree of u is at most 2, the result follows. Proof of Theorem 3.23. Clearly the problem is in NP. To show NP-hardness, we reduce the Weighted Graph Metric Embedding problem for cycles from the Weighted Graph Metric Embedding problem for lines. We give the reduction for a special case where w(G) ≤ |V (G)| = n and |V (C)| = 4dn 2 + 1. We need to prove that there exists an embedding of G into L if and only if there exists an embedding of G into C.
Let F be a required embedding from G to L. By Observation 3.24, there exists a maximal subpath P ′ of 2dn 2 vertices of L such that F (x) ∈ V (P ′ ) for all x ∈ V (G). Let Q ′ be a maximal subpath of 2dn 2 vertices of C and Φ be a bijection from P ′ to Q ′ such that D L (u, v) = D C (Φ(u), Φ(v)) for any u, v ∈ V (P ′ ). Such a bijection exists as |V (C)| = 4dn 2 +1. Now consider the function F ′ from V (G) to V (C) defined as follows. For any x ∈ V (G), F ′ (x) = Φ(F (x)).
For the converse part, let F be a non-contracting distortion d embedding from G to C. By Observation 3.24, there exists a maximal subpath Q ′ of 2dn 2 vertices of C such that F (x) ∈ V (Q ′ ) for all x ∈ V (G). Let P ′ be a subpath of 2dn 2 vertices of L and Ψ be a bijection from Q ′ to P ′ such that D C (u, v) = D L (Ψ(u), Ψ(v)) for any u, v ∈ V (Q ′ ). Such a bijection exists as |V (C)| = 4dn 2 + 1. Now consider the function F ′ from V (G) to V (C) defined as follows. For any x ∈ V (G), F ′ (x) = Ψ(F (x)). Since |V (C)| > 2 |V (Q ′ )| = 2 |V (P ′ )|, it follows that F ′ is a non-contracting and distortion d embedding of G into L.

Bijective Graph Metric Embedding for bounded treewidth graphs
In this section, we consider the bijective Graph Metric Embedding problem for the graph class G, which consists of graphs with treewidth at most α for a given constant α. Let (G, D G ) be the input connected graph metric to be embedded into the output graph metric (H, D H ), where H ∈ G. Also, |V (G)| = |V (H)|. We design an FPT algorithm for the problem parameterized by the distortion d and the maximum degree ∆(H). We will also refer to ∆(H) as ∆. Again, the strategy is to define feasible partial embeddings locally, and a notion of succession amongst partial embeddings such that we can build towards a bijective non-contracting distortion d metric embedding of G into H. We use a tree decomposition of H to define the notions of partial embeddings and successions. We also use the tree decomposition to design a dynamic programming algorithm to derive a non-contracting distortion d embedding of G into H from a set of partial embeddings that is computed in FPT time. The ideas used to design this algorithm is essentially similar to those used for designing an FPT algorithm for embedding into trees with bounded degree [FFL + 13]. However, we need to modify the definitions and the algorithm according to the need of our problem.
Let T = (T, {X u } u∈V (T ) ) be a nice tree decomposition [CFK + ] of H. Recall that X r = ∅ and X ℓ = ∅, where r is the root of the tree T and ℓ is any leaf of T . We use N T (u), C T (u) to denote the set of neighbours and children of u in T , respectively. Let T u denote the subtree rooted at the node u ∈ V (T ) and H u denote the subgraph induced by Next, we define partial embeddings with respect to the sets B(u, d + 1), u ∈ V (T ). For ease of notations, we abuse the usual set theoretic terminology by using A \ a to denote A \ {a}.
where u ∈ V (T ) and U ⊆ V (G). We refer to U as Dom fu .
is the union of vertex sets of all connected components of G \ Dom fu that have neighbours in Dom fu (v).
The feasibility of partial embeddings in order for them to build up to a metric embedding is defined as below. (i) f u is a non-contracting and distortion d embedding of U into B(u, d + 1).
(iii) All neighbours of Dom 0 fu are in U . Similarly, we define succession of partial embeddings, keeping in mind that we want to find a set of partial embeddings and put them together to form a non-contracting distortion d metric embedding.
Definition 4.3. Let f u and f v be two feasible partial embeddings and v ∈ C T (u). Then f v succeeds f u if the following conditions are satisfied.
(i) Dom fu ∩ Dom fv = Dom fv if u is an introduce node and Dom fu = Dom fv , otherwise.
Next, we describe how we put together feasible partial embeddings. In the case of cycles, we used the structure of the cycle. Here, we use the structure of the tree T . (i) Each f u is feasible, u ∈ V (T ).
(ii) Let us take any u ∈ V (T ). Then for every v ∈ C T (u), f v succeeds f u .
The next Lemma shows that it is enough to design an algorithm to find an embeddable set of partial embeddings. Proof. Let F be a non-contracting distortion d embedding of G into H. For u ∈ V (T ), consider f u to be F restricted to the preimage of B(u, d + 1). Let Π = {f u : u ∈ V (T )}. It is easy to verify that Π is an embeddable set of partial embeddings.
For the converse part, Let Π = {f u : u ∈ V (T )} be an embeddable set of partial embeddings. Let us construct F = Φ Π , as in Definition 3.6. First consider the following claims, which we prove later.
By Claim 4.6 and Claim 4.7, F is a bijective function from V (G) to V (H) as |V (G)| = |V (H)|. We are done with the proof of the converse part by the following claims, which we prove later.
If x ∈ Dom fv 1 , then we are done. Otherwise, x ∈ M [f v 1 , v 2 ] for exactly one v 2 ∈ N T (v 1 ) \ r, due to condition (ii) of Definition 4.2. The choice of v 2 implies that x / ∈ M [f v 2 , v 1 ]. Again by condition (iii) of Definition 4.3 and condition (ii) of Definition 4.2, we can say that either In both cases, we proceed as before. Either we get a non-leaf node u ∈ V (T ) such that x ∈ Dom fu , or a leaf v i such that Proof of Claim 4.7. (a) We give a proof by contradiction. Let us consider u, v ∈ V (T ) such that x ∈ Dom fu ∩ Dom fv and (u, v) / ∈ E(T ). Let P = u 1 . . . u k , k ≥ 3, be the path from u = u 1 to v = u k in T such that for some i, 1 < i < k, x / ∈ Dom fu i . By Definition 4.1, . This contradicts the fact that f u i is a feasible partial embedding.
(b) The statement follows from Part (a) and by using the definition of succession, i.e., Definition 4.3.
Proof of Claim 4.8. Consider an edge (x, y). Let F (x) ∈ X u for some u ∈ V (T ). Observe that in this case x ∈ Dom 0 fu . By condition (iii) of Definition 4.2, y ∈ Dom fu . Also, note that f u is a feasible partial embedding. This implies D H (F (x), F (y)) ≤ d.
Therefore, for any edge (x, y) ∈ E(G), D H (F (x), F (y)) ≤ d. Now, we apply induction similar to that in the proof of Claim 3.11, and get the required result.
Proof of Claim 4.9. We need to show that D G (x, y) ≤ D H (F (x), F (y)) for any x, y ∈ V (G). We prove it by the method of induction on D H (F (x), F (y)). For the base case consider D G (F (x), F (y)) = 1, or (F (x), F (y)) ∈ E(H). By the definition of tree decomposition, there exists u ∈ V (T ) such that F (x), F (y) ∈ X u . Now using the fact that both x, y ∈ Dom fu and f u is a feasible partial embedding of Dom fu , D G (x, y) ≤ D H (F (x), F (y)). Hence, the base case holds.
For the inductive step assume that D G (x, y) ≤ D H (F (x), F (y)) holds for any x, y such that D H (F (x), F (y)) < ℓ. Now, we have to show for the case D H (F (x), F (y)) = ℓ > 1. There exists u ∈ V (T ) such that F (x) ∈ X u . Let f u : U → B(u, d + 1). The shortest F (x) to F (y) path must contain a vertex a ∈ V (H) such that a ∈ B(u, d + 1) and D H (F (x), F (y)) = D H (F (x), a) + D H (a, F (y)). Let a = F (w) for some w ∈ V (G). Such a w exists as the embedding F is a bijection. By the induction hypothesis, Putting everything together, we have an FPT algorithm for the problem.
Proof. Due to Observation 2.5, if ∆(G) > ∆ d , then there does not exist an embedding from G to H. So, assume that ∆(G) ≤ ∆ d .
Let T = (T, {X u } u∈V (T ) ) be a nice tree decomposition. Note that |X u | ≤ α, X r = ∅ and X ℓ = ∅, where r is the root of T and ℓ is any leaf of T . We do a dynamic programming. For each u ∈ V (T ), we create a binary list of all possible feasible u-partial embeddings from some subset of V (G) to B(u, d + 1). For any leaf ℓ ∈ V (T ), make all entries to be true. For the root r, just create one entry in the list, whose value is to be assigned. Let u be a non-leaf node. Let f u be a feasible partial embedding. Suppose for every v ∈ C T (u), there exists a feasible partial embedding f v and f v succeeds f u . Then assign the corresponding entry of f u to be true. Assign true to the corresponding entry of r if there exists a feasible partial embeddings for each child of r. By Lemma 4.5, one can observe that the algorithm is correct.
For the running time, we have to bound the total number of feasible partial embeddings.
Proof. Let us consider a u-partial embedding f u from some subset of V (G) to B(u, d + 1).
Observe that |B(u, d + 1)| ≤ α.∆ d+1 . As we are considering non-contracting embeddings, the domain of f u must be contained in the union of at most α balls of radius 2d + 2, where each ball is centered at some vertex of G.
So, the total number of feasible u-partial embeddings is at most Let f u and f v be given such that v ∈ C T (u). From Definition 4.3, one can decide whether Recall that T is a nice tree decomposition, which implies |V (T )| = O(α.n) and ∆(T ) = O(1).
So, observe that there are at most α.n.n α · (α · ∆ d+1 ) ∆ O(α·d 2 ) partial embeddings. Note that the bags corresponding to two adjacent vertices of T , differ by at most one vertex of H. So, each feasible partial embedding can take part in at most n · α · ∆ d+1 ∆ O(α.d 2 ) number of successions.

A note on bijective Gen-Graph Metric Embedding for bounded treewidth graphs
Assume that the input of the Red Blue Graph Metric Embedding problem is such that the output metric (H, D H ) has the following property: given V (H) = R⊎ B, any path of length d+ 1 in H has at least one internal vertex in R. Also, we want to find a non-contracting distortion d embedding that is a bijection between V (G) and R. For this variant of the Red Blue Graph Metric Embedding, the above algorithm can be easily modified to give a solution. Most details of the above algorithm remain the same. Note that for a u ∈ V (T ), a u-partial embeddings of U ∈ V (G) is a function f u : U → B(u, d+ 1)∩ R. We explicitly prove the equivalent of Claim 4.9, since that is the only major place of difference. We restate the claim for a map F obtained from an embeddable set of partial embeddings, as in Lemma 4.5.
Claim 4.12. F is a non-contracting embedding of G into H.
Proof. We need to show that D G (x, y) ≤ D H (F (x), F (y)) for any x, y ∈ V (G). We prove it by the method of induction on D H (F (x), F (y)). For the base case consider D G (F (x), F (y)) ≤ d. By the definition of tree decomposition, there exists u ∈ V (T ) such that F (x), F (y) ∈ B(u, d+1). Now using the fact that both x, y ∈ Dom fu and f u is a feasible partial embedding of Dom fu , D G (x, y) ≤ D H (F (x), F (y)). Hence, the base case holds.
For the inductive step assume that D G (x, y) ≤ D H (F (x), F (y)) holds for any x, y such that D H (F (x), F (y)) < ℓ. Now, we have to show for the case D H (F (x), F (y)) = ℓ > 1. There exists u ∈ V (T ) such that F (x) ∈ X u . Let f u : U → B(u, d + 1). Since ℓ ≥ d + 1, the shortest F (x) to F (y) path must contain a vertex a ∈ R such that a ∈ B(u, d + 1) and D H (F (x), F (y)) = D H (F (x), a)+D H (a, F (y)). Let a = F (w) for some w ∈ V (G). Such a w exists as the embedding F is a bijection between V (G) and R. By the induction hypothesis, Thus, we obtain an FPT algorithm for this variant of Red-Blue Graph Metric Embedding. Due to Lemma 2.4 and Proposition 2.2, we obtain the following result.

Graph Metric Embedding and connected treewidth
In this Section, we will look at the Graph Metric Embedding problem with respect to the added parameters of treewidth and longest geodesic cycle of the output graph metric. Let (G, D G ) be the input connected graph metric to be embedded into (H, D H ). We show that this problem is FPT, when parameterized by the distortion d, the treewidth tw(H) = α, the length ℓ g of the longest geodesic cycle of H, and the maximum degree ∆(H) = ∆. From [DM17] it can be shown that for a graph with longest geodesic cycle ℓ g , a tree decomposition of treewidth α ′ can be converted into a connected tree decomposition of width α ′ + α ′ 2 (ℓ g (α ′ − 2) − 1) in polynomial time. Since trees have constant connected treewidth, our algorithm is a generalization of the FPT algorithm for Graph Metric Embedding for trees, parameterized by distortion d and maximum degree ∆ [FFL + 13]. As before, we employ a dynamic programming to build a noncontracting distortion d metric embedding using a set of partial embeddings that are computed in FPT time.
Let (G, D G ) be a graph metric to be embedded into (H, D H ). Here the parameters are the treewidth α of H, the length of the longest geodesic cycle ℓ g in H, the distortion d and the maximum degree ∆ of H. Let T be a nice tree decomposition of H with width µ. Since from [DM17] H has a connected tree decomposition of width µ, we may assume that the nice tree decomposition is derived from the connected tree decomposition [CFK + ] and therefore the maximum distance between any two vertices inside a bag in T is Γ ≤ µ.
We borrow the definition of feasible partial embeddings and succession of feasible partial embeddings from Definitions 4.1, 4.2, and 4.3.
Unlike the arguments of Section 4, now ensuring non-contraction for a non-contracting distortion d metric embedding F is more elaborate. Local non-contraction no longer implies global non-contraction. This problem was dealt with in [FFL + 13] by introducing the notion of types. For our algorithm too, for a vertex u ∈ V (T ) we need to define a type for every vertex of V (G) that is mapped into the subgraph H u , to indicate how it behaves with the rest of the graph. More specifically, let x ∈ V (G) be a vertex that is mapped to F (x) ∈ V (H u ). Consider any other vertex y ∈ V (G) such that F (y) is a vertex from V (H) \ V (H u ). Then, a type relates D H (F (x), F (y)) with D G (x, y). The crucial observation here is that (i) the shortest path between F (x) and F (y) must pass through a vertex in X u , and (ii) the shortest path between x and y in G is such that there is at least one internal vertex x ′ such that F (x ′ ) ∈ B(u, d + 1), as otherwise F does not have distortion d. Thus, the types store information of the interaction of vertices of the graph seen so far with the boundary vertices, and this is enough to ensure global non-contraction.
Definition 5.1. Let u ∈ V (T ), f u be a feasible partial embedding and X u = {u 1 , . . . , u k }, Intuitively, we want to define a type corresponding to each vertex mapped into H u . However, this blows up the number of types. In order to handle this, it can be shown that we do not need to remember the type of each vertex, and that it is enough to only remember the type of vertices "close to" the vertices in X u . Now we present the formal arguments. To bound the total number of possible types, we define a function β as follows: β(k) = k if k < 2Γ + 3d + 3, and β(k) = ∞ otherwise. In the following definitions, treat β(k) = k and the definition of β will be clear while we prove our claims.
Definition 5.2. Let us consider u ∈ V (T ), v ∈ N T (u). Let f u be a feasible partial embedding and L be a [f u , v] type-list. Then L is said to be compatible with Dom fu (v) if the following condition is satisfied.
• For each x ∈ Dom fu (v) there exists a type t ∈ L, such that for each y ∈ Dom fu (v), for all Definition 5.3. Let u ∈ V (T ) and f u be a feasible partial embedding. Also consider v, w ∈ N T (u) along with a [f u , v] type-list L 1 and a [f u , w] type-list L 2 such that v = w. Then L 1 and L 2 agree if the following condition is satisfied for all u i ∈ X u .
• For every t 1 ∈ L 1 and t 2 ∈ L 2 , there exists x ∈ Dom fu (v) and y ∈ Dom fu (w) such that t u i 1 (x) + t u i 2 (y) ≥ D G (x, y) for all u i ∈ X u .
Next, we define a state with respect to a vertex in T .
Definition 5.4. Let u ∈ V (T ). A u-state constitutes of a feasible partial embedding f u , a Notice that it is no longer enough to consider feasibility and succession of partial embeddings. We also need to take care of the types of vertices. Therefore, we define feasibility and succession of states.
Definition 5.5. A u-state is said to be feasible if the following conditions are satisfied.
, for any v, w ∈ N T (u) and v = w.
Definition 5.6. Let u ∈ V (T ) and v ∈ C T (u). Let S u , S v be feasible u-state and v-state, respectively. S v is said to succeed S u if the following properties hold.
satisfying the following conditions. y)) .
(d) For all x ∈ Dom fu (v) \ Dom fv (w) and a ∈ X u \ X v , (iii) For every w ∈ N T (u) \ v and a type t 1 ∈ L[f u , w] there exists a type t 2 ∈ L[f v , u] satisfying the following conditions.
(a) For all x ∈ Dom fv (u) ∩ Dom fu (w) and a ∈ X u ∩ X v , t a 2 (x) = t a 1 (x). (b) For all x ∈ Dom fv (u) ∩ Dom fu (w) and a ∈ X v \ X u , Now, we define the embeddability of a set of feasible states.
Definition 5.7. For u ∈ V (T ), let S u denote a u-state. The set {S u : u ∈ V (T )} is said to be an embeddable set of feasible states if the following conditions are satisfied.
(i) For each u ∈ V (T ), S u is a feasible state.
(ii) For u ∈ V (T ) and v ∈ C T (u), S v succeeds S u .
The above definitions are enough to show the relation between the existence of a noncontracting distortion d embedding of G into H and the existence of an embeddable set of feasible states. This is proved over the following two Lemmas.
Lemma 5.8. Let F be a non-contracting and distortion d embedding of G into H. Then there exists an embeddable set of feasible states.
Proof. For u ∈ V (T ), consider f u to be the function F restricted to B(u, d + 1). Observe that each f u is feasible. It is also easy to verify that for u ∈ V (T ) and v ∈ C T (u), f v succeeds f u .
To show the existence of feasible u-states, we have to define types. Let u = {u 1 , . . . , u k } ∈ V (T ) and v ∈ C(u). We create a type by the following observation, which we prove later.
Observation 5.9. For any u i ∈ X u and y ∈ Dom fu (v), t u i x (y) ≥ −(Γ + d + 1). For any x, y ∈ Dom fu (v), we have the type t Let S u constitute the feasible u-partial embedding f u along with L(f u , v) for each v ∈ N T (u). From Definition 5.5, S u is a feasible u-state by the the following claim, which we prove later.
To complete the proof of existence of a set of embeddable feasible states, we have to prove that conditions (ii) and (iii) of Definition 5.6 hold for the above description of types. Condition (ii) holds by the following claim, and Condition (iii) can be proved similarly. The following claim will be proved later.
Claim 5.11. Let u ∈ V (T ) and v ∈ N T (u). Then for every w ∈ N T (v) \ u and a type t 1 ∈ L[f v , w] there exists a type t 2 ∈ L[f u , v] satisfying the following conditions.
(a) For all x ∈ Dom fu (v) ∩ Dom fv (w) and a ∈ X u ∩ X v , t a 2 (x) = t a 1 (x) Proof. This Lemma will be proved by a series of claims. The Claims 5.13, 5.14 and 5.15 can be proved in the similar way that we proved Claims 4.6, 4.7 and 4.8, respectively. We prove Claim 5.16 and 5.17 later.
Claim 5.13. For every x ∈ V (G), there exists a feasible u-state such that x ∈ Dom fu .
Claim 5.14. The subgraph of T induced by A Now by Definition 3.6, we construct F = Φ Π , where Π = {f u : u ∈ V (T )}.
Claim 5.15. F is a metric embedding with expansion at most d.
Claim 5.16. Consider a path P = u 1 u 2 . . . u k from u = u 1 to v = v k in T . Then for every x ∈ Dom fv , at least one of the following properties hold.
Prop-1: There exists a u j ∈ P and y ∈ Dom fu j such that y) for all y ∈ Dom fu (u 2 ) and u ′ ∈ X u .
Claim 5.17. Consider a path P = u 1 u 2 . . . u k from u to v in T , where u = u 1 and v = u k . Then F restricted to Now we will be done if we prove that F is a non-contracting embedding. Let us consider two vertices x, y ∈ V (G). Note that each of F (x) and F (y) is in some bag. Fix u, v ∈ V (T ) such that F (x) ∈ X u and F (y) ∈ X v . Consider the path P = u 1 u 2 . . . u k from u to v in T , where u = u 1 and v = u k . By Claim 5.17, the shortest path between F (x) to F (y) is non-contracting as x, y ∈ u i ∈P Dom fu i .
Proof of Observation 5.9. Observe that The first inequality follows from the fact that F is a non-contracting embedding, while the second inequality follows from triangle inequality. The third inequality follows from the fact that y ∈ B(u, d + 1) along with the fact that H has bounded connected treewidth.
Proof of Claim 5.10. For contradiction, let there exist t p ∈ L[f u , v] and t q ∈ L[f u , w] such that for all x ∈ Dom fu (v) and y ∈ Dom fu (w) there is some u i ∈ X u , t u i p (x) + t u i q (y) < D G (x, y). Let x ′ ∈ Dom fu (v) and y ′ ∈ Dom fu (w) be two vertices such that there is a u i with t u i p (x ′ ) + t u i q (y ′ ) < D G (x ′ , y ′ ) and for all x ∈ Dom fu (v), y ∈ Dom fu (w) and u j with t y). This implies Now, we can say By the choice of x ′ and y ′ , D G (p, x ′ ) + D G (q, y ′ ) + D G (x ′ , y ′ ) = D G (p, q) as any p to q path in G must pass through some vertex in Dom fu (v) and Dom fu (w). Putting everything together, D H (F (p), F (q)) < D G (p, q). It contradicts the fact that F is non-contracting.
Proof of Claim 5.11. Let t p = (t v 1 p , . . . , x)) for all x ∈ Dom fv (w). As u is not a forget node, As we are assuming that we are working with a nice tree decomposition and that the graph has bounded connected treewidth, • For all x ∈ Dom fu (v) ∩ Dom fv (w) and a ∈ X u ∩ X v , it is easy to see that z a p (x) = t a p (x) .
• For all x ∈ Dom fu (v)∩Dom fv (w) and a ∈ X u \X v , we can say the following. D H (F (p), a) = min b∈Xv (D H (F (p), b) + D H (b, a)). It is because we are assuming each bag is connected and any path from F (p) to a in H, must pass through some vertex in X v . Hence, • For all x ∈ Dom fu (v) \ Dom fv (w) for any a ∈ X u ∩ X v , we can say the following. Any path from p to x in G must pass through a vertex in Dom fv (w), i.e., D G (p, x) = min • For all x ∈ Dom fu (v) \ Dom fv (w) for any a ∈ X u \ X v , we can say the following. Any path from p to x in G must pass through a vertex in Dom fv (w), i.e., D G (p, x) = min a)). Hence, Proof of Claim 5.16. We prove the claim by induction on k. First consider k = 1. Note that S u is a feasible state. Observe that Prop-2 holds by Definition 5.5 and 5.2. Therefore, the base case holds. Let the statement be true for all k ′ < k. Now we show for k. If Prop-1 holds for some x ∈ Dom fv , we are done for that x. So, consider some x ∈ Dom fv such that for every u j ∈ P and y ∈ Dom fu j there exists u ′ ∈ X u j such that D H (F (x), u ′ ) − D G (x, y) ≤ Γ + d + 1.
Consider the sub-path P ′ = u 2 . . . u k . Recall that Prop-1 does not hold for the x ∈ Dom fv with respect to P ′ . By the induction hypothesis, there exists a type t x ∈ L[f u 2 , u 3 ] such that t u ′ x (y) = D H (F (x), u ′ ) − D G (x, y) for all y ∈ Dom fu 2 (u 3 ) and u ′ ∈ X u 2 . Note that either S u 2 succeeds S u 1 or S u 1 succeeds S u 2 depending on u 2 ∈ C(u 1 ) or u 1 ∈ C(u 2 ). Now by Definition 5.6, we will have a type z x ∈ L[f u , u 2 ] such that the following properties hold.
• For all y ∈ Dom fu (u 2 ) ∩ Dom fu 2 (u 3 ) and a ∈ X u ∩ X u 2 , • For all y ∈ Dom fu (u 2 ) ∩ Dom fu 2 (u 3 ) and a ∈ X u \ X u 2 , • For all y ∈ Dom fu (u 2 ) \ Dom fu 2 (u 3 ) and a ∈ X u ∩ X u 2 , z a x (y) = β max • For all y ∈ Dom fu (u 2 ) \ Dom fu 2 (u 3 ) and a ∈ X u \ X u 2 , Proof of Claim 5.17. We prove by the method of induction on k. If k = 1, the statement is valid as S u is a feasible u-partial embedding. Now assume that the statement is true for all k ′ < k. Now, we show for k.
Observe that it is enough to show the following. For any two vertices x ∈ Dom fu 1 \ Dom fu 2 and y ∈ Dom fu k \ Dom fu k−1 , D H (F (x), F (y)) ≥ D G (F (x), F (y)). All other cases are taken care of by the Induction Hypothesis on shorter length paths. Note that x satisfies either Prop-1 or Prop-2 in Claim 5.16.
• Case 1(Prop-1 holds) In this case there exists a u j and z ∈ Dom fu j , in the path P such that D H (F (y), u ′ ) − D G (y, z) ≥ 2Γ + 3d + 3 for all u ′ ∈ X u j .
Observe that any path from F (x) and F (y) must pass through some vertex u ′′ ∈ X u j . So, The last inequality holds due to the following. z ∈ Dom fu j and u ′′ ∈ X u j . Recalling the fact that we are considering bounded connected treewidth, we can say that D H (u ′′ , F (z)) ≤ Γ + d + 1.
• Case 2(Prop-2 holds) In this case there exists a type t y ∈ L[f u , u 2 ] such that t u ′ y (y) = D H (F (y), u ′ ) − D G (y, z) for all z ∈ Dom fu 2 (u) and u ′ ∈ X u . Let x ∈ Dom fu (w) for some w ∈ N T (u) \ u 1 . Note that S u is a feasible partial embedding and hence L[f u , w] is compatible with Dom fu (w). So, there exists a type t Again considering the fact that S u is a feasible partial embedding, L[f u , u 2 ] and L[f u , w] must agree. Now by Definition 5.3, there exists y ′ ∈ Dom fu (u 2 ) and x ′ ∈ Dom fu (w) such that t u ′ x (x ′ ) + t u ′ y (y ′ ) ≥ D G (x ′ , y ′ ). As the shortest path from F (x) to F (y) passes through some vertex u ′′ ∈ X u , we can deduce the following.
Now, we are ready to design the FPT algorithm.
Proof. Due to Observation 2.5, if ∆(G) > ∆ d , then there does not exist an embedding from G to H. So, assume that ∆(G) ≤ ∆ d . First, by [FG06], we find a tree decomposition of width 4α in time 2 O(α) · n 2 . Then using the arguments in [DM17], we can convert this tree decomposition in polynomial time to a connected tree decomposition whose width is µ = 4(α + α 2 (ℓ g (α − 2) − 1)). Let T = (T, {X u } u∈V (T ) ) be a nice tree decomposition derived from it is constant time. Note that |X u | ≤ µ, X r = ∅ and X ℓ = ∅, where r is the root of T and ℓ is any leaf of T . We do a dynamic programming. For each u ∈ V (T ), we create a binary list of all possible feasible u-state. For any leaf ℓ ∈ V (T ), make all entries to be true. Let u be a non-leaf node. Let S u be a feasible u-state. Suppose for every v ∈ C T (u), there exists a feasible partial embedding S v and S v succeeds S u . Then assign the corresponding entry of S u to be true. Assign true to the corresponding entry of r if there exists a feasible u-state for each child of r. By Lemmas 5.8 and 5.12, one can observe that the algorithm is correct.
For the running time, we have to bound the total number of feasible partial embeddings and total number of feasible states. Before proceeding further, let n u denote the number of feasible u-states, where u ∈ V (T ), and let t s denote the time required to test whether a feasible state succeeds another.
Proof. Let us consider a u-partial embedding f u from some subset of V (G) to B(u, d + 1).
Observe that |B(u, d + 1)| ≤ µ.∆ d+1 . Note that the distance between two vertices in B(u, d + 1), is at most Γ. As we are considering non-contracting embedding, the domain of f u must be contained in a ball of radius Γ + 2d + 2 centered at some vertex of G. As ∆(G) ≤ ∆ d , the domain of f u can contain at most ∆ O(Γ.d+d 2 ) vertices. So, the total number of feasible u-partial embeddings is at most n · µ · ∆ d+1 ∆ O(Γ·d+d 2 ) . Now consider some u ∈ V (T ) and v ∈ N T (u). The total number of [f u , v] types is at most (4(Γ + d)) µ 2 ·∆ d+1 and hence the total number of [f u , v] typelists is at most 2 (4(Γ+d)) µ 2 ·∆ d+1 . Note that the maximum degree of T is O(1). So, the total number of feasible u-states, i.e., n u is at Recalling Definition 4.3 and 5.6, we can say the following. Let f u and f v correspond to u ∈ V (T ) and v ∈ C T (u). One can decide whether f v succeeds f u in time O n · µ · ∆ d+1 and hence the time required to test whether a feasible state succeeds another t s = n · µ · ∆ d+1 + µ · ∆ d+1 · 2 O((4(Γ+d)) µ 2 ·∆ d+1 ) .
First, a tree decomposition has to be constructed and converted into a connected tree decomposition in 2 O(α) · n 2 + n O(1) time. This connected tree decomposition is converted into a nice tree decomposition in polynomial time, with the guarantee that the distance between two vertices in a bag of the nice tree decomposition is at most Γ. Recall that T is a nice tree decomposition, which implies |V (T )| = O(µ.N ) and ∆(T ) = O(1). So, there are at most O (µ · N n u ) feasible states. Note that the bags corresponding to two adjacent vertices of T , differ by at most one vertex of H. So, each feasible partial embedding can take part in at most µ · ∆ d+1 ∆ O(µ.d 2 ) number of successions. Thus the total running time of the algorithm is · t s . Since Γ ≤ µ, the running time is O(n 2 ·N )·(µ·∆ d+1 ) ∆ O(µ·d+d 2 ) ·2 O((4(µ+d)) µ 2 ·∆ d+1 ) +n O(1) , where µ = 4(α+ α 2 (ℓ g (α−2)−1)).

Graph Metric Embedding for Generalized Theta graphs
In this section, we design an FPT algorithm for embedding unweighted graphs into generalized theta graphs. Our FPT algorithm is parameterized by the distortion d and the number k of paths in the generalized theta graph. The strategy for the algorithm is still the same: that of putting together partial embeddings to obtain a non-contracting distortion d metric embedding. For this algorithm, we also observe structural properties of graphs that are embeddable into generalized theta graphs. We exploit these properties to obtain an FPT algorithm to compute a set of partial embeddings, and then use a dynamic programming algorithm to put together partial embeddings from the set to obtain the solution metric embedding. Our notion of partial embeddings will be more involved in this algorithm.
Let (G, D G ) be the graph metric that we want to embed into the graph metric (H, D H ). Here H is a generalized theta graph defined at s,t and let P be the family of s − t paths that define H. To begin with, we try to guess the non-contracting distortion d embedding of (G, D G ) into (H, D H ), when restricted to a d-ball around s and around t.
The following observation talks about the degree bound on the vertices of a graph that is embeddable into a generalized theta graph. • All other vertices of G can have degree at most 2d.
Observation 6.3. The number of possible non-contracting distortion d embeddings of some Proof. Observe that |B s | , |B t | ≤ kd + 1. As we are considering non-contracting embeddings, the preimage of B s (B t ) lies in a ball of radius 2d centered at some vertex of G. By Observation 6.2, the size of the pre-image of B s (B t ) is at most (2d) O(kd) . Hence, the number of required embeddings can be at most n 2 · (kd + 1) 2.(2d) O(kd) .
We prove several properties of graphs that are embeddable into generalized theta graphs. For the given input graph G, let F be a non-contracting distortion d embedding and Ψ : . We will derive certain properties of G with the help of the embedding F . Proof. Let F be a non-contracting distortion d embedding. Assume that there are three connected components C i 1 , C i 2 , C i 3 of G \ (Dom F s ∪ Dom F t ) mapped into path P ′ i for some i ∈ [k]. As all components are mapped into a path, at most one of them has some neighbours, in G, mapped into B s (B t ). So, there must be a component that has no neighbour mapped into B s ∪ B t . This implies the graph is disconnected.
Thus, there can be at most 2k components of G \ (Dom F s ∪ Dom F t ).
Definition 6.6. Let F be a non-contracting distortion d embedding. An empty subpath of F is a subpath of the generalized theta graph where none of the vertices have any preimage. If a path P ′ i , i ∈ [k], has an empty subpath with one endpoint at t i , then such a subpath is called a t-empty subpath. Similarly, if a path P ′ i has an empty subpath with one endpoint at s i , then such a subpath is called a s-empty subpath. If a path P ′ i contains an empty subpath that coincides with neither s i nor t i , then such a subpath is called an internal-empty subpath. Finally, it is possible that the path P ′ i itself is an empty subpath and then P ′ i is called a fully-empty subpath.
Note that a path P ′ i can have at most one empty subpath with respect to F . Similarly, we classify the components of G \ (Dom F s ∪ Dom F t ). Since F is a non-contracting distortion d embedding, the following observation is true.
Observation 6.8. Let F be a non-contracting distortion d embedding. Any path P i , P ′ i = ∅, can be one of the following forms. If we refer P i to be of form-st , then P i is of form-1 or form-2 or form-3.
The objective is to find a non-contracting distortion d embedding F , if it exists. Although we do not know about F , we want to store a snapshot of F . Definition 6.9. A configuration X is a tuple (Ψ, P ′ ,P) where: • Let U ⊆ V (G) be such that G \ U creates a set of components {C 1 , C 2 , . . . , C a }, a ≤ 2k.
Ψ : U → B s ∪ B t is a non-contracting distortion d embedding of U .
• P ′ ⊆ P, •P is a family of |P \ P ′ | tuples such that for each path P i ∈ P \ P ′ , there is a tuple (form i , C P i , comp i ) with the following information: (i) form i assigns the name of a form to P i .
(ii) The set C P i is a set of at most 2 components of G \ U that are assigned to P ′ i and to no other P ′ j , j = i. (iii) The function comp i indicates for each C ∈ C P i whether it is an s-component or a t-component or full-component, with respect to Ψ.
The number of configurations is bounded for a fixed Ψ.
Observation 6.10. For any fixed Ψ, the total number of configurations is O(k 2k ).
Proof. When Ψ : U → B s ∪ B t is fixed, the components {C 1 , C 2 , . . . , C a } of G \ U are fixed. Also, whether a component is an s-component, a t-component or a full-component gets fixed. The total number of ways in which the components can be assigned to paths of P is O(k 2k ). Once an assignment of the components to the paths is fixed, in constant time, we can find out P ′ , and for each i ∈ [k], the tuple (form i , C P i , comp i ). Therefore, the total number of configurations for a fixed Ψ is O(k 2k ).
Next, we define feasible configurations that can be associated with metric embeddings.
Definition 6.11. A configuration X = (Ψ, P ′ ,P) is said to be feasible with respect to a noncontracting distortion d embedding F of G into H if the following hold: is empty for each P i ∈ P ′ ⊆ P. , • For each P i that is non-empty with respect to F ,P contains a tuple (form i , C P i , comp i ) with the following information: (ii) The set C P i is the set of at most 2 components of G \ U that are embedded into P ′ i by F .
(iii) The function comp i indicates for each C ∈ C P i whether it is an s-component or a t-component or full-component, with respect to F .
By Observation 6.4, in a feasible configuration |C P i | ≤ 2. Note that if |C P i | = 0, then P i can only be of form-5. If |C P i | = 1, then P i can be of form-1, form-2 or form-4. If |C P i | = 2, then P i can only be of form-3 where one component of C P i is a s-component and the other one is a t-component. Note that each non-contracting distortion d embedding F induces a feasible configuration. We denote it by X (F ). Also, the total number of feasible configurations is bounded by the total number of configurations.
Next, we define the notion of a last vertex for a component of G \ (Dom F s ∪ Dom F t ) with respect to the embedding F . Definition 6.12. Let F be a non-contracting distortion d embedding. Let C be a j-component, j ∈ {s, t}. A vertex ℓ in C is the last vertex of C with respect to embedding F if D H (j, F (ℓ)) ≥ D H (j, F (x)) for all x ∈ C.
The following Lemma gives a bound on the potential last vertices of a component of G \ (Dom F s ∪ Dom F t ) if G is embeddable into H.
Lemma 6.13. Let F be a family of non-contracting distortion d embedding of G into H such that X (F 1 ) = X (F 2 ) for any F 1 , F 2 ∈ F. Then for any form-st path P i and any s(t)-component C ∈ C P i , there are d O(d 2 ) vertices that are candidates for being the last vertex of C with respect to some F ∈ F.
Proof. Without loss of generality, assume that C is an s-component.
Let v ∈ C be a candidate for the last vertex of C with respect to some F ∈ F. Let u ∈ S i be some vertex in Dom F s that is mapped to a vertex in P i . Since G is a connected graph, such a vertex always exists. We show that, in G, v must be either a vertex furthest away from u or at most d 2 distance away from a furthest vertex. LetQ be the subpath of P i between F (u) and F (v). Consider the subpath Q ⊆Q that has length d 2 and has an endpoint at F (v). Before proceeding further, we need the following Claim.
Claim 6.14. For any vertex x that is mapped into some vertex ofQ \ Q, D G (u, x) < D G (u, v).
Proof. If the shortest path between u and v passes through x in G, then we are done. Therefore, assume that the shortest path between u and v passes through two vertices of an edge (y, z) such that D H (F (u), F (y)) < D H (F (u), F (x)) and D H (F (u), F (z)) > D H (F (u), F (x)). For ease of notation, when D H (F (u), F (y)) < D H (F (u), F (x)) we say that y is mapped before x. Similarly, when D H (F (u), F (z)) > D H (F (u), F (x)) we say that z is mapped after x. Note that such an edge (y, z) exists on the shortest path between u and v. Also, since the expansion is at most d, Therefore, all vertices that are furthest away from u must be mapped to vertices of Q. As we are constructing a non-contracting embedding, all vertices that are mapped to vertices of Q must be within distance d 2 of the furthest vertices from u.
There can be at most d 2 furthest vertices from u. By Observation 6.2, each vertex is of degree at most 2d. Hence, the total number of candidate vertices for v is bounded by d 2 .(2d) d 2 .
Next, we define the notion of a shortest embedding of a component in a path of P.
Definition 6.15. Let Y be a feasible configuration such that Y = X (F ) for a non-contracting distortion d embedding F . Let P i be a form-st path, C ∈ C P i be a s-component of G \ (Dom F s ∪ Dom F t ) and ℓ ∈ C be a candidate to be the last vertex of C with respect F . Recall that S i is the set of vertices of Dom F s that are mapped into P i . Let A be a family of non-contracting and distortion d embedding of C ∪ S i into P i such that the following conditions hold, (i) f 1 | S i = f 2 | S i for any f 1 , f 2 ∈ A.
(ii) For each f ∈ A, f (x) is a vertex of P ′ i for any x ∈ C.
(iii) For each f ∈ A, F | C∪S i = f and ℓ is the last vertex of C with respect to F .
(iv) For each f ∈ A, for any x ∈ Dom F s ∪ Dom F t , the path between f (ℓ) and f (x) is noncontracting with expansion at most d.
Then the shortest embedding of C ∪ S i into P i with respect to Y and ℓ, is an embedding f ∈ A such that D H (s, f (ℓ)) ≤ D H (s, f ′ (ℓ)) for all f ′ ∈ A. If C is a t-component, T i is taken to be the set of vertices of Dom F t that are mapped into P i and we can define the shortest embedding of C ∪ T i with respect to Y and ℓ in a similar way.
We can extend the notion of shortest embedding of a component into a path of P to that of a non-contracting distortion d embedding of G into H that has shortest embeddings for all s-components and t-components.
Definition 6.16. Let us consider a non-contracting distortion d embedding F of G into H. We say F is a special embedding with respect to feasible configuration X (F ) if for every path P i of form-st and s (t)-component C ∈ C P , the following holds: F | C∪S i (F | C∪T i ) is the shortest embedding of C ∪ S i (C ∪ T i ) into P i with respect to the feasible configuration X (F ) and the last vertex of C with respect to F . be required for checking whether an obtained function from V (G) to V (H) is a noncontracting distortion d embedding.
Let us fix a non-contracting distortion d embedding Ψ of U ⊆ V (G) into B s ∪ B t and a configuration Y containing Ψ. If the degree of any vertex in G \ U is more than 2d, then we decide that there does not exist any desired embedding with respect to Y. Otherwise, we proceed as follows. Let F be the special embedding of G into H with respect to Y that we want to find, if one exists. Note that U = Dom F s ∪ Dom F t .
(i) If a path P i is of form-5, we don't have to do anything for that.
(ii) Let a path P i be of form-4, and suppose C ∈ C P i is the only full component mapping into P i . The vertices in S i ∪ T i ⊂ U are the points that are mapped into P i \ P ′ i . Then we find a non-contracting distortion d embedding f C , if possible, of C ∪ S i ∪ T i into P i such that f C | S i = Ψ| S i and f C | T i = Ψ| T i . Note that S i (T i ) is the set of vertices of Dom F s (Dom F t ) that are mapped into P i . Such an embedding f C can be found by running the algorithm described in Lemma 3.18. This algorithm admits a time complexity of O n 2 · d 2d+3 · (4d(2d + 2)) 2d+2 = O n 2 · d O(d) . If we cannot find such an embedding, then there does not exist any special embedding of G into H with respect to Y.
(iii) Let P i be a form-st path and C ∈ C P i be an (a) s (t)-component. Without loss of generality, assume that C is an s-component. Here, our objective is to find the shortest embedding f of C ∪ S i into P i with respect to Y and some ℓ, where ℓ is the last vertex of C with respect to F . We guess a vertex ℓ ∈ C, as the last vertex. This vertex is either a furthest vertex from a fixed vertex a ∈ S i or lies within distance of d 2 from a furthest vertex from a in G. By Lemma 6.13, the total number of candidates for the last vertex of C with respect to F is d O(d 2 ) .
It is easy to see that |C ∪ S i | ≤ D H (f (ℓ), f (a)) ≤ 2d. |C ∪ S i | by Observation 2.6. Thus, the length of the shortest embedding of C ∪ S i , where ℓ is the last vertex, is also in this range. For each possible length |C ∪ S i | ≤ len ≤ 2d. |C ∪ S i |, we try to find a noncontracting distortion d embedding f len of C ∪ S i into a path P len = {1, 2, . . . , len} such that f len restricted to the first |S i | vertices is same as the mapping by Ψ, and for each u ∈ C ∪ S i , D P len (1, f len (u)) ≤ D P len (1, f len (ℓ)). Observe that we have to run the algorithm described in Corollary 3.21. If the algorithm returns no for all lengths, for every candidate ℓ for the last vertex, then there does not exist any special embedding of G into H with respect to Y. Otherwise, assume that for the current guess ℓ the shortest length for which the algorithm returns a required non-contracting distortion d embedding is len ′ . Let this embedding be f C . In the worst case this step will incur a time complexity of d O(d 2 ) · O 2nd · n 2 · d 2d+3 · (4d(2d + 2)) 2d+2 = O n 3 · d O(d 2 ) .
Let F = Φ Π be the function such that Π = {Ψ} ∪ {f C | C is a component of G \ U }. We verify whether the obtained F is a non-contracting distortion d embedding from G to H. If yes, we are done. If not, then there does not exist any special embedding with respect to Y. Observe that the distance between two given points in H, can be computed in O(1) time using D st . Since we only need to check for non-contraction and distortion d for every pairs of mapped vertices in H, the verification of F for a desired embedding can be done by spending O(n 2 ) time.
Note that in the worst case, we have to run the above steps for all possible configurations. If we decide that there does not exist a special embedding with respect to all configurations, then we report that G does not admit the desired embedding of G into H. The correctness of the algorithm follows from Lemma 6.17. Now we analyze the running time of the algorithm. Recall that there can be 2k components of G\U . In the execution of our algorithm for a fixed configuration, we spent 2k·n 2 ·d O(d 2 ) +O(n 2 ) time. By Observation 6.3 and 6.8, the total number of configuration is at most k 2k · n 2 · (kd + 1) (2d) O(kd) . Note that we have spent O(N + k) time to compute D st . Putting everything together, the time complexity of our algorithm is bounded by O (N ) + n 5 · k 2k+1 · (kd + 1) (2d) O(kd) · d O(d 2 ) .

Conclusion
In this paper, we presented several FPT algorithms for embedding into different graph classes. Note that for all the considered graph classes, our results can be modified to answer the Weighted Graph Metric Embedding problem for the graph classes. Similar to the results in Section 3, for a particular graph class considered in this paper, when we take the maximum edge weight M to be a parameter along with the set of parameters considered for the graph class, then the problem is still FPT. On the other hand, without M as a parameter, the problem is NP-Complete for any distortion d > 2. The question of the parameterized complexity of embedding into trees of unbounded degree, asked in [FFL + 13], still remains open. Another important question is to determine the parameterized complexity of Graph Metric Embedding for bounded treewidth graphs, even when the treewidth is taken to be some constant. Since trees with unbounded degree have treewidth 1, the latter open problem is a generalization of the former.