Greedy , AStar , and Dijkstra ’ s Algorithms in Finding Shortest Path

Received Dec 19, 2020 Revised Jan 16, 2021 Accepted Feb 01, 2021 The problem of finding the shortest path from a path or graph has been quite widely discussed. There are also many algorithms that are the solution to this problem. The purpose of this study is to analyze the Greedy, A-Star, and Dijkstra algorithms in the process of finding the shortest path. The author wants to compare the effectiveness of the three algorithms in the process of finding the shortest path in a path or graph. From the results of the research conducted, the author can conclude that the Greedy, A-Star, and Dijkstra algorithms can be a solution in determining the shortest path in a path or graph with different results. The Greedy algorithm is fast in finding solutions but tends not to find the optimal solution. While the A-Star algorithm tends to be better than the Greedy algorithm, but the path or graph must have complex data. Meanwhile, Dijkstra's algorithm in this case is better than the other two algorithms because it always gets optimal results.


INTRODUCTION
Finding the shortest path in a graph is a problem that is often discussed and has been widely applied in optimizing the running of a system process. Edges and Vertices can be used to solve the problem of finding the shortest distance. There are several algorithms or methods that can be used in the process of finding a path with a minimum distance between the source to the destination such as the Greedy Algorithm, A-Star, Dijkstra, and so on.
Bhosale et al. in his research states that the Greedy algorithm can be close to the optimum to approach the factor (1-1e). However, this algorithm is quite expensive to overcome the problem maximization effect on large scale networks [1]. Zhenhuan in his research explained, the greedy algorithm can reach a good solution in a short time, the experimental data shows that it is quite effective [2]. Meanwhile, Patil & Amaratir concluded that the greedy algorithm is faster and more efficient in terms of the number of iterations needed to segment objects from an image compared to the M Kass algorithm [3]. Duchon et al. in his research stated that the A-Star algorithm is suitable for use in cases where it is necessary to find a path quickly and well in various environments [4]. Septiana et al. in his research explained that the optimal path search process in the WSN routing technique using the A-Star algorithm is very dependent on the heuristic function, so that the effectiveness of the evaluation function is increased by adding a heuristic function when searching [5]. Whereas, Wang et al. in his research explained that a good path search algorithm is needed in navigating the path of travel, the A-Star algorithm is used to overcome low computation in map navigation and add a hierarchical mechanism to the path search problem [6].
Sabri et al. in his research revealed that Dijkstra's algorithm can find the shortest path in the case of choosing an exit route for the evacuation process. This algorithm was chosen because it can efficiently deduce the shortest path in its solution [7]. Abderrahim et al. in his research proposes a new energy saving algorithm using Dijkstra's algorithm, where this strategy can improve the results obtained [8]. Meanwhile, Jiang et al. In his research extending the famous shortest path algorithm to consider edge weights and node weights for graphs derived from SDN topology, the Dijkstra algorithm is applied in extended pyretics [9].
Several studies have shown that the Greedy, A-Star, and Dijkstra algorithms can be applied in the process of finding the shortest or fastest path in a path or graph. Each algorithm has its own advantages and disadvantages. This is what underlies the author to further analyze the Greedy, A-Star, and Dijkstra algorithms. The purpose of this research is to analyze the Greedy, A-Star, and Dijkstra algorithms in the process of finding the shortest path. The author wants to compare the effectiveness of the three algorithms in the process of finding the shortest path in a graph.

Greedy Algorithm
Greedy Algorithm is an algorithm that can solve problems by making the best choices in certain cases. Many optimization problems can be solved using this algorithm [10]. The Greedy algorithm can reduce the computational complexity with the persistence of high mesh quality, however, this algorithm generates additional time costs, resulting from the selection loop [11]. Greedy algorithm can be combined in finding sub-optimal solutions in a shorter time [12]. The Greedy Algorithm is a gradual inference process starting from the zero model and solving the problem heuristically [13]. Greedy algorithm is recommended in signal processing and machine learning [13][14] [15]. The Greedy Algorithm solves the problem step by step, at every step: a. Take the best option available at that time. b. Hope that by selecting local-optimum at each step will achieve global-optimum. This algorithm assumes that the local optimum is part of the global optimum.
The optimization problem in the context of the Greedy algorithm is composed of the following elements: a. Candidate set (c). b. The set of solutions (s). c. Selection function. d. Feasibility function. e. Objective function.
In other words, the Greedy algorithm involves the search for a subset s, from the set of candidates c, in which case s must meet some specified criteria, namely declaring a solution and s being optimized by an objective function. Figure 1 shows an illustration of the Greedy algorithm

A-Star Algorithm
The A-Star algorithm is one of the best-known path planning algorithms [16], which can be applied to a configuration space metric or topology. This algorithm uses heuristic search and search based on the shortest path [17]. In terms of search, this algorithm is good in various environments [4]. The A-Star algorithm is a classic path search algorithm and can be used to search mazes [18]. The A-Star algorithm guides the optimal path to the goal if the heuristic function h(n) is acceptable, meaning that it will never overestimates the original cost [19] or actual cost [20]. Evaluation function f(n) = g(n) + h(n), where [17][21] [22]: g(n) = cost so far to reach n. h(n) = estimated cost from n to target (goal). f(n) = estimated total cost of the path through n to the target.

Dijkstra's Algorithm
Dijkstra's algorithm can be used to find the shortest path between nodes in a graph, for example on a road network or path. Djikstra's algorithm tends to be fast in finding solutions but is unable to deal with negative weight values [23]. Dijkstra's algorithm has a target, namely to find the distance from one node to another. This algorithm claims to be the best approach in solving the simple shortest path problem [7] [24]. The Dijkstra algorithm for finding the shortest path is as follows [25]

Methodology
The purpose of this study is to analyze the Greedy, A-Star, and Dijkstra algorithms in the process of finding the shortest path and to compare the effectiveness of the three algorithms in the process of finding the shortest path in a path or graph. To achieve this goal, there are several processes or stages in analyzing the Greedy, A-Star, and Dijkstra algorithms in finding the shortest path. Figure 2 shows a diagram of the research method in the analysis of the Greedy, A-Star, and Dijkstra algorithms. In Figure 2, can be see the process of the Greedy, A-Star, and Dijkstra algorithm analysis flowchart in the process of finding the shortest path. Where the goal is to find out which algorithm is best in the process of finding the shortest path.

RESULTS AND DISCUSSION
The analysis process in comparing the Greedy, A-Star, and Dijkstra algorithms in the process of finding the shortest path requires a path or graph that already contains the cost or distance from one node to another. Figure 3 will illustrate the form of a path or graph that will be tested using the three algorithms discussed. The next process is to set node A as the initial state and node N as the final state. Then apply the algorithm to the graph starting with testing the Greedy algorithm. In applying the Greedy algorithm, the results can be seen in Figure 4. In Figure 4, it can be seen that the path taken from the initial state to the final state, the Greedy algorithm through a path that has a cost value that tends to be smaller so that the path that is Next is to apply the A-Star algorithm to the graph with the same initial and final state as in the Greedy algorithm test, namely the initial state at node A and the final state at node N. However, first determine the straight-line distance to node N. The A-Star algorithm shows the results that can be seen in Figure 5.  In Figure 5, you can see the path that will be followed from the initial state to the final state. The A-Star algorithm goes through a path by calculating the cost of a path with straight-line distance to node N so that the path that is passed from the initial state to the final state is A → C → H → M → N, with a total cost of 444.

Straight-line distance to node N
Next is to apply the Djikstra algorithm to the graph with the same initial and final state as in the Greedy and A-Star algorithm tests, namely the initial state at node A and the final state at node N. In applying the Dijkstra algorithm, the results can be seen in Figure 6. In Figure 6, you can see the path that will be followed from the initial state to the final state. Dijkstra's algorithm goes through a path by calculating the cost of a path by comparing each cost in the path from the initial state to the final. So that the shortest path that will be taken from the initial state to the final state is A → C → H → M → N, with a total cost of 444. Next, we retry the three algorithms by placing the initial state on a different node. Table 1 shows the trial results of the comparison of the Greedy, A-Star, and Dijkstra algorithms. In Table 1, we can see the comparison between the Greedy, A-Star, and Dijkstra algorithms. Where the difference in results for each algorithm is seen. In the Greedy and A-Star algorithms, there is a node that cannot be reached. Meanwhile, the Dijkstra algorithm can find all the target nodes but uses a very complex search. Figure 7 shows a comparison graph of the three algorithms. In Figure 7, we can see a comparison between the Greedy, A-Star, and Dijkstra algorithms where the Dijkstra algorithm can find all the nodes that are targeted or destinations. So that from the three algorithms that were tested in the case of finding the shortest path with complex searches, the author recommends the Dijstra algorithm as a problem solution.

CONCLUSION
From the results of the research that has been done, several conclusions can be drawn, including: a. The results of the Greedy algorithm analysis with several trials can find the shortest path in a fast time, but there are some cases where the optimal solution is not found or the solution (final state) is not found at all. b. The results of the A-Star algorithm analysis with several trials can find the shortest path better than the Greedy algorithm, the second equation is that they have found cases where the target (final state) is not found. c. The results of Dijkstra's algorithm analysis with several trials can find the shortest path better than the Greedy and A-Star algorithms. In this case Dijkstra's algorithm can find a solution (final state) which tends to be better than the two and always finds the optimal solution. d. The weakness of the Greedy algorithm is that it tends to take choices that do not take into account the next event, while the weakness of the A-Star algorithm is that the graph must have complex data such as straight-line distance to node (final state), while the weakness of Dijkstra's algorithm is the opposite of the Greedy algorithm. that is, they tend to be slow in finding solutions because they have to compare the cost of one path with the cost of another path.