Dijkstra and Bellman-ford are the two basic methods to solve Single-source shortest paths problem,and SPFA is the optimized version of Bellman-ford. However, since the algorithm time complexity is 0 (kn), SPFA’s time efficiency has some instabilities. This paper will compare the time efficiency between Dijkstra optimized with heap and three kinds of SPFA in different density graphs. Meanwhile, random data is created to test optimized Dijkstra and 3 types of SPFA. Finally, according to the calculation result of two methods’ time efficiency, some suggestion is given for their application under different situation.