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.
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.
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.
k-1.n nodes, then the answer is n-1 + n-2 + ... + n-k+1 = (n(n-1) - (n-k)(n-k+1))/2.(n(n-1) - (n-k)(n-k+1))/2.