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