A set of links can connect every robot-related station at minimum total edge cost while leaving a longer route between particular stations. That is the distinction between paying for a connected network and minimizing distances traveled through it. Both questions use weighted graphs, but their objectives are different.
Consider an invented undirected graph with four vertices A, B, C, and D. We will treat weights as abstract additive costs, not measured cable lengths, travel times, or installation quotations. This is a finite optimization example. No graph library, routing system, or physical network was operated.
State the connection objective
A spanning tree includes every vertex, remains connected, and contains no cycle. With four vertices it has three edges. Its total weight counts each selected edge once, regardless of how often any later route uses that edge.
The graph contains exactly six edges: AB has weight 2, BC has weight 2.5, CD has weight 1, AC has weight 3, BD has weight 4.5, and AD has weight 5. Every edge is usable in either direction. All weights are distinct and positive.
MIT's minimum-spanning-tree lecture defines this total-edge objective and describes greedy tree construction. NetworkX's official reference distinguishes a connected graph's spanning tree from a disconnected graph's spanning forest and notes that tied weights can permit several optimal trees. The graph and all certificates below are original constructions.
Grow a tree without accumulating route distance
Kruskal's rule considers edges in increasing weight order and accepts an edge if it does not close a cycle among accepted edges. Here CD, weight 1, is first. AB, weight 2, is next. These create two separate two-vertex components.
BC, weight 2.5, connects those components. The accepted edges now form the chain A-B-C-D, span all vertices, and total 1 + 2 + 2.5 = 5.5. The three-edge target has been reached.
Notice what the acceptance test used: edge weights and connectivity. It did not compare the total length of a route from A with a competing route from A. An edge can be a good connection purchase while producing a longer route when chained with other selected links.
Use cuts as independent certificates
A cut partitions all vertices into two nonempty groups. Any connected spanning tree must include an edge crossing that partition; otherwise the two groups would remain disconnected.
For the cut separating A from B, C, and D, the crossing weights are AB = 2, AC = 3, and AD = 5. AB is uniquely lightest. If an optimal tree omitted AB, adding it would create a cycle. That cycle must contain another crossing edge; exchanging that heavier edge for AB would lower the total. Thus every minimum tree includes AB.
The cut separating D from the other vertices similarly forces CD, whose weight 1 is less than BD = 4.5 and AD = 5. Finally, consider the cut {A,B} versus {C,D}. The crossing edges are BC, AC, BD, and AD, with weights 2.5, 3, 4.5, and 5. It forces BC.
All three selected edges have therefore been certified separately. Together they form a spanning tree of weight 5.5. This is stronger evidence than merely observing that a greedy trace stopped without error.
The cycle rule explains excluded edges
Adding AC to the selected chain creates the cycle A-B-C-A. Its three weights are 2, 2.5, and 3. AC is strictly heaviest. A minimum tree cannot contain a uniquely heaviest cycle edge: deleting it separates the tree, and some lighter edge from that cycle can reconnect the pieces at lower total cost.
The same reasoning excludes BD from cycle B-C-D-B and AD from cycle A-B-C-D-A. In the latter cycle, AD's weight 5 exceeds each other edge individually, even though the alternative A-to-D route totals 5.5. The cycle rule compares individual exchanged edge weights, not that entire route sum.
This last comparison exposes the difference in objectives directly. Removing AD can save connection cost while making the A-to-D path longer.
Build a different tree for shortest routes from A
In the full graph, A-to-B has minimum cost 2 through AB. A-to-C costs 3 through AC, less than 4.5 through AB and BC. A-to-D costs 4 through AC and CD, less than the direct edge's 5 or the chain's 5.5.
The edges AB, AC, and CD therefore form a shortest-path tree rooted at A. Its root distances are 2, 3, and 4, summing to 9. Its total selected-edge cost is 2 + 3 + 1 = 6.
The minimum spanning tree's root distances instead are 2, 4.5, and 5.5, summing to 12, while its selected-edge cost is only 5.5. The shortest-path tree spends an extra 0.5 on selected links and improves these routes. Neither result is contradictory: the two trees minimize different quantities.
Ties change what a certificate can force
Modify only AC, reducing its weight from 3 to 2.5. Both AB-BC-CD and AB-AC-CD now total 5.5. The {A,B} cut has two equally light crossing edges. Each can occur in an optimal tree, but that cut no longer forces one specific choice into every optimum.
Likewise, a cycle edge tied for maximum weight cannot be excluded by the strict-heaviest argument. An exchange may preserve weight instead of improving it. Distinctness was useful for the earlier uniqueness certificates; it is not required for the mathematical minimum to exist.
Retain the model boundary
An MST guarantees connectivity using the least total tree-edge weight supplied to that model. It supplies no redundant route: removing any selected tree edge disconnects the tree. Requirements for resilience, capacity, geometric clearance, or short operating routes introduce additional objectives or constraints.
If the original graph is disconnected, no tree spans all vertices through its available edges. A spanning forest then solves separate component problems. Naming the graph, edge interpretation, connectivity assumptions, and desired objective makes the resulting network calculation reviewable rather than treating every small weighted graph as the same routing problem.
Sources checked October 24, 2026:
MIT 1.204, Lecture 11: Greedy Algorithms, Minimum Spanning Trees: https://ocw.mit.edu/courses/1-204-computer-algorithms-in-systems-engineering-spring-2010/ecbf088d8b500c663ba108d8175a741d_MIT1_204S10_lec11.pdf
NetworkX: minimum_spanning_tree: https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.tree.mst.minimum_spanning_tree.html
Concept illustration: A small robot beside a laptop provides context for graph models. The image does not represent the invented weighted graph, an executed spanning-tree algorithm, a routed link, or an installed network.