Skip to main content
2 of 5
edited body
Pat Devlin
  • 2.8k
  • 17
  • 22

Not sure what you mean by saying vertices "can form an acceptable connected component" but no, your greedy algorithm isn't right.

Here are two examples that disprove what you want based on what exactly you're saying (example 2 is probably better).

Example 1: [this might not be a counterexample depending on what you intended your algorithm to do. See example 2 if you aren't happy with this.] As in your example, I'll call the vertices $\{A_1, A_2, A_3, B_1, \ldots, C_3\}$. The graph is the complete graph minus two edges. Namely, we insist $A_1 \not \sim A_2$ and $A_2 \not \sim A_3$. The weights should be $A_1$ has weight 1000, $A_2$ has weight 999, $A_3$ has weight $2$, and all the others have weight 1. If your algorithm picks the heaviest vertex and then grows this by greedily finding the heaviest adjacent vertex (et cetera), then your algorithm with fail on this input.

Example 2: this has 5 vertices (if you don't like that, add isolated vertices). The graph has 4 edges, which are $A_1 \sim B_2 \sim B_1 \sim A_2 \sim A_3$. The weights are that $B_1$ and $B_2$ have weight 100, and the other vertices have weight 99. The best min-weight decomposition here has weight $200$ but [if yours does anything close to what I think it does] your algorithm will give a weight of $100 + 99 +99$.

That said! Is there a polynomial-time algorithm? I bet there is by some sort of greedy with augmentation, but I haven't thought too much about that.

Pat Devlin
  • 2.8k
  • 17
  • 22