BEST ALGORITHM FOR SHORTEST DISTANCE BETWEEN TWO POINT

Sanskar Dhomse

Copywriter
Medium
Microsoft Office 365

Abstract —

Presently days in PC network steering depends on the briefest way to issue algorithms. This paper's fundamental goal is to comprehend the filling in as well as attempt to think about different highlights of various most limited way calculations like Dijkstra calculation, Flloyd-Warshall calculation, Bellman portage calculation, and A* calculation, and more which are utilized in tackling briefest way issues to assess the best calculation. A concise assessment of different kinds of most limited-way calculations is done.
In this paper, we contrast four calculations that assist with finding the best calculation for the briefest distance between two points. In this examination, we find out about the running time with A* is quicker than with DijkstrÀs calculation, and the time intricacies are like those of DijkstrÀs algorithm. In general, studies suggest that A* computations are better than other calculations.

Keywords —

DijkstrÀsAlgorithm, Bellman-FordAlgorithm, Floyd-Warshall Algorithm, A*algorithm, Shortest Distance Finding, Best Algorithm for Shortest Distance Finding.

Introduction

From sending emails to text messaging to utilizing social media and even maps, technology has shown to be quite beneficial to us. People use maps for a variety of purposes, including finding the nearest restaurant, café, or gas station, as well as getting instructions from home to work. The “shortest path” from the starting point to the destination is typically the answer when looking for a way to get from one place to another.
For many years, researchers have investigated the topic of determining the shortest path. The shortest path between nodes or vertices in a graph is determined using this issue (in this case, a road network). The set of vertex points on a graph is known as an edge. A graph is a two-dimensional mathematical entity made up of vertices and edges. The shortest path problem is the challenge of determining the shortest path between two nodes if we are going to journal. It is a problem of finding the lowest-cost path between two vertices in a network with edges connecting them.
Distribution is a marketing activity whose goal is to make it easier for manufacturers to convey goods to buyers. In the distribution process, a producer in a certain area serves a set of clients. At the producer’s office, a team is in charge of a fleet of automobiles. A depot meets each customer’s requirements. To lower their entire operating transportation cost of distribution, the depot must locate a suitable road network for the vehicles as a manufacturer.
Many algorithms exist to tackle the shortest route issue. DijkstrÀs algorithm, for example, is a greedy algorithm. A graph search method is utilized in this approach to locate the shortest path on a graph with no negative side costs and to generate the shortest path tree. It’s commonly used to fix routing problems. A heuristic is a technique for swiftly resolving an issue. That is completed using substituting correctness, optimality, completeness, or precision for pace.
. The A* method finds a path from a given beginning node to a given goal node in a graph. It calculates the best route through that node using a “heuristic estimate” h(x).
These four algorithms all work with graphs, which are a sort of data structure. A graph is made up of nodes, or vertices, designated V, and connections, or edges, labeled E, that link them. Each edge is also given a non-negative integer weight, which indicates the metric distance between two nodes. The total of the weights of the edges that make up the path determines the distance between two nodes. The key goal is to identify the shortest path between nodes with this in mind.
It visits the nodes in the order determined by the heuristic estimate. This study will examine and contrast DijkstrÀs and A* algorithms, Bellman-Ford Algorithm, and Floyd-Warshall Algorithm to solve the shortest path issue.

RelatedWork

Following are some algorithms that can be used to analyze and find the fastest route & shortest between two point
He Li1, Lai Zhijian published in 2010 ”The Study and Implementation of Mobile GPS Navigation System Based on GoogleMaps’’IN This paper provides a mobile GPS solution that includes features like Google map browsing and querying, bus line search, and fast local placement on your phone. According to the research, a Google Maps-based mobile navigation system is practical and viable, and it can be used in PDAs, mobile phones, and other portable information terminals.
Kairanbay Magzhan and Hajar Mat Jani published in June 2013 ”A Review And Evaluations Of Shortest Path Algorithms The primary goal of this research is to compare and contrast DijkstrÀs Algorithm, Floyd-Warshall Algorithm, Bellman-Ford Algorithm, and Genetic Algorithm (GA) for determining the shortest path. The computed time complexity for each of the DijkstrÀs, Floyd-Warshall, and Bellman-Ford algorithms shows that their overall performance in solving the shortest path issue is satisfactory. Because the result can vary each time the GA is run, the key advantage of GA over these algorithms is that it can produce a variety of optimal solutions.
In 2015, Shrawan Kr. Sharma and B.L. Pal published “Shortest Path Searching for Road Networks Using A* Algorithm,” in which they investigate how the A* algorithm outperforms DijkstrÀs algorithm. They claim that this is true in medical emergencies, spying, theft detection, firefighting, and market-like situations. The A* algorithm is the fastest and provides the best shortest path. Due to the demands of time and situations, we will choose the Bi-directional search technique for searching the path instead of the Dijkstra algorithm because of its resilience and variants. This strategy minimizes the system’s searching time and finds the quickest and optimal path.
Jennifer C. Dela Cruz, Glenn V. Magwili, Juan Pocholo E. Mundo, Giann Paul B. Gregorio, Monique Lorraine L. La Moca, published in 2016 “Items-mapping and Route Optimization in a Grocery Store using DijkstrÀs, Bellman-Ford, and FloydWarshall Algorithms” The study uses three shortest-path-finding algorithms in a grocery store, namely DijkstrÀs, Bellman-Ford, and FloydWarshall Algorithms, to provide users with the shortest path to take while getting the items on their grocery list. The three algorithms produce similar path lengths in most cases, but they differ in processing time due to the different number of items in the list and it also reduces the distance traveled by the user and steps taken with the help of the application.
Amgad Madkour, Walid G. Aref, Faizan Ur Rehman, Mohamed Abdur Rahman, and Saleh Basalamah published in May 2017 “ A Survey of Shortest-Path Algorithms” This study gives a taxonomy-based survey of shortest-path algorithms. The various types of shortest-path problems are one dimension of this taxonomy. Because of the space and time complexities associated with each algorithm, there is no single general algorithm capable of solving all variants of the shortest-path problem. The survey also discusses the challenges and potential solutions for each taxonomic category.
Yuda Dian Harja published in 2018” Determine The Best Option for Nearest MedicalServices Using Google Maps API, Haversine and TOPSIS Algorithm” This study intends to provide a location-based medical service that takes into account two important variables: journey distance and time. This system uses the Haversine algorithm to locate medical services within a given radius. The best option for the results is determined using the TOPSIS algorithm. Using this strategy, the entire system demonstrates that the research findings provide a better decision-making method than previous studies
In 2018, Zafar Ali Khan released “Comparison of DijkstrÀs Algorithm with Other Proposed Algorithms.” In this work, we look at DijkstrÀs Algorithm, which has received a lot of attention since it can handle several real-world issues. This algorithm is greedy. Other sorts of algorithms are also developed and compared. Application-based adjustments are made to the original algorithm. The time complexity of the method is increased at the price of its space complexity. Because contemporary technology allows for increased space complexity, such an algorithm may be built.
Dian Rachmawati and Lysander Gustin published “Analysis of DijkstrÀs Algorithm and A* Algorithm in Shortest Path Issue” in 2019. In this research article, we compare A* Algorithm and DijkstrÀs Algorithm to solve the shortest path problem. Dijkstra and A* practically match each other due to this work. When it comes to large-scale maps, however, A* is marginally better than Dijkstra.
“Survey of Shortest Path Algorithms,” by Dr. Shaveta Bhatia, was released in 2019. The major purpose of this study is to evaluate and analyze numerous shortest-route algorithms used to solve shortest-path issues, such as the Dijkstra algorithm, the Floyd-Warshall algorithm, the Bellman-Ford method, and the Genetic algorithm, among others. The outcome of comparing the temporal complexity of the Dijkstra, Floyd, Marshall, and Bellman-Ford algorithms.
.DAN-DAN ZHU AND JUN-QING SUN published “A New Algorithm Based on Dijkstra for VehiclePath Planning Considering Intersection Attribute” in 2021. In this research work, we look at “A New Algorithm Based on Dijkstra for VehiclePath Planning Considering Intersection Attribute.” In a deterministic network, the purpose of optimization is to reduce transit time from the origin to the destination. They employ the Dijkstra algorithm to find the source and destination (RLDA). Convergence efficiency and calculation speed of RLDA and PSO, GA, ACO, NNA, and OPAL The RLDA algorithm has a greater convergence rate than ACO, NNA, and GA, according to the statistical data.

Methodology

Fig .1)Road map as a weighted graph
A ) DijkstrÀs Algorithm — Steps for the Nodes :
The following graph shows the total distance between the previous one and the nodes. These details are usually only in the table above, not in the chart.
Step 1: Analysis of the First Nodes Neighbors.
Table No 1) Table of Nodes and Total Distance
Step 2: Analyzing Nodes Nearby NODE È
We repeat the identical procedure of step 1 of beginning node 1 for the next node within the node list. acquaintances three take a look at nodes 2, 3, 4, 3, 4. Among nodes A and B, the full distance remains endless. As a result, we set their total distances to be the sum of the overall distances of the contemporary 2 and 3 nodes.
Here is the diagram with the updated data A ‘and B’: This absolute distance appears differently about F’s complete distance. The figured complete distance 7 surpasses the put away absolute distance 4.
Table No 2) Table of results status
The new entries should be written as follows: À and B’ were identified; À takes 4 minutes to reach through node E’, whereas B’ takes 6 minutes to reach node E’.
Step 3: Analyzing Nodes Nearby NODE Ć
We take it off the list and examine its immediate neighbors, R, M, and K: Node N has been removed from consideration and is no longer on the list. The following are the total distances between R and N and K.
À already has a shorter route through E’ with a total distance of 4 saves. As a result, we disregard the newly identified path through C’ to À with the longest total distance 5 and leave Às table entry untouched.
Table No 3) It shows the Position of Ġ

Step 4: Examining All Unvisited Neighbors of the Next Node

Investigate all unvisited neighbors of the ongoing hub and register their distances by increasing the ongoing hub’s ongoing distance by the edge’s weight, which makes the connection between the ongoing hub and the neighbor hub. Contrast the recently figured distance with the distance allocated to the close by the hub and believe the outcome to be the adjoining hub’s ongoing distance.
Step 5: Finding the Shortest Route to Your Destination
Our objective hub K is presently the primary thing on the rundown. There are not any more obscure hubs with a more limited all-out separation from which to track down a more limited way.
The table shows that the fastest course to the objective hub K is through R and has a complete distance of 9.0.
Thus, the most limited way is:Ḋ — Ć’- Ġ- Ḣ
.
III.2 ) A* Algorithm analysis Step –
In the image below, all that is left of the previous system and package. This information is usually displayed on the table and not in the picture, and it is easy to understand when you are playing.
Fig .2)Remaining costs calculated by the heuristic function
Step 1: Analyzing the Starting Point’s Neighbors
We examine the first element in the table, node Ḋ, and its neighbors, nodes Ć, È, and Ḟ:
The total costs of the neighboring nodes are still infinite at this point, indicating that no paths have yet been found. Now we know how to get there — specifically, to the starting point Ḋ.
The values for C’, for instance, are as follows: Total cost from beginning to end: 3.0 (cost from D’ to C’) The remaining cost is 3.20. All costs added together: 3.0 + 3.20 = 6.20 The same procedure is followed for E’ and F’. To make things clearer, we’ve added the following results to the graph:
The configuration is as follows: Find nodes E’, F’, and C’. They can be achieved by taking D’ for 1, 4, and 3.0 minutes, respectively. After adding the balance to the destination, it takes 3.50, 5.50, and 6.20 minutes to reach the destination through the corresponding node. Unlike Dijkstro’s algorithm, differences can be avoided.
This is the difference between the DigkstrÀ and A* algorithms. We installed a table at full cost, which explains why the transmitter is in front of the node.
The nodes are shown in the wrong direction, but the Onjeja nodes are in the same direction. A* Algorithms quickly recognize that routing through nodes gets faster over time. However, in most cases, the difference is greater. As a result, they take precedence.
.
Step 2: Analyzing All Nearby Nodes to the È
We rehash the interaction for the hub that is presently at the highest point of the table. That is node È. We extricate it and take a gander at its neighbors, À, B’, Ḋ, and F’
In the table, Node Ḋ is at this point not present. That implies we’ve proactively tracked down the briefest course to it (it’s a similar beginning hub we managed before). Subsequently, we can disregard it as of now.
We haven’t yet found a way to Nodes À and Ḃ because their all-out costs are limitless. By adding the complete expense for the ongoing hub È, as well as the expense from node È to hubs An and B, we can compute the all-out cost from the start to these hubs:
The path to node Ḟ has already been discovered for 4.0. The paths to the present node È might be quicker. To test this we must compute the whole cost through node È to node Ḟ and ensure that the overall costs estimated using È (7) are more than the total costs previously stored (4). That is, we may uncover a new approach to Ḟ, but it will be taking more time than the one we currently know. As a consequence, we disregard it and leave node Ḟ table entries alone.
The new entries are as follows: Nodes À and B’ have been found. They may be accessed in 4 and 6 minutes, respectively, through node È’. When the destination’s minimal remaining charges are included, the total time to reach the destination through the corresponding nodes is 7.90 and 10.3 minutes, respectively. Because these values are greater than the values of nodes Ḟ and C’, then nodes À and B’ are nevertheless shown after Ḟ and Ć.
Step 3: Analyzing All nearby Node for Ḟ
We repeat the procedure for node Ḟ, looking at its neighbors Ḋ, È, and Ḣ: Nodes Ḋ and È have been removed from the table. We’ve already determined the quickest routes to them (in the previous two steps).
The final point is Node Ḣ. As a result, we won’t need to add any additional expenses. We complete the preceding and total costs as follows:
As a result, we’ve discovered a route to the destination node Ḣ. It has a total cost of 11 and travels through node Ḟ. In the table, we make the following changes to node Ḣ:
In the table, there are three nodes with a cost sum of less than 11, indicating that we might be able to find a faster route to the destination through these three nodes. We must continue until the target node reaches the table’s top.
Step 4: Analyzing the All of Neighbors Node K
The next node in the table is node N. We remove it and examine its neighbors, M, L, and I:
We had proactively found a way to hub À through È with an all-out cost from the beginning of 4. The complete expense through the new course to An is higher (5), so we disregard the newfound way.
We had not yet found a way to hub Ġ. We add to the equitable determined absolute expenses from the beginning the leftover expenses for the objective determined ahead of time:
Node Ġ has risen to the top of the table. The A* algorithm now assumes, with the help of the heuristic, that node G is the quickest way to the destination.
Step 5: Analyzing of Neighbors of Node Ġ
So we have to look at the neighbors of nodes Ġ, Ć, and Ḣ. We had completed the Node Ć in the previous step, then it’s no longer in that table.
From start node to finish, from node Ġ to node Ḣ, we have to calculate the total cost:
Node Ḣ has a cost of 11. As a result of this, we’ve discovered a faster route from node Ġ to the end node Ḣ. The destination node in the table is still ahead of Node À. The entire cost of this node is less than the total cost of node Ḣ, which was just computed. The algorithm will then determine whether or not such a path exists.
Step 6: Analyzing All of the Neighbors Node of À
We should have gone about it: We take hub An and look at its neighbors, Ć ‘, and E’: Both hubs are at this point not in the table. We have proactively handled the two of them. So in this progression, we won’t track down an unseen way to the objective.
The quickest route to the destination has been discovered. That is to say, there are no nodes through which we can find a path to the end node that is even shorter. Not even by way of node Ḃ?
Our target node has risen to the top of the table.
The quickest route to the destination has been discovered. That is to say, there are no nodes through which we could find the path to the end node that is shorter than this. Not even by way of node Ḃ?
III.3) Floyd-Warshall Algorithm Steps by Step analysis
In a weighted diagram, the Floyd-Warshall Calculation is utilized to track down the most limited way between all sets of vertices. Both coordinated and undirected weighted diagrams are upheld by this calculation. Nonetheless, it works for diagrams with negative cycles (i.e., when the amount of a cycle’s edges is negative).
For a graph with N vertices, the algorithm steps are as follows:
Step 1: Use Infinity to create the shortest paths between any two vertices.
Step 2: Find all pairs of shortest paths that have 0 intermediate vertices, 1.0 intermediate vertice, and so on, until all nodes are used as intermediate nodes.
Step 3: In the previous operation, reduce the number of shortest paths between any two pairs.
Step 4: For any two vertices (Ì, Ĵ), the shortest path should be found by minimizing the distances between them using the first K nodes.
III.4 ) Bellman Ford Algorithm –Steps by Step analysis
As the name suggests, Bellman Ford’s algorithm lengthens the path length between start and end, then duplicates the prediction by finding a new path and then finding a shorter path than expected in the length of the route
Fig .3)Graph with negative edge weights
Step 1: Start with the weighted graph
Step 2: After choosing a starting node, assign an infinity to the path of values to all other nodes.
Step 3: Examine each edge and, if necessary, adjust the path distances.
Step 4: We must repeat this procedure times because, in the worst-case scenario, a node path length may need to be adjusted.
Step 5: Take note of how the path length of the node in the upper side right corner was changed.
Step 6: Now that all of the vertices have their path lengths, we can see if there is a negative cycle.
IV. Result & Discussion
To ensure that each algorithm’s theoretically calculated time complexity is right.
The A* algorithm significantly improves runtimes (by a factor of two to four). This, however, is not a universally true statement. The structure of the graph has a big impact on whether or not A* is faster than Dijkstra. When it comes to street maps, A* is usually much faster.
Only use Floyd-Warshall when looking for the shortest paths between all node pairs. When the graph has negative edge weights, Bellman-Ford should be used.
If the graph does not have negative edge weights and a heuristic can be defined, A* should be used.
DijkstrÀs algorithm should be used in the absence of negative edge weights and heuristics.
V. Conclusion:
However, neither Dijkstra nor A* are acceptable algorithms in some instances. The A* The set of rules extensively improves runtimes. This, however, isn’t always a universally authentic announcement. The structure of the graph has a large impact on whether or not longer A* is quicker than Dijkstra. when it comes to road maps, A* is commonly plenty faster. Moreover, Dijkstra, Floyd-Warshall algorithm, and Bellman-Ford are mostly applicable for short graphs. For large graph sizes, A* is the best-suited algorithm. We taught (or re-learned) about negative edge weights, how the Bellman-Ford technique finds the shortest path in a directed graph with negative edge weights, and how negative cycles are found.
Bellman The structure of Ford and DijkstrÀs algorithms is extremely similar. While Dijkstra only considers a vertex’s immediate neighbors, Bellman goes through each edge in each iteration, resulting in substantially greater temporal complexity than Dijkstra and A*. The Floyd-Warshall algorithm, how it works, and how it detects negative cycles (where you need the shortest distances between all node pairs). The time complexity is much higher than that of all previous pathfinding techniques. As a result, Floyd-Warshall should only be used for the authorized purpose.
Partner With Sanskar
View Services

More Projects by Sanskar