Given a collection of n edges, each represented by three numbers a, b, and c, you need to: • Output whether we can even make a MST. This requires that our graph can have all nodes connected to one another without cycling and without creating disjoint graphs. • Output the magnitude of the MST, or in other words the value of all edges of the MST added together. If there is no MST possible, output "No". If there is, output "Yes" and continue to the second task. On a new line, output "MST = " + the magnitude of the MST. a is the label of one vertex, b is the label of the other vertex, and c is the size of the edge that connects them. Each value is separated by a space, and each line ends with a endl character. The input will begin with the value of n, followed by a number of combinations of a, b, and c that could be constructed (note: the number of lines are not necessarily equal to or less than n). Make sure your output follows the structure given in the test cases. You MAY use STL to construct the graph, using vectors, lists, maps, or however you want to create them. Additionally, the use of STL implementation of priority queues are highly encouraged. However, you must implement either Prim's or Krustal's algorithm by hand. Either algorithm can be used: it will not impact results. Pick your favorite! Case 1: Input 1: 6 Output 1: Yes 0 1 9 MST = 20 0 4 8 1 5 5 2 0 6 3 2 2 1 3 1 2 1 3 4 3 7 5 3 4 Case 2: Input 2: 7 Output 2: No 2 3 3 1 0 1 6 5 9 2 0 5 2 4 1 0 4 4 1 3 7 3 0 7 Case 3: Input 3: 10 Output 3 is unknown, solve. 0 1 19 (that means put your own solution 3 4 1 here,

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Question

c++ 

Given a collection of n edges, each represented by three numbers a, b, and c, you need to: • Output whether we can even make a MST. This requires that our graph can have all nodes connected to one another without cycling and without creating disjoint graphs. • Output the magnitude of the MST, or in other words the value of all edges of the MST added together. If there is no MST possible, output "No". If there is, output "Yes" and continue to the second task. On a new line, output "MST = " + the magnitude of the MST. a is the label of one vertex, b is the label of the other vertex, and c is the size of the edge that connects them. Each value is separated by a space, and each line ends with a endl character. The input will begin with the value of n, followed by a number of combinations of a, b, and c that could be constructed (note: the number of lines are not necessarily equal to or less than n). Make sure your output follows the structure given in the test cases. You MAY use STL to construct the graph, using vectors, lists, maps, or however you want to create them. Additionally, the use of STL implementation of priority queues are highly encouraged. However, you must implement either Prim's or Krustal's algorithm by hand. Either algorithm can be used: it will not impact results. Pick your favorite! Case 1: Input 1: 6 Output 1: Yes 0 1 9 MST = 20 0 4 8 1 5 5 2 0 6 3 2 2 1 3 1 2 1 3 4 3 7 5 3 4 Case 2: Input 2: 7 Output 2: No 2 3 3 1 0 1 6 5 9 2 0 5 2 4 1 0 4 4 1 3 7 3 0 7 Case 3: Input 3: 10 Output 3 is unknown, solve. 0 1 19 (that means put your own solution 3 4 1 here,

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Polynomial time
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education