通用最小生成树

发布于 2024-12-16 02:10:05 字数 668 浏览 1 评论 0原文

我正在阅读有关科门的最小生成树等内容。以下是 通用最小生成树。

假设我们有一个连通的无向图 G = (V, E) 并带有权重 函数 w:E->R,我们希望找到 G 的最小生成树。 这里我们使用贪心的方法。这种贪婪策略被捕获 遵循“通用”算法,生成最小生成树 一次一个边缘。该算法管理一组边 A, 保持以下循环不变式。

在每次迭代之前,A 是某个最小生成树的子集。

GENERIC-MST(G,w) 
A = NULL
while A is not a spanning tree 
  do find an edge (u, v) that is safe for A 
  A = A ∪ {(u, v)}
end while

return A

问题

  1. 作者在不变量中意味着什么“A”是某个最小值的子集 生成树?这句话中的“一些”是什么?我教过只有一个 MST。

  2. 在上面的伪代码中,作者所说的“A不是生成树”是什么意思? 即, while 循环如何以及何时退出?

  3. 在伪代码中,“一些”最小生成树,这里我的理解只有一个。 我对吗?

任何人都可以用小例子解释一下吗?

谢谢!

I am reading myself about Minimum Spanning trees in Cormen,etc. Following is the
generic minimum spanning tree.

Assume we have a connected, undirected graph G = (V, E) witha a weight
function w:E->R and we wish to find a minimum spanning tree for G.
Here we use greedy approach. This greedy strategy is captured by the
following "generic" algorithm, which grows the minimum spanning tree
one edge at a time. The algorithm manages a set of edges A,
maintaining the following loop invariant.

Prior to each iteration, A is subset of some minimum spanning tree.

GENERIC-MST(G,w) 
A = NULL
while A is not a spanning tree 
  do find an edge (u, v) that is safe for A 
  A = A ∪ {(u, v)}
end while

return A

Questions

  1. What does authore mean in invariant that "A" is subset of some minimum
    spanning tree? What is "some" in this statement? i taught there is only one MST.

  2. In above pseudocode what does author mean by "A is not a spanning tree"?
    i.e., how and when while loop exits?

  3. In pseudo code where "some" minimum spanning tree, here my understading is only one.
    am i right?

Can any one pls explain with small example?

Thanks!

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

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

发布评论

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

评论(4

时光暖心i 2024-12-23 02:10:05

1.绝对不是。 MST 不一定是唯一的。例如:

所有边的权重相等。

u --- v
|     |
|     |
w --- x

上图通过删除任何边有 4 个 MST。

2. G = (V,E) 中的生成树 T = (V,e) 满足 |e| = |V|-1

3. 否。

1. Absolutely not. MST are not necessarily unique. For example:

All edges are of equal weight.

u --- v
|     |
|     |
w --- x

The above graph has 4 MSTs, by removing any edge.

2. A spanning tree T = (V,e) in G = (V,E) is such that |e| = |V|-1

3. No.

一城柳絮吹成雪 2024-12-23 02:10:05
  1. 这是错误的。即使只有两条边相等,图也可能有许多 MST。

  2. A 不是最小生成树,因为:

    2.1 首先,A 不是一棵树 - 它是断开连接的。

    2.2 不跨越图表

    满足上述条件时循环将退出

  3. 说它在 some MST 中是正确的,因为有很多。

  1. This is false. A graph may have many MST even if only two edges are equal.

  2. A is not minimum spanning tree because of:

    2.1 First of all A is not a tree - it is disconnected.

    2.2 It does not span the graph

    The loop will exit when the above conditions are met

  3. It is correct to say that it is in some MST as there are many.

枫林﹌晚霞¤ 2024-12-23 02:10:05
  1. 当您说图的生成树是唯一的时,您是正确的。但这是当图的所有边长都不同时的情况。正如上面的答案所解释的,具有相等边长的图可以有许多不同的生成树(当然它们都具有相同的总权重)。
  2. 当您将图的所有顶点包含在生成树中时,就会出现 while 循环。为此,您在 while 循环中添加一个检查。
  1. You are correct when you say a spanning tree of a graph is unique . But this is the case when all the edge lengths of the graph are different. As explained in the above answer, a graph with equal edge lengths can have many different spanning trees(all of them having the same total weight of course) .
  2. The while loop exists when you have included all the vertices of the graph in your spanning tree . For this you add a check in your while loop .
皓月长歌 2024-12-23 02:10:05
  1. 根据@davin 不正确

  2. 该算法维护您拥有森林的不变量,但在您添加足够的边之前,森林不会跨越图形。因此,您必须不断添加边,直到没有一条边是安全的(此时循环中断)。

  3. 参见 1。

  1. Incorrect as per @davin

  2. The algorithm maintains the invariant that you have a forest, but the forest will not span the graph until you add enough edges. Thus you have to keep adding edges until none of them are safe (at which point the loop breaks).

  3. see 1.

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