summaryrefslogtreecommitdiff
path: root/graph/maxCarBiMatch.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
commit98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch)
tree5113d5cc24d1ad5f93810b6442ce584a36950dc8 /graph/maxCarBiMatch.cpp
parentad3856a6b766087df0036de0b556f4700a6498c9 (diff)
parent8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff)
mzuenni tests
Diffstat (limited to 'graph/maxCarBiMatch.cpp')
-rw-r--r--graph/maxCarBiMatch.cpp25
1 files changed, 0 insertions, 25 deletions
diff --git a/graph/maxCarBiMatch.cpp b/graph/maxCarBiMatch.cpp
deleted file mode 100644
index e928387..0000000
--- a/graph/maxCarBiMatch.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-vector<vector<int>> adj;
-vector<int> pairs; // Der gematchte Knoten oder -1.
-vector<bool> visited;
-
-bool dfs(int v) {
- if (visited[v]) return false;
- visited[v] = true;
- for (int u : adj[v]) if (pairs[u] < 0 || dfs(pairs[u])) {
- pairs[u] = v; pairs[v] = u; return true;
- }
- return false;
-}
-
-int kuhn(int l) { // l = #Knoten links.
- pairs.assign(sz(adj), -1);
- int ans = 0;
- // Greedy Matching. Optionale Beschleunigung.
- for (int v = 0; v < l; v++) for (int u : adj[v])
- if (pairs[u] < 0) {pairs[u] = v; pairs[v] = u; ans++; break;}
- for (int v = 0; v < l; v++) if (pairs[v] < 0) {
- visited.assign(l, false);
- ans += dfs(v);
- }
- return ans; // Größe des Matchings.
-}