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. Prims algorithm and Kruskals 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 algorithms 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 Kruskals complexity is related to the number of edges, so it is better for sparse graphs. Prims 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, Prims algorithm is better for dense graphs.