The Minimum Eccentricity Shortest Path (MESP) problem asks, given an undirected graph and a non-negative integer , to find a shortest path with eccentricity at most —a shortest path (no path joining the same endpoints is shorter) whose distance to all other vertices in the graph is at most . The shortest path achieving the minimum may be viewed as the “most accessible”, and as such, may find applications in communication networks, transportation planning, water resource management, and fluid transportation . Some large graphs constructed from reads similarity networks of genomic data appear to have very long shortest paths with all vertices in short distance from them . Furthermore, MESP can be used to obtain the best to date approximation for a minimum distortion embedding of a graph into the line 
which has applications in computer vision, computational biology and chemistry [13, 12]. If there is a diameter of the graph (a longest among shortest paths) with eccentricity at most , then the graph is called -laminar . This notion is closely tied to the existence of low eccentricity shortest paths .
The problem was first introduced by Dragan and Leitert . They 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 in a graph with vertices and edges in time. They also presented a linear-time algorithm that solves MESP for trees. Additionally, they developed a 2-approximation, a 3-approximation, and an 8-approximation algorithm that runs in time, time, and time, respectively. Birmelé, Montgolfier, and Planche  further improved the 8-approximation to a 3-approximation, which still runs in linear time. Dragan and Leitert  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 graphs and dually chordal graphs. Later, they proved  that the problem is NP-hard even for bipartite planar graphs with maximum degree 3, and W-hard with respect to the desired eccentricity for general graphs. Furthermore, they showed that in a graph with a shortest path of eccentricity , a minimum -dominating set can be found in time. A related problem of finding shortest isometric cycle was studied by Birmelé et al. . Birmelé et al.  studied a generalization of MESP, where the task is to decompose a graph into subgraphs with bounded shortest-path eccentricity, the hub-laminar decomposition.
We continue the research direction of MESP in structured graphs , 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, and maximum leaf number (see Figure 1 for an overview of our results).
We consider finite connected unweighted undirected simple loopless graphs. A graph is a pair of a set of vertices and a set of edges . We denote and .
We denote an ordered sequence of elements . For two sequences we denote their concatenation
A path is a sequence of vertices such that every two consecutive vertices in the sequence are adjacent. The length of a path is the number of edges in it, i.e., . The distance between two vertices is the length of the shortest path between and .
The distance between a vertex and a set of vertices is . The eccentricity of a vertex is defined as . The eccentricity of a set is .
For a path , we denote the set of vertices that are in . However, we simply use instead of if it is clear from the context that we are dealing with a set of vertices, e.g., and .
For vertex we denote the degree of , the open neighborhood of and the closed neighborhood of . We denote the set of vertices at distance at most from . We denote the induced subgraph of on vertices . We denote .
In this paper, we focus on the following problem.
Minimum Eccentricity Shortest Path Problem (MESP) Input: An undirected graph , desired eccentricity . Question: Is there a shortest path in such that ?
Given a graph and a path in we can perform a breadth-first search (BFS) starting in all vertices of with their distance set to 0. The distance of the last-discovered vertex determines the eccentricity of . Hence, we have the following observation.
Given a graph and a path in , the value of may be calculated in time.
The idea in parameterized (or fpt) algorithmics is to accept exponential running times, which are seemingly inevitable in solving NP-hard problems, but to restrict them to one aspect of the problem, the parameter. Formally, an instance of a parameterized problem is a pair consisting of the input and the parameter . A parameterized problem is fixed parameter tractable (FPT) with respect to a parameter if there is an algorithm solving any instance of with size in time for some computable function . Such an algorithm is called a fpt algorithm. See Cygan et al.  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, )
Consider graphs that can be obtained from an algebraic expression that uses the following operations:
create an isolated vertex;
the disjoint union of graphs (the disjoint union of graphs and is the graph );
the complete join of graphs (the complete join of graphs and is the graph );
the substitution operation with respect to some pattern graph (for a graph with vertices and graphs the substitution of the vertices of by the graphs is the graph with vertex set and edge set ).
Let be an algebraic expression that uses only the operations (O1)–(O4). We define the width of as the maximum number of operands used by any occurrence of the operation (O4) in . The modular-width of a graph , denoted , can be defined as the least integer such that can be obtained from such an algebraic expression of width at most . An algebraic expression of width can be constructed in linear time .
Definition 2 (Distance to cluster graph)
For a graph , a modulator to cluster graph is a vertex subset such that is a vertex-disjoint union of cliques. The distance to cluster graph is the size of the smallest modulator to cluster graph.
Definition 3 (Distance to disjoint paths)
For a graph a modulator to disjoint paths is a vertex subset , such that is a vertex-disjoint union of paths. The distance to disjoint paths is the size of the smallest modulator to disjoint paths.
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.
3 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 and present an algorithm to solve it. 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. Again, this algorithm depends on the solution of the CSC problem. In Subsection 3.5, we present an algorithm parameterized by the maximum leaf number.
3.1 Modular Width
In this section, we present an fpt algorithm for MESP parameterized by the modular width.
Let be a graph with modular width and be the corresponding algebraic expression describing the graph. We take a look at the last operation applied in . Operation (O1) is trivial and (O2) yields a disconnected graph, therefore we suppose the last operation is either (O3) or (O4).
If the last operation is (O3) and is a path, then the whole path is trivially a shortest path with eccentricity 0. If is not isomorphic to a path, then the minimum eccentricity shortest path is any single edge connecting the two original graphs, and its eccentricity is 1.
If the last operation is (O4), we consider the pattern graph with and the substituted graphs . We suppose that and is not a clique; otherwise could be created using only operations (O1)–(O3). We continue by showing that the structure of the pattern graph restricts the structure of any shortest path in the resulting graph significantly.
If the last operation in is (O4), then there is a minimum eccentricity shortest path in which contains at most one vertex from each for .
Let be a shortest path in .
If the length of is at most 2 and contains two vertices from , then we create a path with . Because was created with (O4), we know that , thus . We denote the two vertices from on . If there is another vertex on on and , we let ; otherwise we choose a vertex arbitrarily from some such that and . Then, we let . For every vertex we have and for every vertex we have .
If the length of is at least 3, we show by contradiction that it cannot contain two vertices from . Let . Suppose that . Clearly, at least one of is not an endpoint of (otherwise the length of would be at most 2). Without loss of generality, suppose that is not an endpoint of , thus it has a predecessor and . We have and . Path may be shortened to . Thus, is not a shortest path. ∎
We have shown that there is a minimum eccentricity shortest path which contains at most one vertex from each graph . Now, we show that with respect to eccentricity, all vertices in the same graph are equivalent, and it does not matter which of them we choose. In other words, a minimum eccentricity shortest path in can be found by trying all shortest paths in .
Let be a shortest path in and . We create a path by substituting in by any . Then, .
Let such that and . If , then and thus . If , then and because the neighbors of on , as well as the neighbors of on , are also neighbors of . Moreover, . ∎
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 the subsets of and all their permutations (containing all shortest paths in ). For each of them and each we let arbitrarily and let . Then we check whether is a shortest path with eccentricity at most in . By the above arguments, if there is a shortest path of eccentricity at most , we will find one.
As there are possible subsets and possible orders, we arrive at the following theorem.
There is an algorithm that solves MESP in time, where is the modular width of the input graph.
3.2 Constrained Set Cover
In this subsection we define the Constrained Set Cover (CSC) problem and present an algorithm to solve it. In the next subsection it will be used as a subroutine to solve MESP.
Constrained Set Cover Input: A set of candidates, a set of requirements to be satisfied, and a function 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 such that together they satisfy all the requirements, i.e., ?
To help us solve CSC, we now define a function for each .
Let be an instance of CSC. We define function as follows:
If there are more candidates in the second case, we select an arbitrary one to make 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 effectively. Note that if and otherwise.
Let . Then can be computed recursively as follows.
We suppose that the initial values of are taken directly from 5 and prove the lemma for any . First, we show that if the recursion yields some value , then it is one of the correct possible values of according to 5. Second, we show that if , then the recursion does not yield either.
If the recursion yields , then there is some such that . From induction, the value of is correct, thus there exist . Hence, , which corresponds to 5 and yields a correct value.
If , then there are some candidates such that . Let . Then, and . Hence the recursion does not yield . ∎
We continue by showing how a solution of CSC may be extracted from the values of . We will use each function to choose the candidate from .
If , then no solution exists. Otherwise, the solution can be found by iterating through the calculated values backwards and setting: , , …, , …, .
By the definition of , we only have if no set of candidates exists, such that , i.e., if no solution of the CSC instance exists.
Otherwise, using the definition of , we can set . We know that given an , all the requirements are satisfied by , so the rest of them needs to be satisfied by . Also, by the definition of we know that there exists such that they satisfy the rest of the requirements. Then, by the definition of , we have . ∎
Finally, we propose Algorithm 1 to solve CSC. It is a dynamic programming algorithm that first computes all values for each of using the recursion from 3, and then constructs the solution from them as in 4. The following lemma summarizes the properties of Algorithm 1.
Constrained Set Cover can be solved in time.
We show that Algorithm 1 works correctly and runs in time.
The for-loop on line 4 iterates over all sets of candidates and the foreach-loop on line 7 iterates over all candidates in each set. Together, lines 8–10 will be executed times. The foreach-loop on line 8 iterates over all subsets of and all subsets of the output of , which sums to at most iterations in total. Lines 9–10 can be implemented in time. The for-loop on line 12 has iterations, and lines 13–14 can be implemented in time. ∎
3.3 Distance to Cluster Graph
In this section, we present an fpt algorithm for MESP parametrized by the distance to cluster graph. We do not consider the trivial case of a graph with distance to cluster graph 0. A connected graph with distance to cluster graph 0 is a clique, and any single edge in such a graph is the minimum eccentricity shortest path.
Let be a graph with modulator to cluster graph . Then, for any edge in , and have the same neighborhood in .
Lemma 6 (Boral et al. )
A modulator to cluster graph of a graph with distance to cluster graph can be found in time.
First, we discuss some properties of graphs in which a shortest path with eccentricity at most exists.
Let be a graph with modulator to cluster graph and let be a shortest path with . Then, there exists a shortest path such that it contains at least one vertex from and .
Suppose that only contains vertices from . All these vertices form a clique, so the length of is at most 1. Let . If there is some vertex such that it is a neighbor of exactly one endpoint of , then either or is the sought path. If all vertices in are neighbors of both and , then for any is the sought path. ∎
Let be a graph with a modulator to cluster graph . Let be a shortest path in with that contains at least one vertex from . We denote and the permutation/order of vertices from in which they appear on the path . We denote the set of vertices in partition that are at distance from , for .
Since is a disjoint union of cliques, and for every , all vertices that are between and on are from , we have , as otherwise would not be a shortest path.
Let be a candidate on Intuitively, if we had the correct values of , we would only need to select the (at most two) vertices between each . Also, if there is an edge between some and , then there will be no other vertex between them on .
To help us refer to those pairs between which we still need to choose some vertices we denote the increasing sequence of all indices such that . For every , there is no vertex between and on . For every : If , then there is one vertex on between and , and it is from . If , then there are two vertices on between and , and both are from .
We define the set of candidate vertices between and for each .
For with , the set contains pairs of the same vertices . To avoid adding some vertex into a path twice, we define the function which maps a pair of any two elements to a sequence of length 1 or 2 as follows
To solve MESP, we need to choose exactly one pair from each of . Later, we will show that the problem of choosing these pairs is an instance of CSC.
First, we define a function that will help us prove that the path constructed from the CSC solution will have a small eccentricity.
We define function as .
Function is a good estimate of the distance from
is a good estimate of the distance from:
for every , and
for every .
Let be the nearest vertex to on and be the shortest path from to . If there are any vertices from on , let be the last vertex from on . We know that because is a shortest path and all vertices connected in form a clique. If , then . If , then . If , then . Hence, . If consists only of vertices from , let be the nearest vertex to such that . Clearly, and . ∎
Now we show how to choose optimal vertices from each by solving CSC.
Suppose that is a shortest path in with , both endpoints of are in , and we have the corresponding values of as described in 6. Let and be a solution of the CSC instance with requirements , sets of candidates , and function . Consider the following path.
Then, is a shortest path and .
Clearly, is a shortest path.
Thanks to the way we chose and from 8 we know that:
for every ,
for every .
If and , then . Because contains at least one vertex from and all vertices in form a clique, we have . ∎
Clearly, if , then we can use 9 to construct a shortest path with eccentricity at most . Now, we discuss the case when .
If , then for every we have .
If , then either or , and . For each , let be the nearest vertex to on from . Because all vertices that are connected in form a clique, we get , and hence . ∎
If , then a path with can be constructed similarly as in 9 but for each candidate set which contains some pair such that there is a neighbor of (and of , they have the same neighborhood in ) with , removing every such that is not a neighbor of (and ) from .
For any , if any of the removed pairs were selected into , then the distance of to would be and therefore . ∎
We have shown how to construct a shortest path with eccentricity at most by solving the CSC problem, even if . Finally, we observe that such a path can be constructed even if one or both of its endpoints are in .
If has an endpoint , its neighbor might also be in . Let . We may obtain a path with by removing (and if ) from , finding by solving the CSC, and prepending (and if ) to .
All vertices in are on , and, thanks to the way we chose , all vertices in are at distance from either , , or one of . Thus, the same argument as in the proof of 9 applies. ∎
MESP can be solved by trying all possible combinations of is a permutation of , . For each combination, the following steps should be performed.
In a graph with distance to cluster graph , MESP can be solved in time.
There are at most different combinations of . In step 1, there are at most sets and each of these can be constructed in time. In step 2, the CSC instance can be solved by Algorithm 1 in time as and . In step 4, there are at most combinations of vertices to prepend/append, and checking the length of the resulting path and its eccentricity can be implemented in time. ∎
3.4 Distance to Disjoint Paths
In this section, we present an fpt algorithm for MESP parameterized by the distance to disjoint paths and the desired eccentricity, combined.
For completeness, we include the following result which is rather folklore.
The modulator to disjoint paths of a graph with distance to disjoint paths can be found in time.
If the highest degree in is at most 2, then 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 time by identifying all cycles with a depth-first search.
If the highest degree in is at least 3, then the modulator to disjoint paths can be found by a simple branching rule.
Select any vertex with
Either or some subset of size must be in .
We show that this algorithm has time complexity for some constant , where is the given maximum distance to disjoint paths. We show that by induction on . For we only have to check whether the graph is a disjoint union of paths, which can be done in time, i.e., time for a suitably chosen .
For we have for some , which, by induction hypothesis is at most . To show that this is at most , it remains to show that , i.e., that for every . For we have , whereas for we have and for we have .
Hence, the time complexity is indeed . ∎
We start by discussing some properties of graphs in which a shortest path with does exist. Assume that is such a path, fixed for the next few lemmas and definitions.
Let be a shortest path in with . Let . Let . We denote the permutation/order of vertices from on the path . We define function for every .
Let , , and be candidates for , , and , respectively. For each consecutive pair of vertices , there may be multiple shortest paths connecting them, such that they do not contain any other vertices from . Exactly one of these shortest paths is contained in for each pair. We say is a candidate segment if it is a sequence of vertices on some shortest path from to excluding the endpoints and . We define as a set of all candidate segments between and . We denote the set of all candidate segments in . We say that a candidate segment is a necessary segment if it must be part of any shortest path such that , , is the order of vertices from on the path , and .
Intuitively, if we had the correct values of , we would only need to select one segment out of each for