# networkx.algorithms.approximation.steinertree.steiner_tree¶

steiner_tree(G, terminal_nodes, weight='weight')[source]

Return an approximation to the minimum Steiner tree of a graph.

Parameters
• G (NetworkX graph)

• terminal_nodes (list) – A list of terminal nodes for which minimum steiner tree is to be found.

Returns

Approximation to the minimum steiner tree of G induced by terminal_nodes .

Return type

NetworkX graph

Notes

Steiner tree can be approximated by computing the minimum spanning tree of the subgraph of the metric closure of the graph induced by the terminal nodes, where the metric closure of G is the complete graph in which each edge is weighted by the shortest path distance between the nodes in G . This algorithm produces a tree whose weight is within a (2 - (2 / t)) factor of the weight of the optimal Steiner tree where t is number of terminal nodes.