A Performance Comparison of Shortest Path Algorithms in Directed Graphs †
Abstract
1. Introduction
2. Methods
2.1. Testing Framework
- Random generation of directed graphs with controllable parameters;
- Implementation and execution of the four shortest path algorithms;
- Measurement of execution time and visualization of results;
- Comparison of algorithm performance across multiple metrics.
2.2. Graph Generation Methodology
- Minimum and maximum number of vertices (V).
- Minimum and maximum edge density (as a ratio of possible edges).
- Edge weight range (1–10 in the current implementation).
- No self-loops are created (edges from a vertex to itself);
- Edge weights are positive integers;
- Source and target vertices are distinct.
3. Results and Discussion
3.1. Algorithm Implementations
3.1.1. Dijkstra’s Algorithm
3.1.2. Bellman–Ford Algorithm
3.1.3. Floyd–Warshall Algorithm
3.1.4. Dantzig’s Algorithm
3.2. Performance Metrics and Testing Environment
- Processor: AMD Ryzen 7 7800X3D 8-Core Processor;
- Memory: 32 GB DDR5 6400 MHz;
- Operating System: Windows 10;
- Development Environment: Visual Studio 2022.
3.3. Comparative Execution Time
- Dijkstra’s algorithm maintained relatively good performance up to several hundred vertices (around 3298 microseconds for 1000 vertices);
- The Bellman–Ford algorithm’s performance deteriorated more rapidly with increasing vertices and edges (10,902 microseconds for 1000 vertices);
- The Floyd–Warshall and Dantzig algorithms showed consistent but slower performance for larger graphs, with execution times in the millions of microseconds for graphs with 1000 vertices.
3.4. Complexity Analysis
3.5. Path-Finding Success
3.6. Algorithm Performance Characteristics
- Dijkstra’s algorithm.
Algorithm 1: Dijkstra’s Algorithm |
- 2.
- Bellman–Ford Algorithm.
Algorithm 2: Bellman–Ford Algorithm |
- 3.
- Floyd—Warshall Algorithm.
Algorithm 3: Floyd–Warshall Algorithm |
- 4.
- Dantzig’s Algorithm
Algorithm 4: Dantzig’s Algorithm |
4. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
Abbreviations
MSAGL | Microsoft Automatic Graph Layout |
V | number of vertices in a graph |
E | number of edges in a graph |
S | source vertex |
T | target vertex |
References
- Wang, R.; Zhou, M.; Wang, J.; Gao, K. An Improved Discrete Jaya Algorithm for Shortest Path Problems in Transportation-Related Processes. Processes 2023, 11, 2447. [Google Scholar] [CrossRef]
- Sapundzhi, F.; Popstoilov, M. Optimization algorithms for finding the shortest paths. Bulg. Chem. Commun. 2018, 50, 115–120. [Google Scholar]
- Guo, J.; Liu, T.; Song, G.; Guo, B. Solving the Robust Shortest Path Problem with Multimodal Transportation. Mathematics 2024, 12, 2978. [Google Scholar] [CrossRef]
- Priliana, C.Y.; Rosyida, I. The Ambulance Route Efficiency for Transporting Patients to Referral Hospitals Based on Distance and Traffic Density Using the Floyd–Warshall Algorithm and Google Traffic Assistance. In Proceedings of the 4th International Seminar on Science and Technology (ISST 2022), Palu, Indonesia, 2–3 November 2022; Atlantis Press: Amsterdam, The Netherlands, 2023; pp. 349–360. [Google Scholar]
- Wahhab, O.; Al-Araji, A.S. An Optimal Path Planning Algorithms for a Mobile Robot. Iraqi J. Comput. Commun. Control Syst. Eng. 2021, 21, 44–58. [Google Scholar]
- Murrieta-Mendoza, A.; Romain, C.; Botez, R.M. 3D Cruise Trajectory Optimization Inspired by a Shortest Path Algorithm. Aerospace 2020, 7, 99. [Google Scholar] [CrossRef]
- Dijkstra, E.W. A note on two problems in connexion with graphs. Numer. Math. 1959, 1, 269–271. [Google Scholar] [CrossRef]
- Bellman, R. On a routing problem. Q. Appl. Math. 1958, 16, 87–90. [Google Scholar] [CrossRef]
- Ford, L.R., Jr. Network Flow Theory; Paper P-923; RAND Corporation: Santa Monica, CA, USA, 1956. [Google Scholar]
- Floyd, R.W. Algorithm 97: Shortest Path. Commun. ACM 1962, 5, 345. [Google Scholar] [CrossRef]
- Warshall, S. A theorem on boolean matrices. J. ACM (JACM) 1962, 9, 11–12. [Google Scholar] [CrossRef]
- Dantzig, G.; Blattner, W.; Rao, M. All Shortest Routes in a Graph; Rosenstiehl, P., Ed.; Theorie des Graphes; Dunod: Paris, France, 1966; pp. 91–92. [Google Scholar]
- Dantzig, G.; Fulkerson, D.; Johnson, S. Solution for a large-scale traveling-salesman problem. J. Oper. Res. Soc. Am. 1954, 2, 393–410. [Google Scholar] [CrossRef]
- Brown, E. Windows Forms Programming with C#; Manning Publications Co.: Shelter Island, NY, USA, 2019. [Google Scholar]
- Wiese, R.; Eiglsperger, M.; Kaufmann, M. yFiles—Visualization and automatic layout of graphs. In Graph Drawing Software; Springer: Berlin/Heidelberg, Germany, 2004; pp. 173–191. [Google Scholar]
- Microsoft Automatic Graph Layout (MSAGL). Available online: https://www.microsoft.com/en-us/research/project/microsoft-automatic-graph-layout/ (accessed on 1 April 2025).
- Sapundzhi, F.; Kitanov, A.; Lazarova, M.; Georgiev, S. A Mobile App Game Based on the Development and Design of a Puzzle Created for Educational Learning. In International Conference in Methodologies and Intelligent Systems for Techhnology Enhanced Learning; Springer Nature: Cham, Switzerland, 2023; pp. 223–230. [Google Scholar]
- Sapundzhi, F.; Kitanov, A.; Lazarova, M.; Georgiev, S. Mobile Game Development Using Unity Engine. In International Conference in Methodologies and Intelligent Systems for Techhnology Enhanced Learning; Springer Nature: Cham, Switzerland, 2023; pp. 129–138. [Google Scholar]
- Nedyalkov, I.; Georgiev, G. Performance comparison of ip network using mpls and mpls te. In Proceedings of the 12th National Conference with International Participation (ELECTRONICA), Sofia, Bulgaria, 27–28 May 2021; pp. 1–4. [Google Scholar]
- Nedyalkov, I. Benefits of Using Network Modeling Platforms When Studying IP Networks and Traffic Characterization. Computers 2023, 12, 41. [Google Scholar] [CrossRef]
- Sapundzhi, F.; Popstoilov, M. C# implementation of the maximum flow problem. In Proceedings of the 27th National Conference with International Participation (TELECOM), Sofia, Bulgaria, 30–31 October 2019; pp. 62–65. [Google Scholar]
- Cormen, T.; Leiserson, C.; Rivest, R.; Stein, C. Introduction to Algorithms, 3rd ed.; MIT Press: Cambridge, MA, USA, 2009. [Google Scholar]
- Sedgewick, R.; Wayne, K. Algorithms, 4th ed.; Addison-Wesley Professional: Boston, MA, USA, 2011. [Google Scholar]
- Bagheri, A.; Akbarzadeh-T, M.-R.; Saraee, M. Finding the shortest path with learning algorithms. Int. J. Artif. Intell. 2008, 1, 86–95. [Google Scholar]
- Feijen, W.; Schäfer, G. Using Machine Learning Predictions to Speed-up Dijkstra’s Shortest Path Algorithm. arXiv 2021, arXiv:2112.11927. [Google Scholar]
Graph Size | Dijkstra | Bellman—Ford | Floyd—Warshall | Dantzig |
---|---|---|---|---|
7V, 14E | 1.7 | 5.8 | 10.9 | 10.4 |
17V, 28E | 3.9 | 6.8 | 30.1 | 29.9 |
41V, 82E | 8.3 | 29.2 | 283.3 | 295.6 |
659V, 1538E | 309.5 | 3601.2 | 1,112,193 | 9617.9 |
657V, 2168E | 3015.2 | 5315.2 | 1,429,713 | 1,521,213 |
1000V, 2800E | 3298.4 | 10,902.2 | 4,492,317 | 551,157.7 |
Graph Size | Dijkstra O(E + V log V) | Bellman—Ford O(V·E) | Floyd—Warshall O(V3) | Dantzig O(V3) |
---|---|---|---|---|
7V, 14E | 27.6 | 98 | 343 | 343 |
17V, 28E | 76.9 | 476 | 4913 | 4913 |
41V, 82E | 234.3 | 3362 | 68,921 | 68,921 |
659V, 1538E | 5890.4 | 1,078,922 | 29,418,309 | 29,418,309 |
657V, 2168E | 6430.4 | 1,424,376 | 283,593,393 | 283,593,393 |
1000V, 2800E | 9707.8 | 2,800,000 | 1,000,000,000 | 1,000,000,000 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Sapundzhi, F.; Danev, K.; Ivanova, A.; Popstoilov, M.; Georgiev, S. A Performance Comparison of Shortest Path Algorithms in Directed Graphs. Eng. Proc. 2025, 100, 31. https://doi.org/10.3390/engproc2025100031
Sapundzhi F, Danev K, Ivanova A, Popstoilov M, Georgiev S. A Performance Comparison of Shortest Path Algorithms in Directed Graphs. Engineering Proceedings. 2025; 100(1):31. https://doi.org/10.3390/engproc2025100031
Chicago/Turabian StyleSapundzhi, Fatima, Kristiyan Danev, Antonina Ivanova, Metodi Popstoilov, and Slavi Georgiev. 2025. "A Performance Comparison of Shortest Path Algorithms in Directed Graphs" Engineering Proceedings 100, no. 1: 31. https://doi.org/10.3390/engproc2025100031
APA StyleSapundzhi, F., Danev, K., Ivanova, A., Popstoilov, M., & Georgiev, S. (2025). A Performance Comparison of Shortest Path Algorithms in Directed Graphs. Engineering Proceedings, 100(1), 31. https://doi.org/10.3390/engproc2025100031