Graph Algorithms



Answer & solution
Answer: n²−1. (no official key was published)
There are n² vertices, so every spanning tree has exactly n²−1 edges. Distinct integer lattice points are at distance at least 1; hence every spanning tree has weight at least n²−1.
This bound is achievable without using any diagonals. In each row, connect its n vertices consecutively with n−1 horizontal unit edges. This uses n(n−1) edges and leaves n connected row paths. Connect consecutive rows by vertical unit edges along the first column, using n−1 more edges. The result is connected and has n(n−1)+(n−1)=n²−1 edges; equivalently, joining the disjoint row trees by a path cannot create a cycle. Its weight is exactly n²−1, matching the lower bound.
For n=2 this construction has three unit edges and weight 3. Using a diagonal would replace a unit edge by one of length √2 and cannot improve the minimum.
For this minimum, however, the same answer remains valid under that literal variant. All distinct vertices are still at least unit distance apart, and the unit-edge construction is still allowed. Thus this particular answer is robust even though the printed graph definitions differ.