Skip to content

Commit

Permalink
some small optimisations for weakly connected components
Browse files Browse the repository at this point in the history
  • Loading branch information
arashbm committed Nov 15, 2024
1 parent 214828a commit a349e87
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/algorithms.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,14 @@ namespace reticula {
for (std::size_t i = 0; auto& v: verts)
vert_idx.emplace(v, i++);

for (auto e: net.edges())
for (auto v1: e.mutator_verts())
for (auto v2: e.mutated_verts())
for (auto e: net.edges()) {
auto mutator_verts = e.mutator_verts();
auto mutated_verts = e.mutated_verts();
for (auto v1: mutator_verts)
for (auto v2: mutated_verts)
if (!is_undirected_v<EdgeT> || v1 < v2)
disj_set.merge(vert_idx.at(v1), vert_idx.at(v2));
disj_set.merge(vert_idx[v1], vert_idx[v2]);
}

auto sets = disj_set.sets(singletons);
std::vector<component<typename EdgeT::VertexType>> comp_vector;
Expand Down

0 comments on commit a349e87

Please sign in to comment.