views:

49

answers:

3

I have an unweighted, connected graph. I want to find a connected subgraph that definitely includes a certain set of nodes, and as few extras as possible. How could this be accomplished?

Just in case, I'll restate the question using more precise language. Let G(V,E) be an unweighted, undirected, connected graph. Let N be some subset of V. What's the best way to find the smallest connected subgraph G'(V',E') of G(V,E) such that N is a subset of V'?

Approximations are fine.

A: 

You could try to do the following:

  1. Creating a minimal vertex-cover for the desired nodes N.

  2. Collapse these, possibly unconnected, sub-graphs into "large" nodes. That is, for each sub-graph, remove it from the graph, and replace it with a new node. Call this set of nodes N'.

  3. Do a minimal vertex-cover of the nodes in N'.

  4. "Unpack" the nodes in N'.

Not sure whether or not it gives you an approximation within some specific bound or so. You could perhaps even trick the algorithm to make some really stupid decisions.

aioobe
A: 

I can't think of an efficient algorithm to find the optimal solution, but assuming that your input graph is dense, the following might work well enough:

  1. Convert your input graph G(V, E) to a weighted graph G'(N, D), where N is the subset of vertices you want to cover and D is distances (path lengths) between corresponding vertices in the original graph. This will "collapse" all vertices you don't need into edges.

  2. Compute the minimum spanning tree for G'.

  3. "Expand" the minimum spanning tree by the following procedure: for every edge d in the minimum spanning tree, take the corresponding path in graph G and add all vertices (including endpoints) on the path to the result set V' and all edges in the path to the result set E'.

This algorithm is easy to trip up to give suboptimal solutions. Example case: equilateral triangle where there are vertices at the corners, in midpoints of sides and in the middle of the triangle, and edges along the sides and from the corners to the middle of the triangle. To cover the corners it's enough to pick the single middle point of the triangle, but this algorithm might choose the sides. Nonetheless, if the graph is dense, it should work OK.

Gintautas Miliauskas
Thanks, I think this would work.
hyluka
A: 

This is exactly the well-known NP-hard Steiner Tree problem. Without more details on what your instances look like, it's hard to give advice on an appropriate algorithm.

Falk Hüffner
I hadn't heard of Steiner trees, but I had reached the Wikipedia page for k-minimum spanning trees, which I think is the same thing as the MST version of Steiner trees.
hyluka
I don't think this is exactly the Steiner Tree problem. First, the value being optimized is the number of vertices rather than length of edges, and second, you can't add arbitrary vertices. You are right though that this problem is close and investigating its solutions might give insight into the problem at hand.
Gintautas Miliauskas
If you set the edge lengths to 1, the number of edges will be minimized, and since the resulting subgraph must be a tree, which has exactly one edge less than vertices, this is the same as minimizing the number of vertices. I don't understand what you mean by "you can't add arbitrary vertices".
Falk Hüffner
"Arbitrary vertices" refers to the "Euclidean Steiner tree" problem, which, according to Wikipedia, is the Steiner tree's original form. http://en.wikipedia.org/wiki/Steiner_tree
hyluka
I see, the Wikipedia page is indeed a bit confusing there. I was referring to the general Steiner Tree problem, also known as "Steiner Tree in Graphs".
Falk Hüffner