From f8f53c2f9e63f0ac89b67dc4d413ec9a76415a73 Mon Sep 17 00:00:00 2001 From: Gloria Mundi Date: Sat, 7 Jun 2025 19:42:50 +0200 Subject: adapt Tutte matching to new Gauss, and remove some global variables --- content/graph/matching.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'content/graph/matching.cpp') 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> adj, mat; +constexpr int mod = 1'000'000'007, I = 10; -int max_matching() { +int max_matching(const vector> &adj) { int ans = 0; - mat.assign(ssize(adj), {}); + vector> 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; -- cgit v1.2.3