Minimum Spanning Trees, Prim’s, Kruskal’s and Round‐ Robin Algorithms

A Minimum Spanning Tree (MST) is a subgraph of an undirected graph such that the subgraph spans (includes) all nodes, is connected, is cyclic, and has minimum total edge weight. Any undirected graph has aminimum spanning forest, which is a union of minimum spanning trees for its connected components. Kruskal Algorithm works as: Find the MST by taking the smallest weight in the graph and connecting the two nodes and repeating until all nodes are connected to just one tree. This is done by creating a priority queue using the weights as keys. Prim's Algorithm works as: Select any vertex Select the shortest edge connected to that vertex Select the shortest edge connected to any vertex already connected Repeat step 3 until all vertices have been connected

Summary

A Minimum Spanning Tree (MST) is a subgraph of an undirected graph such that the subgraph spans (includes) all nodes, is connected, is cyclic, and has minimum total edge weight. Any undirected graph has aminimum spanning forest, which is a union of minimum spanning trees for its connected components. Kruskal Algorithm works as: Find the MST by taking the smallest weight in the graph and connecting the two nodes and repeating until all nodes are connected to just one tree. This is done by creating a priority queue using the weights as keys. Prim's Algorithm works as: Select any vertex Select the shortest edge connected to that vertex Select the shortest edge connected to any vertex already connected Repeat step 3 until all vertices have been connected

Things to Remember

  1. A Minimum Spanning Tree (MST) is a subgraph of an undirected graph such that the subgraph spans (includes) all nodes, is connected, is cyclic, and has minimum total edge weight. 
  2. Any undirected graph has aminimum spanning forest, which is a union of minimum spanning trees for its connected components. 
  3. Kruskal Algorithm works as: Find the MST by taking the smallest weight in the graph and connecting the two nodes and repeating until all nodes are connected to just one tree. This is done by creating a priority queue using the weights as keys.
  4. Prim's Algorithm works as
  • Select any vertex
  • Select the shortest edge connected to that vertex
  • Select the shortest edge connected to any vertex already connected
  • Repeat step 3 until all vertices have been connected

MCQs

No MCQs found.

Subjective Questions

Q1:

Define malaria?


Type: Very_short Difficulty: Easy

Show/Hide Answer
Answer: <p>Malaria is a disease caused by a parasite, transmitted by the bite of infected mosquitoes. Malaria produces recurrent attacks of chills and fever.</p>

Q2:

What is the cause of malaria and list down its sympyoms?


Type: Short Difficulty: Easy

Show/Hide Answer
Answer: <p>&nbsp;</p>
<p><strong>Causes</strong></p>
<p>Bite of female anopheles mosquitoes.</p>
<p>Malaria is caused by a type of microscopic parasite that's transmitted most commonly by mosquito bites.</p>
<p><strong>Symptoms</strong></p>
<p>A malaria infection is generally characterized by recurrent attacks with the following signs and symptoms:</p>
<p>- Moderate to severe shaking chills</p>
<p>- High fever</p>
<p>- Profuse sweating as body temperature falls</p>
<p>- Headache</p>
<p>- Vomiting</p>
<p>- Diarrhea</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

Q3:

Hiw it can be treated and prevented?


Type: Long Difficulty: Easy

Show/Hide Answer
Answer: <p><strong>Treatments and drugs</strong></p>
<p>The types of drugs and the length of treatment will vary, depending on the type of parasite you have.</p>
<p>Medications</p>
<p>The most common antimalarial drugs include:</p>
<p>- Chloroquine (Aralen)</p>
<p>- Quinine sulfate (Qualaquin)</p>
<p>- Hydroxychloroquine (Plaquenil)</p>
<p>- Mefloquine</p>
<p>- Combination of atovaquone and proguanil (Malarone)</p>
<p>&nbsp;</p>
<p><strong>Prevention</strong></p>
<p>_ Remove stagnant water, where the mosquito is more likely to breed.</p>
<p>_ Increase the nutritional status of the child.</p>
<p>_ Protect children from malaria by using bed nets.</p>
<p>_ To prevent the entry of mosquito the nets should be used on door and windows.</p>
<p>_ Spray DDT around the surrounding.</p>
<p>_ To prevent children from mosquitoes bite, it is good to cover the maximum part of your body.</p>
<p>_ Different kinds of creams and lotions can be used on the body.</p>
<p>_ If any sings and symptoms appear then go for the medical treatment.</p>
<p>&nbsp;</p>

Videos

No videos found.

Minimum Spanning Trees, Prim’s, Kruskal’s and Round‐ Robin Algorithms

Minimum Spanning Trees, Prim’s, Kruskal’s and Round‐ Robin Algorithms

Minimum Spanning Tree

A Minimum Spanning Tree (MST) is a subgraph of an undirected graph such that the subgraph spans (includes) all nodes, is connected, is cyclic, and has minimum total edge weight. A single graph can have various different spanning trees. We can also assign a weight to each edge, which is a number representing how unfavorable it is, and use it to calculate the total weight of the spanning tree formed.A minimum spanning tree (MST) or minimum weight spanning tree is the one with weight less than or equal to the weight of every other spanning tree. In general, any undirected graph has a minimum spanning forest, which is a union of minimum spanning trees for its connected components.

1

Fig: MST of a planar graph
Fig: MST of a planar graph

Applications of MST

  • Minimumcost-spanning trees have many applications, some of them are:
    • Building cable networks that join n locations with minimum cost
    • Building a road network that joins n cities with minimum cost
    • Obtaining an independent set of circuit equations for an electrical network
    • In pattern recognition, MSTs can be used to find noisy pixels.

Kruskal's Algorithm

Description
Find the MST by taking the smallest weight in the graph and connecting the two nodes and repeating until all nodes are connected to just one tree. This is done by creating a priority queue using the weights as keys.

1

Example

1

2

3

4

5

Prim's Algorithm

In computer science, Prim's algorithm is a greedy algorithm that finds an MSTfor a weighted undirected graph. This means it finds a subset of the edges that forms tree including every vertex, with the total weight of all the edges in the tree minimized. The algorithm works by building this tree one vertex at a time, from an arbitrary starting vertex, at each step adding the cheapest possible connection from the tree to another vertex in terms of weight of the graph.

  1. Select any vertex
  2. Select the shortest edge connected to that vertex
  3. Select the shortest edge connected to any vertex already connected
  4. Repeat step 3 until all vertices have been connected

Let

T = a spanning tree containing a single node s;

E = set of edges adjacent to s;

while T does not contain all the nodes{

remove an edge (v,w) of lowest cost from E

if w is already in T, then discard edge (v,w)

else {

add edge (v,w) and node w to T

add to E the edges adjacent to w

}

}

Example:

1

2

3

4

5

References

1.https://en.wikipedia.org/wiki/Kruskal's_algorithm

2.https://en.wikipedia.org/wiki/Prim's_algorithm

3. Karumanchi, N. "Data Structures and Algorithms Made Easy"

4. Y. Langsam, M. J. Augenstein and A. M Tenenbaum, “Data Structures using C and C++”

5. R. L. Kruse, B. P. Leung, C. L. Tondo, “Data Structure and Program design in C”

Lesson

Graphs

Subject

Computer Engineering

Grade

Engineering

Recent Notes

No recent notes.

Related Notes

No related notes.