0% found this document useful (0 votes)
2 views

Research of Shortest Path Algorithm Based on the Data Structure (1)

This paper discusses an optimization of the Dijkstra algorithm for solving the shortest path problem, focusing on improving node selection and data storage efficiency. The proposed method reduces storage space and enhances operational efficiency compared to traditional Dijkstra, making it more applicable for large-scale problems. Comparative analysis shows significant improvements in computational speed and reduced data redundancy with the optimized algorithm.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Research of Shortest Path Algorithm Based on the Data Structure (1)

This paper discusses an optimization of the Dijkstra algorithm for solving the shortest path problem, focusing on improving node selection and data storage efficiency. The proposed method reduces storage space and enhances operational efficiency compared to traditional Dijkstra, making it more applicable for large-scale problems. Comparative analysis shows significant improvements in computational speed and reduced data redundancy with the optimized algorithm.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Research of Shortest Path Algorithm Based on the

Data Structure

Jinhao Lu Chi Dong


Department of Computer Science Petroleum Engineering Institute
Northeast Petroleum University at Qin Huangdao Northeast Petroleum University
Qin Huangdao, China Da Qing, China
[email protected] [email protected]

Abstract-The shortest path problem based on the data structure


has become one of the hot research topics in graph theory. As the II. IDEA ANALYSIS
basic theory of solving this problem, Dijkstra algorithm has been
widely used in engineering calculations. Aiming at the A. The relevant concepts
shortcomings of traditional Dijkstra algorithm, this paper has Definition 1 Define the simple weighted graph
proposed an optimization method which has mainly improved the G=<V,E, W>; Assume VOoo,v(m_l),vm EV, where V(i-l),Vi is the
nodes selection of the shortest path and data storage structure node on the edge or arch ei; The set Vo, Vi, Vm denotes the
and organization. Through comparison and analysis, the
0 0 . 0 0 .

path between Va and Vm, which is written as 0, 1, ... i, ... m, and


improved algorithm has been obtained, which has reduced the
the rank of the path is the number of edges existing in the path.
storage space, improved the operational efficiency and has a
The length of the path is denoted as WrJl + W12+ W(n-l)no
better applicability in the shortest path calculation.
0 0 .

Therefore, the shortest path between Va and Vm is the length of


Key words-data structure; shortest path;Dijkstra algorithm the path between Va and Vm. Generally the directed graph and
undirected graph are taken as the exceptions in weighted graph.
I. INTRODUCTION Definition 2 Define the simple weighted graph
G=<V,E, W>, Va ...v(n-l) EV Denote the adjacency matrix of a
People's requirements for living and production efficiency
has improved with the rapid development of computer science, graph G by A(G),where:
in which the shortest path problem has become more prominent, jmij there are edges between V and V (
i i
and gradually becomes one of the hot topics of geographic 1)
information science,operations research,computer science and a = 00 there are no edges between V and V
ij i j

other disciplines [ 1]. It is not only the key problem in network o i=j
analysis but also the key issue in graph theory, and therefore it Where,wijis the weight value of the edge between Vi and Vi'
has been widely used in electronic navigation, network
optimization, logistics, transportation and other areas in From above formula, we can know that the main idea of
people's daily life. The shortest path is also the one between Dijksra algorithm is to iterate the path,and get the shortest path
the nodes in weighted graph of a data structure. Dijkstra according to the increase order of the path length, as is shown
algorithms used for calculating the shortest path, which was in (2).
introduced by the famous Dutch computer scientist
Eiziga Dijkstra,was recognized as the best algorithm that can

(2)
be applied to get the shortest path from a node to any other B. weighted graph storage
nodes [2]. Identify a shortest distance from the source point to
Graph storage problem in the computer is the primary
the other target nodes, and then use the path length to find the
consideration before programming. In this paper, weighted
shortest path iteratively, that is, the basic idea of Dijkstra
graph is denoted by the adjacency matrix cost [max][AX].
algorithm. However, with the development of the computer,
When there is an edge or arch between nodes Vi and Vi, cost[iJ[jJ
the scale of the problems is increasing continuously, and
is the weight value on the edge(Vi,vJ, and it will be presented
meanwhile the use of traditional Dijkstra has increased the
by OCJ when there is no edge. Combining with adjacency matrix
space and time complexity. Therefore, this paper has proposed
cost,the node order and the shortest path length between Vi and
the optimization of algorithm based on the data structure,
which has very important significance for improving the Vi can be obtained. Weighted graph is shown in Fig. 1, and its
efficiency of solving the shortest path algorithm. cost matrix is shown in Fig. 2.

978-1-4673-2008-5/12/$31.00 ©2012 IEEE

The Education Department of Heilongjiang province science and


technology research project: "Shortest Path Algorithm Application in
Logistics Management". Number: 12511065

108
Authorized licensed use limited to: Indraprastha Institute of Information Technology. Downloaded on February 06,2025 at 08:59:42 UTC from IEEE Xplore. Restrictions apply.
A. Analysis ofoptimization ideas
1) The selection of the shortest path nodes and nodes
ranking.
In Dijkstra algorithm, each node in the network diagram
will be changed from unmarked node to the shortest path node.
This change requires scanning a large number of stored
disorder unmarked nodes one by one, so that the shortest path
Figure 1. A directed weighted graph
of the intermediate node can be achieved. If calculating on the
basis of this large amount of data,the calculation speed will be
certainly affected. Now we can rank the nodes to be scanned
0 00 4 30 00 00
according to the label value, and it needs only one iteration to
0 00 00 8 00 obtain the eligible nodes, which increases the computational
00 15 0 00 00 5
efficiency significantly. Here the heap sort method given by
cost = Willioms is used to select the shortest path node.
00 00 00 0 00 00

In algorithm optimization, the original sorting nodes are


00 00 00 4 0 00
stored disorderly in the one-dimensional array and then was
00 00 00 10 18 00 ordered by heap sort to be changed into a small group,when all
the nodes can be stored according to the structure and storage
order of complete binary tree. After that, the 0 node stored is
Figure 2. Cost matrix
the heap element,followed by the left subtree and right subtree.
The time complexity (log N) is 0 in the heap adjustment
III. DUKSTRA ALGORITHM process, where N denotes the number of nodes to be ranked.
Compared to the next shortest path node selection from a list or
A. The classical Dijkstra algorithm description an array with disordered structure, this algorithm can highly
Dijkstra algorithm can label the nodes constantly. The improve running speed and reduce running time.
value of the label varies with the nodes, which is the length of 2) Data Storage and Organization.
the shortest path between the starting point and label nodes [3]. Storing and organizing mass data by the adjacency matrix
In addition,the nodes without labels can be labeled temporarily, needs open up NxN storage space (where N represents the
that is, the relative minimum value of the shortest distance for number of nodes) for a large sparse graph, which reduces the
the other nodes is given. Of course,the closer the starting point storage efficiency and computational efficiency greatly, so the
approaches the vertex, the earlier it gets the fixed label. adjacency list can be used to store the network expansion
Combining with the backtracking algorithm we can find the structure to reduce the storage space. The adjacency list is a
node passed by the shortest path between the starting point and kind of diagram-chain stores structure, in which the node
the other nodes,and then obtain the shortest path labeled by the elements can be stored in an array.
node [4].
B. The main idea ofthe improved Dijkstra algorithm
B. Deficiencies o/the traditional Dijkstra algorithm
Give an array T [} and two sets S and ad}, in which T [}
In network, the traditional Dijkstra algorithm has a wide stores the nodes to be sorted, S is the collection of labeled
application, but it is not difficult to find that its computation nodes, and ad} is the collection of the adjacent points. Under
has gradually increased with the network increasing in initial conditions, T [} ad} [va}, S
= {va}. First of all, use
=

complexity. If directly applied to calculating the best path of heap sort to adjust the array T [} into a small heap, take the
the urban road network, this algorithm will need a great heap top node which is also the first element of the array as the
amount of computation, and cannot meet the dynamic needs intermediate nodes, and then add it into the labeled nodes
either [5]. In addition, the adjacency matrix and incidence collection S; Then compare the difference sets indicated
matrix used in the traditional algorithm to store network data collection (ad) [current} -S) with the current shortest path of
will open up a huge storage space to store a large number of any node Vi in the changed current collection of adjacent nodes;
invalid OCJ elements and 0 elements, which is bound to cause Then find the difference set between the unit set of adjacent
huge waste of run time and can also reduce the computational nodes of all nodes in the S collection and S (denoted as U ad)
efficiency in Matrix algorithm. [S} S), put these nodes into the array T in order, cover the
-

node in the original array, and place a counter i to record the


IV. OPTIMIZED DUKSTRA ALGORITHM number of nodes;At last,adjust the first i elements in the array
into a small heap based on the shortest path value, and take
In view of the problems mentioned above in Dijkstra
heap top as the next shortest path node and deposit it into S
algorithm,the selection is optimized for the shortest path node,
collection. Repeat this iterative cycle, until all the nodes are
the data storage and organization in this paper.
stored into the S collection. Now calculate the shortest path D
[V} from the starting node vO to any other node in the graph G
according to the Dijkstra algorithm based on data structure, in

109
Authorized licensed use limited to: Indraprastha Institute of Information Technology. Downloaded on February 06,2025 at 08:59:42 UTC from IEEE Xplore. Restrictions apply.
which the storage structure selected in the graph G IS the From the table we can see that in the process of searching
adjacent list. The optimized algorithm is as follows: for the shortest path, the path number of traditional Dijkstra
algorithm shows an increasing tendency, while the improved
#define n 1000
algorithm is not the case. In the early stage of the running, the
Void Dijkstra (Mgraph G,int YO,int T[ ] ,int D[ ] ,) search path of improved Dijkstra algorithm shows an
{ increasing tendency, but at the latter stage of reaching the end
int i =O,j,F[n] ,T[n] ,p,k; path,it greatly reduced the number of stored paths, while at the
for ( i =0;i < GVexnum;i + + ) end of the algorithm, the path stored in the memory is only 1
{F[i] =O;D [i] =NFNITE;T[V] =0; } that is the shortest path. Therefore, the improved algorithm
for (p =Gvextices[O]. firstarc;p;p =p - > nextarc) releases the storage space, reduces data redundancy, and
{K =p-> adjvex;D [k] =p-> info;T[i] =D [k] ,i + + ; } improves the running time and efficiency.
F[O] = l;D [0] = 0;
for ( j = l;j < GVexnum;j + +) V. SUMMARY
{HeapAdjust (T[n] ,i) ;
This paper mainly studied the application of the shortest
HeapMin (T,current,distance,path);
path algorithm based on the data structure, and proposed the
F[current] = 1; }
improved Dijkstra algorithm, which optimized selection of the
for (p =Gvextices[ current ]. firstarc;p;p =p-> nextarc)
shortest path node and data storage structure and organization.
{ K =p-> adjvex; Studies showed that, compared with the traditional Dijkstra
If( ! F[k]&& D[current] +(p-> info) <D [k] ) algorithm, the optimized Dijkstra algorithm which has
D [k] =D [current] +(p-> info) ; optimized the space complexity, time complexity and storage
SearchAdj (S,T[n] ,i) ; combination reduced the storage space, reduced data
} } redundancy and greatly improved the running rate. It was
clearly showed that the optimized algorithm is more applicable
C. Comparative Analysis
to calculate the shortest path.
Compare the formation of the maximum path number in the
implementation process and its operating efficiency of the
REFERENCES
improved Dijkstra algorithm with that in the traditional
algorithm, and the results are shown in Table l. As shown in [I] Y. Cao, The Shortest path algorithm in data structures, [1]. Yibin
University, vol. 6, 2007,pp.82 -84.
the table, the improved Dijkstra algorithm not only effectively
improves the calculations and running efficiency, but also [2] Q. Sun, J. H. Shen, J. Z. Gu, An improved Dijkstra algorithm [J].
Computer Engineering and Applications, vol. 3 ,2002, pp.99-101.
greatly reduces the number of path in analyzing the shortest
[3] F. S. XU. Shortest path calculation algorithm[1]. Computer Applications,
path.
yoI.5,2004, pp.88 - 89.
[4] L. B. Chen, R. T. Liu, A Dijkstra's shortest path algorithm [J]. Harbin
TABLE I. ALGORITHM OPERATING EFFICIENCY COMPARISON University of Technology, vo1.3,2008,pp. 35 - 37.
[5] F. S. XU, C. Tian, All the Shortest Path Algorithm [J]. Computer
Engineering and Science,YoI.12, 2006,pp. 83-84.
Original data Traditional Dijkstra Improved Dijkstra
algorithm algorithm
Arc Nodes Total Computing Total Computing
number timers) number timers)
ofpaths ofpaths
420 132 387 0.048 87 0.031

3740 1475 4213 0.545 139 0.095

30147 11655 87531 4.294 844 0.527

110
Authorized licensed use limited to: Indraprastha Institute of Information Technology. Downloaded on February 06,2025 at 08:59:42 UTC from IEEE Xplore. Restrictions apply.

You might also like