Simple Proof of Prim's Algorithm Kruskal's Algorithm

The prim algorithm proves:

For the ai points in the minimum cost spanning tree

delete k edges connected to him

The minimal connected graph becomes k+1 connected subgraphs 

Select the minimum edge a1 to a2 connecting the ai point to the outside world

must be an edge in the smallest tree 

 

For two points a1 a2 in the minimum cost spanning tree

delete the k` edges they connect to the outside world

The connected graph becomes k`+1 connected subgraphs

The smallest edge ai to a3 where they connect to the outside world

must be an edge in the tree

........

According to the above steps, the n-1 edges of all n points can be determined

 

kruskal proof

It can be known from the prim algorithm 

The minimum edge connecting a subgraph of a minimum spanning tree to the outside world must be an edge in the minimum spanning tree

The first edge selected according to the kruskal algorithm

a1 to a2, is the smallest edge of a1 connecting the outside world

It can be known from the prim algorithm that it belongs to the minimum spanning tree

Second edge a3 (may be equal to a1 or a2) to a4 (may be equal to a1 or a2) found by kruskal's algorithm 

Take the minimum spanning tree to which a3 belongs to the minimum edge connected to the outside world (the smaller one has either been selected or has formed a loop with the determined edge)

It can be known from the prim algorithm that it belongs to the minimum spanning tree 

........

According to the above steps, the n-1 edges of all n points can be determined

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326504962&siteId=291194637