使用Prim算法求有向图的MST

发布于 2024-10-09 11:23:00 字数 134 浏览 0 评论 0原文

alt text

任何人都可以帮助我如何使用 PRIM 算法查找 MST。突出显示 MST 的边缘并写出节点添加到 MST 的顺序。 谢谢

alt text

can any one plz help me how to Find the MST using the PRIM algorithm. Highlight the edges of the MST and write the sequence in which the nodes are added to the MST..
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫瑟鸿黎 2024-10-16 11:23:00

引用有向最小生成树问题

  1. 丢弃进入根部的弧(如果有);对于除
    root,选择输入弧
    成本最小;令所选的n-1
    弧为集合S。
  2. 如果没有形成环,G(N,S)是一个MST。否则,继续。
  3. 对于形成的每个循环,将循环中的节点收缩为伪节点
    (k),并修改每条弧的成本
    进入循环中的节点(j)
    从循环外的某个节点 (i)
    根据以下等式。
    c(i,k)=c(i,j)-(c(x(j),j)-min_{j}(c(x(j),j))
    这里 c(x(j),j) 是弧的成本
    在进入j的循环中。
  4. 对于每个伪节点,选择具有最小的进入弧
    修改成本;替换圆弧
    通过以下方式进入 S 中的同一实节点
    新选定的弧线。
  5. 使用收缩图转到步骤 2。

该算法的核心思想是
找到替换弧
消除的最小额外成本
周期(如果有)。给定的方程
显示相关的额外费用。

Quoting The Directed Minimum Spanning Tree Problem:

  1. Discard the arcs entering the root if any; For each node other than the
    root, select the entering arc with the
    smallest cost; Let the selected n-1
    arcs be the set S.
  2. If no cycle formed, G(N,S) is a MST. Otherwise, continue.
  3. For each cycle formed, contract the nodes in the cycle into a pseudo-node
    (k), and modify the cost of each arc
    which enters a node (j) in the cycle
    from some node (i) outside the cycle
    according to the following equation.
    c(i,k)=c(i,j)-(c(x(j),j)-min_{j}(c(x(j),j))
    here c(x(j),j) is the cost of the arc
    in the cycle which enters j.
  4. For each pseudo-node, select the entering arc which has the smallest
    modified cost; Replace the arc which
    enters the same real node in S by the
    new selected arc.
  5. Go to step 2 with the contracted graph.

The key idea of the algorithm is to
find the replacing arc(s) which has
the minimum extra cost to eliminate
cycle(s) if any. The given equation
exhibits the associated extra cost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文