最小生成树 (Minimum Spanning Tree)

  • An MST is a subset of the edges of the connected, undirected graph that connect all the vertices together, in which there is no forming of a cycle and there should be minimum possible total edge weight.

    MST是已连接的无向图的边的子集,该边将所有顶点连接在一起,其中不形成循环,因此总边的权重应最小。

  • In this weight of a tree is defined as the sum of the weight of all its edges which are connected but no formation of the cycle is there.

    在该树中,树的权重定义为树的所有相连边的权重之和,但没有形成循环。

  • A tree T is said to be a spanning tree of a connected graph X if T is a subgraph of X and T contains all vertices of X.

    如果TX的子图并且T包含X的所有顶点,则将树T称为连通图X的生成树。

生成树的应用 (Application of Spanning Tree)

  1. Spanning tree has wide applications in many areas like network design.

    生成树在网络设计等许多领域都有广泛的应用。

  2. Spanning tree is important in designing routing algorithms.

    生成树在设计路由算法时很重要。

  3. Practical application based on minimum spanning tree includes taxonomy and cluster analysis.

    基于最小生成树的实际应用包括分类法和聚类分析。

1)Kruskal算法 (1) Kruskal’s Algorithm)

  • It is an application of a greedy algorithm.

    它是贪婪算法的一种应用。

  • In this edges are selected with minimum weight and added to MST till no cycle is formed.

    在这种情况下,以最小的重量选择边缘,并将其添加到MST中,直到没有循环形成为止。

  • It is used to find a minimum cost.

    它用于查找最低成本。

  • It finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized.

    它找到形成树的边缘子集,该树包括每个顶点,树中所有边缘的总权重最小。

  • Kruskal algorithm does not form a tree at each step.

    Kruskal算法并非在每个步骤都形成一棵树。

Steps for the kruskal’s algorithm are as follows:

kruskal算法的步骤如下:

  1. Firstly arrange all the edges in increasing order of their weight.

    首先,以重量增加的顺序排列所有边缘。

  2. Then the edges should be added if it does not form a circuit.

    如果没有形成电路,则应添加边缘。

  3. Continue these steps till all the edges are visited and MST is formed.

    继续这些步骤,直到访问了所有边缘并形成了MST。

  4. Add the cost of all edges in MST to get a minimum cost of a spanning tree.

    在MST中添加所有边的成本,以获取生成树的最低成本。

2)Prim的算法 (2) Prim’s algorithm)

  • This algorithm generally focused on vertices.

    该算法通常集中在顶点上。

  • Prim's algorithm always forms a tree at every step.

    Prim的算法总是在每一步都形成一棵树。

  • It applies the nearest neighbor method to select new edges.

    它应用最近邻居方法来选择新边。

  • This algorithm is generally used when we have to find a minimum cost of a dense graph because this number of edges will be high.

    当我们必须找到密集图的最低成本时,通常会使用此算法,因为该边缘数量很高。

  • Basically, Prim's algorithm is faster than the Kruskal's algorithm in the case of the complex graph.

    基本上,在复杂图的情况下,Prim算法比Kruskal算法更快。

Steps for the Prim’s algorithms are as follows:

Prim算法的步骤如下:

  1. Start with a vertex, say u.

    从顶点开始,说u

  2. Select another vertex v such that edges are formed from u and v and are of minimum weight, connect uv and add it to set of MST for edges A.

    选择另一个顶点v ,以使边缘由uv形成并具有最小权重,连接uv并将其添加到边缘AMST集。

  3. Now among the set of all vertices find other vertex vi that is not included in A such that (vi, vj) is minimum labeled and is the nearest neighbor of all vertices in set A and it does not form a cycle, add it to A.

    现在,集所有顶点中找到其他顶点v 包含在使得(V I,V j)为最小的标记,是集合A所有顶点的近邻,并没有形成一个周期,加它到A。

  4. Continue this process till we get an MST, then the MST formed will be of minimum cost.

    继续执行此过程,直到获得MST为止,然后形成的MST成本最低。

Reference: Kruskal's algorithm

参考: Kruskal算法

翻译自: https://www.includehelp.com/algorithms/p-and-k-algorithms.aspx

Kruskal(P)和Prim(K)算法相关推荐

  1. Kruskal算法和Prim算法

    Kruskal算法和Prim算法 在无向图中,连通且不含圈的图称为树.给定一个无向图G=(V,E),连通G中所有点,且边集使E的子集的树称为G的生成树,其中权值最小的生成树称为最小生成树(MST).构 ...

  2. 技术图文:如何利用C# 实现 Prim 最小生成树算法?

    背景 我们上一篇图文介绍了 如何利用 C# 实现 Kruskal 最小生成树算法?,Kruskal 算法通过寻找边最优的方式来构造最小生成树,本篇图文介绍如何利用 C# 实现 Prim 最小生成树算法 ...

  3. 基于C++的带权无向图的实现 (三)- Prim最小生成树算法

    该系列文章是本人整理的有关带权无向图的数据结构和算法的分析与实现,若要查看源码可以访问我的github仓库,如有问题或者建议欢迎各位指出. 目录 基于C++的带权无向图的实现 (一)- 数据结构 基于 ...

  4. 普里姆(Prim)算法(精讲)

    当我们想要找连通网的最小生成树时,经典的有两种算法,普里姆算法和克鲁斯卡尔算法,这里我们介绍的便是普里姆算法. 普里姆算法流程: ps:上图来自于大话数据结构 1.假设我们找顶点V0作为首个遍历的顶点 ...

  5. prim最小生成树算法原理

    prim 最小生成树算法原理 主要需要了解算法的原理.算法复杂度.优缺点 .刻画和度量指标 评价等 可以查阅相关的文献,这部分内容主要整合了两篇博客的内容 分别是:http://blog.csdn.n ...

  6. 普里姆(Prim)算法

    普里姆(Prim)算法 普里姆(Prim)算法思想 普里姆(Prim)算法是一某个顶点为起点,逐步找各顶点最小权值的边来构建最小生成树. 换一种说法: 从任意一顶点 v0 开始选择其最近顶点 v1 构 ...

  7. Top K算法问题的实现

    前奏     在上一篇文章,程序员面试题狂想曲:第三章.寻找最小的k个数中,后来为了论证类似快速排序中partition的方法在最坏情况下,能在O(N)的时间复杂度内找到最小的k个数,而前前后后upd ...

  8. 最小生成树——Kruskal(克鲁斯卡尔)算法

    [0]README 0.1) 本文总结于 数据结构与算法分析, 源代码均为原创, 旨在 理解 Kruskal(克鲁斯卡尔)算法 的idea 并用 源代码加以实现: 0.2)最小生成树的基础知识,参见 ...

  9. 程序员编程艺术:第三章续、Top K算法问题的实现

    程序员编程艺术:第三章续.Top K算法问题的实现 作者:July,zhouzhenren,yansha.     致谢:微软100题实现组,狂想曲创作组.     时间:2011年05月08日    ...

  10. P 算法与 K 算法

    P 算法与 K 算法 作者:Grey 原文地址: 博客园:P 算法与 K 算法 CSDN:P 算法与 K 算法 说明 P 算法和 K 算法主要用来解决最小生成树问题,即:不破坏连通性删掉某些边,使得整 ...

最新文章

  1. C++中istream的使用
  2. git 基于发布分支的开发
  3. [问题解决] File /struts-tags not found
  4. oracle用户手册在哪里,Oracle用户管理常用操作参考手册
  5. mysql的redo日志_MySQL redo与undo日志解析
  6. 数学公式、可视化图齐齐上阵,神经网络如何一步步走向最优化「看得见」!...
  7. duri oracle 连接字符串_Oracle连接字符串大全
  8. 关于 韩国 申明 豆浆 和 端午 是其国家创造或历史的 看法
  9. 推荐个不错的 Word 全文翻译和压缩工具!
  10. 压缩照片大小——PPT实现
  11. BP神经网络:误差反向传播公式的简单推导
  12. laravel路由的配置,别名,路由群组
  13. PM血泪总结项目管理中存在的教训
  14. Selenium显示等待和隐式等待
  15. 入门量化分析(金融)的一些建议
  16. 基于STM32的Flash擦除方式
  17. 程序员哥哥,你有一枚女朋友请查收。
  18. SOD下载数据注意事项
  19. 【计算机网络学习3】数据链路层
  20. 计算机基础公开课课件比赛,计算机基础公开课课件.ppt

热门文章

  1. 怎样永久更改嵌入式linux系统ip,如何修改嵌入式系统IP
  2. java activity模式_Activity的启动模式
  3. http multipart java_Http MultiPart请求
  4. java 去掉 t_关于Java:在LocalDateTime中不能删除“ T”
  5. 打不开磁盘配额linux,九度OJ 1455 珍惜现在,感恩生活 -- 动态规划(背包问题)...
  6. PHP无法执行MySQL语句,解决PHP执行批量MySQL语句的问题
  7. h5优秀控件_H5前端学习的js插件大全,基本包含了大部分的前端最前沿的js插件和库。...
  8. 倒序查10条数据_10 | 怎么给字符串字段加索引?
  9. JAVA服务器没回应_Java如何面对无服务器的挑战?
  10. Ubuntu 查看磁盘空间 及目录容量