summaryrefslogtreecommitdiff
path: root/graph/maxCarBiMatch.cpp
diff options
context:
space:
mode:
authorPaul Jungeblut <paul.jungeblut@gmail.com>2015-12-03 01:12:26 +0100
committerPaul Jungeblut <paul.jungeblut@gmail.com>2015-12-03 01:12:26 +0100
commit53e7f12d828bb94c05d2b6c4e04d61de9482c426 (patch)
tree6621c2c8f537de6527a6e5354539081b79610399 /graph/maxCarBiMatch.cpp
parentb9e7427d720b489fa8d712a0ab6e8baa1dcca6be (diff)
Improving graoh chapter.
Diffstat (limited to 'graph/maxCarBiMatch.cpp')
-rw-r--r--graph/maxCarBiMatch.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/graph/maxCarBiMatch.cpp b/graph/maxCarBiMatch.cpp
index fb9cb3d..c086abc 100644
--- a/graph/maxCarBiMatch.cpp
+++ b/graph/maxCarBiMatch.cpp
@@ -1,5 +1,6 @@
-vector< vector<int> > adjlist; //seems to work directed, from left to right
-vector<int> pairs; //for every node, stores the matching node on the other side or -1
+// Laufzeit: O(n*(|V|+|E|))
+vector< vector<int> > adjlist; // Gerichtete Kanten, von links nach rechts.
+vector<int> pairs; // Zu jedem Knoten der gematchte Knoten rechts, oder -1.
vector<bool> visited;
bool dfs(int i) {
@@ -13,12 +14,13 @@ bool dfs(int i) {
return false;
}
-int kuhn(int n, int m) { // n = nodes on left side (numbered 0..n-1), m = nodes on the right side
+// n = #Knoten links (0..n-1), m = #Knoten rechts
+int kuhn(int n, int m) {
pairs.assign(n + m, -1);
int ans = 0;
for (int i = 0; i < n; i++) {
visited.assign(n + m, false);
ans += dfs(i);
}
- return ans; //size of the MCBM
+ return ans; // Größe des Matchings.
}