Generating a random minimum spanning tree
Since there are just about 10 random points, the following simplest algorithm is should be fast and easy enough for your need.


Generate random points $p_i$, $0\le i\le9 $ in the grid, in whichever way you prefer.
Compute all Euclidean distances between each pair of points. (In fact, I believe for your purpose, the Manhattan distance should be fine as well. What is nice about Manhattan distance is that it is much easier to code and compute. The MST generated will be roughly the same.)
Compute the MST of the points with the distances between them.


There are many existing libraries that computing MST. You can just select any popular one that is convenient for you. I guarantee you that they will be fast enough for your need.