Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Sometimes we want light spanning trees with certain special properties. Here’s an example.

Input: Undirected graph G=(V,E) ; edge weights we; subset of vertices UV

Output: The lightest spanning tree in which the nodes of U are leaves (there might be other leaves in this tree as well).

(The answer isn’t necessarily a minimum spanning tree.)

Give an algorithm for this problem which runs in O(ElogV) time. (Hint: When you remove nodes Ufrom the optimal solution, what is left?)

Short Answer

Expert verified

Working with lightest spanning tree in the nodes of and to get answer which is necessary minimum spanning tree base on the given formulaO(|E|log|V|).

Step by step solution

01

Step 1: Light-spanning tree algorithm

Both lemma1 as well as feature 1 are being used in the light spanning tree algorithm..

Lemma1:• "If indeed the network has vertices "U" as leaves, a lightest spanning trees containing vertices "U" for leaves isn't really possible." G” There isn't a minimal spanning tree."

Property 1:

• “"Minimal level spanning tree is constructed on the network if eagerly select and add edges while all vertices "U" become leaves."G” It is said to be the lightest spreading tree”.

02

Step 2: Algorithm

Procedure for spreading light across a tree (G,w,E)

Input: Linear graphs G = (V,E) ; edge weights we;UCVWe;UV

Output: The tree with the shortest span

A graph G~=(V~,E~) such that

V~=V-U

E~={u,v:u,vV-Uu,v}

To go and get MST , use Kruskal's methodG~=T~:

/Make sure the tree is still alive. does not exist

if T~does not exist:

It is impossible to plant the lightest spanning tree.Consider an Edge set E~such that:

u,vE~:uUvU

When sorting the edge, loop on until vertex "U" is reached.

//weights for each : uU

//refer textbook for makeset()

Filter all edge weights using makeset(u). E~by w~e

/Continue in this loop until enough edges' weights are rising in sequence.u,vE in increasing order of weight:

/Verify that find(u) isn't really same as,

// find (v)

if find(u)find(v)):

//insert the edges inside tree

add edge u, v to T~

/To combine the u and v , call function union on u , v .

// v

union( u,v )

//Return the tree

returnT~

03

Singleton collection Holding Parameter

makeset()definition:

makeset() generates singleton collections holding all value of the parameter argument. Its meaning of makeset may be found on page 132 of something like the textbook () .

union()definition:

To join the sets involving two outcomes for passing arguments, utilize union(). This definition term union may be stated on page 133 of both the textbook () .

find()definition:

find() is often used to explore each combination to nodes on until necessary sets are found. The definition of discover may be found on page 132 of the textbook() .

Explanation:

While in thinnest spanning tree method described previously,• Construct the graph G~with the vertex V~ and edge E~.

• Obtain the minimal spanning tree for just a graph using the Kruskal's approach.G~.

• Where there is no minimal spanning tree, then thinnest spanning tree can indeed be built..

• Generate any edge collection inside the name of the smallest spanning tree if one exists E~.

• Using for each read all the vertices “U”.

• Using the function make set() sort the weight of the edges.

Using for loop read the order of weight in increasing order.

• Using if condition, check whether find of vertex“u” is not equal to find of vertex“v”.

• If the above condition is true, then add edges to the tree.

• Invoke the union() function by passing the vertex u and v.

• Otherwise, exit the loop.

Finally, return the constructed tree T~.

04

Conclusion

• Other than the edge set “ E”, the remaining complexity is similar to Kruskal’s algorithm. That is, the running time is OElogv.

• Then, construct the set “U”.

o For edge weight “e = (u,v)”. If find(u) is not equal to find(v) . Then, the edge “E” takes the running time of role="math" localid="1658922590785" OElogU.

o When deleting the node “U” from the optimal solution, then, the algorithm is still bounded the running time of OElogV.

Therefore, the total running time for light spanning tree algorithm is OElogV.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free