📜  Boruvka的最小生成树算法(1)

📅  最后修改于: 2023-12-03 15:13:42.369000             🧑  作者: Mango

Boruvka's Algorithm for Minimum Spanning Tree

Boruvka's algorithm is a greedy algorithm used to find the minimum spanning tree of a weighted graph. This algorithm was proposed by Otakar Boruvka in 1926.

Algorithm Description

The algorithm starts with a forest of disconnected trees, with each tree consisting of a single vertex. In each iteration, it finds the cheapest edge of each tree that connects it to another tree, and merges the trees connected by those edges.

The algorithm repeats until there is only one tree left, which is the minimum spanning tree of the original graph.

Pseudo-code
MST-BORUVKA(G):
1.  FOREACH vertex v in G:
2.      CREATE a new tree T with v as its only vertex
3.      SET MST(T) to 0
4.  REPEAT:
5.      SET MST(P) to infinity for each connected component P of the forest
6.      FOREACH edge e=(u,v) in G:
7.          LET P and Q be the connected components that contain u and v respectively
8.          IF P != Q AND weight(e) < MST(P) AND weight(e) < MST(Q):
9.              SET MST(P) to MST(Q) to weight(e)
10.             MERGE P and Q into a single component
11. UNTIL there is only one connected component left
Complexity

The time complexity of Boruvka's algorithm is O(E log V), where E is the number of edges and V is the number of vertices in the graph.

Conclusion

Boruvka's algorithm is a simple and efficient algorithm that can find the minimum spanning tree of a weighted graph. Although it may not always produce the same resulting tree as other algorithms, it is still a useful tool in graph theory and computer science.