# Algorithm for graph with nodes grouped into sets

I have a weighted graph. The nodes of this graph are grouped into sets, and each node has only one corresponding set (no overlapping). Nodes in the same set do not have edges between them. An edge only connects nodes that are in different sets.

I want to select one node from each set, such that the total weight of the edges between these nodes is minimized. Between two sets, I will only be traversing one edge.

Only some sets are adjacent to each other, they are not all interconnected. But some sets do have multiple neighbours. When one set is adjacent to another, the nodes in these two sets form a complete bipartite graph.

Are there any algorithms to accomplish this? And is there a name for this type of graph?

• When you say "the toatal edge weight is minimized", you mean the total weight of the edges between the selected vertices? This doesn't look at all like a minimum spanning tree, to me: the structure you're selecting is neither spanning (it doesn't touch every vertex) nor a tree. Mar 24, 2016 at 2:28
• Yes, the total weight of the edges between the vertices. I said spanning tree because I want to touch all sets, selecting one node from each. It's not really a spanning tree, that may have been a poor analogy. Mar 24, 2016 at 2:33

The special case of zero-one weights is already NP-hard. In fact, even determining whether there is a choice such that the total weight is zero is NP-hard. See this question on cstheory.se. (You can arrange that all the weights are, say, $1$ or $2$, and then the condition that two connected parts are fully connected is satisfied.)