I can create a grid graph with a random weights of edges and compute its minimal spanning tree by:
nx = 3; ny = 5; G = GridGraph[{nx, ny}]; w = RandomInteger[{1, 6}, EdgeCount[G]]; GG = Graph[EdgeList[G], EdgeWeight -> w, VertexLabels -> "Name", VertexLabelStyle -> Directive[Blue, Italic, 10], EdgeLabels -> "EdgeWeight", EdgeStyle -> Directive[Opacity[0.65`], Blue], EdgeLabelStyle -> Directive[Black, Italic, 10]]; k = FindSpanningTree[GG]; HighlightGraph[GG, k, GraphHighlightStyle -> "Thick"] Is there a way to compute the cost of the minimal spanning tree without adding the weights manually?