Question: [PYTHON] In this problem, you will be given a weighted disconnected undirected graph G with N nodes, labelled as 1...N and E edges. You will

[PYTHON]

In this problem, you will be given a weighted disconnected undirected graph G with N nodes, labelled as 1...N and E edges. You will be required to find the weights of minimum spanning trees in Gs maximum random forest. A minimum spanning forest is a union of the minimum spanning trees for its connected components.

Input Format

The first line will contain a positive integer N.

The second line will contain a positive integer E.

Then E lines will follow each containing three space separated integers. The first two will denote the node labels which will be the end points of an undirected edge and the the third integer will be denoting the weight of that edge.

Constraints

  • 0 < N < 100
  • 0 < E < N*(N - 1)/2 + 1

Output Format

Each line of the output should contain a single integer denoting the weight of one of the minimum spanning trees. The order doesnt matter and the weight of a particular minimum spanning tree should be printed only once.

Sample Input

6 6 1 2 2 2 3 2 3 1 1 4 5 2 5 6 2 6 4 1

Sample Output

3 3
 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!