diff options
| author | mzuenni <michi.zuendorf@gmail.com> | 2023-08-29 01:07:11 +0200 |
|---|---|---|
| committer | mzuenni <michi.zuendorf@gmail.com> | 2023-08-29 01:07:11 +0200 |
| commit | bc7a54f2a10ff3bb76cf4920be53000264bad279 (patch) | |
| tree | b19e51925e5aa067bf0aba866b9447ba31973adf /graph/cycleCounting.cpp | |
| parent | 4905811a7c635f28827984a999aedacd910f4dc3 (diff) | |
consistency
Diffstat (limited to 'graph/cycleCounting.cpp')
| -rw-r--r-- | graph/cycleCounting.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/graph/cycleCounting.cpp b/graph/cycleCounting.cpp index bf32874..9772706 100644 --- a/graph/cycleCounting.cpp +++ b/graph/cycleCounting.cpp @@ -8,10 +8,10 @@ struct cylces { cylces(int n) : adj(n), seen(n), paths(n) {} - void addEdge(int a, int b) { - adj[a].push_back({b, sz(edges)}); - adj[b].push_back({a, sz(edges)}); - edges.push_back({a, b}); + void addEdge(int u, int v) { + adj[u].push_back({v, sz(edges)}); + adj[v].push_back({u, sz(edges)}); + edges.push_back({u, v}); } void addBase(cycle cur) { @@ -22,17 +22,17 @@ struct cylces { if (cur.any()) base.push_back(cur); } - void findBase(int c = 0, int p = -1, cycle cur = {}) { + void findBase(int v = 0, int from = -1, cycle cur = {}) { if (adj.empty()) return; - if (seen[c]) { - addBase(cur ^ paths[c]); + if (seen[v]) { + addBase(cur ^ paths[v]); } else { - seen[c] = true; - paths[c] = cur; - for (auto [to, id] : adj[c]) { - if (to == p) continue; + seen[v] = true; + paths[v] = cur; + for (auto [u, id] : adj[v]) { + if (u == from) continue; cur[id].flip(); - findBase(to, c, cur); + findBase(u, v, cur); cur[id].flip(); }}} |
