summaryrefslogtreecommitdiff
path: root/test/graph/cycleCounting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/graph/cycleCounting.cpp')
-rw-r--r--test/graph/cycleCounting.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/test/graph/cycleCounting.cpp b/test/graph/cycleCounting.cpp
index 8e53aec..82caf16 100644
--- a/test/graph/cycleCounting.cpp
+++ b/test/graph/cycleCounting.cpp
@@ -4,20 +4,16 @@
int naive(const vector<pair<int, int>>& edges, int n) {
int res = 0;
- for (int i = 1; i < (1ll << sz(edges)); i++) {
+ for (int i = 1; i < (1ll << ssize(edges)); i++) {
vector<int> deg(n);
- init(n);
+ UnionFind uf(n);
int cycles = 0;
- for (int j = 0; j < sz(edges); j++) {
+ for (int j = 0; j < ssize(edges); j++) {
if (((i >> j) & 1) != 0) {
auto [a, b] = edges[j];
deg[a]++;
deg[b]++;
- if (findSet(a) != findSet(b)) {
- unionSets(a, b);
- } else {
- cycles++;
- }
+ if (!uf.link(a, b)) cycles++;
}
}
bool ok = cycles == 1;
@@ -66,7 +62,7 @@ void performance_test() {
t.start();
hash_t hash = cyc.count();
- cerr << sz(cyc.base) << endl;
+ cerr << ssize(cyc.base) << endl;
t.stop();
if (t.time > 1000) cerr << "too slow: " << t.time << FAIL;