From 88d04413ebaab961f849ac6ef3d6ff2179253d41 Mon Sep 17 00:00:00 2001 From: Gloria Mundi Date: Sat, 7 Jun 2025 21:20:34 +0200 Subject: make union find a struct, remove kruskal --- content/graph/cycleCounting.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'content/graph/cycleCounting.cpp') diff --git a/content/graph/cycleCounting.cpp b/content/graph/cycleCounting.cpp index deac71e..b7545d5 100644 --- a/content/graph/cycleCounting.cpp +++ b/content/graph/cycleCounting.cpp @@ -38,13 +38,11 @@ struct cycles { bool isCycle(cycle cur) {// cycle must be constructed from base if (cur.none()) return false; - init(ssize(adj)); // union find @\sourceref{datastructures/unionFind.cpp}@ + UnionFind uf(ssize(adj)); // union find @\sourceref{datastructures/unionFind.cpp}@ for (int i = 0; i < ssize(edges); i++) { if (cur[i]) { cur[i] = false; - if (findSet(edges[i].first) == - findSet(edges[i].second)) break; - unionSets(edges[i].first, edges[i].second); + if (!uf.link(edges[i].first, edges[i].second)) break; }} return cur.none(); } -- cgit v1.2.3