diff --git a/rogueviz/sag/data.cpp b/rogueviz/sag/data.cpp index f65f56b1..1ebda6b1 100644 --- a/rogueviz/sag/data.cpp +++ b/rogueviz/sag/data.cpp @@ -26,6 +26,7 @@ vector hubval; vector sagedges; vector> edges_yes, edges_no; +vector>> edge_weights; ld edgepower=1, edgemul=1; @@ -53,6 +54,14 @@ void prepare_graph() { edges_no[i].push_back(j); } + edge_weights.clear(); edge_weights.resize(DN); + for(auto& e: sagedges) { + if(e.i == e.j) continue; + e.weight2 = pow((double) e.weight, (double) edgepower) * edgemul; + edge_weights[e.i].emplace_back(e.j, e.weight2); + edge_weights[e.j].emplace_back(e.i, e.weight2); + } + sagnode.clear(); sagnode.resize(isize(sagcells), -1); for(int i=0; iweight2 + match_b; + ld expect = match_a / e.second + match_b; ld dist = cdist - expect; cost += dist * dist; } @@ -60,11 +58,9 @@ double costat(int vid, int sid) { } case smClosest: { - vertexdata& vd = vdata[vid]; - for(int j=0; jweight2; + for(auto& e: edge_weights[vid]) { + auto t2 = e.first; + if(sagid[t2] != -1) cost += sagdist[sid][sagid[t2]] * e.second; } if(!hubval.empty()) {