// $(VARIANT) -nogui -dhrg embedded-graphs/facebook_combined_result -contll -iterate 99 -contll -esave > $@ namespace dhrg { struct pairdata { ld success, route_length; }; #define NOYET 127 vector > actual; vector pairs; vector last_goal; void prepare_pairs() { pairs.resize(N); actual.resize(N); for(int i=0; i bfsqueue; auto& p = actual[i]; auto visit = [&] (int j, int d) { if(p[j] == NOYET) { p[j] = d; bfsqueue.push_back(j); } }; visit(i, 0); for(int k=0; ki ^ ed.second->j ^ a; visit(b, p[a] + 1); } } } last_goal.clear(); last_goal.resize(N, -1); } void route_from(int src, int goal, const vector& distances_from_goal) { if(last_goal[src] == goal) return; if(src == goal) { pairs[src].success = 1; pairs[src].route_length = 0; } else { ld bestd = distances_from_goal[src] - 1e-5; /* iprintf("route_from goal=%d a=%d, bestd = %f\n", goal, src, bestd + 1e-5); indent += 2; */ vector candidates; for(auto ed: rogueviz::vdata[src].edges) { int e = ed.second->i ^ ed.second->j ^ src; ld d = e == goal ? -1 : distances_from_goal[e]; if(d < bestd) bestd = d, candidates.clear(); if(d == bestd) candidates.push_back(e); } pairs[src].success = pairs[src].route_length = 0; for(int c: candidates) { route_from(c, goal, distances_from_goal); // iprintf("candidate = %d\n", c); pairs[src].success += pairs[c].success / isize(candidates); pairs[src].route_length += (1 + pairs[c].route_length) / isize(candidates); } // iprintf("success = %f, route = %f\n", pairs[src].success, pairs[src].route_length); // indent -= 2; } last_goal[src] = goal; } struct iddata { ld tot, suc, routedist, bestdist; iddata() { tot = suc = routedist = bestdist = 0; } } datas[6]; template void greedy_routing(int id, const T& distance_function) { for(int goal=0; goal distances_from_goal(N); for(int src=0; src reps; vector values; auto report = [&] (string s, ld val) { values.push_back(val); reps.push_back(s); println(hlog, "REPORT ", s, " = ", val); }; if(1) { FILE *f = fopen(("embout/" + s).c_str(), "rb"); char buf[999999]; int siz = fread(buf, 1, 999999, f); for(int i=0; iget_growth()); } }