[prev] 24 [next]

Minimum Spanning Trees (cont)

Brute force optimisation solution:

typedef Graph MSTree; // an MST is a subgraph

MSTree findMST(Graph g)
{
   MSTree t, best;  float bestCost = MAXFLOAT;
   foreach (t in AllSpanningTrees(g)) {
      if (cost(t) < bestCost) {
         best = copy(t);  bestCost = cost(t);
      }
   }
   return best;
}

Not useful because #spanning trees is potentially large.