Statistical Methods
Connect a Network with Minimum Total Edge Cost
Define the task
A minimum spanning tree selects connections that minimize their total cost while connecting a network. This is useful for auditing a proposed connection plan, but it is different from finding the shortest route between two locations. Declare nodes, allowed undirected edges and a common cost unit. Missing edges mean unavailable connections. This teaching tool accepts strictly positive edge costs, disallows self-loops and duplicate undirected edges, and keeps isolated nodes in the result.
Carry out the check
List every available connection once. The calculator orders edges by cost and accepts an edge only when it joins previously disconnected groups. If the input network is disconnected, the result is a forest with multiple components, not a completed connection plan. Review the selected links and the component count before reporting a total. Equal costs can permit several equally optimal trees. An optimum under these inputs does not establish real-world feasibility, resilience or capacity; those requirements need separate constraints and review.
Worked hypothetical example
Hypothetical example: four nodes have edges 0–1 costing 1, 1–2 costing 2, 0–2 costing 4 and 2–3 costing 3. The minimum tree selects costs 1,2,3 for a total of 6. The cost-4 edge would close a cycle and is omitted. Remove the only edge to node 3 and the output becomes two components with total selected cost 3. Reporting only that smaller total would hide the disconnected node.
Method checked 24 November 2026 against primary documentation: sparse.csgraph.minimum_spanning_tree.