diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-06-07 21:20:34 +0200 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-06-07 21:20:34 +0200 |
| commit | 88d04413ebaab961f849ac6ef3d6ff2179253d41 (patch) | |
| tree | 075e5f245f160cf3d8a03f728a4ebe41e010c5df /content/graph/cycleCounting.cpp | |
| parent | f8f53c2f9e63f0ac89b67dc4d413ec9a76415a73 (diff) | |
make union find a struct, remove kruskal
Diffstat (limited to 'content/graph/cycleCounting.cpp')
| -rw-r--r-- | content/graph/cycleCounting.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
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(); } |
