
Analysis and comparison of two classical greedy algorithms for minimum spanning tree
- 1 Hebei University of technology
* Author to whom correspondence should be addressed.
Abstract
The total weight of the minimum spanning is the smallest in the connected graph. It can be used to solve many practical problems in urban life. Prim’s algorithm and Kruskal’s algorithm are greedy algorithms for solving the minimum spanning tree problem. But they make greedy choices in different ways. The paper focuses on two greedy algorithms for solving the minimum spanning tree problem. The author will evaluate each algorithm’s complexity and determine their most suitable condition as well. The author compares the running process of the two algorithms and analyzes the relationship between their algorithm complexity and the number of edges, which can describe the sparsity of the graphs. The result shows that Kruskal’s complexity is related to the number of edges, so it is better for sparse graphs. Prim’s complexity is related to the number of vertices, so it is better at analyzing connected graphs with lots of vertices, that is, dense graphs. As a consequence, Prim’s algorithm is better for dense graphs.
Keywords
minimum spanning tree, greedy algorithm, Kruskal, prim, connected graph
[1]. Jin Liu. (2022). The time-varying environment minimum spanning tree model research. Master’s degree thesis. Tianjin Polytechnic University.
[2]. AnanyLevitin. (2012). Introduction to the Design and Analysis of Algorithms(Third Edition)[M]. Pennsylvania: Villanova University, 542-545.
[3]. Ayegba, P., Ayoola, J., Asani, E., & Okeyinka, A. (2020, March). A comparative study of minimal spanning tree algorithms. In 2020 International Conference in Mathematics, Computer Engineering and Computer Science(ICMCECS) (pp. 1-4). IEEE.
[4]. Rodrigues, G. P. W., Costa, L. H. M., Farias, G. M., & de Castro, M. A. H. (2019). A depth-first search algorithm for optimizing the gravity pipe networks layout. Water Resources Management, 33(13), 4583-4598.
[5]. Heimao c. (2020). Super easy to understand the minimum spanning tree(MST property) comprehensive exposition! Minimum Spanning Tree Summary! Kruskal algorithm and Prim algorithm. https://blog.csdn.net/drtfyguhil/article/details/106729280
[6]. Junzhong He & Liju Wang. (2020). Analysis and comparison of Kruskal and Prim algorithms. Journal of Longdong University (02), 8-11
[7]. Huimin Song, Wei Sun & Jianliang Wu. (2021). Further thinking on the acyclic judgment in Kruskal algorithm for finding the minimum tree mathematics learning and research(13), 151-153
[8]. Zhiqin Hu. (2011). Implementation and Analysis of Prim Algorithm. Computer Knowledge and Technology(27), 6711-6712.
[9]. Xiaoju Sun. (2016). Research on Degree Constrained Minimum Spanning Tree Problem Based on Prim Algorithm. Journal of Inner Mongolia Normal University(Chinese version of Natural Science ) (04), 445-448.
Cite this article
Yu,X. (2023). Analysis and comparison of two classical greedy algorithms for minimum spanning tree. Theoretical and Natural Science,5,698-702.
Data availability
The datasets used and/or analyzed during the current study will be available from the authors upon reasonable request.
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 EWA Publishing and/or the editor(s). EWA Publishing 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.
About volume
Volume title: Proceedings of the 2nd International Conference on Computing Innovation and Applied Physics (CONF-CIAP 2023)
© 2024 by the author(s). Licensee EWA Publishing, Oxford, UK. This article is an open access article distributed under the terms and
conditions of the Creative Commons Attribution (CC BY) license. Authors who
publish this series agree to the following terms:
1. Authors retain copyright and grant the series right of first publication with the work simultaneously licensed under a Creative Commons
Attribution License that allows others to share the work with an acknowledgment of the work's authorship and initial publication in this
series.
2. Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the series's published
version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgment of its initial
publication in this series.
3. Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and
during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See
Open access policy for details).