summaryrefslogtreecommitdiff
path: root/graph/maxCarBiMatch.cpp
diff options
context:
space:
mode:
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.
-}