Keywords

1 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) whose distance to all other vertices in the graph 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 [7]. Some large graphs constructed from reads similarity networks of genomic data appear to have very long shortest paths with low eccentricity [17]. Furthermore, MESP can be used to obtain the best to date approximation for a minimum distortion embedding of a graph into the line [7] which has applications in computer vision [16], computational biology and chemistry [11, 12]. The eccentricity of MESP is closely tied to the notion of laminarity (minimum eccentricity of the graph’s diameter) [1].

MESP was introduced by Dragan and Leitert [7] 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 \(\mathcal {O}(n^{2k+2}m)\) time. They also presented a linear-time algorithm for trees. Additionally, they developed a 2-approximation, a 3-approximation, and an 8-approximation algorithm that runs in \(\mathcal {O}(n^3)\) time, \(\mathcal {O}(nm)\) time, and \(\mathcal {O}(m)\) time, respectively. Birmelé et al. [1] further improved the 8-approximation to a 3-approximation, which still runs in linear time. Dragan and Leitert [8] 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 [9] 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^{\mathcal {O}(k)}\) time. A related problem of finding shortest isometric cycle was studied by Birmelé et al. [3]. Birmelé et al. [2] studied a generalization of MESP, where the task is to decompose a graph into subgraphs with bounded shortest-path eccentricity, the hub-laminar decomposition.

Fig. 1.
figure 1

Hasse diagram of the boundedness relation between structural parameters explored in this paper and related ones. An edge between a parameter \(\boldsymbol{A}\) above and a parameter \(\boldsymbol{B}\) below means that whenever \(\boldsymbol{A}\) is bounded for some graph class, then so is \(\boldsymbol{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. The complexity for parameters in gray is open. (Color figure online)

Our Contribution. We continue the research direction of MESP in structured graphs [8], focusing on parameters which can measure the amount of structure present in the graph. As treewidth, the most famous of such measures, remains out of reach, we focus on parameters providing even more structure (see [14] for an overview of some graph measures). 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, and maximum leaf number (see Fig. 1 for an overview of our results).

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

Proofs omitted in this extended abstract due to space restrictions can be found in the full version of the paper, preprint is available on Ar**v [13].

2 Preliminaries

We consider finite connected unweighted undirected simple loopless graphs.

We refer to Diestel [6] for graph notions.

For a graph \(G = (V, E)\) we denote \(n = |V|\) and \(m = |E|\). We denote G[S] the induced subgraph of G on vertices \(S \subseteq V\) and \(G\) \(\setminus \) \(S = G[V\) \(\setminus \) \(S]\).

We denote an ordered sequence of elements \(\boldsymbol{s} = (s_1, \dots , s_{|\boldsymbol{s}|})\). For two sequences \(\boldsymbol{s} = (s_1, \dots , s_{|\boldsymbol{s}|}), \boldsymbol{t} = (t_1, \dots , t_{|\boldsymbol{t}|})\) we denote their concatenation

$$ \boldsymbol{s} \frown \boldsymbol{t} = (s_1, \dots , s_{|\boldsymbol{s}|}, t_1, \dots , t_{|\boldsymbol{t}|}). $$

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 \in V\) is the length of the shortest u-v-path.

The distance between a vertex \(u \in V\) and a set of vertices \(S \subseteq V\) is \(d_G(u, S) = \min _{s \in S}d_G(u, s)\). The eccentricity of a set \(S \subseteq V\) is \(\mathrm{ecc}_G(S) = \max _{u \in 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 \(\mathrm{ecc}_G(P) = \mathrm{ecc}_G(V(P))\).

For vertex \(u \in V\) we denote \(N_G(u)=\{v \mid \{u,v\} \in E\}\) the open neighborhood, \(N_G[u]=N_G(u) \cup \{u\}\) the closed neighborhood, and \(N_G^k[u] = \{v \in V \mid d_G(u, v) \le k\}\) the closed k-neighborhood of u.

In this paper, we focus on the following problem.

figure a

A parameterized problem \(\Pi \) is fixed parameter tractable (FPT) with respect to a parameter k if there is an algorithm solving any instance of \(\Pi \) with size n in \(f(k) \cdot n^{O(1)}\) time for some computable function f. Such an algorithm is called a parameterized or an fpt algorithm. See Cygan et al. [5] 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, [10]). 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 \(\big (V(G_1) \cup V(G_2), E(G_1) \cup E(G_2)\big )\));

  • (O3) the complete join of 2 disjoint graphs (the complete join of graphs \(G_1\) and \(G_2\) is the graph \(\big (V(G_1) \cup V(G_2), E(G_1) \cup E(G_2) \cup \big \{ \{v,w\} \mid v \in V(G_1), w \in V(G_2) \big \}\big )\));

  • (O4) the substitution with respect to some pattern graph T (for a graph T with vertices \(t_1,\dots ,t_n\) and disjoint graphs \(G_1,\dots ,G_n\) the substitution of the vertices of T by the graphs \(G_1,\dots ,G_n\) is the graph with vertex set \(\bigcup _{i=1}^n V(G_i)\) and edge set \(\bigcup _{i=1}^n E(G_i) \cup \big \{ \{u,v\} \mid u \in V(G_i), v \in V(G_j) , and \{t_i, t_j\} \in E(T) \big \}\)).

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 \(\mathrm{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=(V,E)\), an algebraic expression of width \(\mathrm{mw}(G)\) describing G can be constructed in \(O(|V|+|E|)\) time [15].

Definition 2

(Distance to cluster graph). For a graph \(G = (V, E)\), a modulator to cluster graph is a vertex subset \(X \subseteq V\) such that \(G\) \(\setminus \) \(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 \(\mathcal {O}\big (1.9102^p \cdot (n+m)\big )\) time [4].

Definition 3

(Distance to disjoint paths). For a graph \(G = (V, E)\) a modulator to disjoint paths is a vertex subset \(X \subseteq V\), such that \(G\) \(\setminus \) \(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

( \(\star \)Footnote 1). The modulator to disjoint paths C of a graph G with distance to disjoint paths c can be found in \(\mathcal {O}\big (4^c(n+m)\big )\) time.

Definition 4

(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 \subseteq V\), and any vertex \(s \in V\), at most one permutation \(\boldsymbol{\pi }= (\pi _1, \dots , \pi _{|S|})\) of the vertices in S exists, such that there is a shortest path P with the following properties:

  1. 1.

    The first vertex on P is s,

  2. 2.

    P contains all vertices from S, and

  3. 3.

    the vertices from S appear on P in exactly the order given by \(\boldsymbol{\pi }\).

Moreover, given a precomputed distance matrix for G, the permutation \(\boldsymbol{\pi }\) can be found in \(\mathcal {O}(|S| \log |S|)\) time.

Proof

For the sake of deriving a contradiction, suppose that there are two different permutations \(\boldsymbol{\pi }\) and \(\boldsymbol{\pi }'\) satisfying the conditions, and let \(P, P'\) be the respective shortest paths. Let \(i \in \{1, \dots , |S| - 1\}\) be the first position such that \(\pi _i \ne \pi '_i\) and let \(j \in \{2, \dots , |S|\}\) be the position of \(\pi _i\) in \(\boldsymbol{\pi }'\) (clearly, \(j > i\)). Let \(P_1\) be the subpath of P from s to \(\pi _i\), and \(P'_2\) the subpath of \(P'\) from \(\pi '_j\) to \(\pi '_{|S|}\) (excluding the first vertex \(\pi '_j\)). Then, \(P'' = P_1 \frown 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 \(\boldsymbol{\pi }\). It corresponds to some shortest path P if and only if

$$d_G(s, \pi _1) + \textstyle \sum _{i=1}^{|S| - 1}d_G(\pi _i, \pi _{i+1}) = d_G(s, \pi _{|S|}).$$

   \(\square \)

3 Parameterized Algorithms

In this section, we present several fpt algorithms for MESP. In Subsect. 3.1, we present an algorithm parameterized by the modular width. In Subsect. 3.2 we define the Constrained Set Cover (CSC) problem. In Subsect. 3.3 we show an fpt algorithm for MESP parameterized by the distance to cluster graph which reduces MESP to CSC. In Subsect. 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. Subsect. 3.5 presents an algorithm parameterized by the maximum leaf number.

3.1 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, \dots , v_w\}\) and the substituted graphs are \(G_1, \dots , G_w\), then we suppose that \(w \ge 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

( \(\star \) ). 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 \in \{1, \dots , w\}\).

Now, we show that with respect to eccentricity, all vertices in the same graph \(G_i\) are equivalent. I.e., a minimum eccentricity shortest path in G can be found by trying all shortest paths in T.

Lemma 4

( \(\star \) ). Let P be a shortest path in G and \(p \in P \cap G_i\). We create a path \(P'\) by substituting p in P by any \(p' \in G_i\). Then, \(\mathrm{ecc}_G(P') = \mathrm{ecc}_G(P)\).

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 \(\boldsymbol{\pi }\) in T. For each of them and each \(i \in \{1, \dots , |\boldsymbol{\pi }|\}\) we let \(p_i \in G_{\pi _i}\) arbitrarily, and let \(P := (p_1, \dots , p_{|\boldsymbol{\pi }|})\). 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 may 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 1

There is an algorithm that solves MESP in \(\mathcal {O}(2^w \cdot n^3)\) time, where w is the modular width of the input graph.

3.2 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.

figure b

Each candidate can be thought of as a set of (satisfied) requirements. Hence, if we drop the constraints \(s_i \in C_i\), we get the ordinary Set Cover. In our definition several candidates can satisfy the same set of requirements.

In the next two subsections we use the following lemma.

Lemma 5

( \(\star \) ).Constrained Set Cover can be solved in \(\mathcal {O}(2^{2|\mathcal {R}|} |\mathcal {R}| \cdot |\mathcal {C}|)\) time.

3.3 Distance to Cluster Graph

In this subsection, we present an fpt algorithm for MESP parametrized 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\) \(\setminus \) \(U\), u and v have the same neighborhood in \(G\) \(\setminus \) \(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 \(\mathcal {R}_1\) or \(\mathcal {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 \(\mathcal {R}_1, \mathcal {R}_2\) have the respective distance from the path. Finding such a path is reduced to solving the CSC problem presented in Subsect. 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 6

( \(\star \) ). Let G be a graph with modulator to cluster graph U and let P be a shortest path with \(\mathrm{ecc}_G(P) = k\). Then, there exists a shortest path \(P'\) such that it contains at least one vertex from U and \(\mathrm{ecc}_G(P') \le k\).

Definition 5

Let G be a graph with a modulator to cluster graph U. Let P be a shortest path in G with \(\mathrm{ecc}_G(P) \le k\) and \(U\cap P \ne \emptyset \). We denote \(L^P = P \cap U\) and \(\boldsymbol{\pi }^P = (\pi _1^P, \dots , \pi _{|L^P|}^P)\) the permutation/order of vertices from \(L^P\) in which they appear on the path P. We denote \(\mathcal {R}^P_i = \{u \in U \mid d_G(u, P) = i\}\) the set of vertices in U that are at distance i from P, for \(i \in \{1, 2\}\).

Let \(V= V(G)\) \(\setminus \) \(U\). Since G[V] is a disjoint union of cliques, and for every \(i \in \{1, \dots , |L^P| - 1\}\), all vertices that are between \(\pi ^P_i\) and \(\pi ^P_{i+1}\) on P are from V, we have \(d_G(\pi ^P_i, \pi ^P_{i+1}) \le ~3\), as otherwise P would not be a shortest path.

Let \(\boldsymbol{\pi } = (\pi _1, \dots , \pi _{|\boldsymbol{\pi }|})\) be a candidate (guess) on the value of \(\boldsymbol{\pi }^P\). Intuitively, if we had the correct values of \(\boldsymbol{\pi }=\boldsymbol{\pi }^P\), we would only need to select the (at most two) vertices between each \(\pi _i, \pi _{i+1}\).

To help us refer to those pairs \(\pi _i, \pi _{i+1}\) between which we still need to choose some vertices we denote \(\boldsymbol{h}_{\pi } = (h_1, \dots , h_\ell )\) the increasing sequence of all indices i such that \(\{\pi _i, \pi _{i+1}\} \notin E\). For every \(i \notin \boldsymbol{h}_{\pi }\), we have \(\{\pi _i, \pi _{i+1}\} \in E(G)\) and, thus, there is no vertex between \(\pi _i\) and \(\pi _{i+1}\) on P. For every \(h_i \in \boldsymbol{h}_{\pi }\): If \(d_G(\pi _{h_i}, \pi _{h_i+1}) = 2\), then there is one vertex on P between \(\pi _{h_i}\) and \(\pi _{h_i+1}\), and it is from V. If \(d_G(\pi _{h_i}, \pi _{h_i+1}) = 3\), then there are two vertices from V on P between \(\pi _{h_i}\) and \(\pi _{h_i+1}\).

Definition 6

We define the set \(C_{h_i}\) of candidate vertices between \(\pi _{h_i}\) and \(\pi _{h_i+1}\) for each \(h_i \in \boldsymbol{h}_\pi \).

$$C_{h_i} = {\left\{ \begin{array}{ll} \Big \{(u, u) \in V^2 \mid \big \{\{\pi _{h_i}, u\}, \{u, \pi _{h_i+1}\}\big \} \subseteq E\Big \} &{} \text {if } d_G(\pi _{h_i}, \pi _{h_i+1}) = 2\\ \Big \{(u, v) \in V^2 \mid \big \{\left\{ \pi _{h_i}, u\right\} , \{u, v\}, \{v, \pi _{h_i+1}\}\big \} \subseteq E\Big \} &{} \text {if } d_G(\pi _{h_i}, \pi _{h_i+1}) = 3\\ \ \emptyset &{} \text {otherwise} \end{array}\right. }$$

For \(h_i \in \boldsymbol{h}_\pi \) with \(d_G(\pi _{h_i}, \pi _{h_i+1}) = 2\), the set \(C_{h_i}\) contains pairs of the same vertices (uu). To avoid adding some vertex into a path twice, we define a function \(\mu \) which maps a pair of two elements to a sequence of length 1 or 2:

$$\mu (u, v) = {\left\{ \begin{array}{ll} (u) &{} \text {if } u = v,\\ (u, v) &{} \text {if } u \ne v. \end{array}\right. }$$

To solve MESP, we need to choose exactly one pair from each of \(C_{h_1}, \dots , C_{h_\ell }\). Later, we show that the problem of choosing these pairs is an instance of CSC.

First, we define a function \(\delta ^P: U \cup V \rightarrow \mathbb {N}\) that will help us prove that the path constructed from the CSC solution will have a small eccentricity:

$$\begin{aligned} \delta ^P(u) = \min \big \{d_G(u, L^P),\ d_G(u, \mathcal {R}^P_1) + 1,\ d_G(u, \mathcal {R}^P_2) + 2\big \}. \end{aligned}$$

Lemma 7

( \(\star \) ). Function \(\delta ^P\) is a good estimate of the distance from P:

  1. 1.

    \(\delta ^P(u) = d_G(u, P)\) for every \(u \in U\), and

  2. 2.

    \(\delta ^P(u) = d_G\big (u, P\) \(\setminus \) \((N_G[u] \cap V)\big )\) for every \(u \in V\).

Now we show how to choose optimal vertices from each \(C_i\) by solving CSC.

Lemma 8

( \(\star \) ). Suppose that P is a shortest path in G with \(\mathrm{ecc}_G(P) \le k\), both endpoints of P are in U, and we have the corresponding values of \(L^P, \pi ^P, \mathcal {R}^P_1, \mathcal {R}^P_2\) as described in Definition 5. Let \(\boldsymbol{h}_{\pi ^P} = (h_1, \dots , h_\ell )\) and \((s_{h_1}, \dots , s_{h_\ell })\) be a solution of the CSC instance with requirements \(\mathcal {R}^P = \mathcal {R}^P_1 \cup \mathcal {R}^P_2\), sets of candidates \(\mathcal {C} = C_{h_1} \cup \dots \cup C_{h_\ell }\), and function \(\varPsi (u, v) = N_G(u) \cup N_G(v) \cup \Big (\big (N_G^2[u] \cup N_G^2[v]\big ) \cap \mathcal {R}^P_2\Big )\). Then

$$\begin{aligned} P' =&\ (\pi ^P_1, \dots , \pi ^P_{h_1}) \frown \mu (s_{h_1}) \frown (\pi ^P_{h_1+1}, \dots , \pi ^P_{h_2}) \\ \dots \frown&\ \mu (s_{h_i}) \frown (\pi ^P_{h_i+1}, \dots , \pi ^P_{h_{i+1}}) \frown \mu (s_{h_{i+1}}) \\ \dots \frown&\ (\pi ^P_{h_{\ell -1}+1}, \dots , \pi ^P_{h_\ell }) \frown \mu (s_{h_\ell }) \frown (\pi ^P_{h_\ell +1}, \dots , \pi ^P_{|L^P|}) \end{aligned}$$

is a shortest path and \(\mathrm{ecc}_G(P') \le \max \{2, k\}\).

Clearly, if \(k \ge 2\), then we can use Lemma 8 to construct a shortest path with eccentricity at most k. Now, we discuss the case when \(k = 1\).

Observation 1

( \(\star \) ). If \(\mathrm{ecc}_G(P) = 1\), then for every \(u \in U \cup V\) we have \(\delta ^P(u) \le ~2\).

Corollary 1

( \(\star \) ). If \(\mathrm{ecc}_G(P) = 1\), then a path \(P'\) with \(\mathrm{ecc}_G(P') \le 1\) can be constructed similarly as in Lemma 8 with the following modification. For each candidate set \(C_i\) which contains some pair \((x, y) \in V^2\) such that there is a neighbor \(z \in V\) of x with \(\delta ^P(z) = 2\), remove every \((u, v) \in V^2\) such that z is not a neighbor of u from \(C_i\).

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 9

( \(\star \) ). If P has an endpoint \(s \in V\), its neighbor \(t \in P\) might also be in V. Let \(P = (s, t, \dots )\). We may obtain a path \(P'\) with \(\mathrm{ecc}_G(P') \le k\) by removing \(\varPsi (s,s)\) (and \(\varPsi (t,t)\) if \(t \in V\)) from \(\mathcal {R}^P\), finding \(s_{h_1}, \dots , s_{h_\ell }\) by solving the CSC, and prepending s (and t if \(t \in V\)) to \(P'\).

MESP can be solved by trying all possible combinations of \((L, s, \mathcal {R}): L \subseteq U, s \in L, \mathcal {R} = \mathcal {R}_1 \cup \mathcal {R}_2 \subseteq (U\) \(\setminus \) \(L)\). For each combination, do:

  1. 1.

    Find a permutation \(\boldsymbol{\pi }\) of L, such that \(\pi _1 = s\) and \(\sum _{i=1}^{|L| - 1}d_G(\pi _i, \pi _{i+1}) = d_G(\pi _1, \pi _{|L|})\). If it does not exist, continue with the next combination.

  2. 2.

    For each \(h_i \in \boldsymbol{h}_{\pi }\): create set \(C_{h_i}\) according to Definition 6 and Corollary 1.

  3. 3.

    Solve the CSC instance as described in Lemma 8.

  4. 4.

    If the CSC instance has a solution, construct path \(P'\) as in Lemma 8.

  5. 5.

    Check if \(\mathrm{ecc}_G(P') \le 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 9).

Note that by Lemma 2, there is at most one such permutation \(\boldsymbol{\pi }\) in step 1.

Theorem 2

( \(\star \) ). In a graph with distance to cluster graph p, MESP can be solved in \(\mathcal {O}(2^{4p}p \cdot n^6)\) time.

3.4 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.

The high-level idea of the algorithm is similar to that in Subsect. 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, \dots , p_{|P|})\) with \(\mathrm{ecc}_G(P) \le k\) does exist. Assume that P is such a path, fixed for the next few lemmas and definitions.

Definition 7

Let \(\widehat{C}^P = C \cup \{p_1, p_{|P|}\}\). Let \(L^P = P \cap \widehat{C}^P\). We denote \(\boldsymbol{\pi }^P = (\pi ^P_1, \dots , \pi ^P_{|L^P|})\) the permutation/order of vertices from \(L^P\) on the path P. We define function \(\delta ^P(v) = d_G(v, P)\) for every \(v \in V\).

Let \(\widehat{C}\), L be candidates for \(\widehat{C}^P\), \(L^P\), respectively. Similarly as in Subsect. 3.3, the permutation \(\boldsymbol{\pi }= (\pi _1, \dots , \pi _{|L|})\) of the vertices in L is unique (if it exists), and can be found in polynomial time. For each consecutive pair of vertices \(\pi _i, \pi _{i+1} \in L\), there may be multiple shortest paths connecting them, such that they do not contain any other vertices from \(\widehat{C}\). Exactly one of these shortest paths is contained in P for each pair. We say \(\bar{\sigma }\) is a candidate segment if it is a sequence of vertices on some shortest path from \(\pi _i\) to \(\pi _{i+1}\) excluding the endpoints \(\pi _i, \pi _{i+1}\) and \(\bar{\sigma }\cap \widehat{C} = \emptyset \). We define \({\mathcal {S}}(\pi _i, \pi _{i+1})\) as a set of all candidate segments \(\bar{\sigma }\) between \(\pi _i\) and \(\pi _{i+1}\). We denote \(\widetilde{\mathcal {S}} = \bigcup _{i=1}^{|L| - 1}{\mathcal {S}}(\pi _i, \pi _{i+1})\) the set of all candidate segments in G. We say that a candidate segment \(\sigma \in \widetilde{\mathcal {S}}\) is a necessary segment if it must be part of any shortest path \(P'\) such that \(\widehat{C}=\widehat{C}^{P'}\), \(L = L^{P'}\), \(\boldsymbol{\pi }= \boldsymbol{\pi }^{P'}\), and \(\mathrm{ecc}_G(P') \le k\).

Intuitively, if we had the correct values of \(\boldsymbol{\pi }\), we would only need to select one segment out of each \({\mathcal {S}}(\pi _i, \pi _{i+1})\) for \(i \in \{1, \dots , |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 8

(estimate distance to P). For a graph \(G = (V, E)\), a set of vertices \(\widehat{C} \subseteq V\) and a function \(\delta : \widehat{C} \rightarrow \mathbb {N}\) we define \(d_G^\delta : V \times 2^{\widehat{C}} \rightarrow \mathbb {N}\) as

$$d_G^\delta (v, S) = \min _{s \in S}d_G(v, s) + \delta (s).$$

Observation 2

( \(\star \) ). If \(\widehat{C}= \widehat{C}^P\) and \(\delta =\delta ^P|_{\widehat{C}}\) (that is, the restriction of \(\delta ^P\) to \(\widehat{C}\)) for some shortest path P in G, then for every \(v \in V\) we have \(d_G(v, P) \le d_G^\delta (v, \widehat{C})\). In particular, if \(d_G^\delta (v, \widehat{C}) \le k\), then \(d_G(v, P) \le k\).

If we had the correct values for the permutation \(\boldsymbol{\pi }\) of vertices from \(\widehat{C}\) that are on P, we would still have to take care of those vertices \(v \in V\) with \(d_G^e(v, \widehat{C}) > k\), in order to solve MESP. In particular, we would have to choose a segment from each \({\mathcal {S}}(\pi _i, \pi _{i+1})\) in a way that for every vertex v with \(d_G^e(v, \widehat{C}) > k\), there would be some chosen segment at distance at most k from v. We say that a candidate segment \(\bar{\sigma }\in \widetilde{\mathcal {S}}\) satisfies \(v \in V\) \(\setminus \) \(\widehat{C}\) if \(d_G(v, \bar{\sigma }) \le k < d_G^\delta (v, \widehat{C})\).

We continue by showing that the number of vertices v with \(d_G^\delta (v, \widehat{C}) > k\) which do not lie on P is bounded by the size of L.

Lemma 10

( \(\star \) ). Let \(\bar{\sigma }\in \widetilde{\mathcal {S}}\) be a candidate segment and \(D = \{v \in V\) \(\setminus \) \(P \mid \bar{\sigma }\) satisfies \(v\}\). Then \(|D| \le 2\).

Corollary 2

Let P be a shortest path in G with \(ecc_G(P) \le k\). Let \(U = \{v \in V\) \(\setminus \) \(P \mid d_G^{\delta ^P}(v, \widehat{C}^P) > k\}\). There are \(|L^P| - 1\) segments on P, therefore \(|U| \le 2(|L^P| - 1)\).

We have shown that there are not many vertices \(v \notin P\) with \(d_G^{\delta ^P}(v, \widehat{C}^P) > k\). Now, we show that all such vertices actually have \(d_G^{\delta ^P}(v, \widehat{C}^P) = k + 1\).

Lemma 11

( \(\star \) ). Let P be a shortest path in G with \(ecc_G(P) \le k\). Let \(v \in V\) be such that \(d_G^{\delta ^P}(v, \widehat{C}^P) \ge k + 1\). Let \(u \in P\) be the nearest vertex to v on P. Then either \(u = v\), or \(d_G(u, v) = k\) and \(d_G(u, \widehat{C}^P) = 1\).

Fig. 2.
figure 2

Example of a situation from Lemma 11. Path P is red, candidate segments are blue. The segment containing vertex u satisfies v. If all the dashed parts are present in G, then the segment containing vertex w also satisfies v. (Color figure online)

Let \(v \in V\) \(\setminus \) \(P\) be such that \(d_G^{\delta ^P}(v, \widehat{C}^P) = k + 1\) and \(S \subseteq \widetilde{\mathcal {S}}\) be a set of candidate segments that satisfy v. As shown in Fig. 2, there may be multiple such segments in S. However, if v itself lies on some segment, then only segments in the same \({\mathcal {S}}(\pi _i, \pi _{i+1})\) may satisfy v.

Observation 3

( \(\star \) ). Let P be a shortest path in G with \(ecc_G(P) \le k\). Let \(\bar{\sigma }\in {\mathcal {S}}(\pi ^P_i, \pi ^P_{i+1})\) be a candidate segment that contains some vertex u such that \(d_G^{\delta ^P}(u, \widehat{C}^P) = k + 1\). Let \(u' \in P\) be the nearest vertex to u on P. Then \(u'\) lies on a segment \(\sigma \in {\mathcal {S}}(\pi ^P_i, \pi ^P_{i+1})\).

We already know from Lemma 11 that if a candidate segment contains some vertex v with \(d_G^\delta (v, \widehat{C}) > k + 1\), then it is a necessary segment. Now, we show another sufficient condition for a candidate segment to be a necessary segment.

Lemma 12

( \(\star \) ). Let \(\bar{\sigma }\in {\mathcal {S}}(\pi _i, \pi _{i+1})\) be a candidate segment that contains some vertices \(u, v \in \bar{\sigma }\) such that \(u \ne v\) and \(d_G^\delta (u, \widehat{C}) = d_G^\delta (v, \widehat{C}) = k + 1\). Then, \(\bar{\sigma }\) is a necessary segment.

Let us summarize what we have shown so far. If we had the correct values for the permutation \(\boldsymbol{\pi }\) of vertices from \(\widehat{C}\) that are on P, and of \(\delta \), we would only need to select one segment out of each \({\mathcal {S}}(\pi _i, \pi _{i+1})\) to find a shortest path with eccentricity at most k. There are some vertices \(u \in V\) such that \(d_G^\delta (u, \widehat{C}) \le k\) and for these vertices, the distance to the resulting path will be at most k, no matter which segments we choose.

A segment which contains some vertex v with \(d_G^\delta (v, \widehat{C}) > k + 1\) is a necessary segment. A segment which contains two vertices \(u \ne v\) with \(d_G^\delta (u, \widehat{C}) = d_G^\delta (v, \widehat{C}) = k + 1\) is a necessary segment as well. For the remaining segments, we know that for every \(u \in V\) with \(d_G^\delta (u, \widehat{C}) > k\), the shortest path with eccentricity at most k needs to contain some \(\sigma _u \in \widetilde{\mathcal {S}}\) such that \(d_G(u, \sigma _u) \le k\). Furthermore, for every \(v \in \widehat{C}\) with \(d_G(v, L) > \delta (v)\), the path needs to contain some \(\sigma _v \in \widetilde{\mathcal {S}}\) such that \(d_G(v, \sigma _v) \le \delta (v)\).

Clearly, the problem of selecting one segment out of each set of candidate segments is an instance of CSC: the sets of candidates are \(\mathcal {C} = {\mathcal {S}}(\pi _1, \pi _2) \cup \dots \cup {\mathcal {S}}(\pi _{|L|-1}, \pi _{|L|})\), the requirements are \(\mathcal {R} = \{v \in V\) \(\setminus \) \(\widehat{C} \mid d_G^\delta (v, \widehat{C}) > k\} \cup \{v \in \widehat{C}\) \(\setminus \) \(L \mid d_G(v, L) > \delta (v)\}\), and the function \(\varPsi (\bar{\sigma }) = \{v \in V\) \(\setminus \) \(\widehat{C} \mid \bar{\sigma }\text { satisfies } v\} \cup \{v \in \widehat{C}\) \(\setminus \) \(L \mid d_G(v, \sigma ) \le \delta (v)\}\).

We know that the number of vertices outside of P that the segments can satisfy is bounded by the size of L. Furthermore, we know that if a segment contains at least two vertices that need to be satisfied, then it is a necessary segment. Lastly, we know that if a segment from some \({\mathcal {S}}(\pi _i, \pi _{i+1})\) contains one vertex v with \(d_G^\delta (v, \widehat{C}) = k + 1\), then only segments from the same \({\mathcal {S}}(\pi _i, \pi _{i+1})\) may satisfy v. Thus, all segments in \({\mathcal {S}}(\pi _i, \pi _{i+1})\) that do not satisfy v may be disregarded. By this, we ensure that v will be satisfied no matter which segment is chosen, and v does not need to be added to the requirements \(\mathcal {R}\). Hence, the requirements \(\mathcal {R}\) do not need to contain any vertices from P, and the size of \(\mathcal {R}\) is bounded by the size of C.

In the following lemma, we show that we do not need to explicitly check whether a segment contains some vertex v with \(d_G^\delta (v, \widehat{C}) > k + 1\) to decide that it is a necessary segment. This will simplify our algorithm a bit.

Lemma 13

( \(\star \) ). If a segment \(\sigma \in \widetilde{\mathcal {S}}\) contains a vertex u such that \(d_G^\delta (u, \widehat{C}) > k + 1\), then it must also contain two vertices \(v, v'\) with \(d_G^\delta (v, \widehat{C}) = d_G^\delta (v', \widehat{C}) = k + 1\).

Finally, we propose an algorithm that solves MESP. It finds the correct values for \(p_1, \widehat{C}, L\), and \(\delta :\widehat{C} \rightarrow \{0, \ldots , k\}\) by trying all possible combinations. For each combination, it performs the following steps.

  1. 1.

    Find a permutation \(\boldsymbol{\pi }\) of L, such that \(\pi _1 = p_1\) and \(\sum _{i=1}^{|L| - 1}d_G(\pi _i, \pi _{i+1}) = d_G(\pi _1, \pi _{|L|})\). If it does not exist, continue with the next combination.

  2. 2.

    For each \(\pi _i, \pi _{i+1}\), check all candidate segments in \({\mathcal {S}}(\pi _i, \pi _{i+1}).\)

    1. (a)

      If there are any segments containing a vertex u with \(d_G^\delta (u, \widehat{C}) = k + 1\), then we may disregard all candidate segments which do not satisfy u.

    2. (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. 3.

    If there is a vertex v such that \(d_G^\delta (v, \widehat{C}) > k + 1\), and it does not lie on a segment that we have marked as a necessary segment, then no solution exists.

  4. 4.

    Construct the set U of vertices v that are not contained in any segment and have \(d_G^\delta (v, \widehat{C}) = k + 1\). If \(|U| > 2(|L| - 1)\), then no solution exists.

  5. 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 \in \widehat{C}\) \(\setminus \) \(L\) whose distance to the parts of P selected so far is greater than \(\delta (u)\), and all of U.

  6. 6.

    If the CSC instance has a solution, construct a path from \(\boldsymbol{\pi }\) 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 \(\boldsymbol{\pi }\) in step 1.

We arrive at the following theorem.

Theorem 3

( \(\star \) ). For a graph with distance to disjoint paths c, MESP can be solved in \(\mathcal {O}(2^{5c}k^cc \cdot n^4)\).

3.5 Maximum Leaf Number

Theorem 4

( \(\star \) ). There is an algorithm that solves MESP in \(\mathcal {O}(2^\ell \cdot n^3)\) time, where \(\ell \) is the maximum leaf number of the input graph.

4 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 [8] 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 other structural parameters, such as tree depth or feedback vertex set number (see Fig. 1).