Graph and MST, Some Facts and Validity - algorithm

My notes tell me that the first and last is false. I need some idea of how to understand the validity of these sentences in a more simple and concise manner.
Suppose M is an MST (minimum spanning tree) of the Weighted Graph - GR.
Let A be a vertex of GR then M-{A} is also MST of GR-{A}.
Let A be a leaf of M then M-{A} is also MST of GR-{A}.
If e is a edge of M then (M-{e}) is a forest of M1 and M2 trees such that for M_i, i=1,2 is a MST of Induced Graph GR on vertexes T_i.

Let A be a vertex of GR, then M-{A} is also MST of GR-{A}.
This is false.
If A is not a leaf, then M-{A} is not a connected graph, and so it cannot be a MST.
In more detail: A has at least two neighbors, and the single path (MST property) that exists between two of them includes A. If A is removed, then there is no more path between those two other vertices.
Let A be a leaf of M, then M-{A} is also MST of GR-{A}.
This is true.
As A is a leaf, M-{A} is a connected graph, and has one fewer edge than M: it does not have the edge e that connects with A in M.
Now assume that M-{A} is not a MST of GR-{A}. We know that M-{A} is a connected graph, and has no cycles -- otherwise M would not be an MST. So if it is not an MST, it must be that its weight is not minimised. Then there is a different graph P that is a MST of GR-{A}. But then P+e would have less total weight than M, but still be a spanning tree of GR. So then M could not have been a MST of GR. This is a contradiction, and so the original statement is true.
If e is a edge of M then M-{e} is a forest of M1 and M2 trees such that for Mi, i=1,2 is a MST of the induced graph GR on vertexes Ti.
This is true. Your notes are wrong on this one.
Let's assume that Mi (for either i=1,2) is not a MST of the induced graph on vertexes Ti. We know that Mi is not disconnected (the removal of e creates exactly 2 connected graphs), and that it has no cycles (otherwise M would have had those as well). So if it is not a MST, then the reason would be that its weight is not minimised, and another graph Pi is a MST on that induced graph, and has less total weight than Mi.
If you would then reintroduce the edge e, and so connect Pi with M3-i, we would have a spanning tree for GR which would have less weight than M, and so M is not a MST. This is again a contradiction and so the original statement is true.

Related

Prove that a subgraph is a minimum spanning tree

Given:
G = (V,E)
T is an MST of G
G'=(V', E') ⊆ G
T' is an MST of G'
Prove:
(V',E∩T) is a subgraph of T'
Under what conditions is E∩T an MST of G'?
The edge-weights need not be distinct.
My approach:
By applying Kruskal's algorithm to edges in E∩T, one would join edges in ascending order of weight and simultaneously ensure that a join does not produce a cycle. This will produce an MST, but can a we show that this MST is a subgraph of T'?
Does this approach make sense? Since I do not use the fact that T is the MST of G, I have a hunch that I'm ignoring something important.
First observation: any graph with number of nodes |V'| and number of edges other than |V'|-1 is not a tree, so one necessary condition is: |E∩T| = |V'|-1
Second observation: if T' is MST of G' then the sum of its edges is minimal among all other possible spanning trees of G'. which means that if (V', E∩T) is MST of G', then the sum of its edges has to be equal to the sum of edges of T'
From observations above, the necessary and sufficient conditions for (V', E∩T) being MST of G' is:
1. |E∩T| = |V'|-1
2. sumofweights((V', E∩T))=sumofweights(T')
So, basically what you need to do is to count the number of edges in E∩T and compare with |V'|-1, and also calculate the sum of edge weights in T' and compare with the sum of edge weights in E∩T
However I got some suspicions about this line: (V',E∩T) is a subgraph of T'
Since T' also has V' nodes, any subgraph of T' other than T' itself, would not be a tree, and if it's not a tree, it can't be MST either. Probably it is (V',E∩T) is a subgraph of G' or (V',E∩T) is a subgraph of T, not (V',E∩T) is a subgraph of T'?

Minimum Spanning Tree Graph

I have a connected graph G=(V,E) V={1,2,...,n} and a cost function c:E->R
and a second partial graph G'=(V,T) where T={ for every vertex v∈ V find the neighbor with the minimum cost and add the new edge to T}
If G' graph has at least 2 connected components with the set of vertices we consider the graph H where
iff the set of edges (from the initial graph G) is not null.We define over the edges of H a cost function.
Let's say I choose V(H)={a,e,f} and E(H)={ae,af,fe} and
E12={ab,bc,bd,ed}
E23={eg,ef} E31={fc,fd}
c'(ae)=min{c(ab),c(bc),c(bd),c(ed)}=4
c'(af)=min{c(fc),c(fd)}=9
c'(fe)=min{c(eg),c(ef)}=8
Now for every edge e ∈ E(H) we note with e' the edge (from the original graph G)
for which this minimum is attained.
So e'={bc,df,eg} because bc=4 , df=9 and eg=8 and are the min edges that connect my components.
And I have a minimum spanning tree in H relative to the cost function c' and A' is the set of edges for this tree.
So A'={ae,fe} (I deleted the edge with the maximum cost=af from my graph H to create a min spanning tree)
and I have another set of edges A'={e'|e∈A'} and
is a min spanning tree in G relative to the function cost c.
But none of my edges from A' are the same with the ones from e'.
What I'm I doing wrong?
Looks like you're implementing Boruvka's algorithm. If you look at the notation, it says there's an edge from one new node vC1 to a new node vC2 if there are a pair of nodes x ∈ C1 and y ∈ C2 that are adjacentnin the original graph G. In other words, there's an edge between two new nodes if the connected components they correspond to in G' are adjacent in G. The cost of the edge running between them is then the lowest of the costs of any of the edges running between those CC's in the original graph G.

How to update MST from the old MST if one edge is deleted

I am studying algorithms, and I have seen an exercise like this
I can overcome this problem with exponential time but. I don't know how to prove this linear time O(E+V)
I will appreciate any help.
Let G be the graph where the minimum spanning tree T is embedded; let A and B be the two trees remaining after (u,v) is removed from T.
Premise P: Select minimum weight edge (x,y) from G - (u,v) that reconnects A and B. Then T' = A + B + (x,y) is a MST of G - (u,v).
Proof of P: It's obvious that T' is a tree. Suppose it were not minimum. Then there would be a MST - call it M - of smaller weight. And either M contains (x,y), or it doesn't.
If M contains (x,y), then it must have the form A' + B' + (x,y) where A' and B' are minimum weight trees that span the same vertices as A and B. These can't have weight smaller than A and B, otherwise T would not have been an MST. So M is not smaller than T' after all, a contradiction; M can't exist.
If M does not contain (x,y), then there is some other path P from x to y in M. One or more edges of P pass from a vertex in A to another in B. Call such an edge c. Now, c has weight at least that of (x,y), else we would have picked it instead of (x,y) to form T'. Note P+(x,y) is a cycle. Consequently, M - c + (x,y) is also a spanning tree. If c were of greater weight than (x,y) then this new tree would have smaller weight than M. This contradicts the assumption that M is a MST. Again M can't exist.
Since in either case, M can't exist, T' must be a MST. QED
Algorithm
Traverse A and color all its vertices Red. Similarly label B's vertices Blue. Now traverse the edge list of G - (u,v) to find a minimum weight edge connecting a Red vertex with a Blue. The new MST is this edge plus A and B.
When you remove one of the edges then the MST breaks into two parts, lets call them a and b, so what you can do is iterate over all vertices from the part a and look for all adjacent edges, if any of the edges forms a link between the part a and part b you have found the new MST.
Pseudocode :
for(all vertices in part a){
u = current vertex;
for(all adjacent edges of u){
v = adjacent vertex of u for the current edge
if(u and v belong to different part of the MST) found new MST;
}
}
Complexity is O(V + E)
Note : You can keep a simple array to check if vertex is in part a of the MST or part b.
Also note that in order to get the O(V + E) complexity, you need to have an adjacency list representation of the graph.
Let's say you have graph G' after removing the edge. G' consists have two connected components.
Let each node in the graph have a componentID. Set the componentID for all the nodes based on which component they belong to. This can be done with a simple BFS for example on G'. This is an O(V) operation as G' only has V nodes and V-2 edges.
Once all the nodes have been flagged, iterate over all unused edges and find the one with the least weight that connects the two components (componentIDs of the two nodes will be different). This is an O(E) operation.
Thus the total runtime is O(V+E).

How to find MST of a subset of the vertices in a graph?

Given a graph G = (V, E) and a subset v of V how do you compute a "minimal spanning tree" m that connects all the nodes in v together? That is to say, it can have paths that go through vertices not in v.
My first thought was that m must be a subset of M where M is the MST of G but here is a counter-example through this diagram: Find the MST of {B, C}. It is clearly the shortest path, the edge with weight 17, which is not a subset of M.
I'm having trouble reducing this problem/defining exactly what to run a classic MST algorithm on.
Thanks in advance!

Finding a New Minimum Spanning Tree After a New Edge Was Added to The Graph

Let G = (V, E) be a weighted, connected and undirected graph and let T be a minimum spanning tree. Let e be any edge not in E (and has a weight W(e)).
Prove or disprove:
T U {e} is an edge set that contains a minimum spanning tree of G' = (V, E U {e}).
Well, it sounds true to me, so I decided to prove it but I just get stuck every time...
For example, if e is the new edge with minimum weight, who can promise us that the edges in T weren't chosen in a bad way that would prevent us from obtaining a new minimum weight without the 'help' of other edges in E - T ?
I would appreciate any help,
Thanks in advance.
Let [a(1), a(2), ..., a(n-1)] be a sequence of edges selected from E to construct MST of G by Kruskal's algorithm (in the order they were selected - weight(a(i)) <= weight(a(i + 1))).
Let's now consider how Kruskal's Algorithm behaves being given as input E' = E U {e}.
Let i = min{i: weight(e) < weight(a(i))}. Firstly algorithm decides to choose edges [a(1), ..., a(i - 1)] (e hasn't been processed yet, so it behaves the same). Then it need to decide on e - if e is dropped, solution for E' will be the same as for E. So let's suppose that first i edges selected by algorithm are [a(1), ..., a(i - 1), e] - I will call this new sequence a'. Algorithm continues - as long as its following selections (for j > i) satisfy a'(j) = a(j - 1) we are cool. There are two scenarios that break such great streak (let's say streak breaks at index k + 1):
1) Algorithm selects some edge e' that is not in T, and weight(e') < weight(a(k+1)). By now a' sequence is:
[a(1), ..., a(i-1), e, a(i), a(i+1), ..., a(k-1), a(k), e']
But if it was possible to append e' to this list it would be also possible to append it to [a(1), ..., a(k-1), a(k)]. But Kruskal's algorithm didn't do it when looking for MST for G. That leads to contradiction.
2) Algorithm politely selected:
[a(1), ..., a(i-1), e, a(i), a(i+1), ..., a(k-1), a(k)]
but decided to drop edge a(k+1). But if e was not present in the list algorithm would decide to append a(k+1). That means that in graph (V, {a(1), ..., a(k)}) edge a(k+1) would connect the same components as edge e. And that means that after considering by algorithm edge a(k + 1) in case of both G and G' the division into connected components (determined by set of selected edges) is the same. So after processing a(k+1) algorithm will proceed in the same way in both cases.
When ever a edge is add to a graph without adding a node , then that edge creates a cycle in minimum spanning tree of graph, cycle length may vary from 2 to n where n= no of nodes in graph.
T = Minimum spanning tree of G
Now to find the MST for (T + added edge) , we have to just remove one edge from that cycle .. so remove that edge which has maximum weight.
So T' always comes from T U {e}.
And if you are thinking that this doesn't prove that new MST will be an edge set of T U {e} then analyse Kruskal algorithim for for new graph. i.e. if e is of minimum weight it must have been selected for MST acc to Kruskal algorithim and same here if it is minimum it can not be removed from cycle.

Resources