
Finding Optimal Longest Paths by Dynamic Programming in Parallel Kai Fieger1, Toma´sˇ Balyo1, Christian Schulz2, Dominik Schreiber1 1Karlsruhe Institute of Technology Karlsruhe, Germany 2University of Vienna, Faculty of Computer Science Vienna, Austria fi[email protected], [email protected], [email protected], [email protected] Abstract no two edges have any vertex in common. A sequence of vertices s !···! t such that each pair of consecutive ver- We propose an exact algorithm for solving the longest sim- s-t path ple path problem between two given vertices in undirected tices is connected by an edge, is called an . We say weighted graphs. By using graph partitioning and dynamic that s is the source and t is the target. A path is called simple programming, we obtain an algorithm that is significantly if it does not contain a vertex more than once. The length of faster than other state-of-the-art methods. This enables us to a path is defined by the sum of its edge weights. If the graph solve instances that were previously unsolved and solve hard is unweighted, then edge weights are assumed to be one. instances significantly faster. Lastly, we present a scalable Given a graph G = (V; E; !) as well as two vertices parallelization which yields the first efficient parallel algo- s; t 2 V , the longest path (LP) problem is to find the longest rithm for the problem. simple path from s to t. Another version of the LP problem is to find the overall longest simple path in the graph. How- 1 Introduction ever, the problem can be solved by introducing two vertices s; t, connecting them to all other vertices in the graph by The longest path problem (LP) is to find a simple path (each edges of weight zero and then running algorithms tackling vertex visited at most once) of maximum length between the LP problem on the modified instance. two given vertices of a graph, where length is defined as k V the number of edges or the total weight of the edges in the A -way partition of a graph is a division of into blocks B B B [···[ B = V path. The problem is known to be NP-complete (Garey and of vertices 1,. , k, i.e. 1 k and Bi \ Bj = ; for i 6= j.A balancing constraint de- Johnson 1979) and has several applications such as design- jV j ing circuit boards (Ozdal and Wong 2006a; Ozdal and Wong mands that 8i 2 f1::kg : jBij ≤ Lmax := (1 + )d k e 2006b), project planning (Brucker 1995), information re- for some imbalance parameter . The objective is typi- P trieval (Wong, Lau, and King 2005) or patrolling algorithms cally to minimize the total cut i<j !(Eij) where Eij := for multiple robots in graphs (Portugal and Rocha 2010). ffu; vg 2 E : u 2 Bi; v 2 Bjg. In this paper we present the algorithm LPDP (Longest Path by Dynamic Programming) and its parallel version. 2.1 Related Work LPDP makes use of graph partitioning and dynamic pro- Previous work by Stern et al. (2014) mainly focuses on the gramming. Unlike many other approaches for NP-complete possibility of applying algorithms that are usually used to problems, LPDP is not an approximation algorithm – it finds solve the shortest path problem (SP) to the longest path prob- an optimal longest path. Through experiments we compare lem. Stern et al. (2014) make clear why LP is so difficult arXiv:1905.03645v1 [cs.DS] 8 May 2019 LPDP to previous LP algorithms and evaluate the speedups compared to SP. Several algorithms are presented that are achieved by the parallel algorithm. frequently used to solve SP or other minimization search problems. They are modified in order to be able to solve LP. 2 Preliminaries The search algorithms are put into three categories: heuris- In the following we consider an undirected graph G = tic, uninformed and suboptimal. Each of the algorithms in (V; E; !) with (symmetric) edge weights ! : E ! R≥0, the first two categories yields optimal solutions to the prob- n = jV j, and m = jEj. We extend ! to sets, i.e., lem. The most relevant category for this paper is heuristic 0 P !(E ) := e2E0 !(e). N(v) := fu : fv; ug 2 Eg denotes searches. Here, a heuristic can provide extra information the neighbors of v.A subgraph is a graph whose vertex and about the graph or the type of graph. Heuristic searches re- edge sets are subsets of another graph. We call a subgraph in- quire a heuristic function that estimates the remaining length duced if every edge among the included vertices is included. of a solution from a given vertex of the graph. This can A subset of a graph’s vertices is called a clique if the graph give important information helping to prune the search space contains an edge between every two distinct vertices of the and to speed up the search. Stern et al. (2014) show that subset. A matching is a subset of the edges of a graph where heuristic searches can be used efficiently for the longest path problem. Some examples of algorithms in this category are 3 Longest Path by Dynamic Programming Depth-First-Branch-and-Bound (DFBnB) and A*. Another We now introduce the main contribution of our paper which category represents “uninformed” searches, which do not re- is a new algorithm to tackle the longest path problem based quire any information other than what is already given in the on principles of dynamic programming. Hence, our algo- definition of the problem. Examples from this category are rithm is called “Longest Path by Dynamic Programming” Dijkstra’s algorithm or DFBnB without a heuristic. Modify- (LPDP). Our algorithm solves the longest path problem (LP) ing these algorithms to fit LP basically leads to brute force for weighted undirected graphs. algorithms, which means that they still have to look at every possible path in the search space. Hence, these uninformed search strategies are not very beneficial for LP. The last cat- 3.1 Exhaustive Depth First Search egory are suboptimal searches. The authors looked at a large A simple way to solve the longest path problem is exhaustive number of these algorithms that only find approximations of depth-first search (Stern et al. 2014). In regular depth-first a longest path. search (DFS) a vertex has two states: marked and unmarked. Initially, all vertices are unmarked. The search starts by call- ing the DFS procedure with a given vertex as a parameter. A similar problem to LP called Snake in the Box (SIB) This vertex is called the root. The current vertex (the param- is the problem of finding the longest simple path in an n- eter of the current DFS call) is marked and then the DFS dimensional hypercube. Additionally to the constraint of not procedure is recursively executed on each unmarked vertex allowing repeated vertices in the path it is required that for reachable by an edge from the current vertex. The current any two vertices u; v there is no edge between u and v un- vertex is called the parent of these vertices. Once the recur- less u and v are adjacent in the path. Heuristic search LP sive DFS calls are finished we backtrack to the parent vertex. algorithms can be adapted to efficiently solve SIB (Palombo The search is finished once DFS backtracks from the root. et al. 2015) by designing SIB specific heuristics. However, these techniques cannot be transferred to solving the general LP problem since they rely on SIB specific heuristics and Search exhaustiveDFS(v) therefore these results are not relevant for our work. if v is unmarked then mark v; foreach fv; wg 2 E do The LP problem is related to the Traveling Salesper- exhaustiveDFS(w); son Problem (TSP), which is a very well studied prob- end lem. There exist several exact algorithms and solvers for unmark v; TSP, such as the Integer Linear Programming based exact end solver Concorde (Applegate et al. 1994). TSP problems can Algorithm 1: Exhaustive depth first search. In order to be solved by translating them into LP problems and using solve LP we start this search from the start node and up- an LP solver (Hardgrave and Nemhauser 1962). The trans- date the best found solution each time the (unmarked) tar- lation is very efficient since it only adds one new vertex get node is found. and at most n new edges, where n is the number of ver- tices of the TSP problem. This raises the question if we can solve TSP problems faster by using our new algorithm Exhaustive DFS is a DFS that unmarks a vertex upon (after translating them to LP) than the state of the art TSP backtracking. In that way every simple path in the graph solver Concorde (Applegate et al. 1994). If we consider the starting from the root vertex is explored. The LP problem standard TSP benchmark problems, i.e., the TSPLib collec- can be solved with exhaustive DFS by using the start ver- tion (Reinelt 1991), the answer is no. The reason is that all tex as root. During the search the length of the current path the TSPLib benchmark problems are cliques and they re- is stored and compared to the previous best solution each main cliques after translating them to LP (Hardgrave and time the target vertex is reached. If the current length is Nemhauser 1962). This is very unfortunate, since our algo- greater than that of the best solution, it is updated accord- rithm relies on graph partitioning, which is not very help- ingly.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages9 Page
-
File Size-