The Storage of Weighted Directed Graph in Relational Database and Implementation of Dijkstra Algorithm

Yanchen Li,Yuan Feng,Feng Hong,Ying Bi
DOI: https://doi.org/10.1007/978-3-642-22456-0_7
2011-01-01
Abstract:As an important data structure, map is widely used in modern enterprise management software. Route planning, decision support, finding the critical path, and other activities all need the algorithms in graph theory. And once the map becomes more complex. it has to be stored in database. While the traditional adjacency matrix and adjacency list stored in the database have their limitations. If still achieve the appropriate algorithm using a programming language, software and database will exchange large amounts of data when the software and database are not in the same computer. So this method will inevitably affect the efficiency of the algorithm, and this situation is extremely difficult to optimize. Based on the characteristics of relational database, our paper designs a storage model of a directed graph in relational database. Using the SQL language and set operations, we successfully achieve the Dijkstra algorithm. In the process of Dijkstra algorithm, we use the mechanism of UPDATE in SQL instead of the inner loop steps in Dijkstra algorithm, thus the time cost by database operations is reduced greatly and the efficiency is raised.
What problem does this paper attempt to address?