I'm trying to solve the following graph exercise:
In an undirected weighted graph, there are V vertices and E edges. Find the minimum weight needed to visit T(T<=V) vertices, starting from the vertex labeled as 0. Additionally, if there is an edge between two visited vertices, its weight is set to 0.
This isn't a classic traveling salesman problem, because of the added condition that if you visit two vertices, the weight of the edge between them is reduced to 0.
Approaching it with Prim's minimum spanning tree algorithm solves the problem if T == V, but since you don't necessarily have to visit all vertices, this will not always return the minimum weight.
I thought about finding the minimum spanning tree and then cutting every edge that wouldn't hinder my ability to reach all of my 'target' vertices, but that seems excessive and possibly incorrect.
Any thoughts?
EDIT: I'll give you an example. Suppose we have a graph with 4 vertices labeled 0,1,2 and 3. We have the following edges(from,to,weight): (0,1,1) (0,2,2) (1,3,4) (2,3,1) The minimum spanning tree would contain edges: (0,1,1), (0,2,2) and (2,3,1). With it, every vertex is reachable starting from 0. However, the goal of the exercise is to reach a T number of those vertices. That being said, we might, for example, only need to reach vertices 2 and 3, making the edge (0,1,1) unnecessary, and thus the total weight needed to reach our target vertices is 2+1, instead of 1+2+1.