diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-06-07 19:42:50 +0200 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-06-07 19:42:50 +0200 |
| commit | f8f53c2f9e63f0ac89b67dc4d413ec9a76415a73 (patch) | |
| tree | 7210642adde99db427b3da70c0f3f41355eb71f4 /content/graph | |
| parent | e65975ec92509abbf0078673b7a8495bfc47a245 (diff) | |
adapt Tutte matching to new Gauss, and remove some global variables
Diffstat (limited to 'content/graph')
| -rw-r--r-- | content/graph/matching.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/content/graph/matching.cpp b/content/graph/matching.cpp index 3619d7c..f0f34a3 100644 --- a/content/graph/matching.cpp +++ b/content/graph/matching.cpp @@ -1,22 +1,17 @@ -constexpr int MOD=1'000'000'007, I=10; -vector<vector<ll>> adj, mat; +constexpr int mod = 1'000'000'007, I = 10; -int max_matching() { +int max_matching(const vector<vector<int>> &adj) { int ans = 0; - mat.assign(ssize(adj), {}); + vector<vector<ll>> mat(ssize(adj)); for (int _ = 0; _ < I; _++) { for (int v = 0; v < ssize(adj); v++) { mat[v].assign(ssize(adj), 0); for (int u : adj[v]) { if (u < v) { - mat[v][u] = rand() % (MOD - 1) + 1; - mat[u][v] = MOD - mat[v][u]; + mat[v][u] = rand() % (mod - 1) + 1; + mat[u][v] = mod - mat[v][u]; }}} - gauss(ssize(adj), MOD); //LGS @\sourceref{math/lgsFp.cpp}@ - int rank = 0; - for (auto& row : mat) { - if (*ranges::max_element(row) != 0) rank++; - } + int rank = ssize(gauss(mat)); // LGS @\sourceref{math/lgsFp.cpp}@ ans = max(ans, rank / 2); } return ans; |
