Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5765 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4993 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1272 |

@bt8816103042 | 739 |

@rohitanand | 495 |

@codeantik | 479 |

@shalinibhataniya1097 | 472 |

@amrutakashikar2 | 464 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@shivanandp12345678910 | 453 |

@akashkale117 | 453 |

@SherlockHolmes3 | 447 |

Complete Leaderboard |

Reverse Delete algorithm is closely related to Kruskal’s algorithm. In Reverse Delete algorithm, we sort all edges in decreasing order of their weights. After sorting, we one by one pick edges in decreasing order. We include current picked edge if excluding current edge causes disconnection in current graph. The main idea is delete edge if its deletion does not lead to disconnection of graph. Your task is to print the value of total weight of Minimum Spanning Tree formed.

**Input:**

The first line of the input contains an integer 'T' denoting the number of test cases. Then 'T' test cases follow. Each test case consists of two lines.

Description of test cases is as follows:

The First line of each test case contains two integers 'V' and 'E' which denotes the no of vertices and no of edges respectively.

The Second line of each test case contains 'E' space separated triplets of m , n and w denoting that there is an edge from m to n and their weights.

**Output:**

Print the desired output in each line.

**Constraints:**

1<=T<=100

1<=V,E<=100

1<=m,n<=V

1<=w<=100

**Example:
Input:**

1

4 5

0 1 10 0 2 6 0 3 5 1 3 15 2 3 4

**Output:**

19

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Reverse Delete Algorithm for Minimum Spanning Tree

...