}
// extremely primitive O(V^2) prim
-int prim_mst(std::vector<std::pair<unsigned, unsigned> > &points, try_order *temp, unsigned toi)
+int prim_mst(std::set<std::pair<unsigned, unsigned> > &set1)
{
- std::set<std::pair<unsigned, unsigned> > set1, set2;
-
- for (unsigned i = 0; i < toi; ++i)
- set1.insert(points[temp[i].o.pt]);
+ std::set<std::pair<unsigned, unsigned> > set2;
// pick the first one
std::set<std::pair<unsigned, unsigned> >::iterator start = set1.begin();
unsigned last_switch = points[ord[ind-1].pt].second;
unsigned last_side = ord[ind-1].side;
+ std::set<std::pair<unsigned, unsigned> > mst_set;
+ mst_set.insert(std::make_pair(last_row, last_switch));
+
for (unsigned i = 0; i < points.size(); ++i) {
/* taken earlier? */
for (unsigned j = 0; j < ind; ++j) {
temp[toi].cost = distance(last_row, last_switch, last_side,
points[i].first, points[i].second, +1);
++toi;
+
+ mst_set.insert(points[i]);
taken:
1;
}
- unsigned min_rest_cost = prim_mst(points, temp, toi);
+ unsigned min_rest_cost = prim_mst(mst_set);
if (cost_so_far + min_rest_cost >= best_so_far) {
return UINT_MAX;
}