最小生成树

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总权值最小的一条边

如果这条边连接了两颗不同的树,把这条边加到森林里,同时把两棵树合并成一颗

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值