@@ -68,7 +68,7 @@ std::string GraphPartitioner::validPartitionMethodsStr()
6868 return valid_methods.str ();
6969}
7070
71- static void write_node_by_partition (const sbg_partitioner::PartitionMap &partitions , const SBG ::LIB ::WeightedSBGraph &sb_graph,
71+ static void write_node_by_partition (const sbg_partitioner::PartitionMap &partition , const SBG ::LIB ::WeightedSBGraph &sb_graph,
7272 const std::string &partition_method_name)
7373{
7474 std::cout << " writing results of SBG to " << partition_method_name << std::endl;
@@ -81,42 +81,37 @@ static void write_node_by_partition(const sbg_partitioner::PartitionMap &partiti
8181 sbg_partitioner::sort_partition_intervals (nodes);
8282
8383 // expand it and write it
84- std::vector<unsigned > partition_by_node;
8584 std::ofstream output_file (partition_method_name);
85+ std::vector<unsigned > partition_vector (sb_graph.V ().cardinal (), 0 );
86+
8687 if (sb_graph.V ().arity () == 2 ) {
87- partition_by_node = std::vector<unsigned >(sb_graph.V ().cardinal (), 0 );
8888 size_t row_size = (*sb_graph.V ().begin ()).intervals ()[0 ].cardinal ();
89- for (unsigned i = 0 ; i < partitions.size (); i++) {
90- for (const auto &n : partitions.at (i)) {
91- for (size_t v_0 = n.intervals ()[0 ].begin (); v_0 <= n.intervals ()[0 ].end (); v_0++) {
92- for (size_t v_1 = n.intervals ()[1 ].begin (); v_1 <= n.intervals ()[1 ].end (); v_1++) {
93- size_t vertex = v_0 * row_size + v_1;
94- partition_by_node[vertex] = i;
89+ for (size_t i = 0 ; i < partition.size (); i++) {
90+ const auto &p = partition.at (i);
91+ for (const auto &set : p) {
92+ for (const auto sp : set) {
93+ for (size_t row = sp.intervals ()[0 ].begin (); row <= sp.intervals ()[0 ].end (); row++) {
94+ for (size_t col = sp.intervals ()[1 ].begin (); col <= sp.intervals ()[1 ].end (); col++) {
95+ auto val = row * row_size + col;
96+ partition_vector[val] = i;
97+ }
9598 }
9699 }
97100 }
98101 }
99- for (size_t i = 0 ; i < partition_by_node.size (); i++) {
100- output_file << std::to_string (partition_by_node[i]) << std::endl;
101- }
102102 } else {
103- for (const auto &n : nodes) {
104- for (size_t v_0 = n.intervals ()[0 ].begin (); v_0 <= n.intervals ()[0 ].end (); v_0++) {
105- SBG ::LIB ::SetPiece set_piece;
106- set_piece.emplaceBack (SBG::LIB::Interval (v_0, n.intervals ()[0 ].step (), v_0));
107- for (size_t i = 0 ; i < partitions.size (); i++) {
108- sbg_partitioner::Partition p = partitions.at (i);
109- auto p_set = sbg_partitioner::from_vector (p);
110- if (not SBG ::LIB ::SET_FACT .createSet (set_piece).intersection (p_set).isEmpty ()) {
111- partition_by_node.push_back (i);
112- std::cout << i << std::endl;
113- output_file << std::to_string (i) << std::endl;
114- break ;
115- }
103+ for (unsigned i = 0 ; i < partition.size (); i++) {
104+ for (size_t vert_idx = 0 ; vert_idx < partition.at (i).size (); vert_idx++) {
105+ for (size_t val = (*(*partition.at (i).at (vert_idx).begin ()).begin ()).begin ();
106+ val <= (*(*partition.at (i).at (vert_idx).begin ()).begin ()).end (); val++) {
107+ partition_vector[val] = i;
116108 }
117109 }
118110 }
119111 }
112+ std::cout << " parts ok" << std::endl;
113+
114+ for_each (partition_vector.begin (), partition_vector.end (), [&output_file](const auto val) { output_file << val << " \n " ; });
120115}
121116
122117std::tuple<Partition, std::chrono::duration<double >> GraphPartitioner::createPartition (const std::string &partition_method_name,
0 commit comments