Function min_spanning_tree_prim

Source
pub fn min_spanning_tree_prim<G>(g: G) -> MinSpanningTreePrim<G> 
Expand description

[Generic] Compute a minimum spanning tree of a graph using Prim’s algorithm.

Graph is treated as if undirected. The computed minimum spanning tree can be wrong if this is not true.

Graph is treated as if connected (has only 1 component). Otherwise, the resulting graph will only contain edges for an arbitrary minimum spanning tree for a single component.

Using Prim’s algorithm with runtime O(|E| log |V|).

The resulting graph has all the vertices of the input graph (with identical node indices), and |V| - 1 edges if input graph is connected, and |W| edges if disconnected, where |W| < |V| - 1.

Use from_elements to create a graph from the resulting iterator.

See also: .min_spanning_tree(g) for implementation using Kruskal’s algorithm and support for minimum spanning forest.