Skip to content

Commit eeb24af

Browse files
committed
speedup
1 parent b67c8fd commit eeb24af

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

library/graphs/strongly_connected_components/offline_incremental_scc.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ vi offline_incremental_scc(vector<array<int, 2>> eds,
1515
int m = sz(eds);
1616
vi ids(n, -1), joins(m, m), idx(m), vs(n), scc_id;
1717
iota(all(idx), 0);
18+
vector<vi> adj;
1819
auto divide_and_conquer = [&](auto&& self, auto el,
1920
auto er, int tl, int tr) {
2021
int mid = midpoint(tl, tr), p = 0;
21-
vector<vi> adj;
2222
for (auto it = el; it != er; it++) {
2323
auto& [u, v] = eds[*it];
2424
for (int w : {u, v}) {
@@ -32,6 +32,7 @@ vi offline_incremental_scc(vector<array<int, 2>> eds,
3232
}
3333
rep(i, 0, p) ids[vs[i]] = -1;
3434
scc_id = sccs(adj).scc_id;
35+
adj.clear();
3536
auto split = partition(el, er, [&](int i) {
3637
return scc_id[eds[i][0]] == scc_id[eds[i][1]];
3738
});
@@ -41,8 +42,6 @@ vi offline_incremental_scc(vector<array<int, 2>> eds,
4142
auto& [u, v] = eds[*it];
4243
u = scc_id[u], v = scc_id[v];
4344
}
44-
// deallocate to avoid O(m log m) memory
45-
vector<vi>().swap(adj);
4645
self(self, el, split, tl, mid);
4746
self(self, split, er, mid, tr);
4847
};

0 commit comments

Comments
 (0)