1.MST(Minimum spanning tree)
A minimum spanning tree is a spanning tree of a connected,undirected graph.
It connects all the verticals together with the minimum total weighting for it's edges.
最小生成树是一个联通无向图的生成树。
它把所有的点连在一起,同时边的权值总和最小。
2.Prim
Input: all verticals and all edges
Initial:a new set V containing a vertical,a new set E empty
while V doesn't containing all the vertiacls in thr graph:
chooose an edge(u,v )which satisfy that :
u is the vertex in V, v is not
(u,v)has the minimal weught
add v to V, add (u,v) to E
输入:所有的顶点和所有的边
初始化:一个点集,包含图中一个任意的点
一个边集,为空
当点集还未包含所有的顶点时:
选一条边(u,v),满足以下条件:
u是V中的点,v不是
(u,v)权值最小
把u,v加入到边集中,把v加入到点集中
3.Kruskal
create a forest F, where each vertax in the graph is a separate tree
create a set S containing all the edges in the graph
while S is nonempty and F is not spanning:
remove an edges with the minimum weight from S
if the edge connects two seperate trees, then add it to the forest and combine the two tree into a single one.
创建一个森林F,图中的每一个点都是一颗单独的树
创建一个集合S,S包含图中的每一条边
当S不为空并且F没有生成的时候:
移除s总权值最小的一条边
如果这条边连接了两颗不同的树,把这条边加到森林里,同时把两棵树合并成一颗