How do I approach the problem: Minimum amount of edges to remove to create k connected components? The graph might already be a forest, though not necessarily one with k connected components, and may have cycles. It is unweighted and undirected.
Asked
Active
Viewed 1,111 times
3 Answers
1
- If the graph already has at least k components, then the answer is 0.
- If the graph is a tree, then the answer is
k-1
. - If the graph is the complete graph with
n
nodes, then the answer isn-1 + n-2 + ... + n-k+1 = (n(n-1) - (n-k)(n-k+1))/2
. - Without assumption, the answer can be any number between 0 and
(n(n-1) - (n-k)(n-k+1))/2
.

Stef
- 13,242
- 2
- 17
- 28
0
If the original graph is a tree, then the removal of each edge will increase the number of connected components by 1. After removing k-1 edges, the graph will become a forest with k connected components.

Ashwin Ganesan
- 331
- 1
- 4
-
1I agree, but what if it is not a tree? β fool_of_a_took Apr 27 '22 at 04:51
-
@fool_of_a_took Then the answer does not depend on only k and more information is necessary to answer the question. β Ashwin Ganesan Apr 27 '22 at 04:59
0
we can use DSU(disjoint sets) kind of thing.
-
As itβs currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). β Community Jun 07 '23 at 22:32