networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturns
steiner_tree(G, terminal_nodes, weight='weight')

The minimum Steiner tree of G w.r.t a set of :None:None:`terminal_nodes` is a tree within G 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.

Notes

For multigraphs, the edge between two nodes with minimum weight is the edge put into the Steiner tree.

Parameters

G : NetworkX graph
terminal_nodes : list

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 by :None:None:`terminal_nodes` .

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

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/algorithms/approximation/steinertree.py#49
type: <class 'function'>
Commit: