Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:11:05+00:00 2026-06-03T03:11:05+00:00

Here is an excise: Consider the problem of finding a minimum weight connected subset

  • 0

Here is an excise:

Consider the problem of finding a minimum weight connected subset T of edges from a weighted connected graph G. The weight of T is the sum of all the edge weights in T.Give an efficient algorithm to compute the minimum weight connected subset T.

Here are what I have got:

  1. I have to assume the weights are mixed by both positive and negative ones. Only the mix of both kinds of weights can make sense for this excise.

  2. I will sort the edges first, so the negative edges will come first.

  3. I will consider utilise Kruskal’s algorithm, but should be with some modifications

  4. Because I welcome negative edges, I will try to add as many negative edges as possible.

  5. In addition, some positive edges may be added to just in case that not all negative edges are connected and they may need some positive edges as bridges.


Ok, above is my thinking. But when I try to get my hands dirty, I get stuck.

How can I always record the possible minimum weights set?

For example,

{0, 1} is with weight -20

{2, 3} is with weight -10

if {1, 3} has weight of 11, then of course I don’t want {1, 3}

or if {1, 3} has weight of 9, then I want

With what kind of data structure I can always keep the minimum weight and the vertices for that weight?


It is worth to note that the subset this excise seeks for aim at edges.

Consider the problem of finding a minimum weight connected subset T of
edges
from a weighted connected graph G

This means that all vertices still need to be included.

Also it is more than a MST. Consider that if a vertex has two edges, one is -1, another is -2. In a normal MST algorithm, only edge of -2 will be taken. But in this excise, both -1 and -2 need to be taken to reduce the overall weight further.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:11:06+00:00Added an answer on June 3, 2026 at 3:11 am

    I think your algorithm is mostly correct already, but with slight modifications it becomes trivial to implement.

    First, every negative edge has to be included in order to minimize the resulting weight. Next, calculate the number of connected components c. If c=1, you’re done. Otherwise you need extra c-1 positive edges.

    Now, while you were adding negative edges, consider this already as a Kruskal’s algorithm process. Every negative edges may unite a couple of trees in the Kruskal’s forest. However, you add the negative edge even if its ends belong to the same tree in the Kruskal’s forest — unlike the usual Kruskal’s algorithm where you only add those edges that unite two different trees.

    After this phase, you’re left with a graph of c connected components (they may not be trees anymore). Now just continue the Kruskal’s algorithm as usual. Process the positive edges in the increasing order, keeping track of the number of unions the you’ve made with positive edges. Once this number gets to c-1, you’re done.

    By the way, all the process of Kruskal’s algorithm can be implemented easily if you represent the forest as disjoint-set data structure. It requires just a couple of lines of code to write, and after that it is trivial to keep track of the number of unions that were made.


    Some pseudocode follows:

    sort(edges);
    c := n;
    for edge in edges:
        if edge.weight < 0:
            if find(edge.firstEnd) != find(edge.secondEnd):
                --c;
            unite(edge.firstEnd, edge.secondEnd);
        else:
            if c == 1: break;
            if find(edge.firstEnd) != find(edge.secondEnd):
                unite(edge.firstEnd, edge.secondEnd);
                --c;
    

    Here unite and find are the functions of disjoint-set data structure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an excise: Let G be a weighted directed graph with n vertices
Here is an excise Suppose we are given the minimum spanning tree T of
Here is an excise: In certain graph problems, vertices have can have weights instead
Here is a excise from The book Algorithm Design Manual . In the bin-packing
Here is an excise for graph. Given an undirected graph G with n vertices
I am finding a lot of useful help here today, and I really appreciate
First of all, please excuse any typo, English is not my native language. Here's
Here is my SQL SELECT items.name, items.id, items.price, COUNT(cart_items.itemId) AS quantity FROM `cart_items` LEFT
Firstly here is the problem: A positive integer is called a palindrome if its
In Graph, there is a triangular strip problem. Basically, we have a set of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.