Connected Cluster Based Node Reduction and Traversing for the Shortest Path on Digital Map
This paper elaborates the algorithm and methods applied on a digital map and explains how the digital map is reduced into its nodal form for obtaining the shortest path along with navigation, directions and the individual distances. The algorithm uses different types of data structures appropriate for different approaches and interacts with the digital map or its nodal form. Auxiliary data structures along with the respective methods are added in the algorithm to decrease the time and space complexity. The time-memory tradeoff is observed during the implementation through the two memory allocation schemes. In the beginning, static memory allocation is used which is followed by the dynamic memory allocation. Both the schemes have their corresponding consequences. Precision in navigation is varied on the basis of peculiar requirements so that the overall complexity of the algorithm can be reduced. The algorithm first processes the digital map and identifies roads and junctions which will be the input for further processing. Cluster based approaches are applied for simplification and efficiency purposes. The paper compares the various algorithms for obtaining the shortest path. Comparison of the diverse experiment results show the improvement in the execution time and memory consumption.
KeywordsShortest path Algorithm Analysis Data structure Cluster Node representation Node reduction Optimization Digital map Navigation
The shortest path algorithm is conceptualized on an appropriate data structure. Digital map, an image having numeric values, represents roads. The road is considered to be present where the connected pixels have 1 s. Digital map is a network that is taken as an input for finding junctions within it. Program memory is allocated on static or dynamic basis and as per starting and destination points, the algorithm is then executed, data structures are manipulated and decisions are taken. Initially, the paper explains the basic algorithm and its interaction with the data structure. Then, it describes how optimization is applied on the data structure as well as on the algorithm. Subsequently, it demonstrates how auxiliary data structures are introduced. These three phenomena are elaborated in their respective sections. The entire algorithm, along with its further optimization, is implemented in Language C. Sufficient care is taken on memory deallocation by applying the methodologies present in [1, 4].
Throughout the paper, the two-dimensional array (MAP) refers to the digital map. Different colors in figures are associated with their values of pixels and behaviors. Ls and Ld symbolizes starting location and destination location respectively. They are represented in terms of the Cartesian coordinate system i.e. (xstart, ystart) and (xdestination, ydestination). Digital map represents the interconnected paths from which the algorithm gets reference of available paths and locations from where there may be more than one way to go further i.e. a junction. Initially, a digital map is a binary-valued MAP.
3 Static Memory Based Algorithm (SMA)
3.1 Data Structure
Data structure pathVector is a 3D array that stores all the possible paths from Ls to Ld. Its significance is discussed now. pathVector[index][state]: index and state as column and row respectively in Fig. 1, pathVector = x coordinate of any location, pathVector = y coordinate of any location, pathVector = 1 if (x, y) is a path else 0. Initially, Ls is inserted into pathVector i.e. xstart, ystart into pathVector and pathVector respectively.1 Data structure found is an integer array to store all the indexes of pathVector[index] in which the last state has Ld. That is pathVector[index][statelast] = xdestination and pathVector[index][statelast] = ydestination. Till state = statelast, pathVector[index][statelast] is 1. For next state = statelast+ 1, pathVector[index][statelast+ 1] is 0, indicating that the ongoing path is now terminated. The foundIndex is a variable pointing to the current index of array found where the upcoming index value will be stored and the terminating location is Ld. This data structure is modified further for faster execution.
3.2 Algorithm Description
The algorithm starts its execution from Ls and terminates at Ld. Since Ls is inserted into pathVector as stated earlier, it is the location from where the algorithm explores all the possible paths through its adjacent locations towards Ld. This procedure is repeated continuously. Recursion is responsible for finding the shortest path automatically but for this, current paths must be saved so that they can be compared with upcoming paths and hence, the shortest distance can be computed. Algorithm saves coordinates of the path into pathVector on which it is currently moving. Now, for each next adjacent location, there are two possibilities i.e. whether it will be a path or a junction. If it is a path then the algorithm simply keeps moving on it, which indicates that there is only one adjacent location (except the previous location) that is available for the next step. If it is a junction then the traversed path till that junction will be saved following which all adjacent locations will be traversed. This procedure will be executed in a loop for all the adjacent locations (except the previous location), where the path till the current junction is accessible in the scope. In this case, for each adjacent location, a new index of pathVector will be generated for each new path traversed through that adjacent location. The next free index of pathVector is saved in a variable called pathIndex. After having junction and the new adjacent location, pathIndex will be incremented. Execution of the algorithm is elaborated with parts of the code.
Functions trace(), split(), getEndpoint() and replicateIndex() are explained below using the definition and the body of each. The code is having pointers of Language C. Pointers are used so that they can be parameterized and passed into the function representing the address of the particular 2D array.
Algorithm executes the function shown in Fig. 3 each time it moves on to the next adjacent location. If the current location is Ld then, the currently used index of pathVector[index] will be saved as found[foundIndex] = index where foundIndex will be incremented. Thus, the list of paths having Ld as a terminating location can be acquired from found for further processing. If the current location is a junction then it will call the function split(). Else, if it is a path then it will find the next adjacent location. If the adjacent location is a path then it will insert that adjacent location into the end location of the current branch i.e. at the location pointed by branchEnd, which gives the array index that is not filled by the location value earlier and comes next to that array index having a location value. Here, **p is a pointer of a 2D array to the pathVector which comes from parameters of the function. Function trace() is called by inserting that adjacent location as a parameter, **p being same as that of the parameters. Parameter vect points the pathIndex of **p. If an adjacent location is a junction then the function trace() will be called without any insertion and control will be transferred to the function split().
The function shown in Fig. 3 is applied when the current location is a junction. Since it is a junction, there will be more than one possibility where the algorithm will spread itself. Those new possible paths will have paths from start till the current location in common. After the initialization of these common locations, their independent path locations will be filled up in arrays pointed by their respective indexes. Here, the function replicateIndex(int) returns an Integer value of the array index that is available for replicating common location coordinates. Current pathIndex is pointed by vect and the common locations are to be copied from the index vect into the newly generated index newIndex for each new possible path passing from an adjacent location. The function getEndpoint(int, int, int**) returns the Integer value 1 if the locations represented by first two arguments are present in the array and 0 if they are not. It changes the global variable branchEnd to the index where the current location coordinate will be inserted and the function trace() will be executed on it along with that newIndex pointing it for being further copied if any junction comes.
4 Dynamic Memory Based Algorithm (DMA)
4.1 Solved Issues of SMA
Dynamic Memory based Algorithm (DMA) uses the Linked List because it is a memory efficient data structure. SMA was based on the static memory that was allocated before the actual execution of the algorithm. DMA shows a significant improvement in the space complexity. In the data structure pathVector shown in Fig. 1, there are unutilized memory blocks which remains unutilized throughout the execution. This issue of wastage of useful memory under SMA needs to be solved. DMA allocates only necessary chunks of memory while execution for computation. As a specific part of the execution ends, it deallocates the memory used during such execution so that the same memory can be allocated again. The vital benefit of DMA is that, the memory parts of all the pathVector which were used to show whether the location coordinates are saved or not, making a distinction, is not needed in DMA because Linked List will allocate and append only the necessary memory chunks and when NULL comes, it will be the end of the Linked List.
4.2 Data Structure, Converted Methods and Results
5 Cluster Based Node Reduction Algorithm (CNRA)
5.1 Solved Issues of SMA and DMA
This approach gives a major breakthrough to DMA in dealing with much more complex maps particularly when there are cluster of coordinates close-by, representing the same nearby location. DMA is unessentially accurate which is not required in the real-world. By referring [2, 3], multiple interconnected junctions can be represented by one junction representing all of them. Hence, there is only one split() instead of multiple splits which implies a reduction in the time and space complexity.
5.2 Algorithm with Auxiliary Functions
The function assignCenter() traverses through all the junctions, assigns the center coordinate value and the number of junctions to the arrays, which are represented by the junctions of the cluster in centerMap. Whenever the algorithm approaches any of the junction, it will move to the center for the junction and then it will spread towards each path connected to that cluster. The center of the cluster is associated with the paths connected by the junctions. Function allocateBranch() links those paths in 2D array represented by the location of the center for junction on 4D array linkMap. Function getBranch() gives coordinates of path connected with a junction for assigning with allocateBranch().
5.3 Proposed Data Structure
6 Connected Cluster Based Traversing Algorithm (CCTA)
6.1 Traversal Overhead in CNRA
CNRA is based on digital map traversal, where the algorithm finds the path towards the adjacent location. If there is a path instead of a junction then the algorithm will simply traverse through all the continuous locations representing the same path. On every traversal of each path from their adjacent junctions, many locations are traversed invariably and this is the overhead. The algorithm should therefore, jump onto one junction from another directly without traversing intermediate nodes.
6.2 Connected Clusters Approach and Its Significance
Connecting clusters over their path removes overhead produced by traversing the entire path. If each cluster knows its adjacent clusters connected to it then, each cluster will be identified as a node and will be traversed directly to its adjacent clusters. Functionalities of DMA and CNRA are preserved in Connected Cluster based Traversing Algorithm (CCTA), only intermediate approach is modified. For applying this approach, the data structure of CCTA is modified and the required functions are added. Here, data structure linkMap is extended to its 4th dimension to length 5 i.e. linkMap. First two values represent branch coordinates, 3rd and 4th values represent coordinates of adjacent cluster connected to those branch coordinates and 5th value represents the length of the path between the current cluster and the adjacent cluster. These values are calculated before the actual execution of CCTA.
7 Comparison Among Approaches
Performance comparison among approaches.
Workstation, Intel Xeon, 24 Core CPU, 24 GB RAM
PC, Intel Core i7, Quad Core CPU, 16 GB RAM, Clock speed 3.4 GHz
Same as DMA
Same as CNRA
Thus, by the aforementioned analysis and the implementation of the algorithms, it is observed that SMA requires plenty of memory because of its static allocation. DMA on the contrary requires less memory but needs more execution time because it is entirely based on dynamic memory allocation – algorithm allocates and deallocates memory for further use which takes the CPU time (clock cycles). CNRA solves problems of both SMA and DMA by implementing auxiliary methods which simplify the execution. Clustering of junctions decreases the number of effective nodes and extends feasibility for much complex maps. CCTA bypasses the traversal of the path directly to the cluster so that it removes unnecessary intermediate traversal overhead. In doing so, it gives the same result as CNRA. In addition, it improves the execution time and memory consumption.
This paper illustrates how the digital map is represented and processed in its nodal form. CCTA can be elaborated like this – “Transform the given data into its compact form, process its compact form, generate an intermediate result and map it to the original data for an accurate result” i.e. transform the digital map into its cluster based node representation, process and map it to the digital map for obtaining the real-world shortest path.
These approaches can further be extended by compressing the nodal map of CCTA by some layers for simplifying it. Each layer can be mapped in a sequence. After having the shortest path by processing the compact map of the bottommost layer, its mapping with an above layered map can be used for obtaining an equivalent shortest path which is much apparent. Repeating the same procedure till the digital map i.e. till the topmost layer will give the real-world shortest path. Moreover, if the algorithm is modified to make it follow the direction towards the destination, it will eliminate the false positive directions further. In case, the algorithm is unable to find the destination, other possibilities of directions can be listed into the priority queue that depends upon the gradient of the current location to the destination location. The direction based approach is fast and intelligent while the earlier recursive approach is accurate, hence they exhibits the time-accuracy tradeoff.
Index 0 is shifted into index 1 only for first two dimensions so that representation can be user friendly i.e. pathVector and pathVector are shown as pathVector and pathVector only in figures. Index starts from 0 in actual practical implementation in Language C.
- 4.Kadia, D.: Binary search optimization: implementation and amortized analysis for splitting the binary tree. Int. J. Comput. Sci. Inf. Secur. 15(3), 338–341 (2017)Google Scholar
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made. The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.