diff --git a/include/KM.h b/include/KM.h index 27d12fd..8820b4b 100644 --- a/include/KM.h +++ b/include/KM.h @@ -14,7 +14,7 @@ class KM { public: KM(const vector< vector > & _edges); vector solve(); - vector cut_loops(); + vector< vector > cut_loops(); void print_edges(); void print_matches(); diff --git a/src/solver/KM.cpp b/src/solver/KM.cpp index 8bfb5a5..9cff97d 100644 --- a/src/solver/KM.cpp +++ b/src/solver/KM.cpp @@ -53,7 +53,7 @@ vector KM::solve() { } -vector KM::cut_loops() { +vector< vector > KM::cut_loops() { vector arr; vector visited(nodes_n, false); @@ -83,19 +83,12 @@ vector KM::cut_loops() { p = match_x[p]; } while (p != match_x[st_idx]); + reverse(group.begin(), group.end()); groups.push_back(group); - } - for (int i = 0; i < groups.size(); i++) { - - for (int j = 0; j < groups.size(); j++) { - if (i == j) continue; - - } } - reverse(arr.begin(), arr.end()); - return arr; + return groups; } diff --git a/src/solver/stripes_solver.cpp b/src/solver/stripes_solver.cpp index 6d50f9b..3024b03 100644 --- a/src/solver/stripes_solver.cpp +++ b/src/solver/stripes_solver.cpp @@ -673,9 +673,9 @@ void StripesSolver::m_metric() { vector< vector > StripesSolver::reassemble_greedy() { - random_device rand_device; - default_random_engine rand_engine(rand_device()); - uniform_real_distribution uniform_unit_dist(0, 1); + // random_device rand_device; + // default_random_engine rand_engine(rand_device()); + // uniform_real_distribution uniform_unit_dist(0, 1); vector stripe_left(stripes_n, -1); vector stripe_right(stripes_n, -1); @@ -862,13 +862,26 @@ void StripesSolver::optimal_match(vector< vector > & fragments) { KM KM_solver(bigraph_w); KM_solver.solve(); - vector arr = KM_solver.cut_loops(); + vector< vector > groups = KM_solver.cut_loops(); #ifdef DEBUG KM_solver.print_edges(); KM_solver.print_matches(); #endif + int groups_n = groups.size(); + for (int i = 0; i < groups_n; i++) { + for (int j = 0; j < groups_n; j++) { + if (i == j) continue; + if (bigraph_w[i][j]) + group_pairs.push_back(StripePair(i, j, bigraph_w[i][j])); + } + } + + sort(group_pairs.begin(), group_pairs.end()); + + + composition_order.clear(); for (int frag_idx: arr) { composition_order.insert(