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.
The minimum Steiner tree of
G
w.r.t a set ofterminal_nodes
is a tree withinG
that spans those nodes and has minimum size (sum of edge weights) among all such trees.The minimum Steiner tree can be approximated by computing the minimum spanning tree of the subgraph of the metric closure of G 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.
- Parameters
- GNetworkX graph
- terminal_nodeslist
A list of terminal nodes for which minimum steiner tree is to be found.
- Returns
- NetworkX graph
Approximation to the minimum steiner tree of
G
induced byterminal_nodes
.
Notes
For multigraphs, the edge between two nodes with minimum weight is the edge put into the Steiner tree.
References
- 1
Steiner_tree_problem on Wikipedia. https://en.wikipedia.org/wiki/Steiner_tree_problem