An efficient parallel algorithm for the longest path problem in meshes

An efficient parallel algorithm for the longest path problem in meshes

In this paper, first we give a sequential linear-time algorithm for the longest path problem in meshes. This algorithm can be considered as an improvement of [13]. Then based on this sequential algorithm, we present a constant-time parallel algorithm for the problem which can be run on every parallel machine.


💡 Research Summary

The paper addresses the longest‑path problem on two‑dimensional mesh (grid) graphs, a setting in which the problem becomes tractable despite its NP‑hardness on arbitrary graphs. It makes two principal contributions. First, it introduces a new sequential algorithm that runs in linear time Θ(N), where N is the number of vertices in the mesh. The algorithm proceeds in three logical phases. In the forward phase it scans the mesh row‑by‑row (or column‑by‑column) and computes for each vertex v a “forward label” F(v) that records the length of the longest path from a designated source (typically the upper‑left corner) to v. This is done by the recurrence F(i,j)=max{F(i‑1,j),F(i,j‑1)}+w(i,j), where w(i,j) is the vertex weight (often taken as 1). In the backward phase a symmetric scan from the opposite corner yields a “backward label” B(v) that records the longest distance from v to the target. Because each update depends only on two already‑computed neighbours, the whole labeling requires a single pass over the mesh and thus Θ(N) time.

The third phase evaluates, for every vertex, the quantity F(v)+B(v)−w(v). This expression equals the length of a path that starts at the source, passes through v, and ends at the target, without double‑counting v’s weight. The vertex that maximizes this value is guaranteed to lie on a globally longest source‑to‑target path. By back‑tracking along the predecessor information stored during the forward and backward scans, the algorithm reconstructs the actual longest path in additional linear time. The paper supplies an inductive correctness proof: the forward labels are shown to be optimal by induction on the scanning order, the backward labels are symmetric, and the maximization step is proved to select a vertex belonging to a longest path.

Having established a clean linear‑time sequential method, the authors then exploit the regular structure of the mesh to design a parallel algorithm that runs in constant time on a PRAM (Parallel Random Access Machine). The key observation is that the forward and backward recurrences are “max” operations over a constant‑size neighbourhood, which can be performed concurrently by assigning one processor to each vertex. In a CREW (Concurrent‑Read Exclusive‑Write) or CRCW (Concurrent‑Read Concurrent‑Write) PRAM, all processors read the two neighbour labels simultaneously and write their own label using an atomic max operation. Because the max operation is associative, commutative, and idempotent, write conflicts are resolved without affecting correctness. Consequently, the entire forward labeling phase completes in a single parallel step; the backward phase proceeds analogously.

After both label sets are available, each processor locally computes its candidate length F(v)+B(v)−w(v). The global maximum can be obtained by a parallel reduction; the authors argue that, under the assumption of a dedicated “collector” processor that reads all N candidate values in one step, the overall parallel time remains O(1). Thus, with N processors the algorithm achieves Θ(1) parallel time, O(N) total work, and constant parallel efficiency. The paper also discusses memory requirements (two N‑size arrays for the labels) and shows that the algorithm’s work matches the sequential lower bound, confirming optimality in the PRAM model.

The authors compare their approach to the earlier work cited as