Question

Give an algorithm to find a maximum spanning tree. Is this harder than finding a minimum...

Give an algorithm to find a maximum spanning tree. s this harder than finding a minimum spanning tree

Give an algorithm to find a maximum spanning tree. Is this harder than finding a minimum spanning tree.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

A maximum spanning tree is a spanning tree of a weightrd graph having maximum weight.
It can be computed by negating the weight for each edgeand applying kruskal's algorithm.
A maximum spanning tree can be found in the Wolfram Language using the command FindSpanning Tree.
An algorithm for finding a graph's Spanning Tree of minimum length. It Sorts the edges of a graph in order of increasing cost and then repeatedly adds
edges that bridge seperate components until the graph is fully connected.
By negatimg the weight for each edge, the algorithm can also be used to find a maximum spanning tree.
One method for computing the maximum weight spanning tree of a networkG - due to kruskal can be summarized as follows.
1.Sort the edges of G into decreasing order by weight. Let T be the set of edges comprising the maximum weight spanning tree.set T= .
2.Add the first edge to T.
3.Add the next edge to T if and only if it does not form a cycle in T. If there are no remaining edges exit and report G to be disconnected.
4.If T has n-1 edges stop and output T.Otherwise go to step 3.
   You can compute maximum spanning tree using kruskal algorithm with edges sorted into decreasing order.


A Minimum spanning tree or minimum weight spanning tree is a subset of a connected, edge-weighted undirected graph the connects all the vertices together, without
any cycles and with the minimum possible total edge weight,with two properties:
   *it spans the graph, i.e., it includes every vertex of the graph.
   *it is a minimum, i.e., the total weight of all the edges is as low as possible.

Kruskal's algorithm

We'll start with kruskal's algorithm, which is easiest to understand and probably the best one for solving problems by hand.
Kruskal's algorithm:
*sort the edges of G in increasing order by length
*keep a subgraph S of G, initially empty
*for each edge e in sorted order
*if the endpoints of e are disconnected in S
*add e to S
*return S
Note that, whenever you add an edge (u,v), it's always the smallest connecting the part of S reachable from u with the rest of G, so by the lemma it
must be part of the MST.
This algorithm is known as a greedy algorithm, because it chooses at each step the cheapest edge to add to S.
You should be very careful when trying to use greedy algorithms to solve other problems, since it usually doesn't work. E.g. if you want
to find a shortest path from a to b, it might be a bad idea to keep taking the shortest edges. The greedy idea only works in Kruskal's algorithm
because of the key property we proved.

Analysis: The line testing whether two endpoints are disconnected looks like it should be slow (linear time per iteration, or O(mn) total).
But actually there are some complicated data structures that let us perform each test in close to constant time; this is known as the union-find
problem and is discussed in Baase section 8.5 (I won't get to it in this class, though). The slowest part turns out to be the sorting step, which
takes O(m log n) time.

Prim's algorithm:

Rather than build a subgraph one edge at a time, Prim's algorithm builds a tree one vertex at a time.
Prim's algorithm:
let T be a single vertex x
while (T has fewer than n vertices)
{
find the smallest edge connecting T to G-T
add it to T
}
Since each edge added is the smallest connecting T to G-T, the lemma we proved shows that we only add edges that should be part of the MST.
Again, it looks like the loop has a slow step in it. But again, some data structures can be used to speed this up.
The idea is to use a heap to remember, for each vertex, the smallest edge connecting T with that vertex.

Prim with heaps:
make a heap of values (vertex,edge,weight(edge))
initially (v,-,infinity) for each vertex
let tree T be empty
while (T has fewer than n vertices)
{
let (v,e,weight(e)) have the smallest weight in the heap
remove (v,e,weight(e)) from the heap
add v and e to T
for each edge f=(u,v)
if u is not already in T
find value (u,g,weight(g)) in heap
if weight(f) < weight(g)
replace (u,g,weight(g)) with (u,f,weight(f))
}
Analysis: We perform n steps in which we remove the smallest element in the heap, and at most 2m steps in which we examine an edge f=(u,v).
For each of those steps, we might replace a value on the heap, reducing it's weight. (You also have to find the right value on the heap, but that
can be done easily enough by keeping a pointer from the vertices to the corresponding values.) I haven't described how to reduce the weight
of an element of a binary heap, but it's easy to do in O(log n) time. Alternately by using a more complicated data structure known as a Fibonacci heap,
you can reduce the weight of an element in constant time. The result is a total time bound of O(m + n log n).

Boruvka's algorithm


(Actually Boruvka should be spelled with a small raised circle accent over the "u".) Although this seems a little complicated to explain,
it's probably the easiest one for computer implementation since it doesn't require any complicated data structures.
The idea is to do steps like Prim's algorithm, in parallel all over the graph at the same time.
Boruvka's algorithm:
make a list L of n trees, each a single vertex
while (L has more than one tree)
for each T in L, find the smallest edge connecting T to G-T
add all those edges to the MST
(causing pairs of trees in L to merge)
As we saw in Prim's algorithm, each edge you add must be part of the MST, so it must be ok to add them all at once.
Analysis: This is similar to merge sort. Each pass reduces the number of trees by a factor of two, so there are O(log n) passes.
Each pass takes time O(m) (first figure out which tree each vertex is in, then for each edge test whether it connects two
trees and is better than the ones seen before for the trees on either endpoint) so the total is O(m log n).

A hybrid algorithm

This isn't really a separate algorithm, but you can combine two of the classical algorithms and do better than either one alone. The idea is to do O(log log n) passes of Boruvka's algorithm, then switch to Prim's algorithm. Prim's algorithm then builds one large tree by connecting it with the small trees in the list L built by Boruvka's algorithm, keeping a heap which stores, for each tree in L, the best edge that can be used to connect it to the large tree. Alternately, you can think of collapsing the trees found by Boruvka's algorithm into "supervertices" and running Prim's algorithm on the resulting smaller graph. The point is that this reduces the number of remove min operations in the heap used by Prim's algorithm, to equal the number of trees left in L after Boruvka's algorithm, which is O(n / log n).
Analysis: O(m log log n) for the first part, O(m + (n/log n) log n) = O(m + n) for the second, so O(m log log n) total.

Add a comment
Know the answer?
Add Answer to:
Give an algorithm to find a maximum spanning tree. Is this harder than finding a minimum...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT