International Journal of Computer Applications (0975 8887) Volume 163 No 8, April 2017 46 An Efficient Scheme for the Single Source Shortest Path Problem based on Dijkstra and SPFA Methodologies G. L. Prajapati, PhD Dept. of Comp. Engg. IET-Devi Ahilya University Indore Pulkit Singhal Dept. of Comp. Engg. IET-Devi Ahilya University Indore Ayush Ranjan Sharma Dept. of Comp. Engg. IET-Devi Ahilya University Indore Neelesh Chourasia Dept. of Comp. Engg. IET-Devi Ahilya University Indore ABSTRACT This paper presents detailed comparisons and analysis of various single source shortest path algorithms. The paper proposes comparison among these algorithms on the basis of execution time taken by the algorithms to completely find the shortest path to all the nodes from a starting node. The algorithms have been analyzed on the various parameters: number of vertices, number of edges, and structure of the graph. This analysis will help in selecting the appropriate algorithm to be used in solving a particular real-life problem. This paper also proposes an algorithm that works efficiently over all types of the graph. General Terms Shortest Path, Algorithms, Theoretical Computer Science. Keywords Single Source Shortest Path, Execution Time, Performance Analysis 1. INTRODUCTION Shortest path problem [1] is the problem of finding a path between two vertices in a graph such that the sum of the weights of its constituent edges is minimized. Without the use of shortest path algorithms, the naïve approach for finding the shortest path between two vertices is to enumerate all possible paths between the vertices and select the shortest one i.e. brute force. However for the various domain specific applications of the shortest path problem, brute force approach is not feasible and hence require more optimal solution i.e. the shortest path algorithms. The aim of shortest path algorithms is to find the shortest path among all paths available between the pair of vertices. Some shortest path algorithms works only over the non-negative weighted graphs while some can works with negative weighted graphs too. Also the distinction between the algorithms is made by whether these are single source shortest path (SSSP) or all pair shortest path algorithm (APSP). This paper focuses on single source shortest path algorithms for the non-negative weighted graphs. Some of the shortest path algorithms are greedy in nature while some uses the dynamic programming. The shortest path algorithms works over the principle of relaxation. In such algorithms, optimization is based on the number of times relaxation is performed during the execution. Various real life applications of shortest path algorithms are finding the shortest route between the two places, social network analysis (SNA) to calculate degree of separation between two users on a social networking medium and so on. This paper compares the set of algorithms among themselves on the basis of execution time on datasets of different types. 2. SET OF SHORTEST PATH ALGORITHMS UNDER ANALYSIS 2.1 Bellman-Ford Algorithm Bellman-Ford algorithm [2] uses the principle of edge-based relaxation. In every iteration it relaxes all the edges and these iterations are done V-1 times as the maximum number of edges in the shortest path between two vertices are V-1, where V is the number of vertices in the graph. If the relaxation can be done more than V-1 times, it indicates the presence of the negative cycles. The worst case complexity of this algorithm is O(VE). 2.2 Dijkstra Algorithm Dijsktra algorithm [3] uses the same principle of relaxation as Bellman-Ford algorithm. It works over the graph with non- negative weighted edges only. In every iteration, it greedily chooses the vertex which is not selected before and has minimum cost. It tries to relax vertices through the selected vertex. Selection of vertex with minimum cost primarily affects the complexity of algorithm. In case of binary heap, worst case complexity of this algorithm is O(E logV). We are also considering an implementation of Dijkstra [4] which fastens the performance in case where the number of distinct weighted edges is less. 2.3 Pape-Levit Algorithm Pape-Levit [5] is an incremental graph algorithm, where the two sets of vertices are maintained. One set of vertices contains those vertices which are scanned at least once while the second set contains those vertices which have never been scanned. The priority is given to first set for selection of vertex. The worst case complexity of this algorithm is O(VE). It works quite fast on the randomly weighted graphs. 2.4 SPFA The Shortest Path Faster Algorithm (SPFA) [6] is an improvement of the BellmanFord algorithm which computes single-source shortest paths in a weighted directed graph. The algorithm is believed to work well on random sparse graphs and is particularly suitable for graphs that contain negative- weight edges. The performance of the algorithm is strongly determined by the order in which candidate vertices are used to relax other vertices. 2.5 Proposed Algorithm As the performance of some algorithms highly depends over the order in which candidate vertices are used to relax the other vertices, we can see the linear time performance over the various type of graph structures while it also goes to O(VE) worst case time complexity. On the other hand, algorithms like the Dijkstra gives O(E logV) time complexity on every type of graph structure. This proposed algorithm harnesses the