Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt	(revision 549)
+++ test/CMakeLists.txt	(revision 594)
@@ -30,5 +30,5 @@
   kruskal_test
   maps_test
-  max_matching_test
+  matching_test
   min_cost_arborescence_test
   path_test
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 564)
+++ test/Makefile.am	(revision 594)
@@ -26,5 +26,5 @@
 	test/kruskal_test \
 	test/maps_test \
-	test/max_matching_test \
+	test/matching_test \
 	test/min_cost_arborescence_test \
 	test/path_test \
@@ -71,5 +71,5 @@
 test_maps_test_SOURCES = test/maps_test.cc
 test_mip_test_SOURCES = test/mip_test.cc
-test_max_matching_test_SOURCES = test/max_matching_test.cc
+test_matching_test_SOURCES = test/matching_test.cc
 test_min_cost_arborescence_test_SOURCES = test/min_cost_arborescence_test.cc
 test_path_test_SOURCES = test/path_test.cc
Index: test/euler_test.cc
===================================================================
--- test/euler_test.cc	(revision 531)
+++ test/euler_test.cc	(revision 592)
@@ -19,61 +19,64 @@
 #include <lemon/euler.h>
 #include <lemon/list_graph.h>
-#include <test/test_tools.h>
+#include <lemon/adaptors.h>
+#include "test_tools.h"
 
 using namespace lemon;
 
 template <typename Digraph>
-void checkDiEulerIt(const Digraph& g)
+void checkDiEulerIt(const Digraph& g,
+                    const typename Digraph::Node& start = INVALID)
 {
   typename Digraph::template ArcMap<int> visitationNumber(g, 0);
 
-  DiEulerIt<Digraph> e(g);
+  DiEulerIt<Digraph> e(g, start);
+  if (e == INVALID) return;
   typename Digraph::Node firstNode = g.source(e);
   typename Digraph::Node lastNode = g.target(e);
-
-  for (; e != INVALID; ++e)
-  {
-    if (e != INVALID)
-    {
-      lastNode = g.target(e);
-    }
+  if (start != INVALID) {
+    check(firstNode == start, "checkDiEulerIt: Wrong first node");
+  }
+
+  for (; e != INVALID; ++e) {
+    if (e != INVALID) lastNode = g.target(e);
     ++visitationNumber[e];
   }
 
   check(firstNode == lastNode,
-      "checkDiEulerIt: first and last node are not the same");
+      "checkDiEulerIt: First and last nodes are not the same");
 
   for (typename Digraph::ArcIt a(g); a != INVALID; ++a)
   {
     check(visitationNumber[a] == 1,
-        "checkDiEulerIt: not visited or multiple times visited arc found");
+        "checkDiEulerIt: Not visited or multiple times visited arc found");
   }
 }
 
 template <typename Graph>
-void checkEulerIt(const Graph& g)
+void checkEulerIt(const Graph& g,
+                  const typename Graph::Node& start = INVALID)
 {
   typename Graph::template EdgeMap<int> visitationNumber(g, 0);
 
-  EulerIt<Graph> e(g);
-  typename Graph::Node firstNode = g.u(e);
-  typename Graph::Node lastNode = g.v(e);
-
-  for (; e != INVALID; ++e)
-  {
-    if (e != INVALID)
-    {
-      lastNode = g.v(e);
-    }
+  EulerIt<Graph> e(g, start);
+  if (e == INVALID) return;
+  typename Graph::Node firstNode = g.source(typename Graph::Arc(e));
+  typename Graph::Node lastNode = g.target(typename Graph::Arc(e));
+  if (start != INVALID) {
+    check(firstNode == start, "checkEulerIt: Wrong first node");
+  }
+
+  for (; e != INVALID; ++e) {
+    if (e != INVALID) lastNode = g.target(typename Graph::Arc(e));
     ++visitationNumber[e];
   }
 
   check(firstNode == lastNode,
-      "checkEulerIt: first and last node are not the same");
+      "checkEulerIt: First and last nodes are not the same");
 
   for (typename Graph::EdgeIt e(g); e != INVALID; ++e)
   {
     check(visitationNumber[e] == 1,
-        "checkEulerIt: not visited or multiple times visited edge found");
+        "checkEulerIt: Not visited or multiple times visited edge found");
   }
 }
@@ -82,71 +85,138 @@
 {
   typedef ListDigraph Digraph;
-  typedef ListGraph Graph;
-
-  Digraph digraphWithEulerianCircuit;
-  {
-    Digraph& g = digraphWithEulerianCircuit;
-
-    Digraph::Node n0 = g.addNode();
-    Digraph::Node n1 = g.addNode();
-    Digraph::Node n2 = g.addNode();
-
-    g.addArc(n0, n1);
-    g.addArc(n1, n0);
-    g.addArc(n1, n2);
-    g.addArc(n2, n1);
-  }
-
-  Digraph digraphWithoutEulerianCircuit;
-  {
-    Digraph& g = digraphWithoutEulerianCircuit;
-
-    Digraph::Node n0 = g.addNode();
-    Digraph::Node n1 = g.addNode();
-    Digraph::Node n2 = g.addNode();
-
-    g.addArc(n0, n1);
-    g.addArc(n1, n0);
-    g.addArc(n1, n2);
-  }
-
-  Graph graphWithEulerianCircuit;
-  {
-    Graph& g = graphWithEulerianCircuit;
-
-    Graph::Node n0 = g.addNode();
-    Graph::Node n1 = g.addNode();
-    Graph::Node n2 = g.addNode();
-
-    g.addEdge(n0, n1);
-    g.addEdge(n1, n2);
-    g.addEdge(n2, n0);
-  }
-
-  Graph graphWithoutEulerianCircuit;
-  {
-    Graph& g = graphWithoutEulerianCircuit;
-
-    Graph::Node n0 = g.addNode();
-    Graph::Node n1 = g.addNode();
-    Graph::Node n2 = g.addNode();
-
-    g.addEdge(n0, n1);
-    g.addEdge(n1, n2);
-  }
-
-  checkDiEulerIt(digraphWithEulerianCircuit);
-
-  checkEulerIt(graphWithEulerianCircuit);
-
-  check(eulerian(digraphWithEulerianCircuit),
-      "this graph should have an Eulerian circuit");
-  check(!eulerian(digraphWithoutEulerianCircuit),
-      "this graph should not have an Eulerian circuit");
-
-  check(eulerian(graphWithEulerianCircuit),
-      "this graph should have an Eulerian circuit");
-  check(!eulerian(graphWithoutEulerianCircuit),
-      "this graph should have an Eulerian circuit");
+  typedef Undirector<Digraph> Graph;
+  
+  {
+    Digraph d;
+    Graph g(d);
+    
+    checkDiEulerIt(d);
+    checkDiEulerIt(g);
+    checkEulerIt(g);
+
+    check(eulerian(d), "This graph is Eulerian");
+    check(eulerian(g), "This graph is Eulerian");
+  }
+  {
+    Digraph d;
+    Graph g(d);
+    Digraph::Node n = d.addNode();
+
+    checkDiEulerIt(d);
+    checkDiEulerIt(g);
+    checkEulerIt(g);
+
+    check(eulerian(d), "This graph is Eulerian");
+    check(eulerian(g), "This graph is Eulerian");
+  }
+  {
+    Digraph d;
+    Graph g(d);
+    Digraph::Node n = d.addNode();
+    d.addArc(n, n);
+
+    checkDiEulerIt(d);
+    checkDiEulerIt(g);
+    checkEulerIt(g);
+
+    check(eulerian(d), "This graph is Eulerian");
+    check(eulerian(g), "This graph is Eulerian");
+  }
+  {
+    Digraph d;
+    Graph g(d);
+    Digraph::Node n1 = d.addNode();
+    Digraph::Node n2 = d.addNode();
+    Digraph::Node n3 = d.addNode();
+    
+    d.addArc(n1, n2);
+    d.addArc(n2, n1);
+    d.addArc(n2, n3);
+    d.addArc(n3, n2);
+
+    checkDiEulerIt(d);
+    checkDiEulerIt(d, n2);
+    checkDiEulerIt(g);
+    checkDiEulerIt(g, n2);
+    checkEulerIt(g);
+    checkEulerIt(g, n2);
+
+    check(eulerian(d), "This graph is Eulerian");
+    check(eulerian(g), "This graph is Eulerian");
+  }
+  {
+    Digraph d;
+    Graph g(d);
+    Digraph::Node n1 = d.addNode();
+    Digraph::Node n2 = d.addNode();
+    Digraph::Node n3 = d.addNode();
+    Digraph::Node n4 = d.addNode();
+    Digraph::Node n5 = d.addNode();
+    Digraph::Node n6 = d.addNode();
+    
+    d.addArc(n1, n2);
+    d.addArc(n2, n4);
+    d.addArc(n1, n3);
+    d.addArc(n3, n4);
+    d.addArc(n4, n1);
+    d.addArc(n3, n5);
+    d.addArc(n5, n2);
+    d.addArc(n4, n6);
+    d.addArc(n2, n6);
+    d.addArc(n6, n1);
+    d.addArc(n6, n3);
+
+    checkDiEulerIt(d);
+    checkDiEulerIt(d, n1);
+    checkDiEulerIt(d, n5);
+
+    checkDiEulerIt(g);
+    checkDiEulerIt(g, n1);
+    checkDiEulerIt(g, n5);
+    checkEulerIt(g);
+    checkEulerIt(g, n1);
+    checkEulerIt(g, n5);
+
+    check(eulerian(d), "This graph is Eulerian");
+    check(eulerian(g), "This graph is Eulerian");
+  }
+  {
+    Digraph d;
+    Graph g(d);
+    Digraph::Node n0 = d.addNode();
+    Digraph::Node n1 = d.addNode();
+    Digraph::Node n2 = d.addNode();
+    Digraph::Node n3 = d.addNode();
+    Digraph::Node n4 = d.addNode();
+    Digraph::Node n5 = d.addNode();
+    
+    d.addArc(n1, n2);
+    d.addArc(n2, n3);
+    d.addArc(n3, n1);
+
+    checkDiEulerIt(d);
+    checkDiEulerIt(d, n2);
+
+    checkDiEulerIt(g);
+    checkDiEulerIt(g, n2);
+    checkEulerIt(g);
+    checkEulerIt(g, n2);
+
+    check(!eulerian(d), "This graph is not Eulerian");
+    check(!eulerian(g), "This graph is not Eulerian");
+  }
+  {
+    Digraph d;
+    Graph g(d);
+    Digraph::Node n1 = d.addNode();
+    Digraph::Node n2 = d.addNode();
+    Digraph::Node n3 = d.addNode();
+    
+    d.addArc(n1, n2);
+    d.addArc(n2, n3);
+
+    check(!eulerian(d), "This graph is not Eulerian");
+    check(!eulerian(g), "This graph is not Eulerian");
+  }
 
   return 0;
Index: test/matching_test.cc
===================================================================
--- test/matching_test.cc	(revision 594)
+++ test/matching_test.cc	(revision 594)
@@ -0,0 +1,424 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2009
+ * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Research Group on Combinatorial Optimization, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <queue>
+#include <cstdlib>
+
+#include <lemon/matching.h>
+#include <lemon/smart_graph.h>
+#include <lemon/concepts/graph.h>
+#include <lemon/concepts/maps.h>
+#include <lemon/lgf_reader.h>
+#include <lemon/math.h>
+
+#include "test_tools.h"
+
+using namespace std;
+using namespace lemon;
+
+GRAPH_TYPEDEFS(SmartGraph);
+
+
+const int lgfn = 3;
+const std::string lgf[lgfn] = {
+  "@nodes\n"
+  "label\n"
+  "0\n"
+  "1\n"
+  "2\n"
+  "3\n"
+  "4\n"
+  "5\n"
+  "6\n"
+  "7\n"
+  "@edges\n"
+  "     label  weight\n"
+  "7 4  0      984\n"
+  "0 7  1      73\n"
+  "7 1  2      204\n"
+  "2 3  3      583\n"
+  "2 7  4      565\n"
+  "2 1  5      582\n"
+  "0 4  6      551\n"
+  "2 5  7      385\n"
+  "1 5  8      561\n"
+  "5 3  9      484\n"
+  "7 5  10     904\n"
+  "3 6  11     47\n"
+  "7 6  12     888\n"
+  "3 0  13     747\n"
+  "6 1  14     310\n",
+
+  "@nodes\n"
+  "label\n"
+  "0\n"
+  "1\n"
+  "2\n"
+  "3\n"
+  "4\n"
+  "5\n"
+  "6\n"
+  "7\n"
+  "@edges\n"
+  "     label  weight\n"
+  "2 5  0      710\n"
+  "0 5  1      241\n"
+  "2 4  2      856\n"
+  "2 6  3      762\n"
+  "4 1  4      747\n"
+  "6 1  5      962\n"
+  "4 7  6      723\n"
+  "1 7  7      661\n"
+  "2 3  8      376\n"
+  "1 0  9      416\n"
+  "6 7  10     391\n",
+
+  "@nodes\n"
+  "label\n"
+  "0\n"
+  "1\n"
+  "2\n"
+  "3\n"
+  "4\n"
+  "5\n"
+  "6\n"
+  "7\n"
+  "@edges\n"
+  "     label  weight\n"
+  "6 2  0      553\n"
+  "0 7  1      653\n"
+  "6 3  2      22\n"
+  "4 7  3      846\n"
+  "7 2  4      981\n"
+  "7 6  5      250\n"
+  "5 2  6      539\n",
+};
+
+void checkMaxMatchingCompile()
+{
+  typedef concepts::Graph Graph;
+  typedef Graph::Node Node;
+  typedef Graph::Edge Edge;
+  typedef Graph::EdgeMap<bool> MatMap;
+
+  Graph g;
+  Node n;
+  Edge e;
+  MatMap mat(g);
+
+  MaxMatching<Graph> mat_test(g);
+  const MaxMatching<Graph>&
+    const_mat_test = mat_test;
+
+  mat_test.init();
+  mat_test.greedyInit();
+  mat_test.matchingInit(mat);
+  mat_test.startSparse();
+  mat_test.startDense();
+  mat_test.run();
+  
+  const_mat_test.matchingSize();
+  const_mat_test.matching(e);
+  const_mat_test.matching(n);
+  const MaxMatching<Graph>::MatchingMap& mmap =
+    const_mat_test.matchingMap();
+  e = mmap[n];
+  const_mat_test.mate(n);
+
+  MaxMatching<Graph>::Status stat = 
+    const_mat_test.status(n);
+  const MaxMatching<Graph>::StatusMap& smap =
+    const_mat_test.statusMap();
+  stat = smap[n];
+  const_mat_test.barrier(n);
+}
+
+void checkMaxWeightedMatchingCompile()
+{
+  typedef concepts::Graph Graph;
+  typedef Graph::Node Node;
+  typedef Graph::Edge Edge;
+  typedef Graph::EdgeMap<int> WeightMap;
+
+  Graph g;
+  Node n;
+  Edge e;
+  WeightMap w(g);
+
+  MaxWeightedMatching<Graph> mat_test(g, w);
+  const MaxWeightedMatching<Graph>&
+    const_mat_test = mat_test;
+
+  mat_test.init();
+  mat_test.start();
+  mat_test.run();
+  
+  const_mat_test.matchingWeight();
+  const_mat_test.matchingSize();
+  const_mat_test.matching(e);
+  const_mat_test.matching(n);
+  const MaxWeightedMatching<Graph>::MatchingMap& mmap =
+    const_mat_test.matchingMap();
+  e = mmap[n];
+  const_mat_test.mate(n);
+  
+  int k = 0;
+  const_mat_test.dualValue();
+  const_mat_test.nodeValue(n);
+  const_mat_test.blossomNum();
+  const_mat_test.blossomSize(k);
+  const_mat_test.blossomValue(k);
+}
+
+void checkMaxWeightedPerfectMatchingCompile()
+{
+  typedef concepts::Graph Graph;
+  typedef Graph::Node Node;
+  typedef Graph::Edge Edge;
+  typedef Graph::EdgeMap<int> WeightMap;
+
+  Graph g;
+  Node n;
+  Edge e;
+  WeightMap w(g);
+
+  MaxWeightedPerfectMatching<Graph> mat_test(g, w);
+  const MaxWeightedPerfectMatching<Graph>&
+    const_mat_test = mat_test;
+
+  mat_test.init();
+  mat_test.start();
+  mat_test.run();
+  
+  const_mat_test.matchingWeight();
+  const_mat_test.matching(e);
+  const_mat_test.matching(n);
+  const MaxWeightedPerfectMatching<Graph>::MatchingMap& mmap =
+    const_mat_test.matchingMap();
+  e = mmap[n];
+  const_mat_test.mate(n);
+  
+  int k = 0;
+  const_mat_test.dualValue();
+  const_mat_test.nodeValue(n);
+  const_mat_test.blossomNum();
+  const_mat_test.blossomSize(k);
+  const_mat_test.blossomValue(k);
+}
+
+void checkMatching(const SmartGraph& graph,
+                   const MaxMatching<SmartGraph>& mm) {
+  int num = 0;
+
+  IntNodeMap comp_index(graph);
+  UnionFind<IntNodeMap> comp(comp_index);
+
+  int barrier_num = 0;
+
+  for (NodeIt n(graph); n != INVALID; ++n) {
+    check(mm.status(n) == MaxMatching<SmartGraph>::EVEN ||
+          mm.matching(n) != INVALID, "Wrong Gallai-Edmonds decomposition");
+    if (mm.status(n) == MaxMatching<SmartGraph>::ODD) {
+      ++barrier_num;
+    } else {
+      comp.insert(n);
+    }
+  }
+
+  for (EdgeIt e(graph); e != INVALID; ++e) {
+    if (mm.matching(e)) {
+      check(e == mm.matching(graph.u(e)), "Wrong matching");
+      check(e == mm.matching(graph.v(e)), "Wrong matching");
+      ++num;
+    }
+    check(mm.status(graph.u(e)) != MaxMatching<SmartGraph>::EVEN ||
+          mm.status(graph.v(e)) != MaxMatching<SmartGraph>::MATCHED,
+          "Wrong Gallai-Edmonds decomposition");
+
+    check(mm.status(graph.v(e)) != MaxMatching<SmartGraph>::EVEN ||
+          mm.status(graph.u(e)) != MaxMatching<SmartGraph>::MATCHED,
+          "Wrong Gallai-Edmonds decomposition");
+
+    if (mm.status(graph.u(e)) != MaxMatching<SmartGraph>::ODD &&
+        mm.status(graph.v(e)) != MaxMatching<SmartGraph>::ODD) {
+      comp.join(graph.u(e), graph.v(e));
+    }
+  }
+
+  std::set<int> comp_root;
+  int odd_comp_num = 0;
+  for (NodeIt n(graph); n != INVALID; ++n) {
+    if (mm.status(n) != MaxMatching<SmartGraph>::ODD) {
+      int root = comp.find(n);
+      if (comp_root.find(root) == comp_root.end()) {
+        comp_root.insert(root);
+        if (comp.size(n) % 2 == 1) {
+          ++odd_comp_num;
+        }
+      }
+    }
+  }
+
+  check(mm.matchingSize() == num, "Wrong matching");
+  check(2 * num == countNodes(graph) - (odd_comp_num - barrier_num),
+         "Wrong matching");
+  return;
+}
+
+void checkWeightedMatching(const SmartGraph& graph,
+                   const SmartGraph::EdgeMap<int>& weight,
+                   const MaxWeightedMatching<SmartGraph>& mwm) {
+  for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
+    if (graph.u(e) == graph.v(e)) continue;
+    int rw = mwm.nodeValue(graph.u(e)) + mwm.nodeValue(graph.v(e));
+
+    for (int i = 0; i < mwm.blossomNum(); ++i) {
+      bool s = false, t = false;
+      for (MaxWeightedMatching<SmartGraph>::BlossomIt n(mwm, i);
+           n != INVALID; ++n) {
+        if (graph.u(e) == n) s = true;
+        if (graph.v(e) == n) t = true;
+      }
+      if (s == true && t == true) {
+        rw += mwm.blossomValue(i);
+      }
+    }
+    rw -= weight[e] * mwm.dualScale;
+
+    check(rw >= 0, "Negative reduced weight");
+    check(rw == 0 || !mwm.matching(e),
+          "Non-zero reduced weight on matching edge");
+  }
+
+  int pv = 0;
+  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
+    if (mwm.matching(n) != INVALID) {
+      check(mwm.nodeValue(n) >= 0, "Invalid node value");
+      pv += weight[mwm.matching(n)];
+      SmartGraph::Node o = graph.target(mwm.matching(n));
+      check(mwm.mate(n) == o, "Invalid matching");
+      check(mwm.matching(n) == graph.oppositeArc(mwm.matching(o)),
+            "Invalid matching");
+    } else {
+      check(mwm.mate(n) == INVALID, "Invalid matching");
+      check(mwm.nodeValue(n) == 0, "Invalid matching");
+    }
+  }
+
+  int dv = 0;
+  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
+    dv += mwm.nodeValue(n);
+  }
+
+  for (int i = 0; i < mwm.blossomNum(); ++i) {
+    check(mwm.blossomValue(i) >= 0, "Invalid blossom value");
+    check(mwm.blossomSize(i) % 2 == 1, "Even blossom size");
+    dv += mwm.blossomValue(i) * ((mwm.blossomSize(i) - 1) / 2);
+  }
+
+  check(pv * mwm.dualScale == dv * 2, "Wrong duality");
+
+  return;
+}
+
+void checkWeightedPerfectMatching(const SmartGraph& graph,
+                          const SmartGraph::EdgeMap<int>& weight,
+                          const MaxWeightedPerfectMatching<SmartGraph>& mwpm) {
+  for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
+    if (graph.u(e) == graph.v(e)) continue;
+    int rw = mwpm.nodeValue(graph.u(e)) + mwpm.nodeValue(graph.v(e));
+
+    for (int i = 0; i < mwpm.blossomNum(); ++i) {
+      bool s = false, t = false;
+      for (MaxWeightedPerfectMatching<SmartGraph>::BlossomIt n(mwpm, i);
+           n != INVALID; ++n) {
+        if (graph.u(e) == n) s = true;
+        if (graph.v(e) == n) t = true;
+      }
+      if (s == true && t == true) {
+        rw += mwpm.blossomValue(i);
+      }
+    }
+    rw -= weight[e] * mwpm.dualScale;
+
+    check(rw >= 0, "Negative reduced weight");
+    check(rw == 0 || !mwpm.matching(e),
+          "Non-zero reduced weight on matching edge");
+  }
+
+  int pv = 0;
+  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
+    check(mwpm.matching(n) != INVALID, "Non perfect");
+    pv += weight[mwpm.matching(n)];
+    SmartGraph::Node o = graph.target(mwpm.matching(n));
+    check(mwpm.mate(n) == o, "Invalid matching");
+    check(mwpm.matching(n) == graph.oppositeArc(mwpm.matching(o)),
+          "Invalid matching");
+  }
+
+  int dv = 0;
+  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
+    dv += mwpm.nodeValue(n);
+  }
+
+  for (int i = 0; i < mwpm.blossomNum(); ++i) {
+    check(mwpm.blossomValue(i) >= 0, "Invalid blossom value");
+    check(mwpm.blossomSize(i) % 2 == 1, "Even blossom size");
+    dv += mwpm.blossomValue(i) * ((mwpm.blossomSize(i) - 1) / 2);
+  }
+
+  check(pv * mwpm.dualScale == dv * 2, "Wrong duality");
+
+  return;
+}
+
+
+int main() {
+
+  for (int i = 0; i < lgfn; ++i) {
+    SmartGraph graph;
+    SmartGraph::EdgeMap<int> weight(graph);
+
+    istringstream lgfs(lgf[i]);
+    graphReader(graph, lgfs).
+      edgeMap("weight", weight).run();
+
+    MaxMatching<SmartGraph> mm(graph);
+    mm.run();
+    checkMatching(graph, mm);
+
+    MaxWeightedMatching<SmartGraph> mwm(graph, weight);
+    mwm.run();
+    checkWeightedMatching(graph, weight, mwm);
+
+    MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight);
+    bool perfect = mwpm.run();
+
+    check(perfect == (mm.matchingSize() * 2 == countNodes(graph)),
+          "Perfect matching found");
+
+    if (perfect) {
+      checkWeightedPerfectMatching(graph, weight, mwpm);
+    }
+  }
+
+  return 0;
+}
Index: test/max_matching_test.cc
===================================================================
--- test/max_matching_test.cc	(revision 593)
+++ 	(revision )
@@ -1,424 +1,0 @@
-/* -*- mode: C++; indent-tabs-mode: nil; -*-
- *
- * This file is a part of LEMON, a generic C++ optimization library.
- *
- * Copyright (C) 2003-2009
- * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
- * (Egervary Research Group on Combinatorial Optimization, EGRES).
- *
- * Permission to use, modify and distribute this software is granted
- * provided that this copyright notice appears in all copies. For
- * precise terms see the accompanying LICENSE file.
- *
- * This software is provided "AS IS" with no warranty of any kind,
- * express or implied, and with no claim as to its suitability for any
- * purpose.
- *
- */
-
-#include <iostream>
-#include <sstream>
-#include <vector>
-#include <queue>
-#include <cstdlib>
-
-#include <lemon/max_matching.h>
-#include <lemon/smart_graph.h>
-#include <lemon/concepts/graph.h>
-#include <lemon/concepts/maps.h>
-#include <lemon/lgf_reader.h>
-#include <lemon/math.h>
-
-#include "test_tools.h"
-
-using namespace std;
-using namespace lemon;
-
-GRAPH_TYPEDEFS(SmartGraph);
-
-
-const int lgfn = 3;
-const std::string lgf[lgfn] = {
-  "@nodes\n"
-  "label\n"
-  "0\n"
-  "1\n"
-  "2\n"
-  "3\n"
-  "4\n"
-  "5\n"
-  "6\n"
-  "7\n"
-  "@edges\n"
-  "     label  weight\n"
-  "7 4  0      984\n"
-  "0 7  1      73\n"
-  "7 1  2      204\n"
-  "2 3  3      583\n"
-  "2 7  4      565\n"
-  "2 1  5      582\n"
-  "0 4  6      551\n"
-  "2 5  7      385\n"
-  "1 5  8      561\n"
-  "5 3  9      484\n"
-  "7 5  10     904\n"
-  "3 6  11     47\n"
-  "7 6  12     888\n"
-  "3 0  13     747\n"
-  "6 1  14     310\n",
-
-  "@nodes\n"
-  "label\n"
-  "0\n"
-  "1\n"
-  "2\n"
-  "3\n"
-  "4\n"
-  "5\n"
-  "6\n"
-  "7\n"
-  "@edges\n"
-  "     label  weight\n"
-  "2 5  0      710\n"
-  "0 5  1      241\n"
-  "2 4  2      856\n"
-  "2 6  3      762\n"
-  "4 1  4      747\n"
-  "6 1  5      962\n"
-  "4 7  6      723\n"
-  "1 7  7      661\n"
-  "2 3  8      376\n"
-  "1 0  9      416\n"
-  "6 7  10     391\n",
-
-  "@nodes\n"
-  "label\n"
-  "0\n"
-  "1\n"
-  "2\n"
-  "3\n"
-  "4\n"
-  "5\n"
-  "6\n"
-  "7\n"
-  "@edges\n"
-  "     label  weight\n"
-  "6 2  0      553\n"
-  "0 7  1      653\n"
-  "6 3  2      22\n"
-  "4 7  3      846\n"
-  "7 2  4      981\n"
-  "7 6  5      250\n"
-  "5 2  6      539\n",
-};
-
-void checkMaxMatchingCompile()
-{
-  typedef concepts::Graph Graph;
-  typedef Graph::Node Node;
-  typedef Graph::Edge Edge;
-  typedef Graph::EdgeMap<bool> MatMap;
-
-  Graph g;
-  Node n;
-  Edge e;
-  MatMap mat(g);
-
-  MaxMatching<Graph> mat_test(g);
-  const MaxMatching<Graph>&
-    const_mat_test = mat_test;
-
-  mat_test.init();
-  mat_test.greedyInit();
-  mat_test.matchingInit(mat);
-  mat_test.startSparse();
-  mat_test.startDense();
-  mat_test.run();
-  
-  const_mat_test.matchingSize();
-  const_mat_test.matching(e);
-  const_mat_test.matching(n);
-  const MaxMatching<Graph>::MatchingMap& mmap =
-    const_mat_test.matchingMap();
-  e = mmap[n];
-  const_mat_test.mate(n);
-
-  MaxMatching<Graph>::Status stat = 
-    const_mat_test.status(n);
-  const MaxMatching<Graph>::StatusMap& smap =
-    const_mat_test.statusMap();
-  stat = smap[n];
-  const_mat_test.barrier(n);
-}
-
-void checkMaxWeightedMatchingCompile()
-{
-  typedef concepts::Graph Graph;
-  typedef Graph::Node Node;
-  typedef Graph::Edge Edge;
-  typedef Graph::EdgeMap<int> WeightMap;
-
-  Graph g;
-  Node n;
-  Edge e;
-  WeightMap w(g);
-
-  MaxWeightedMatching<Graph> mat_test(g, w);
-  const MaxWeightedMatching<Graph>&
-    const_mat_test = mat_test;
-
-  mat_test.init();
-  mat_test.start();
-  mat_test.run();
-  
-  const_mat_test.matchingWeight();
-  const_mat_test.matchingSize();
-  const_mat_test.matching(e);
-  const_mat_test.matching(n);
-  const MaxWeightedMatching<Graph>::MatchingMap& mmap =
-    const_mat_test.matchingMap();
-  e = mmap[n];
-  const_mat_test.mate(n);
-  
-  int k = 0;
-  const_mat_test.dualValue();
-  const_mat_test.nodeValue(n);
-  const_mat_test.blossomNum();
-  const_mat_test.blossomSize(k);
-  const_mat_test.blossomValue(k);
-}
-
-void checkMaxWeightedPerfectMatchingCompile()
-{
-  typedef concepts::Graph Graph;
-  typedef Graph::Node Node;
-  typedef Graph::Edge Edge;
-  typedef Graph::EdgeMap<int> WeightMap;
-
-  Graph g;
-  Node n;
-  Edge e;
-  WeightMap w(g);
-
-  MaxWeightedPerfectMatching<Graph> mat_test(g, w);
-  const MaxWeightedPerfectMatching<Graph>&
-    const_mat_test = mat_test;
-
-  mat_test.init();
-  mat_test.start();
-  mat_test.run();
-  
-  const_mat_test.matchingWeight();
-  const_mat_test.matching(e);
-  const_mat_test.matching(n);
-  const MaxWeightedPerfectMatching<Graph>::MatchingMap& mmap =
-    const_mat_test.matchingMap();
-  e = mmap[n];
-  const_mat_test.mate(n);
-  
-  int k = 0;
-  const_mat_test.dualValue();
-  const_mat_test.nodeValue(n);
-  const_mat_test.blossomNum();
-  const_mat_test.blossomSize(k);
-  const_mat_test.blossomValue(k);
-}
-
-void checkMatching(const SmartGraph& graph,
-                   const MaxMatching<SmartGraph>& mm) {
-  int num = 0;
-
-  IntNodeMap comp_index(graph);
-  UnionFind<IntNodeMap> comp(comp_index);
-
-  int barrier_num = 0;
-
-  for (NodeIt n(graph); n != INVALID; ++n) {
-    check(mm.status(n) == MaxMatching<SmartGraph>::EVEN ||
-          mm.matching(n) != INVALID, "Wrong Gallai-Edmonds decomposition");
-    if (mm.status(n) == MaxMatching<SmartGraph>::ODD) {
-      ++barrier_num;
-    } else {
-      comp.insert(n);
-    }
-  }
-
-  for (EdgeIt e(graph); e != INVALID; ++e) {
-    if (mm.matching(e)) {
-      check(e == mm.matching(graph.u(e)), "Wrong matching");
-      check(e == mm.matching(graph.v(e)), "Wrong matching");
-      ++num;
-    }
-    check(mm.status(graph.u(e)) != MaxMatching<SmartGraph>::EVEN ||
-          mm.status(graph.v(e)) != MaxMatching<SmartGraph>::MATCHED,
-          "Wrong Gallai-Edmonds decomposition");
-
-    check(mm.status(graph.v(e)) != MaxMatching<SmartGraph>::EVEN ||
-          mm.status(graph.u(e)) != MaxMatching<SmartGraph>::MATCHED,
-          "Wrong Gallai-Edmonds decomposition");
-
-    if (mm.status(graph.u(e)) != MaxMatching<SmartGraph>::ODD &&
-        mm.status(graph.v(e)) != MaxMatching<SmartGraph>::ODD) {
-      comp.join(graph.u(e), graph.v(e));
-    }
-  }
-
-  std::set<int> comp_root;
-  int odd_comp_num = 0;
-  for (NodeIt n(graph); n != INVALID; ++n) {
-    if (mm.status(n) != MaxMatching<SmartGraph>::ODD) {
-      int root = comp.find(n);
-      if (comp_root.find(root) == comp_root.end()) {
-        comp_root.insert(root);
-        if (comp.size(n) % 2 == 1) {
-          ++odd_comp_num;
-        }
-      }
-    }
-  }
-
-  check(mm.matchingSize() == num, "Wrong matching");
-  check(2 * num == countNodes(graph) - (odd_comp_num - barrier_num),
-         "Wrong matching");
-  return;
-}
-
-void checkWeightedMatching(const SmartGraph& graph,
-                   const SmartGraph::EdgeMap<int>& weight,
-                   const MaxWeightedMatching<SmartGraph>& mwm) {
-  for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
-    if (graph.u(e) == graph.v(e)) continue;
-    int rw = mwm.nodeValue(graph.u(e)) + mwm.nodeValue(graph.v(e));
-
-    for (int i = 0; i < mwm.blossomNum(); ++i) {
-      bool s = false, t = false;
-      for (MaxWeightedMatching<SmartGraph>::BlossomIt n(mwm, i);
-           n != INVALID; ++n) {
-        if (graph.u(e) == n) s = true;
-        if (graph.v(e) == n) t = true;
-      }
-      if (s == true && t == true) {
-        rw += mwm.blossomValue(i);
-      }
-    }
-    rw -= weight[e] * mwm.dualScale;
-
-    check(rw >= 0, "Negative reduced weight");
-    check(rw == 0 || !mwm.matching(e),
-          "Non-zero reduced weight on matching edge");
-  }
-
-  int pv = 0;
-  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
-    if (mwm.matching(n) != INVALID) {
-      check(mwm.nodeValue(n) >= 0, "Invalid node value");
-      pv += weight[mwm.matching(n)];
-      SmartGraph::Node o = graph.target(mwm.matching(n));
-      check(mwm.mate(n) == o, "Invalid matching");
-      check(mwm.matching(n) == graph.oppositeArc(mwm.matching(o)),
-            "Invalid matching");
-    } else {
-      check(mwm.mate(n) == INVALID, "Invalid matching");
-      check(mwm.nodeValue(n) == 0, "Invalid matching");
-    }
-  }
-
-  int dv = 0;
-  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
-    dv += mwm.nodeValue(n);
-  }
-
-  for (int i = 0; i < mwm.blossomNum(); ++i) {
-    check(mwm.blossomValue(i) >= 0, "Invalid blossom value");
-    check(mwm.blossomSize(i) % 2 == 1, "Even blossom size");
-    dv += mwm.blossomValue(i) * ((mwm.blossomSize(i) - 1) / 2);
-  }
-
-  check(pv * mwm.dualScale == dv * 2, "Wrong duality");
-
-  return;
-}
-
-void checkWeightedPerfectMatching(const SmartGraph& graph,
-                          const SmartGraph::EdgeMap<int>& weight,
-                          const MaxWeightedPerfectMatching<SmartGraph>& mwpm) {
-  for (SmartGraph::EdgeIt e(graph); e != INVALID; ++e) {
-    if (graph.u(e) == graph.v(e)) continue;
-    int rw = mwpm.nodeValue(graph.u(e)) + mwpm.nodeValue(graph.v(e));
-
-    for (int i = 0; i < mwpm.blossomNum(); ++i) {
-      bool s = false, t = false;
-      for (MaxWeightedPerfectMatching<SmartGraph>::BlossomIt n(mwpm, i);
-           n != INVALID; ++n) {
-        if (graph.u(e) == n) s = true;
-        if (graph.v(e) == n) t = true;
-      }
-      if (s == true && t == true) {
-        rw += mwpm.blossomValue(i);
-      }
-    }
-    rw -= weight[e] * mwpm.dualScale;
-
-    check(rw >= 0, "Negative reduced weight");
-    check(rw == 0 || !mwpm.matching(e),
-          "Non-zero reduced weight on matching edge");
-  }
-
-  int pv = 0;
-  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
-    check(mwpm.matching(n) != INVALID, "Non perfect");
-    pv += weight[mwpm.matching(n)];
-    SmartGraph::Node o = graph.target(mwpm.matching(n));
-    check(mwpm.mate(n) == o, "Invalid matching");
-    check(mwpm.matching(n) == graph.oppositeArc(mwpm.matching(o)),
-          "Invalid matching");
-  }
-
-  int dv = 0;
-  for (SmartGraph::NodeIt n(graph); n != INVALID; ++n) {
-    dv += mwpm.nodeValue(n);
-  }
-
-  for (int i = 0; i < mwpm.blossomNum(); ++i) {
-    check(mwpm.blossomValue(i) >= 0, "Invalid blossom value");
-    check(mwpm.blossomSize(i) % 2 == 1, "Even blossom size");
-    dv += mwpm.blossomValue(i) * ((mwpm.blossomSize(i) - 1) / 2);
-  }
-
-  check(pv * mwpm.dualScale == dv * 2, "Wrong duality");
-
-  return;
-}
-
-
-int main() {
-
-  for (int i = 0; i < lgfn; ++i) {
-    SmartGraph graph;
-    SmartGraph::EdgeMap<int> weight(graph);
-
-    istringstream lgfs(lgf[i]);
-    graphReader(graph, lgfs).
-      edgeMap("weight", weight).run();
-
-    MaxMatching<SmartGraph> mm(graph);
-    mm.run();
-    checkMatching(graph, mm);
-
-    MaxWeightedMatching<SmartGraph> mwm(graph, weight);
-    mwm.run();
-    checkWeightedMatching(graph, weight, mwm);
-
-    MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight);
-    bool perfect = mwpm.run();
-
-    check(perfect == (mm.matchingSize() * 2 == countNodes(graph)),
-          "Perfect matching found");
-
-    if (perfect) {
-      checkWeightedPerfectMatching(graph, weight, mwpm);
-    }
-  }
-
-  return 0;
-}
