
ANALYSIS OF DIJKSTRA’S AND A* ALGORITHM TO FIND THE SHORTEST PATH AMANI SALEH ALIJA A thesis submitted in fulfillment of the requirements for the award of the Degree of Master of Computer Science (Software Engineering) Faculty of Computer Science and Information Technology Universiti Tun Hussein Onn Malaysia SEPTEMBER, 2015 v ABSTRACT There are so many algorithms used to find the shortest path such as Dijkstra, A* algorithm, Genetic algorithm, Floyd algorithm and Ant algorithm. In this study, two algorithms will be focused on. This study compares the Dijkstra’s, and A* algorithm to estimate search time and distance of algorithms to find the shortest path. It needs the appropriate algorithm to search the shortest path. Therefore, the purpose of this research is to explore which is the best shortest path algorithm by comparing the two types of algorithms. Such that it can be used to solve the problem path, search to analyze their efficiency in an environment based on two dimensional matrix which is best because of lookup time. This study implements the algorithm in visual C++ 2008 and design interface for the algorithms that allow the user to find the shortest path with the search time and the distance by determine the size of map, starting node and the destination node. The experimental result showed the search time of A* algorithm is faster than Dijkstra’s algorithm with average value 466ms and the distance is same of the both of algorithms. vi ABSTRAK Terdapat banyak algoritma yang digunakan untuk mencari laluan terpendek seperti Dijkstra dan algoritma A*, algoritma genetic, algoritma Floyd dan algoritma Ant. Untuk kajian ini, dua jenis algoritma akan ditekankan. Kajian ini akan membandingkan masa carian daripada Dijkstra dan algoritma A * untuk mengetahui algoritma yang paling pantas apabila mencari laluan terpendek. Ia perlu algoritma yang sesuai untuk mencari laluan terpendek. Oleh itu, tujuan kajian ini adalah untuk meneroka laluan algoritma terpendek yang terbaik dengan membandingkan dua jenis algoritma yang boleh digunakan untuk menyelesaikan masalah laluan carian untuk dianalisa kecekapannya. Lingkungan berdasarkan matriks dua dimensi adalah yang terbaik oleh kerana masa pencariannya. Kajian ini akan menggunakan algoritma visual C++ 2008 dan reka bentuk antaramuka untuk algoritma yang membolehkan pengguna untuk mencari laluan terpendek dengan carian masa dan jarak dengan menentukan saiz peta, nod permulaan dan destinasi nod.Keputusan experimental menunjukkan carian masa bagi algoritma A* adalah lebih pantas daripada algoritma Djikstra dengan nilai purata 466ms dan mempunyai jarak yang sama. Bagi kebanyakkan komputer moden, memori tidak begitu penting, dan jika ia penting sekalipun, kawasan yang tidak digunakan boleh disembunyikan dan dimuaturun bila diperlukan. Untuk membandingkan jalan algoritma terpendek di antara dua algoritma yang digunakan, satu antaramuka telah direkabentuk. Ini adalah supaya perbandingan dapat ditentukan dan algortima yang mana yang lebih sesuai untuk mencari laluan terpendek. vii TABLE OF CONTENTS TITLE i DECLARATION ii DEDICATION iii ACKNOWLEDGEMENT iv ABSTRACT v ABSTRAK vi CONTENTS vii LIST OF TABLE x LIST OF FIGURES xi CHAPTER 1 1 INTRODUCTION 1 1.1 Background of study 1 1.2 Problem Statement 3 1.3 Objectives of the Research 3 1.4 Scope of Research 4 1.5 Motivation 4 1.6 Research Outline 4 CHAPTER 2 5 LITERATURE REVIEW 5 2.1 Introduction 5 2.2 Application Areas of Path Finding Algorithms 5 2.2.1 PFAs in Games and Virtual Tours 6 2.2.2 Robot Motion and Navigation 7 viii 2.2.3 Driverless Vehicles 8 2.2.4 Transportation Networks 10 2.2.5 Human Navigation 11 2.3 Shortest path analysis 14 2.4 Shortest path algorithm 14 2.4.1 Dijkstra’s algorithm 15 2.4.2 Depth-first search algorithm 20 2.4.3 A* algorithm 20 2.4.3.1 Manhattan distance 23 2.4.3.2 Diagonal distance 25 2.4.3.3 Euclidean distance 25 2.5 Comparison of A* and Dijkstra’s 26 2.6 Review of the techniques 27 2.7 Summury 31 CHAPTER 3 32 RESEARCH METHODOLOGY 32 3.1 Introduction 32 3.2 The flow chart for the project work 32 3.2.2 Finding the shortest path using Dijkstra algorithm 35 3.2.2 Finding the shortest path using the A* algorithm 35 3.2.3 Compare the result 37 3.3 Summary 37 CHAPTER 4 38 PSEUDO CODE FOR THE AND IMPLEMENTATION 38 4.1 Introduction 38 4.2 Dijkstra's algorithm 38 4.2.1 Pseudo code for Dijkstra's algorithm 39 4.2.2 Implementation of Dijkstra's algorithm 40 4.3 A* algorithm 41 ix 4.3.1 Pseudo code for the A * algorithm 42 4.3.2 Implementation of A* algorithm 43 4.4 Summary 44 CHAPTER 5 45 RESULT AND DISCUSSION 45 5.1 Introduction 45 5.2 Comparative Analysis 45 5.3 Summary 50 CHAPTER 6 51 CONCLUSIONS 51 6.1 Objectives Achievement 51 6.2 Summary 51 6.3 Future Work 52 REFERENCES 53 VITA 56 APPENDIX I 57 x LIST OF TABLES 2.1 Difference between A* algorithm and Dijkstra’s algorithm 26 2.2 Comparison of finding path algorithm 30 5.1 Comparison between A* algorithm and Dijkstra’s algorithm in search time 50 xi LIST OF FIGURES 2.1 3D Model of latiff and Hassan 6 2.2 (a) Grid vs (b) Framed-Quadtreee approach in D* algorithm 8 2.3 Autonomuos vehicle used in D* algorithm test 9 2.4 Champion DARPA challenge race 2005 10 2.5 (a) Dijkstra’s search, (b)A* search on road network of Dallas Ft-Worth urban Area 11 2.6 Kulyukin’s Robotic Aid 12 2.7 Wearable interface for Finger-Braille 12 2.8 Drishti’s navigation system 13 2.9 Dijkstra’s search 16 2.10 First step of Dijkstra’s algorithm 16 2.11 Second step of Dijkstra’s algorithm 17 2.12 Third step of Dijkstra’s algorithm 17 2.13 Step 4 of Dijkstra’s algorithm 18 2.14 Fifth step of Dijkstra’s algorithm 18 2.15 Step6 of Dijkstra’s algorithm 19 2.16 Shortest path by Dijkstra’s algorithm 19 2.17 Starting and Destination point in A* algorithm 21 2.18 Starting the A* search algorithm 21 2.19 Putting the neighboring cells to the open list 22 xii 2.20 Parent relation of Starting Node 22 2.21 Manhattan distance calculation 24 2.22 Diagonal distance calculation 25 2.23 Euclidean distance calculation 26 2.24 Comparison between A* and Dijkstra’s algorithm 27 3.1 The Steps Involved in the project work 33 3.2 The flow chart of Dijkstra’s algorithm 34 3.3 The flow chart of A* algorithm 36 4.1 Pseudo-code of the dijkstra’s algorithm for the shortest path problem 39 4.2 Segmentation source code for Dijkstra’s algorithm 40 4.3 Interface of Dijkstra’s algorithm 41 4.4 Pseudo-code of the A* algorithm for the shortest path problem 42 4.5 Segmentation source code for A* algorithm 43 4.6 Interface of A* algorithm 44 5.1 Case1 of Comparison between A*algorithm and Dijkstra’s algorithm 6 5.2 Case2 of Comparison between A*algorithm and Dijkstra’s algorithm 47 5.3 Case3 of Comparison between A*algorithm and Dijkstra’s algorithm 48 5.4 Case4 of Comparison between A*algorithm and Dijkstra’s algorithm 49 CHAPTER 1 INTRODUCTION 1.1 Background of the Study Path finding is defined as the process of moving an object from its earlier position to the final position. Different application areas used Path Finding Algorithms (PFA). These include Games and Virtual Tours, Driverless Vehicles, Robot Motion and Navigation. Path finding is usually described as a process of finding a path between two points in a certain environment. In most cases the objective is to find the shortest path possible, which would be optimal i.e., the shortest, cheapest or simplest. Several criteria such as, path which imitates path chosen by a person, path which requires the lowest amount of fuel, or from two points A and B through point C is often found relevant in many path finding tasks. Finding the shortest path is the most difficult issue in many fields, starting with navigational systems, artificial intelligence and ending with computer simulations. Although these fields have their own specific algorithms, there are many general purpose path finding algorithms that are applied successfully. However, it remains unclear what benefits certain algorithm have in comparison with others. Shortest path algorithms are currently used widely. They are the basis of some problems such as network flow problems, tree problems and other related problems. They decide the minimum cost of travel of the problems production cycle, the shortest path in an electric circuit or the most reliable way. The internet is a vast field where the shortest path algorithm is usually applied. The Internet problems comprise data package transmissions with minimal time or using the most reliable path. 2 This research attempts to make an implementation of a shortest path algorithm by using A* algorithm and compare it with Dijkstra's algorithm on different criteria, including search time and the distance were implemented to analyze their efficiency in an environment based on 2 dimensional matrix. A* algorithm is an algorithm that is widely used in path finding and graph traversal. The process of plotting a resourcefully traversal path between points is called nodes. A* traverses the chart and follows the lowermost known path, keeping a sorted priority queue of alternate path sections along the system. If at any position, a segment of the path being traversed has a higher cost as compared to another encountered path segment, it leaves the higher-cost path segment and traverse low cost path segment instead this procedure continues until the goal is reached.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages36 Page
-
File Size-