Keywords

1 Introduction

Many sport events, especially endurance sport competitions, take place in urban spaces. Throughout the past years, fun runs or obstacle runs gained public attention with growing participant numbers. Labels like XLETIX, Tough Mudder, Strongman, Münz Sportkonzept or B2Run emerged from the popularity of such events. For example, the Münz Firmenlauf 2017 in Koblenz is expecting about 17,500 athletes [1]. For a city like Koblenz this constitutes an immense intervention into traffic for each afternoon the run is being carried out. Often, those competitions are reoccurring on an annual basis and have grown to an extent that their race track disrupts the local traffic situation. Traffic participants may encounter road closures and long waiting times. Up until now event organizers have to propose a potential track at the corresponding municipal administration office and order office including start point and finish point considering all requirements for the track. If the authorities approve the proposed track the event organizer is free to publish and advertise their venture. This planning step is not trivial as the event may be canceled because authorities consider the route as inadequate or the track may negatively affect the local traffic situation. Overcrowded roads and impatient drivers can lead to a bad reputation for the organizer, which may lead to cancellation in the future as well. In this paper, we present a combinatorial algorithm to find possible running tracks of specific length in a road network. Since also running tracks are often designed as cycles the presented method constitutes a valuable tool for organizers of running events.

In this article, we provide a combinatorial algorithm to solve the problem of finding given-length cycles or given-length paths. This method of finding such paths and cycles especially benefits organizers of running events as this algorithm can be applied to road networks. As a result, this approach constitutes a simplification tool in the decision making process of finding adequate race tracks. Since the algorithm returns a number of possibilities from which organizers are able to choose the track that meets most requirements desired by the organizer, it is also thinkable to apply a second optimization phase to these solutions.

2 Preliminaries from Network Optimization

The algorithms used in this paper rely on basics of graph theory and network optimization. We will briefly recall the most important definitions in this section. For a more detailed overview, we refer the reader to the book of [2].

A directed graph \(G = (V, A)\) consists of a set V of nodes (or sometimes called vertices) and a set A of edges whose elements are ordered pairs of distinct nodes. A directed network is a directed graph whose nodes or edges have associated numerical values (typically costs, lengths, travel times, capacities...).

In this paper we do not make a distinction between graphs and networks, so we use the terms “graph” and “network” synonymously. For convenience we set \(n = |V|\) the number of nodes and \(m = |A|\) the number of edges in the network.

For a directed graph \(G = (V, A)\) with node set V, edge set A and cost function \(c :A \rightarrow \mathbb {N}\) that associates costs \(c_{ij}\) with each edge \((i, j) \in A\) and a distinguished node \(s\in V\), Dijkstra’s Algorithm [2] can be used to compute shortest paths from the source node s to all other nodes in the graph.

Remark 1

Dijkstra’s algorithm using a naïve implementation has a worst case time-complexity of \(\mathcal {O}(n^2)\) [2]. Using Fibonacci heaps, the time complexity can be improved to \(\mathcal {O}(m + n\log n)\) [3].

In the following, we assume that only simple paths are qualified as candidates for running tracks. A path is called simple if it contains no repeated vertices. The simpleness of a running track is an important property, since otherwise the path would contain repeated edges and thus intersections which may lead to interruptions in the operational flow.

3 Finding Paths or Cycles of Specific Lengths

In this paragraph, we describe the algorithm used to find simple paths or cycles in a network with prespecified length.

First, we address the computational complexity of the problem. For a given graph \(G = (V, A)\), two distinguished nodes \(s, t \in V\) and a target length \(L \in \mathbb {N}\), the task is to find a simple path \(P_{s, t}\) from s to t such that its cost \(c\left( P_{s, t}\right) \) is as close as possible to L. If \(L \le c^*\left( P_{s, t}\right) \) where \(c^*\left( P_{s, t}\right) \) is the cost of the shortest path between s and t, the problem is solvable in polynomial time since it suffices to compute the shortest path between s and t. Otherwise, it can be shown that the problem is \(\mathsf {NP}\)-hard.

Theorem 1

The general problem of finding a simple path P between two nodes st in a weighted directed graph whose cost c(P) equals a given target value L is \(\mathsf {NP}\)-hard.

Proof

The problem is clearly in \(\mathsf {NP}\). We construct a reduction from the subset-sum problem, which is known to be \(\mathsf {NP}\)-complete [4].

Given an instance \(\left( \{s_1, \ldots , s_n\}, L\right) \) of the subset-sum problem, construct a weighted graph \(G_L = (V_L, A_L)\), where \(V_L = \{v_0,\ldots , v_n, v_0^\prime ,\ldots , v_n^\prime \}\) and there is an edge \((v_{i-1}, v_i)\) with weight \(s_i\). Additionally, add the edges \((v_{i-1}, v_i^\prime )\) and \((v_i^\prime , v_i)\) with a weight of zero. Obviously, there exists a simple path between \(v_0\) and \(v_n\) of cost L if and only if there is a subset of \(\{s_1,...,s_n\}\) whose sum is equal to L, which concludes the proof.    \(\square \)

As a consequence of Theorem 1, there is no algorithm to solve the general problem of finding a path with specific length in a network in polynomial time, provided that \(\mathsf {P} \ne \mathsf {NP}\).

Nevertheless, a combinatorial approach to solve the problem is now as follows: from a given starting point s use the K-shortest path algorithm by [5] to successively compute new shortest paths to the target point t until the length of the kth shortest path (for \(1 \le k \le K\)) is within a threshold of the desired target length L. A formal description of Yen’s Algorithm is given in Algorithm 1.

Yen’s Algorithm works in two phases, determining the first of the K-shortest path \(P^1\) and subsequently determining all other K-shortest path for \(K>1\). The algorithm maintains a list A to save the k-shortest path and a heap B to hold the potential k-shortest paths. Using this notation, the first element of A is the shortest path from the starting point s to finish t. To determine this shortest path, we use Dijkstra’s algorithm.

figure a

Lemma 1

For a given graph \(G= (V, A)\), Yen’s Algorithm to find the K shortest loopless paths can be implemented in such a way that the time complexity is \(\mathcal {O}(Kn(m + n\log n))\).

Proof

The time complexity of Yen’s Algorithm mainly depends on the shortest path algorithm used in line 12 for the computation of the spur paths. We assume that Dijkstra’s Algorithm is used. Yen’s Algorithm makes Kl calls to the Dijkstra algorithm in computing the spur paths, where l is the length of spur paths. In the worst case, the spur path passes all other nodes in the graph, so it holds that \(l = n\). This concludes the proof.    \(\square \)

Remark 2

The technique described in this section can be used to find paths of specific length. Due to the way how Yen’s Algorithm works, Algorithm 1 cannot be used if we want to find a cycle, i.e., it holds that \(s = t\). This can be fixed by a small modification of the original network: instead of using the identical nodes s and t as input for the algorithm, we introduce an artificial node \(\tilde{t}\) with small distance \(\varepsilon \) to s to the network and use the nodes s and \(\tilde{t}\) for the computations.

4 Application and Results

The core idea of finding a running track with prespecified length is now as follows: For a given starting point s and target t compute successively paths \(P_{s, t}^k\) with Yen’s Algorithm until the length \(c(P_{s, t}^k)\) is within a feasible windows around the desired length L. Algorithm 2 shows the algorithmic framework of this approach.

figure b

To illustrate the application of our model, we compare our results to the actual track of the 5 km long B2RUN Kaiserslautern run from the year 2017. The map of the event is shown in Fig. 1a. One solution with the same starting and target point and similar length (\(\approx \,{4993\,}{\mathrm{m}}\)) found by our method is shown in Fig. 1b. Obviously, it is also possible to reconstruct the original running track for a fitting threshold parameter l.

Fig. 1
figure 1

Application and comparison of the proposed method

Furthermore, the presented methodology can easily be adapted to to integrate “routes of interest” into the running track. This can be done in an iterative approach by adding intermediate targets: to include a desired route in the running track, one uses Algorithm 2 from the starting point of the running track to the starting point of the route and additionally uses Algorithm 2 from the endpoint of the route to the target point. This approach may cause the algorithm to malfunction in the following way: since the algorithm operates on two separate parts of the running track, it is not assured that the overall concatenated path is simple, so an additional filtering step might be needed.

5 Conclusions and Further Research

In this paper we presented a real world problem of finding paths or cycles of prespecified lengths in a network. We showed that this problem cannot be solved in polynomial time until \(\mathsf {P} \ne \mathsf {NP}\). However, we adapted a combinatorial algorithm to solve the problem in reasonable time.

In contrast to other methods like integer programming based models, our method is capable to find several solutions within the window around the desired target length. All the found solutions fulfill the length requirement by construction of the algorithm. In an additional step, those solutions can be classified further. A possible extension of our model would be (multiobjective) optimization over the solution set. For instance, the altitude difference that is traveled in the course of the running track is one criterion, that can be optimized. Alternatively, the shape of the route can be optimized. Since the original algorithm only takes the length of the track into account, the solutions may contain artifacts like zig-zags in such a way, that the track is not suitable as a running track.