Reputation: 11441
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
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.
In above pseudocode what does author mean by "A is not a spanning tree"? i.e., how and when while loop exits?
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!
Upvotes: 2
Views: 3138
Reputation: 717
This is false. A graph may have many MST even if only two edges are equal.
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
It is correct to say that it is in some MST as there are many.
Upvotes: 1
Reputation: 2962
Incorrect as per @davin
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).
see 1.
Upvotes: 0
Reputation: 11385
Upvotes: 0
Reputation: 45555
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.
Upvotes: 4