Minimum Eccentricity Shortest Path Problem with Respect to Structural Parameters

The Minimum Eccentricity Shortest Path Problem consists in finding a shortest path with minimum eccentricity in a given undirected graph. The problem is known to be NP-complete and W[2]-hard with respect to the desired eccentricity. We present fpt-algorithms for the problem parameterized by the modular width, distance to cluster graph, the combination of treewidth with the desired eccentricity, and maximum leaf number.


Introduction
The Minimum Eccentricity Shortest Path (MESP) problem asks, given an undirected graph and an integer k, to find a shortest path with eccentricity at most k-a shortest path (between its endpoints) such that the distance from every vertex in the graph to the nearest vertex on the path is at most k. The shortest path achieving the minimum k may be viewed as the "most accessible", and as such, may find applications in communication networks, transportation planning, water resource management, and fluid transportation [1]. Some large graphs constructed from reads similarity networks of genomic data appear to have very long shortest paths with low eccentricity [2]. vertex cover # max leaf # neighborhood diversity twin cover # tree depth dist. to cluster graph dist. to disjoint paths feedback vertex set # modular width tree width Fig. 1: Hasse diagram of the boundedness relation between structural parameters explored in this paper and related ones. An edge between a parameter A above and a parameter B below means that whenever A is bounded for some graph class, then so is B. The parameters for which MESP is FPT are in green (dark if the result is described in this paper, light if implied by those described). Yellow represents a parameter for which MESP is FPT in combination with the desired eccentricity (again, dark if the result is described in this paper, light if implied by those described). The figure is inspired by [11].
Furthermore, MESP can be used to obtain the best to date approximation for a minimum distortion embedding of a graph into the line [1] which has applications in computer vision [3], computational biology and chemistry [4,5]. The eccentricity of MESP is closely tied to the notion of laminarity (minimum eccentricity of the graph's diameter) [6].
MESP was introduced by Dragan and Leitert [1] who showed that it is NP-hard on general graphs and constructed a slice-wise polynomial (XP) algorithm, which finds a shortest path with eccentricity at most k in a graph with n vertices and m edges in O(n 2k+2 m) time. They also presented a lineartime algorithm for trees. Additionally, they developed a 2-approximation, a 3-approximation, and an 8-approximation algorithm that runs in O(n 3 ) time, O(nm) time, and O(m) time, respectively. Birmelé et al. [6] further improved the 8-approximation to a 3-approximation, which still runs in linear time. Dragan and Leitert [7] showed that MESP can be solved in linear time for distance-hereditary graphs (generalizing the previous result for trees) and in polynomial time for chordal and dually chordal graphs. Later, they proved [8] that the problem is NP-hard even for bipartite subcubic planar graphs, and W [2]-hard with respect to the desired eccentricity for general graphs. Furthermore, they showed that in a graph with a shortest path of eccentricity k, a minimum k-dominating set can be found in n O(k) time. A related problem of finding shortest isometric cycle was studied by Birmelé et al. [9]. Birmelé et al. [10] studied a generalization of MESP, where the task is to decompose a graph into subgraphs with bounded shortest-path eccentricity, the hub-laminar decomposition.

Our contribution
We continue the research direction of MESP in structured graphs [7], focusing on parameters which can measure the amount of structure present in the graph. We provide fpt-algorithms for the problem with respect to the modular width, distance to cluster graph, distance to disjoint paths combined with the desired eccentricity, treewidth combined with the desired eccentricity, and maximum leaf number (see Figure 1 for an overview of our results).

Outline
In Section 2, we provide necessary notations and formal definitions. In Section 3, we describe our parameterized algorithms. In Section 4, we discuss possible future work.

Preliminaries
We consider finite connected unweighted undirected simple loopless graphs.
We refer to Diestel [12] for graph notions. For a graph G = (V, E) we denote n = |V | and m = |E|. We denote We denote an ordered sequence of elements s = (s 1 , . . . , s |s| ). For two sequences s = (s 1 , . . . , s |s| ), t = (t 1 , . . . , t |t| ) we denote their concatenation A path is a sequence of vertices where every two consecutive vertices are adjacent. The first and last vertices of the path are called its endpoints. A path between u and v or u-v-path is a path with endpoints u and v. The length of a path P is the number of edges in it, i.e., |P | − 1. A u-v-path is shortest if it has the least length among all u-v-paths. The distance d G (u, v) between two vertices u, v ∈ V is the length of the shortest u-v-path.
The distance between a vertex u ∈ V and a set of vertices S ⊆ V is d G (u, S) = min s∈S d G (u, s). The eccentricity of a set S ⊆ V is ecc G (S) = max u∈V d G (u, S). For a path P , we use P instead of V (P ) for its set of vertices, if there is no risk of confusion, e.g., d G (u, P ) = d G (u, V (P )) and ecc G (P ) = ecc G (V (P )).
In this paper, we focus on the following problem. Minimum Eccentricity Shortest Path Problem (MESP) Input: An undirected graph G, desired eccentricity k ∈ N. Question: Is there a path P in G which is a shortest path between its endpoints with ecc G (P ) ≤ k?
A parameterized problem Π is fixed parameter tractable (FPT) with respect to a parameter k if there is an algorithm solving any instance of Π with size n in f (k)·n O(1) time for some computable function f . Such an algorithm is called a parameterized or an fpt-algorithm. See Cygan et al. [13] for more information on parameterized algorithms.
In this paper, we present fpt-algorithms for MESP with respect to the following structural parameters.
Definition 1 (Modular width, [14]) Consider graphs that can be obtained from an algebraic expression that uses the following operations: (O1) create an isolated vertex; (O2) the disjoint union of 2 disjoint graphs (the disjoint union of graphs G 1 and G 2 is the graph (O3) the complete join of 2 disjoint graphs (the complete join of graphs G 1 and G 2 is (O4) the substitution with respect to some pattern graph T (for a graph T with vertices t 1 , . . . , tn and disjoint graphs G 1 , . . . , Gn the substitution of the vertices of T by the graphs G 1 , . . . , Gn is the graph with vertex set n i=1 V (G i ) and . We define the width of an algebraic expression A as the maximum number of operands used by any occurrence of the operation (O4) in A. The modular-width of a graph G, denoted mw(G), can be defined as the least integer m such that G can be obtained from such an algebraic expression of width at most m.
Given a graph G with n vertices and m edges, an algebraic expression of width mw(G) describing G can be constructed in O(n + m) time [15]. Definition 2 (Distance to cluster graph) For a graph G = (V, E), a modulator to cluster graph is a vertex subset X ⊆ V such that G \ X is a vertex-disjoint union of cliques. The distance to cluster graph is the size of the smallest modulator to cluster graph.
A modulator to cluster graph of a graph with distance to cluster graph p can be found in O 1.9102 p · (n + m) time. [16] Definition 3 (Distance to disjoint paths) For a graph G = (V, E) a modulator to disjoint paths is a vertex subset X ⊆ V , such that G \ X is a vertex-disjoint union of paths. The distance to disjoint paths is the size of the smallest modulator to disjoint paths.
For completeness, we include the following result which is rather folklore.

Lemma 1
The modulator to disjoint paths C of a graph G with distance to disjoint paths c can be found in O 4 c (n + m) time.
Proof If the highest degree in G is at most 2, then G consists only of disjoint paths and cycles, and the modulator to disjoint paths is a set of vertices containing one vertex from each cycle. Thus, the modulator to disjoint paths can be found in O(n + m) time by identifying all cycles with a depth-first search.
If the highest degree in G is at least 3, then the modulator to disjoint paths can be found by a simple branching rule.
1. Select any vertex u with degree deg G (u) ≥ 3.
2. Either u ∈ C or some subset S ⊆ N G (u) of size |S| = deg G (u) − 2 must be in C.
We show that this algorithm has time complexity 4 c q(n+m) for some constant q, where c is the given maximum distance to disjoint paths. We show that by induction on c. For c = 0 we only have to check whether the graph is a disjoint union of paths, which can be done in O(n + m) time, i.e., 4 0 q(n + m) time for a suitably chosen q. For . Hence, the time complexity is indeed O(4 c (n + m)).
The width of a tree decomposition (T, β) is max{|β(x)|−1 : x ∈ V (T )}. The treewidth tw(G) of a graph G is the smallest width over all tree decomposition of G.
Definition 5 (Maximum leaf number) The maximum leaf number of a graph G is the maximum number of leaves in a spanning tree of G.
The presented algorithms rely on the following lemma.
Lemma 2 For any graph G = (V, E), any set S ⊆ V , and any vertex s ∈ V , at most one permutation π = (π 1 , . . . , π |S| ) of the vertices in S exists, such that there is a shortest path P with the following properties: 1. The first vertex on P is s, 2. P contains all vertices from S, and 3. the vertices from S appear on P in exactly the order given by π.
Moreover, given a precomputed distance matrix for G, the permutation π can be found in O(|S| log |S|) time.
Proof For the sake of deriving a contradiction, suppose that there are two different permutations π and π ′ satisfying the conditions, and let P, P ′ be the respective shortest paths. Let i ∈ {1, . . . , |S| − 1} be the first position such that π i = π ′ i and let j ∈ {2, . . . , |S|} be the position of π i in π ′ (clearly, j > i). Let P 1 be the subpath of P from s to π i , and P ′ 2 the subpath of P ′ from π ′ j to π ′ |S| (excluding the first vertex π ′ j ). Then, P ′′ = P 1 ⌢ P ′ 2 is a path which is strictly shorter than P ′ and has the same endpoints. This contradicts P ′ being a shortest path.
Sorting all vertices in S by increasing distance from the starting endpoint s yields our permutation π. It corresponds to some shortest path P if and only if

Parameterized Algorithms
In this section, we present several fpt-algorithms for MESP. In Subsection 3.1, we present an algorithm parameterized by the modular width. In Subsection 3.2 we define the Constrained Set Cover (CSC) problem. In Subsection 3.3 we show an fpt-algorithm for MESP parameterized by the distance to cluster graph which reduces MESP to CSC. In Subsection 3.4, we present an fpt-algorithm parameterized by the distance to disjoint paths and the desired eccentricity, combined. This algorithm also depends on the solution of the CSC problem. In Subsection 3.5, we present an fptalgorithm parametrized by treewidth and the desired eccentricity, combined. In Subsection 3.6 we present an algorithm parameterized by the maximum leaf number.

Modular Width
We present an fpt-algorithm for MESP parameterized by the modular width.
Let G = (V, E) be a graph with modular width w and A be the corresponding algebraic expression describing the graph. We take a look at the last operation applied in A. Operation (O1) is trivial and (O2) yields a disconnected graph, therefore we suppose the last operation is either (O3) or (O4).
If it is (O3) and G is a path (of length at most 3), then the whole path is trivially a shortest path with eccentricity 0. If G is not a path, then the minimum eccentricity shortest path is any single edge connecting the two original graphs with eccentricity 1.
If it is (O4), the pattern graph is T = (V T , E T ) with V T = {v 1 , . . . , v w } and the substituted graphs are G 1 , . . . , G w , then we suppose that w ≥ 3 and T is not a clique (otherwise (O3) could be used as the last operation). We continue by showing that the structure of the pattern graph restricts the structure of any shortest path in the resulting graph significantly.

Lemma 3 If the last operation in
A is (O4), then there is a minimum eccentricity shortest path in G which contains at most one vertex from each G i for i ∈ {1, . . . , w}.
Proof Let P be a shortest path in G.
If the length of P is at most 2 and P contains two vertices from G i , then we create a path P ′ with ecc G (P ′ ) ≤ ecc G (P ). Because G was created with (O4), we know that G ≃ P , thus ecc G (P ) ≥ 1. We denote a, b the two vertices from G i on P . If there is another vertex on x on P and x / ∈ G i , we let c = x; otherwise we choose a vertex c arbitrarily from some G j such that If the length of P is at least 3, we show by contradiction that it cannot contain two vertices from G i . Let P = (p 1 , . . . , p ℓ ). Suppose that ps, p t ∈ G i . Clearly, at least one of ps, p t is not an endpoint of P (otherwise the length of P would be at most 2). Without loss of generality, suppose that ps is not an endpoint of P , thus it has a predecessor p s−1 and P = (p 1 , . . . , p s−1 , ps, . . . , p t , . . . , p ℓ ). We have {p s−1 , ps} ∈ E and {p s−1 , p t } ∈ E. Path P may be shortened to P ′ = (p 1 , . . . , p s−1 , p t , . . . , p ℓ ). Thus, P is not a shortest path. Now, we show that with respect to eccentricity, all vertices in the same graph G i are equivalent. That means a minimum eccentricity shortest path in G can be found by trying all shortest paths in T .

Lemma 4 Let P be a shortest path in
because the neighbors of p on P , as well as the neighbors of p ′ on P ′ , are also neighbors of u.
Based on what we have shown, we can construct an algorithm to solve MESP. We handle separately the graphs created using (O1) or (O3) as the last operation. For (O4), we iterate through all possible shortest paths π in T . For each of them and each i ∈ {1, . . . , |π|} we let p i ∈ G πi arbitrarily, and let P := (p 1 , . . . , p |π| ). Then we check whether P is a shortest path with eccentricity at most k in G. By the above arguments, if there is a shortest path of eccentricity at most k, we will find one.
All shortest paths in a graph can be found by simply performing n DFS traversals (one starting in each vertex). Each forward step of the DFS represents a new shortest path; we skip edges that would break the shortest path property (this can easily be checked with a precomputed distance matrix).
By assuming a trivial upper bound 2 w on the number of shortest paths in T , we arrive at the following theorem.
Theorem 5 There is an algorithm that solves MESP in O(2 w · n 3 ) time, where w is the modular width of the input graph.

Constrained Set Cover
In this subsection we define the Constrained Set Cover (CSC) problem. In the folllowing two subsections it will be used as a subroutine to solve MESP.

Constrained Set Cover
Input: A set C = C 1 ∪ · · · ∪ C m of candidates, a set R = {r 1 , . . . , r n } of requirements to be satisfied, and a function Ψ : C → 2 R that determines for each candidate which requirements it satisfies. Question: Is there a constrained set cover, that is, a set of candidates, exactly one from each set s 1 ∈ C 1 , . . . , s m ∈ C m such that together they satisfy all the requirements, i.e., Ψ(s 1 ) ∪ · · · ∪ Ψ(s m ) = R?
Each candidate can be thought of as a set of (satisfied) requirements. Hence, if we drop the constraints s i ∈ C i , we get the ordinary Set Cover with a universe R, a family of sets {Ψ(c) | c ∈ C}, and the question of whether there is a set cover of size at most m. In our definition several candidates can satisfy the same set of requirements.
In the next two subsections we use the following theorem.
The rest of this subsection is devoted to the proof of Theorem 6. To prove Theorem 6, we need some further definitions and lemmas.
To help us solve CSC, we now define a function D i for each i ∈ {1, . . . , m}.
Definition 6 Let R = {r 1 , . . . , rn}, C = C 1 ∪ · · · ∪ Cm, Ψ : C → 2 R be an instance of CSC. We define function D i : 2 R → C ∪ {⊤, ⊥} as follows: Given some requirements R ⊆ R, If there are more candidates in the second case, we select an arbitrary one to make D i a function. As we will see, it does not matter which specific value it has, as long as it satisfies the definition.
Before using this function to solve CSC, we need to know how to calculate its values efficiently. Note that D 0 (R) = ⊤ if R = ∅ and ⊥ otherwise.
can be computed recursively as follows.
Proof We suppose that the initial values of D 0 are taken directly from Definition 6 and prove the lemma for any i ≥ 0. First, we show that if the recursion yields some value s i+1 , then it is one of the correct possible values of D i+1 (R) according to Definition 6. Second, we show that if D i (R) = ⊥, then the recursion does not yield ⊥ either. If the recursion yields s i+1 ∈ C i+1 , then there is some , which corresponds to Definition 6 and D i+1 (R) yields a correct value.
If D i+1 (R) = s i+1 ∈ C i+1 , then there are some candidates We continue by showing how a solution of CSC may be extracted from the values of D 1 , . . . , D m . We will use each function D i to choose the candidate s i from C i .

Algorithm 1 Constrained Set Cover
Input: Set of requirements R, sets of candidates C = C 1 ∪ · · · ∪ C m , function Ψ : C → 2 R 1: for all S ⊆ R do

Distance to Cluster Graph
In this subsection, we present an fpt-algorithm for MESP parameterized by the distance to cluster graph. The trivial case where distance to cluster graph is 0 is omitted. Note that if G is a graph with a modulator to cluster graph U , then, for any edge {u, v} in G \ U , u and v have the same neighborhood in G \ U .
The high-level idea of the algorithm is that we iteratively guess (by trying all possible combinations), for each vertex in the modulator to cluster U , whether it lies on the desired shortest path (we say it belongs to the set L), or it is at distance 1 or 2 from the shortest path (it belongs to the set R 1 or R 2 , respectively), or at an even further distance. Then, we try to find a shortest path such that all vertices from L lie on it, and all vertices in R 1 , R 2 have the respective distance from the path. Finding such a path is reduced to solving the CSC problem presented in Subsection 3.2. Once we guess the correct combination of these sets, we actually construct the MESP.
First, we discuss some properties of graphs having the desired path.
Lemma 9 Let G be a graph with modulator to cluster graph U and let P be a shortest path with ecc G (P ) = k. Then, there exists a shortest path P ′ such that it contains at least one vertex from U and ecc G (P ′ ) ≤ k.
Proof Suppose that P only contains vertices from V = V (G) \ U . All these vertices form a clique, so the length of P is at most 1. Let P = (u, v). If there is some vertex w ∈ U such that it is a neighbor of exactly one endpoint of P , then either P ′ = (u, v, w) or P ′ = (w, u, v) is the sought path. If all vertices in U are neighbors of both u and v, then P ′ = (v, w) for any w ∈ U is the sought path.
Definition 7 Let G be a graph with a modulator to cluster graph U . Let P be a shortest path in G with ecc G (P ) ≤ k and U ∩ P = ∅. We denote L P = P ∩ U and π P = (π P 1 , . . . , π P |L P | ) the permutation/order of vertices from L P in which they appear on the path P . We denote R P i = {u ∈ U | d G (u, P ) = i} the set of vertices in U that are at distance i from P , for i ∈ {1, 2}.
is a disjoint union of cliques, and for every i ∈ {1, . . . , |L P | − 1}, all vertices that are between π P i and π P i+1 on P are from V , we have d G (π P i , π P i+1 ) ≤ 3, as otherwise P would not be a shortest path.
Let π = (π 1 , . . . , π |π| ) be a candidate (guess) on the value of π P . Intuitively, if we had the correct values of π = π P , we would only need to select the (at most two) vertices between each π i , π i+1 .
To help us refer to those pairs π i , π i+1 between which we still need to choose some vertices we denote h π = (h 1 , . . . , h ℓ ) the increasing sequence of all indices i such that {π i , π i+1 } / ∈ E. For every i / ∈ h π , we have {π i , π i+1 } ∈ E(G) and, thus, there is no vertex between π i and π i+1 on P . For every h i ∈ h π : If d G (π hi , π hi+1 ) = 2, then there is one vertex on P between π hi and π hi+1 , and it is from V . If d G (π hi , π hi+1 ) = 3, then there are two vertices from V on P between π hi and π hi+1 . Definition 8 We define the set C hi of candidate vertices between π hi and π hi+1 for each h i ∈ hπ.
For h i ∈ h π with d G (π hi , π hi+1 ) = 2, the set C hi contains pairs of the same vertices (u, u). To avoid adding some vertex into a path twice, we define a function µ which maps a pair of two elements to a sequence of length 1 or 2: To solve MESP, we need to choose exactly one pair from each of C h1 , . . . , C h ℓ . Later, we show that the problem of choosing these pairs is an instance of CSC.
First, we define a function δ P : U ∪ V → N that will help us prove that the path constructed from the CSC solution will have a small eccentricity: Lemma 10 Function δ P is a good estimate of the distance from P , meaning that: Let z be the nearest vertex to u on P and Q be the shortest path from u to z. If there are any vertices from U on Q, let x be the last vertex from U on Q. We know that d G (x, z) ≤ 2 because Q is a shortest path and all vertices connected in G[V ] form a clique. If x = z, then x ∈ L P . If d G (x, z) = 1, then x ∈ R P 1 . If d G (x, z) = 2, then x ∈ R P 2 . Hence, δ P (u) ≤ d G (u, z) = d G (u, P ). If Q consists only of vertices from V , let s be the nearest vertex to u such that s ∈ P \ (N G [u] ∩ V ). Clearly, s ∈ L P and δ P (u) ≤ d G (u, s) = d G u, P \ (N G [u] ∩ V ) . Now we show how to choose optimal vertices from each C i by solving CSC.

Lemma 11
Suppose that P is a shortest path in G with ecc G (P ) ≤ k, both endpoints of P are in U , and we have the corresponding values of L P , π P , R P 1 , R P 2 as described in Definition 7. Let h π P = (h 1 , . . . , h ℓ ) and (s h1 , . . . , s h ℓ ) be a solution of the CSC instance with requirements Then is a shortest path and ecc G (P ′ ) ≤ max{2, k}.
Proof Clearly, P ′ is a shortest path.
Thanks to the way we chose s h1 , . . . s h ℓ and from Lemma 10 we know that: If u ∈ V and P ∩ (N G [u] ∩ V ) = ∅, then d G (u, P ) ≤ 1. Because P contains at least one vertex from U and all vertices in Clearly, if k ≥ 2, then we can use Lemma 11 to construct a shortest path with eccentricity at most k. Now, we discuss the case when k = 1.
Proof If u ∈ U , then either u ∈ L P or u ∈ R P 1 , and δ P (u) ≤ 1. For each u ∈ V , let v ∈ L P be the nearest vertex to u on P from U . Because all vertices that are connected in G[V ] form a clique, we get d G (u, v) ≤ 2, and hence δ P (u) ≤ 2.

Corollary 13
If ecc G (P ) = 1, then a path P ′ with ecc G (P ′ ) ≤ 1 can be constructed similarly as in Lemma 11 with the following modification. For each candidate set C i which contains some pair (x, y) ∈ V 2 such that there is a neighbor z ∈ V of x with δ P (z) = 2, remove every (u, v) ∈ V 2 such that z is not a neighbor of u from C i .
Proof For any C i , if any of the removed pairs were selected into P ′ , then the distance of z to P ′ would be d G (z, P ′ ) = 2 and therefore ecc G (P ′ ) > 1.
We have shown how to construct a shortest path with eccentricity at most k by solving the CSC problem, even if k = 1. Finally, we observe that such a path can be constructed even if one or both of its endpoints are in V . Lemma 14 If P has an endpoint s ∈ V , its neighbor t ∈ P might also be in V . Let P = (s, t, . . . ). We may obtain a path P ′ with ecc G (P ′ ) ≤ k by removing Ψ(s, s) (and Ψ(t, t) if t ∈ V ) from R P , finding s h1 , . . . , s h ℓ by solving the CSC, and prepending s (and t if t ∈ V ) to P ′ . Proof All vertices in L P are on P ′ , and, thanks to the way we chose s h1 , . . . , s h ℓ , all vertices in R P i are at distance i from either s, t, or one of s h1 , . . . , s h ℓ . Thus, the same argument as in the proof of Lemma 11 applies. MESP can be solved by trying all possible combinations of (L, s, R) : L ⊆ U, s ∈ L, R = R 1 ∪ R 2 ⊆ (U \ L). For each combination, do: 1. Find a permutation π of L, such that π 1 = s and . If it does not exist, continue with the next combination. 2. For each h i ∈ h π : create set C hi according to Definition 8 and Corollary 13. 3. Solve the CSC instance as described in Lemma 11. 4. If the CSC instance has a solution, construct path P ′ as in Lemma 11. 5. Check if ecc G (P ′ ) ≤ k. If yes, return P ′ . If not, try the same after prepending and/or appending all combinations of single vertices and of pairs of vertices to P ′ (see Lemma 14). Note that by Lemma 2, there is at most one such permutation π in step 1.

Theorem 15
In a graph with distance to cluster graph p, MESP can be solved in O(2 4p p · n 6 ) time.
Proof First, we precompute a distance matrix in O(n 3 ) time. There are at most O(4 p · n) different combinations of (L, s, R 1 , R 2 ). By Lemma 2, step 1 can be implemented in O(p log p) time. In step 2, there are at most O(p) sets C hi and each of these can be constructed in O(n+m) time. In step 3, the CSC instance can be solved by Algorithm 1 in O(2 2p pn 2 ) time as |R| ≤ p and |C| ≤ n 2 .
Step 4 can be implemented in O(n) time. In step 5, there are at most O(n 4 ) combinations of vertices to prepend/append, and checking the length of the resulting path and its eccentricity can be implemented in O(n) time using the precomputed distance matrix.

Distance to Disjoint Paths
In this subsection, we present an fpt-algorithm for MESP parameterized by the distance to disjoint paths and the desired eccentricity, combined. While the existence of such an fpt-algorithm is implied by the results of Subsection 3.5, the treewidth algorithm uses Courcelle's theorem and, as such, is rather of classification nature. In comparison, in this section, we present an explicit algorithm with moderate dependency on the parameters.
The high-level idea of the algorithm is similar to that in Subsection 3.3. We iteratively guess (by trying all possible combinations), for each vertex in the modulator to disjoint paths C, what is the distance to the desired shortest path. Then, we try to find a shortest path which satisfies all the guessed distance requirements by solving an instance of the CSC problem. We argue that if these requirements are guessed correctly, the resulting path will indeed be the desired MESP.
We start by discussing some properties of graphs in which a shortest path P = (p 1 , . . . , p |P | ) with ecc G (P ) ≤ k does exist. Assume that P is such a path, fixed for the next few lemmas and definitions.
Definition 9 Let C P = C ∪ {p 1 , p |P | }. Let L P = P ∩ C P . We denote π P = (π P 1 , . . . , π P |L P | ) the permutation/order of vertices from L P on the path P . We define function δ P (v) = d G (v, P ) for every v ∈ V .
Let C, L be candidates for C P , L P , respectively. Similarly as in Subsection 3.3, the permutation π = (π 1 , . . . , π |L| ) of the vertices in L is unique (if it exists), and can be found in polynomial time. For each consecutive pair of vertices π i , π i+1 ∈ L, there may be multiple shortest paths connecting them, such that they do not contain any other vertices from C. Exactly one of these shortest paths is contained in P for each pair. We sayσ is a candidate segment if it is a sequence of vertices on some shortest path from π i to π i+1 excluding the endpoints π i , π i+1 andσ ∩ C = ∅. We define S(π i , π i+1 ) as a set of all candidate segmentsσ between π i and π i+1 . We denote S = |L|−1 i=1 S(π i , π i+1 ) the set of all candidate segments in G. We say that a candidate segment σ ∈ S is a necessary segment if it must be part of any shortest path P ′ such that C = C P ′ , L = L P ′ , π = π P ′ , and ecc G (P ′ ) ≤ k.
Intuitively, if we had the correct values of π, we would only need to select one segment out of each S(π i , π i+1 ) for i ∈ {1, . . . , |L|−1}, in order to construct the path P . To do so, we need the following function, which estimates the distance from a vertex to the path P .
Definition 10 (estimate distance to P ) For a graph G = (V, E), a set of vertices C ⊆ V and a function δ : Observation 16 If C = C P and δ = δ P | C (that is, the restriction of δ P to C) for some shortest path P in G, then for every Proof By definition, for any v ∈ V , there is some s ∈ C such that d δ If we had the correct values for the permutation π of vertices from C that are on P , we would still have to take care of those vertices v ∈ V with d e G (v, C) > k, in order to solve MESP. In particular, we would have to choose a segment from each S(π i , π i+1 ) in a way that for every vertex v with d e G (v, C) > k, there would be some chosen segment at distance at most k from v. We say that a candidate segmentσ . We continue by showing that the number of vertices v with d δ G (v, C) > k which do not lie on P is bounded by the size of L.
Proof Let v ∈ D and u ∈σ be the nearest vertex to v on segmentσ. There is a shortest path from u to v which does not contain any vertex from C (if it did, then d δ G (v, C) = d G (v, P ) ≤ k). Because G \ C is a union of disjoint paths and it contains the whole segmentσ as well as the path from u to v, these two paths must be connected through their endpoints. Neither of the endpoints is in C, so no more than two such connections can be present in G (see Figure 2).
We have shown that there are not many vertices v / ∈ P with d δ P G (v, C P ) > k. Now, we show that all such vertices actually have d δ P G (v, C P ) = k + 1.

Lemma 19
Let P be a shortest path in G with ecc G (P ) ≤ k. Let v ∈ V be such that d δ P G (v, C P ) ≥ k + 1. Let u ∈ P be the nearest vertex to v on P . Then either u = v, or d G (u, v) = k and d G (u, C P ) = 1.
Proof If v ∈ P , then the nearest vertex on P is itself, so u = v. Suppose that v / ∈ P (see Figure 3). There is no vertex from C P on any shortest path between v and u (otherwise d δ P G (v, C P ) ≤ d G (v, u) ≤ k). In particular, u / ∈ C P , therefore, u has exactly 2 neighbors on P . It also has at least one neighbor outside of P , through which it is connected to v. In G \ C P , u must have at most 2 neighbors, thus at least one of its neighbors on P is in C P . Because L P = P ∩ C P , we get d G (u, L P ) = 1. Then, from Let v ∈ V \ P be such that d δ P G (v, C P ) = k + 1 and S ⊆ S be a set of candidate segments that satisfy v. As shown in Figure 3, there may be multiple such segments in S. However, if v itself lies on some segment, then only segments in the same S(π i , π i+1 ) may satisfy v. Observation 20 Let P be a shortest path in G with ecc G (P ) ≤ k. Let σ ∈ S(π P i , π P i+1 ) be a candidate segment that contains some vertex u such that d δ P G (u, C P ) = k + 1. Let u ′ ∈ P be the nearest vertex to u on P . Then u ′ lies on a segment σ ∈ S(π P i , π P i+1 ).
We already know from Lemma 19 that if a candidate segment contains some vertex v with d δ G (v, C) > k + 1, then it is a necessary segment. Now, we show another sufficient condition for a candidate segment to be a necessary segment.
Proof Suppose thatσ is not a necessary segment, let P be a shortest path in G with ecc G (P ) ≤ k, C = C P , L = L P , π = π P , and δ P | C P = δ and let σ ∈ S(π i , π i+1 ) be a part of P , σ =σ. By Lemma 19 there must be some vertices u ′ , v ′ ∈ P with d G (u, u ′ ) = d G (v, v ′ ) = k. By Observation 20, both u ′ and v ′ are in σ. No shortest path between u and u ′ , contains any vertex from C (otherwise d δ G (u, C) ≤ d G (u, u ′ ) = k). The same applies for any shortest path between v and v ′ . Thus, in G \ C, u is connected to v, v is connected to v ′ , v ′ is connected to u ′ , and u ′ is connected to u. Due to the length constraints, all these paths are disjoint (except for their endpoints). There is a cycle in G \ C, which is a contradiction with C being a modulator to disjoint paths.
Finally, we propose an algorithm that solves MESP. It finds the correct values for p 1 , C, L, and δ : C → {0, . . . , k} by trying all possible combinations. For each combination, it performs the following steps.
1. Find a permutation π of L, such that π 1 = p 1 and . If it does not exist, continue with the next combination. 2. For each π i , π i+1 , check all candidate segments in S(π i , π i+1 ).
(a) If there are any segments containing a vertex u with d δ G (u, C) = k +1, then we may disregard all candidate segments which do not satisfy u. (b) After disregarding these segments, if there is only one candidate segment left, it is a necessary segment. If there is no candidate segment left, then no solution exists. 3. If there is a vertex v such that d δ G (v, C) > k + 1, and it does not lie on a segment that we have marked as a necessary segment, then no solution exists. 4. Construct the set U of vertices v that are not contained in any segment and have d δ G (v, C) = k + 1. If |U | > 2(|L| − 1), then no solution exists. 5. Choose the rest of the segments from all candidate segments (except those disregarded in step 1) by solving the CSC instance, with requirements u ∈ C \ L whose distance to the parts of P selected so far is greater than δ(u), and all of U . 6. If the CSC instance has a solution, construct a path from π and from the chosen candidate segments. If the resulting path has eccentricity at most k, return it. Note that by Lemma 2, there is at most one such permutation π in step 1. We arrive at the following theorem.
Theorem 23 For a graph with distance to disjoint paths c, MESP can be solved in O(2 5c k c c · n 4 ).

Proof
The distances between all pairs of vertices can be precomputed in O(n 3 ) time.
There are at most O(n 2 ) possible combinations for the first and last vertex on the path giving C. For each of them, there at most O(2 c k c ) possible values of L and δ.
By Lemma 2, step 1 can be implemented in O(c log c) time.
In step 2, we iterate over i ∈ {1, . . . , |L − 1|}, and each time we find a set K of all such vertices u that lie on some segmentσ ∈ S(π i ,π i+1 ) and have d δ G (u, C) = k + 1. The set can be constructed in O(n + m) time. Because of Lemma 21, at most two vertices need to be stored in K for each candidate segment. Thus, by Lemma 17, each segment will satisfy at most four vertices from K (two lying on the segment, and two outside the segment). If |K| > 4, we know right away that there is no solution for the current configuration of (L, π, δ). Otherwise, we construct the set C i of candidate segments which satisfy all vertices from K in O(n + m) time by iterating over all vertices in all the candidate segments and checking at most 4 conditions for each vertex. Thus, the complexity of step 2 is O(cn 2 ).
Steps 3 and 4 can be performed in one loop, taking O(cn) time.
The CSC instance in step 5 can be solved by Algorithm 1 in O(2 4c cn) time as |C| = O(n) and In step 6, constructing the path and checking its eccentricity takes at most O(n) time.

Treewidth
In this section, we show that the MESP problem is FPT with respect to the combination of treewidth and the desired eccentricity. We present a proof which uses Courcelle's theorem. Although this result has theoretical significance and the proof is constructive, the multiplicative constants of the resulting algorithm are too high for it to be useful in practice, even for graphs with treewidth 1.
To use Courcelle's theorem, properties of graphs are usually described using the fragment of logic called monadic second-order logic (MSOL). The graph is described using a universe consisting of vertices and edges, unary predicates distinguishing between these two and two binary predicates adj and inc, describing the adjacencies between vertices and incidencies between vertices and edges, respectively. MSOL allows quantification over individual vertices and edges and over sets of vertices and edges, membership queries, and standard logical operators.
We use the following extension of Courcelle's theorem.
There is an fpt-algorithm that decides for any given G, T, β, ϕ whether G |= ϕ in time O (f (t, |ϕ|) · n) for some computable function f . Moreover, if ϕ contains a free variable S, it is possible to find a set S ′ such that (G, S ′ ) |= ϕ(S), and |S ′ | is minimal, in the same running time.
Lemma 25 For any given graph G = (V, E), desired eccentricity k ∈ N and two vertices s, t ∈ V , there is an MSOL formula ϕ(S) of length O(k) such that a shortest s-t path P in G with ecc G (P ) ≤ k exists if and only if there is an assignment S ′ ⊆ V to S such that G |= ϕ(S ′ ) and |S ′ | = d G (s, t) + 1. Moreover, S ′ = V (P ).
Proof We need to find an MSOL formula with a free variable S ⊆ V such that it is satisfied if and only if there exists an s-t path on the vertices of S with eccentricity at

Maximum Leaf Number
Theorem 27 There is an algorithm that solves MESP in O(16 ℓ · n 3 ) time, where ℓ is the maximum leaf number of the input graph.
We use the following lemma to show that the problem can be solved by brute-force.
Lemma 28 (Bouland [19]) If the maximum leaf number of a graph G is equal to ℓ, then G is a subdivision of a graph G = (C, E), such that C ⊆ V and |C| < 4ℓ.
Our algorithm will in fact check all the shortest paths in G to find the one with the smallest eccentricity. It remains to show an upper bound on the number of shortest paths in G.
Lemma 29 Let {s, t} ⊆ V and L ⊆ C. Then, there is at most one shortest s-t path P in G such that P ∩ C = L.
Proof By Lemma 2 there is at most one permutation π of the vertices from L which corresponds to the order on some shortest path starting in s.
Between each pair of vertices in C there is at most one path in G not containing internal vertices from C, since G is a subdivision of G and G is a simple graph. By the same argument, there is also at most one path from s to π 1 , and at most one path from π |L| to t.
Corollary 30 There are at most 2 4ℓ · n 2 distinct shortest paths in G.
All the shortest paths in G may be found exactly the same way as in Subsection 3.1. Again, with a precomputed distance matrix, finding each shortest path will take at most O(n) time, as well as checking its eccentricity. This finishes the proof of Theorem 27.

Future Directions
We have shown that MESP is fixed-parameter tractable with respect to several structural parameters. This partially answers an open question of Dragan and Leitert [7] on classes where the problem is polynomial time solvable, as this is the case whenever we limit ourselves to a class where one of the studied parameters is a constant.
The natural next steps in the research of parameterized complexity of MESP would be to investigate the existence of fpt-algorithms with respect to the distance to disjoint paths alone, and with respect to treewidth alone.