@@ -233,6 +233,18 @@ SBG::LIB::WeightedSBGraph build_computational_sbg(const PartitionerParams& param
233233 cout << " diff1 " << diff1 << " , " << " diff2 " << diff2 << endl;
234234 }
235235
236+ #ifdef SBG_PARTITIONER_LOGGING
237+ cout << " sb_graph: " << sb_graph << endl;
238+ cout << " connections:\n " ;
239+ for (auto it1 = sb_graph.map1 ().begin (), it2 = sb_graph.map2 ().begin ();
240+ it1 != sb_graph.map1 ().end () and it2 != sb_graph.map2 ().end (); ++it1, ++it2) {
241+ auto n1 = (*it1).image ();
242+ auto n2 = (*it2).image ();
243+ cout << n1 << " , " << n2 << " from " << (*it1).dom () << " \n " ;
244+ }
245+ cout << endl;
246+ #endif
247+
236248 return SBG::LIB::WeightedSBGraph (
237249 new_vertices,
238250 SBG ::LIB ::PW_FACT .createPWMap (),
@@ -251,51 +263,23 @@ tuple<SBG::LIB::WeightedSBGraph, PartitionMap, double, double> run_partitioner(c
251263 auto sb_graph = build_computational_sbg (params);
252264 auto end_building_graph = chrono::high_resolution_clock::now ();
253265 auto time_to_build_graph = chrono::duration<double , std::milli>(end_building_graph- start_building_graph).count ();
254- #ifdef SBG_PARTITIONER_LOGGING
255- cout << " sb_graph: " << *sb_graph_ptr << endl;
256- cout << " connections:\n " ;
257- for (auto it1 = sb_graph_ptr->map1 ().begin (), it2 = sb_graph_ptr->map2 ().begin ();
258- it1 != sb_graph_ptr->map1 ().end () and it2 != sb_graph_ptr->map2 ().end (); ++it1, ++it2) {
259- auto n1 = (*it1).image ();
260- auto n2 = (*it2).image ();
261- cout << n1 << " , " << n2 << " from " << (*it1).dom () << " \n " ;
262- }
263- cout << endl;
264- #endif
265266
266267 auto start_partitionate = chrono::high_resolution_clock::now ();
267- auto partitions =
268+ auto partition =
268269 best_initial_partition (sb_graph, *params.number_of_partitions , params.initial_partition_strategy , params.enable_multithreading );
269- cout << " chosen partition " << partitions << endl;
270+ cout << " chosen partition " << partition << endl;
270271
271- kl_sbg_imbalance_partitioner (sb_graph, partitions , params.epsilon , params.enable_multithreading );
272+ kl_sbg_imbalance_partitioner (sb_graph, partition , params.epsilon , params.enable_multithreading );
272273 auto end_partitionate = chrono::high_resolution_clock::now ();
273274 auto time_to_partitionate = chrono::duration<double , std::milli>(end_partitionate - start_partitionate).count ();
274275
275276 if (params.dump_results ) {
276- ofstream edges_file (std::filesystem::path (filename).stem ().string () + " _edges.txt" );
277- auto edges = sb_graph.E ().compact ();
278- for (int i = (*edges.begin ())[0 ].begin (); i <= (*edges.begin ())[0 ].end (); i++) {
279- auto departure = (*sb_graph.map1 ().image (SBG ::LIB ::SET_FACT .createSet (SBG::LIB::Interval (i))).begin ())[0 ].begin ();
280- auto arrival = (*sb_graph.map2 ().image (SBG ::LIB ::SET_FACT .createSet (SBG::LIB::Interval (i))).begin ())[0 ].begin ();
281- edges_file << departure << " " << arrival << endl;
282- }
283-
284-
285- vector<unsigned > partition_vector ((*sb_graph.V ().compact ().begin ())[0 ].end () + 1 , 0 );
286- for (unsigned i = 0 ; i < partitions.size (); i++) {
287- for (int vert_idx = 0 ; vert_idx < partitions.at (i).size (); vert_idx++) {
288- for (int val = (*partitions.at (i).at (vert_idx).begin ()).begin (); val <= (*partitions.at (i).at (vert_idx).begin ()).end (); val++) {
289- partition_vector[val] = i;
290- }
291- }
292- }
293-
294- ofstream parts_file (std::filesystem::path (filename).stem ().string () + " _parts.txt" );
295- for_each (partition_vector.begin (), partition_vector.end (), [&parts_file](const auto val) { parts_file << val << " \n " ; });
277+ // graph may be compacted, so compute it again
278+ auto actual_sbg = get_sbg (*params.filename , *params.number_of_partitions );
279+ metrics::dump_results (actual_sbg, *params.filename , partition);
296280 }
297281
298- return {sb_graph, partitions , time_to_build_graph, time_to_partitionate};
282+ return {sb_graph, partition , time_to_build_graph, time_to_partitionate};
299283}
300284
301285
@@ -432,6 +416,8 @@ int main(int argc, char** argv)
432416
433417 auto [sb_graph, partitions, time_to_build_graph, time_to_partitionate] = run_partitioner (params);
434418
419+ cout << " Partition obtained after refining:\n " << partitions << endl;
420+
435421 if (params.compute_metrics ) {
436422 map<string, metrics::communication_metrics> metrics;
437423
0 commit comments