A Comprehensive Comparison of Label Setting Algorithm and Dynamic Programming Algorithm in Solving Shortest Path Problems

In this paper, Label Setting Algorithm and Dynamic Programming Algorithm had been critically examined in determining the shortest path from one source to a destination. Shortest path problems are for finding a path with minimum cost from one or more origin (s) to one or more destination(s) through a connected network. A network of ten (10) cities (nodes) was employed as a numerical example to compare the performance of the two algorithms. Both algorithms arrived at the optimal distance of 11 km, which corresponds to the paths 1 → 4 → 5 → 8 → 10,1 → 3 → 5 → 8 → 10 , 1 → 2 → 6 → 9 → 10 and 1 → 4 → 6 → 9 → 10 . Thus, the problem has multiple shortest paths. The computational results evince the outperformance of Dynamic Programming Algorithm, in terms of time efficiency, over the Label Setting Algorithm. Therefore, to save time, it is recommended to apply Dynamic Programming Algorithm to shortest paths and other applicable problems over the Label-Setting Algorithm.


Label-Setting Algorithm
This Label-Setting Algorithm was named after the famous Dutch computer scientist and mathematician, Dijktsra, whose 1959 algorithm became the foundation of this type of algorithm. The algorithm is known as Dijkstra's algorithm. According to Schrijver (2010), similar algorithm had been proposed independently by Leyzorek et al. (1957), Dantzig (1958), and Whiting and Hillier (1960).
Dijkstra's algorithm is a graph search algorithm that solves the single-source shortest path problem for a graph with non-negative edge path costs, producing a shortest path tree (Vaibhvi & Chitra, 2014). This algorithm is often used in routing problems and as a subroutine in other graph algorithms (Paraveen & Neha, 2013). For a given source vertex (node) in the graph, the algorithm finds the path with lowest cost (i.e. the shortest path) between that vertex and every other vertex.
At any intermediate step, the algorithm divides the nodes of the network under consideration into two groups: those which it designates as permanently labelled (or permanent), and those that it designates as temporarily labelled (or temporal). The distance labelled permanent to any permanent node represents the shortest from the source node to the current node (Ukwosah et al., 2018).

Mathematical Formulation of the Problem Based on the Label-Setting Algorithms
Let be the shortest distance from source node 1 to node and define ≥ 0 as the length of arc ( , ). Then the algorithm defines the label for an immediately succeeding node j as [ , ] = [ + , ]. The label for starting node is [0, -], signifying that the node has no predecessor.
Below are the steps of this algorithm: Step 1: The source node (node 1) is assigned with the permanent label [0, -]; set i = 1.
Step 2: (i) Compute the temporary label[ + , ]for each node j that is reachable by node , provided j is not permanently labelled. If node j is already labelled with[ , ] through another node k and if + < , then replace [ , ] with [ + , ].
(ii) Stop, if all the nodes are permanently labelled. Otherwise, select the label[ , ] having the shortest distance ( ) among all the temporary labels (break ties arbitrarily). Set = and repeat step 2.

Dynamic Programming
The concept of Dynamic Programming was first conceived by Richard Bellman in 1940s and was recognized by the Institute of Electrical and Electronic Engineers (IEEE) as analysis and engineering topic in 1953(Smith et al., 1997Hillier & Lieberman, 2005).
Bellman, described Dynamic Programming as the process of solving problems where one needs to find the best decision, one after another (Adda et al., 2003). It works on the principle of finding an overall solution by operating on an intermediate point that lies between where we are now and where we want to go. The procedure is recursive in that the next intermediate point is a function of the point already visited. The principle of Bellman optimality states that 'an optimal policy (set of decisions) has the property that whatever the initial state and decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision' (Smith et al., 1997).

Mathematical Formulation of the Problem Based on Dynamic Programing Algorithm
A problem can be solved by the method of Dynamic Programming if it has the following properties: a) The problem can be decomposed into a sequence of decisions made at various stages. b) Each stage has a number of possible states.

c)
A decision takes one from a state at one stage to some state at the next stage.
d) The best sequence of decision also known as policy at any stage is independent of the decisions made at prior stages.
e) There is a well-defined cost for traversing from state across stages. Moreover, there is a recursive relationship for choosing the best decision. The shortest routes will be determined between every two stages for a given network using the Dynamic Programming Algorithm.
Step 0. Definition of variables Let denote the distance from node to node .
Let be the node it is at the stage and the nodes reachable by node .
Let be the state variable.
Let ( , ) denote the minimum distance of the objective function from node , to the final destination 10.
Step 1: The structure of an optimal solution.
The first step of Dynamic Programming is to characterize the structure of an optimal solution.
Let divide the problem into five stages as follows; Figure 1. Schematic representation of the problem as a five-stage dynamic programming problem Stage 1: Consists of city 1.
The return function is Stage 2: Consists of cities 2, 3 and 4.
Step 2: A recursive Solution Let ( , ) denote the minimum distance of the objective function from node , to the final destination 10.
Let ( , ) denote the optimal value of the objective function from any city , to the final destination 10. Hence, the optimum is 1 ( 1 ), the minimum of the sum of the distance from 1 to 10.
Step 3: Computing the stage-wise optimal distance This is the final step in the complete process of the Dynamic Programming Algorithm. The details of this step will be outlined in section 3 to obtain the optimal distances at the various stages.

Results
In this section we present a ten-node network of 20 edges or acrs. In this paper, the nodes represent ten cities and the edges feature their interconnections indicated the respective distances connecting them (See Figures 1 and 2). First, the Dijkstra's algorithm will be implemented and then, the Dynamic Programming Algorithm to inform a comprehensive comparison. Each arc ( , ) is associated with the distance in km.

Implementation of the Dijkstra's Algorithm
The Dijkstra's algorithm is implemented using Figure 2. Each arc ( , ) is associated with the distance in km. The main aim is to determine the shortest path from the source city 1 (node 1) to the destination city 10 (node 10). Figure 2 was adopted from Hillier and Lieberman (2005), which describes a journey from a starting point, Missouri (node 1) to a destination, California (node 10). In the iterations, Column one denotes the nodes; column two, the labels; and column three, the status of the nodes.  [8,2], the smaller distance is 4, and that corresponds with node 3 and node 6 (break ties arbitrarily) i.e., [ 3 ]. Thus, the status of node 3 is changed to permanent.  [7,6], the smallest distance is 7, which corresponds with node 5 and node 9 i.e., [ 5 ]. Thus, the status of node 5 is changed to permanent.  [11,9], the smallest distance is 8, and that corresponds with node 7 and node 8 i.e., [ 7 ]. Thus, the status of node 7 is changed to permanent.  11,9] Temporary Among the temporary labels [8,5] and [11,9], the smallest distance is 8, and that corresponds with node 8 i.e., [ 8 ]. Thus, the status of node 8 is changed to permanent.

Implementation of Dynamic Algorithm
In section 3.2, the Dynamic Programming algorithm is also implemented. The shortest routes will be determined between every two stages for the network, shown in Figure 1 using the Dynamic Programming Algorithm. Figure 3 gives the division of the Figure 2 into five stages. The main aim is to determine the minimum distance from node 1 to node 10.
To illustrate the Step 3, the computation of the stage-wise optimal distances (which was deferred above), we do as follows: (i) Computations for stage 5 (node 10): = 5.
In summary, the optimal distance connecting the cities as obtained from the implemented Dijkstra's algorithm is 11 km.
As an alternative technique, the Dynamic Programming algorithm also yields an optimal or minimum distance of 11, as given by 1 ( 1 ) = 11 which corresponds to 1,3 + 2 ( 2,3 ) and 1,3 + 2 ( 2,3 ). It is imperative to define the notation . The first index , denotes the stage whiles the second j, denotes the node. For instance, 23 means stage 2, node 3 and 24 means stage 2, node 4. As can be followed from the implementation of the Dynamic Programming algorithm, the shortest path from node 1 to node 10 is therefore obtained by tracing the following sequences: (i) 1 , 2,4 , 3,6 , 4,9 and 5,10 as represented by the following order of flow: 1 → 4 → 6 → 9 → 10 giving rise to an optimal distance of 11 km.

Conclusion
In this paper, the performance of Dynamic Programming Algorithm is compared with that of the Label-Setting Algorithm.
The two algorithms were implemented in solving the shortest path problem of a ten-city (node) connected by 20 edges representing varying distances in kilometers.
The two algorithms obtained the sequences that proxy the shortest or optimal path to the problem to be 1 → 4 → 5 → 8 → 10,1 → 3 → 5 → 8 → 10, 1 → 2 → 6 → 9 → 10 and 1 → 4 → 6 → 9 → 10 with a total distance of 11 km. Thus, in reality, the problem typifies a Multiple Shortest Path Problem. The results have uncovered the fact that Dynamic Programming is equally as good as the Label-Setting or the Dijkstra's algorithm, if and only if the problem is well formulated and the steps are thoroughly followed.
Albeit the fact that Hillier and Lieberman (2005) cited an inherent flaw of Dynamic Programming method in respect of its impromptu nature and the fact that it is designed to fit a particular problem rather than a variety of applications, it involves fewer iterations leading to fewer computational steps, thereby making it time efficient in relation to the Dijkstra's (Label-Setting) algorithm. The current trend in the development of algorithms focuses on algorithms that are exemplified by optimal efficiency (optimal performance) and computational or time efficiency. As evinced by the results, both the Dynamic algorithm and the Dijkstra's algorithm perform equally in terms of optimal efficiency. However, on grounds of time efficiency, Dynamic Programming algorithm outperforms the Dijkstra's algorithm. It is therefore recommended in this paper that Dynamic Programming should be applied in solving a shortest path and other applicable problems to save time. Also, further research needs to be done on other areas that Dynamic Programming Algorithm could be applied to solve problems since it provides quality results and saves time.