# What algorithm should I use to find a minimal tree that include certain nodes within a graph?

Assume we need to include a certain set of nodes in the tree within the whole graph, the generated tree can contain nodes other than the specified set of nodes. We also need the number of edges (or the total amount of edge weight) included in the tree is minimum.

This is the famous Steiner tree problem in graphs, which is known as NP-hard.

• Of course, there are still algorithms for NP-hard problems. Jul 9, 2018 at 11:24
• @DavidRicherby It does suggest that the OP would need to provide quite a lot more information in order to suggest which algorithm will meet their requirements. Often the key to an efficient algorithm on such a problem is to take advantage of structure in the data which let you sidestep the pathologically difficult cases. Jul 9, 2018 at 19:56
• @CortAmmon The question doesn't ask for an efficient algorithm: it asks for an algorithm. Even if no efficient algorithm is available for the asker's case, they still want an algorithm. Jul 9, 2018 at 23:24