Application of Dijkstra algorithm in finding the shortest path

As the development of Automotive, people are doing research on self-driving and innovation of public transportation. The coming of 5G will made these come true soon in the future. And this paper is about an algorithm useful on transportation. Using Dijkstra algorithm to match two people who have the similar source and destination, then find the shortest path for them. For each person, the source and destination are two regions but not two points. This paper includes some methods to implement Dijkstra algorithm in detail and two examples to display the results. The algorithm is written in C language.


Introduction
Dijkstra [1] is an algorithm through which in a graph we can get all shortest paths from one point to all other points. This algorithm was pointed out at the year 1959, and it is useful to solve problems todays. For example, the function of finding the shortest path in self-driving cars and finding a partner from a region around a person and which has the similar destination with the person. Both are shown in the following example, which is the core of this paper. Dijkstra algorithm is faster than other algorithms for it can calculate the shortest length to every point, and the example below can display the practicability of Dijkstra algorithm.

introduction to this example
This example can match two people who have the similar source and destination, then find the shortest path for them. For each person, the source and destination are two regions but not two points. [2] The important structures included are pyramid tree and heap.

Find nodes
Firstly, in find nodes function, find all vertex nodes that in range and write them in a vertex set. For pyramid tree node, if it is a leaf node, check if it in range; if it is not a leaf node, recurse. According to professor Steven S. Lumetta, I use a structure called pyramid tree. For all nodes in a graph, we use a pyramid tree to mark. All real nodes in the graph are leaf nodes of pyramid tree, and internal nodes in the pyramid tree divide space into (up to) four quadrants (one node may have fewer children). For example, if one examines an internal node at array index N, array index 4N+1 is a subtree in which all nodes have x values no greater than the x value of the internal node at array index N and y values no greater than the y value of the internal node at array index N. [3] The structure of the pyramid tree is shown as follow. The figure right is from professor Lumetta.

Dijkstra algorithm and Heap
In Dijkstra algorithm, from the initial point, mark all next points we can get directly from initial point, and put all these points in a heap with their distances. Find the point with smallest distance, delete it from the heap, do what do on the initial point before, then update the shortest distance of some vertexes [4] . Repeat this many times until the heap is empty. I use a heap to pop the node with the smallest distance to the root of the top(H(0)), and delete it. Then after once recurrence, pop again. The new nodes added in the heap are as the leaf nodes. What's more, because the source in this example is a region including many vertex but not a vertex, for all vertexes in source, set their distance zero, so we can see them equally.

show it in graph
Figure2 example using ZJUI map data The two orange ranges are the source and destination of the person 1. The two yellow ranges are the source and destination of the person 2. They are matched because there are superpositions of both sources and destination. And the shortest path is shown in the graph. To finish this function, we set a array to store people. When a new person want to match someone, check if he or she can match someone already in the array, if not, put the person into the array to wait. Two matched people can go their shortest path together as shown above. The input data are taken from OpenStreetMap data for the ZJUI campus area.

Improve performance
The algorithm above still need to improve to cope with larger figure. There are four points I think can be researched in the future. Firstly, make use of dynamic allocation in several ways [5] , the structures in this examples including arrays and heaps can be dynamic allocate, so their sizes are related to the data in them, which can save some spaces. At the same time, dynamic allocation is also time consuming, so a practicable method should be used.
Secondly, the Dijkstra algorithm can be improved by using one-dimensional array. [6] And Ping Li, the author, compared the improved Dijkstra algorithm with Prim algorithm [7] and Huffman coding algorithm, and stated that it does save storage space and improves the running rate.
Thirdly, at the find partner part, it can be improved using a special number. This number can be 32 bits, 64 bits, 128 bits or so on, which means the size of this number is related to the number of vertexes in the graph. This number divides the graph in several regions as the number of bits. If this region have vertex in the source, it is represent as 1, otherwise 0. So the situation of one person's source can be represented as a number, AND two people's source numbers, if it is 0, means they are not match. The same as the destination region. This filter partner candidates quickly, which improve the algorithm largely.
Finally, there are many forms of heaps, so the heap used can also be optimized. [8] However, this need more research in the future, I still can't implement is in code.
Improve this example with the first, the second and the third improvement, I find that it can cope with more complex graph and faster. Following is also data taken from OpenStreetMap data for the ZJUI campus area but with more vertexes. This is generated using the first, the second and the third improvement.
Figure3: More complex graph with improvment

Conclusion
This application of Dijkstra algorithm may be used to new form of transportation, such as the combination of self-driving and public transit. This paper illustrates the Dijkstra example about the structure pyramid tree and heap, and then show the results in graph. Then point out four points that have been improved or will be improved in the future. This algorithm is being improved and will be able to cope with more complex graph. [9] In conclusion, this paper can be a base on transportation innovation. [10]