I am asked to write an algorithm that finds the Minimum Spanning Tree in a graph G, but with the condition that each vertex of G be a leave in the spanning Tree T.
How can this be possible if the graph has more than 2 elements? Suppose G contains the vertices a,b and c, the Spanning tree will might something like a--b--c, so in this case b is not a leaf.
I am not looking for a solution to the algorithm, I only want to understand how a Spanning Tree can be composed exclusively of leaves.
Here is the exact wording of the question
Thanks for the help
The question states that S is a subset of the vertices V in the graph. There may be non-leaf nodes. However, you have to make sure that these internal nodes are not in S. If S would be equal to V you'd be right.
Related
Assume you have an undirected-weighted graph G, with different edges weighs but for only two edges: w(e1)=w(e2)
I have to prove that G has at most one minimum spanning tree which includes e1.
Also I have to prove that G has at most one minimum spanning tree which doesnt include e1.
I only need a solution for the first one and will solve the second one alone.
Thanks
For solving part 1:
Consider the graph you get by removing e1 from G (and possibly one of it's vertices, if it's now not connected to the rest of the graph), let's call it G'.
In this graph (G') , all the edge weights are different.
Now suppose G has more than 1 MST which includes e1 - they would both be different MSTs for G'.
Now the trick is that there's a theorem that in this kind of graph (all edges are different), the MST is unique. see the proof(s) here.
edit: You can probably just take the proof from the link and edit it slightly for your case.
My question is what is a exact definition of chord in a tree?? like
if we have the following tree:
a
b c
d e f g
is a tree then dbacg is a chord as I have come to know..
Can ebacg or ebacf also a chord???
As far as I know, there is nothing called chord (or cord) in a tree.
There is a definition of “chord” in general graph, but it operates on cycles. And trees never have cycles by definition, so, following this definition, no tree has a chord.
Maybe your teacher uses that name to mean something that is usually called differently? Did he give you a definition?
chord is a term used for spanning trees. A spanning tree of a graph G is a subgraph that is a tree
and contains all vertices of G with minimum number of edges possible. If T is the set of spanning tree edges, then any graph edge not in T is a chord of the spanning tree.
Also note that a graph can have more than one spanning trees.
I have connected undirected graph.
I am looking for the way to construct the balanced spanning tree (T) of a graph
The specific about balanced spanning tree, I could define as follows:
If the root of the tree is r .All
nodes could be divided to the
levels.I.e all the nodes which
distance from the r (in T) is j are
in the level Lj,etc.
For each node w one can define for a
sub-tree T_w of T,such that w is its
root.
The goal is to define spanning tree
in such a way that for each level
Li,for every two nodes u and v in
level Li the number of nodes in the
T_u and T_v is maximally equivalent.
Does anybody can advice any algorithm/s for building such “relatively” balanced spanning tree?
Thank you in advance.
I am not sure about your expression "maximally equivalent."
This problem may not have a perfect solution, so the obvious thing is how much better can we do?
This problem in generality seems to be NP-Complete. Some greedy approaches might result in constant approx algorithms, if you are lucky.
This appears to be trivial. Let G be your graph. It is connected, so there is an edge between each pair of vertices. Using the definition, construct an arbitrary balanced spanning tree G' with the same number of vertices as G. Starting at r in G' and an arbitrarily chosen vertex of G, map each vertex in G' to a vertex in G. Delete all edges in G that don't have a corresponding edge in G'.
The resulting graph -- call it U for "updated G" -- by construction has the same number of vertices as G', and further by construction, an edge exists in U iff the corresponding edge exists in G'. Thus U=G' and it follows that U is a balanced spanning tree.
You want to construct your tree as an AVL tree.
You can find additional information and code used to implement it starting on page 12 of this PDF document.
This PowerPoint document has some pretty pictures to help explain what's going on and also includes a Java implementation of the AVL Tree data type.
I have tried the following approach:
First I do edge contraction for all the edges in the given set of edges to form a modified graph.
Then I calculate the total number of spanning trees, using the matrix tree theorem, from the modified graph.
I want to know if this method is correct and if there are some other better methods.
Let G be a graph, let e be an edge, and let G/e be the same graph with e contracted. Then,
Proposition: There is a bijection between the spanning trees of G that contain e, and the spanning trees of G/e.
This proposition is not hard to prove; you're better off understanding the proof yourself instead of just asking other people whether it's true. Obviously if you have a spanning T tree of G that contains e, then T/e is a spanning tree of G/e. The thing to think through is that you can also go backwards.
And, as Adam points out, you have to be careful to properly handle graphs with parallel edges and graphs with edges from a vertex to itself.
I don't know if it's correct or not, but you'll have to be careful of the fact that edge contraction can lead to parallel edges. You'll have to make sure that trees differing only by which parallel edge is used are counted as being distinct.
Is there any applicable approach to find two disjoint spanning trees of an undirected graph or to check if a certain graph has two disjoint spanning trees
This is an example of Matroid union. Consider the graphic matroid where the basis are given by the spanning trees. Now the union of this matroid with itself is again a matroid. Your question is about the size of the basis of this matroid. (whether there exist a basis of size $2(|V|-1)$.
The canonical algorithm for this is Matroid partitioning algorithm. There exist an algorithm which does does the following: It maintains a set of edges with a partitioning into two forests. At each step given a new edge $e$, it decides whether there exist a reshuffling of the current partition into a new partition such that the new edge can be added to the set and the partition remains independent. And if not, it somehow will provide a certificate that it cannot.
For details look at a course in Comb. Optimization or the book by Schriver.
Not sure it helps much in the applicable side but Tutte [1961a] and Nash-Williams [1961] independently characterized graphs having k pairwise edge-disjoint spanning trees:
A graph G has k pairwise edge-disjoint spanning trees iff for every partition of the vertices of G into r sets, there are at least k(r-1) edges of G whose endpoints are in different sets of the partition.
Use k=2 and it may give you a lead for your needs.
According to A Note on Finding Minimum-Cost Edge-Disjoint Spanning Trees, this can be solved in O(k2n2) where k is the number of disjoint spanning trees, and n is the number of vertices.
Unfortunately, all but the first page of the article is behind a paywall.
Assuming that the desire is to find spanning trees with disjoint edge sets, what about:
Given a graph G determining the minimum spanning tree A of G.
Defining B = G - A by deleting all edges from G that also lie in A.
Checking if B is connected.
The nature of a minimum spanning tree somehow makes me intuitively believe that choosing it as one of the two spanning trees gives you maximum freedom in constructing the other (that hopefully turns out to be edge disjunctive).
What do You guys think?
edit
The above algorithm makes no sense as a spanning tree is a tree and therefore needs to be acyclic. But there is no guarantee that B = G - A is acyclic.
However, this observations (thx#Tormer) led me to another idea:
Given a graph G determine the minimum spanning tree A of G.
Define B = (V[G], E[G] \ E[A]) where V[G] describes the vertices of G and E[G] describes the edges of G (A respectively).
Determine, if B has a spanning tree.
It could very well be that the above algorithm fails although G indeed has two edge disjunctive spanning trees - just no one of them is G's minimum spanning tree. I can't judge this (now), so I'm asking for Your opinion if it's wise to always chose the minimum spanning tree as one of the two.