Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaGuarracino committed Aug 20, 2023
1 parent 85fad2e commit eae76d3
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,25 +664,27 @@ int main(int argc, char **argv) {

// Prepare the data needed to embed the paths in parallel
ska::flat_hash_map<path_handle_t, std::pair<uint64_t, uint64_t>> path_handle_2_start_and_end_in_path_mapping;
path_handle_t prec_path = smoothxg::get_base_path(path_mapping.read_value(0));
uint64_t prec_i = 0;
for (uint64_t i = 1; i < path_mapping.size(); ++i) {
path_handle_t current_path = smoothxg::get_base_path(path_mapping.read_value(i));
if (current_path != prec_path) {
// Create path handles in the output graph not in parallel to preserve their order
{
path_handle_t prec_path = smoothxg::get_base_path(path_mapping.read_value(0));
uint64_t prec_i = 0;
for (uint64_t i = 1; i < path_mapping.size(); ++i) {
path_handle_t current_path = smoothxg::get_base_path(path_mapping.read_value(i));
if (current_path != prec_path) {
// Create path handles in the output graph not in parallel to preserve their order
smoothed->create_path_handle(path_handle_2_name_and_length[prec_path].first);

// Record the start and end of the path in the path_mapping
path_handle_2_start_and_end_in_path_mapping[prec_path] = std::make_pair(prec_i, i-1);

prec_path = current_path;
prec_i = i;
}
}
if (prec_i != path_mapping.size() - 1) {
smoothed->create_path_handle(path_handle_2_name_and_length[prec_path].first);

// Record the start and end of the path in the path_mapping
path_handle_2_start_and_end_in_path_mapping[prec_path] = std::make_pair(prec_i, i-1);

prec_path = current_path;
prec_i = i;
path_handle_2_start_and_end_in_path_mapping[prec_path] = std::make_pair(prec_i, path_mapping.size() - 1);
}
}
if (prec_i != path_mapping.size() - 1) {
smoothed->create_path_handle(path_handle_2_name_and_length[prec_path].first);
path_handle_2_start_and_end_in_path_mapping[prec_path] = std::make_pair(prec_i, path_mapping.size() - 1);
}

// then for each path, ensure that it's embedded in the graph by walking through
// its block segments in order and linking them up in the output graph
Expand Down

0 comments on commit eae76d3

Please sign in to comment.