How this calculation works
Find a spanning tree minimizing the sum of its weighted distances over all unordered vertex pairs.
RC(T)=Σu<v dT(u, v)=Σe∈T we se(n−se).A worked example
In the default unit-weight complete graphK 4, a star has three adjacent pairs at distance 1 and three leaf pairs at distance 2, so routing cost 9.
Good to know
Connected simple graph on 1–8 vertices and at most 16 edges; positive integer lengths≤1,000,000. Exact(n−1)-edge subset search,1,000,000 subset cap; one optimum and unordered all-pairs unit demands. Not minimum tree-edge weight or minimum worst stretch.
Reference: Wu and colleagues: minimum routing cost spanning trees (opens in a new tab) ↗
Optimizing travel through a retained tree
A spanning tree connects every declared vertex using exactly one route between each pair. Minimum routing cost chooses the tree with the smallest sum of those pairwise path lengths. It therefore values how the retained edges support all trips, not just how cheap the tree's edges are to install.
This page gives every unordered vertex pair one unit of demand. Counting ordered pairs would double the displayed objective without changing which trees minimize it. Unequal communication demands, direction-dependent travel and disconnected service groups are different models and are not inferred from the graph's edge weights.
Compare this with the Minimum stretch spanning tree calculator from graph edges. Minimize the sum of pairwise distances in the retained tree; stretch minimizes a worst distance ratio instead.
Entering lengths instead of installation prices
Each row contains two zero-based vertex labels and a positive integer edge length. A length contributes every time a routed pair uses that edge. All declared vertices must be connected by some input path, including any location that otherwise might appear only in the vertex count.
The implementation narrows lengths to integers so objective comparisons remain exact within the supported magnitude bounds. A common positive unit conversion that preserves integers scales every objective equally. Arbitrary fractional costs should be converted consistently to integer units rather than rounded independently in ways that could reverse a close optimum.
The four-vertex example
The default graph contains all six edges of a four-vertex complete graph, each of length one. Selecting a star gives three center-to-leaf distances equal to one and three leaf-to-leaf distances equal to two. Their unordered-pair sum is three plus six, giving routing cost nine.
A path also has three retained unit edges and hence the same installation total, but its pairwise distances sum to ten. This exposes the difference from ordinary minimum spanning tree: an edge-weight optimum can have a worse routing objective even when every candidate tree uses the same total edge length.
Counting edge use through a cut
Deleting one tree edge separates the tree into sides of sizes s and n minus s. Exactly s times n minus s unordered pairs have their endpoints on opposite sides. Because the tree has unique paths, every one of those pairs uses that edge exactly once.
The objective can therefore be computed by multiplying each retained edge length by its separated-pair count and summing those contributions. The returned split table shows the side sizes and contribution for every edge, making the objective independently checkable without listing every route individually.
Enumerating the finite tree candidates
The exact search enumerates subsets containing n minus one input edges. A disjoint-set structure rejects cycles and disconnected subsets. Every surviving subset is a spanning tree, so the search compares the edge-split objective only among feasible candidates from the original graph.
Once the best tree is selected, its all-pairs distances are recomputed and summed as a second certificate. That distance sum must equal the split contribution sum. A mismatch is an implementation consistency failure, not an alternative definition that is silently averaged into the reported answer.
Minimum routing versus minimum stretch
Minimum stretch compares tree distances to original shortest-path distances and optimizes a worst ratio. Minimum routing cost instead sums absolute tree distances. A tree that protects one difficult pair exceptionally well may have a larger total cost across many other pairs, so the two objectives can select different witnesses.
This calculator does not output a guarantee about the largest detour ratio. Inspect the returned distance matrix if a particular pair matters. If the application requires unequal demand weights or a mandatory edge, those constraints must be modeled separately rather than assumed to be encoded by the equal-demand objective.
Limits and useful verification cases
The graph and subset caps keep exact enumeration finite. A resource error gives no minimum, and a disconnected graph is rejected because no spanning tree exists. For a graph that is already a tree, that tree is the only candidate and its split formula directly determines the answer.
For a complete unit-weight graph, checking a star provides a useful reference value: each retained edge separates one leaf from all other vertices. More generally, compare the returned objective under uniform integer scaling of all lengths. The witness may remain tied with alternatives, but every feasible objective should scale by the same factor.
A few questions, answered
Are vertex pairs ordered?
No. Each unordered pair is counted once; ordered counting would double the reported sum.
Is this an ordinary minimum spanning tree?
No. It minimizes routed pair distances, not only the sum of retained edge lengths.
Can lengths be fractional?
Use a consistent positive integer unit within the stated bound; fractional input is rejected.
What does the edge split count mean?
It counts the unordered pairs whose unique tree route must cross that retained edge.