Index: .hgignore
===================================================================
--- .hgignore	(revision 249)
+++ .hgignore	(revision 298)
@@ -30,4 +30,5 @@
 syntax: regexp
 (.*/)?\#[^/]*\#$
+(.*/)?\.\#[^/]*$
 ^doc/html/.*
 ^doc/.*\.tag
Index: AUTHORS
===================================================================
--- AUTHORS	(revision 320)
+++ AUTHORS	(revision 320)
@@ -0,0 +1,26 @@
+The authors of the 1.x series are
+
+ * Balazs Dezso <deba@inf.elte.hu>
+ * Alpar Juttner <alpar@cs.elte.hu>
+ * Peter Kovacs <kpeter@inf.elte.hu>
+ * Akos Ladanyi <ladanyi@tmit.bme.hu>
+
+For more details on the actual contribution, please visit the history
+of the main LEMON source repository: http://lemon.cs.elte.hu/hg/lemon
+
+Moreover, this version is heavily based on the 0.x series of
+LEMON. Here is the list of people who contributed to those versions.
+
+ * Mihaly Barasz <klao@cs.elte.hu>
+ * Johanna Becker <beckerjc@cs.elte.hu>
+ * Attila Bernath <athos@cs.elte.hu>
+ * Balazs Dezso <deba@inf.elte.hu>
+ * Peter Hegyi <hegyi@tmit.bme.hu>
+ * Alpar Juttner <alpar@cs.elte.hu>
+ * Peter Kovacs <kpeter@inf.elte.hu>
+ * Akos Ladanyi <ladanyi@tmit.bme.hu>
+ * Marton Makai <marci@cs.elte.hu>
+ * Jacint Szabo <jacint@cs.elte.hu>
+
+Again, please visit the history of the old LEMON repository for more
+details: http://lemon.cs.elte.hu/svn/lemon/trunk
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 236)
+++ CMakeLists.txt	(revision 274)
@@ -1,15 +1,6 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 
-#EXECUTE_PROCESS(
-#  COMMAND hg id -i
-#  OUTPUT_VARIABLE HG_REVISION
-#  OUTPUT_STRIP_TRAILING_WHITESPACE)
-
 SET(PROJECT_NAME "LEMON")
-SET(PROJECT_VERSION_MAJOR "0")
-SET(PROJECT_VERSION_MINOR "99")
-SET(PROJECT_VERSION_PATCH "0")
-SET(PROJECT_VERSION
-  "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+SET(PROJECT_VERSION "hg-tip" CACHE STRING "The version string.")
 
 PROJECT(${PROJECT_NAME})
@@ -40,13 +31,10 @@
   SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
 
-  SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
-  SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
-  SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
   SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
 
   SET(CPACK_PACKAGE_INSTALL_DIRECTORY
-    "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
+    "${PROJECT_NAME} ${PROJECT_VERSION}")
   SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
-    "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
+    "${PROJECT_NAME} ${PROJECT_VERSION}")
 
   # Variables to generate a component-based installer.
Index: INSTALL
===================================================================
--- INSTALL	(revision 245)
+++ INSTALL	(revision 318)
@@ -2,9 +2,9 @@
 =========================
 
-   Since you are reading this I assume you already obtained one of the release
+Since you are reading this I assume you already obtained one of the release
 tarballs and successfully extracted it. The latest version of LEMON is
 available at our web page (http://lemon.cs.elte.hu/).
 
-   In order to install LEMON from the extracted source tarball you have to
+In order to install LEMON from the extracted source tarball you have to
 issue the following commands:
 
@@ -22,6 +22,6 @@
 
       This command compiles the non-template part of LEMON into libemon.a
-      file. It also compiles the programs in the tools, benchmark and demo
-      subdirectories when enabled.
+      file. It also compiles the programs in the tools and demo subdirectories
+      when enabled.
 
    4. `make check'
@@ -50,10 +50,10 @@
 ===============================
 
-   In step 2 you can customize the actions of configure by setting variables
+In step 2 you can customize the actions of configure by setting variables
 and passing options to it. This can be done like this:
 `./configure [OPTION]... [VARIABLE=VALUE]...'
 
-   Below you will find some useful variables and options (see
-`./configure --help' for more):
+Below you will find some useful variables and options (see `./configure --help'
+for more):
 
 CXX='comp'
@@ -77,12 +77,4 @@
 
    Do not build the examples in the demo subdirectory (default).
-
---enable-benchmark
-
-   Build the programs in the benchmark subdirectory.
-
---disable-benchmark
-
-   Do not build the programs in the benchmark subdirectory (default).
 
 --enable-tools
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 227)
+++ Makefile.am	(revision 321)
@@ -5,4 +5,5 @@
 
 EXTRA_DIST = \
+	AUTHORS \
 	LICENSE \
 	m4/lx_check_cplex.m4 \
@@ -25,4 +26,5 @@
 bin_PROGRAMS =
 check_PROGRAMS =
+dist_bin_SCRIPTS =
 TESTS =
 XFAIL_TESTS =
@@ -32,5 +34,4 @@
 include doc/Makefile.am
 include demo/Makefile.am
-include benchmark/Makefile.am
 include tools/Makefile.am
 
Index: NEWS
===================================================================
--- NEWS	(revision 5)
+++ NEWS	(revision 322)
@@ -0,0 +1,50 @@
+2008-10-13 Version 1.0 released
+
+	This is the first stable release of LEMON. Compared to the 0.x
+	release series, it features a considerably smaller but more
+	matured set of tools. The API has also completely revised and
+	changed in several places.
+
+	* The major name changes compared to the 0.x series (see the
+          Migration Guide in the doc for more details)
+          * Graph -> Digraph, UGraph -> Graph
+          * Edge -> Arc, UEdge -> Edge
+	  * source(UEdge)/target(UEdge) -> u(Edge)/v(Edge)
+	* Other improvements
+	  * Better documentation
+	  * Reviewed and cleaned up codebase
+	  * CMake based build system (along with the autotools based one)
+	* Contents of the library (ported from 0.x)
+	  * Algorithms
+       	    * breadth-first search (bfs.h)
+       	    * depth-first search (dfs.h)
+       	    * Dijkstra's algorithm (dijkstra.h)
+       	    * Kruskal's algorithm (kruskal.h)
+    	  * Data structures
+       	    * graph data structures (list_graph.h, smart_graph.h)
+       	    * path data structures (path.h)
+       	    * binary heap data structure (bin_heap.h)
+       	    * union-find data structures (unionfind.h)
+       	    * miscellaneous property maps (maps.h)
+       	    * two dimensional vector and bounding box (dim2.h)
+          * Concepts
+       	    * graph structure concepts (concepts/digraph.h, concepts/graph.h,
+              concepts/graph_components.h)
+       	    * concepts for other structures (concepts/heap.h, concepts/maps.h,
+	      concepts/path.h)
+    	  * Tools
+       	    * Mersenne twister random number generator (random.h)
+       	    * tools for measuring cpu and wall clock time (time_measure.h)
+       	    * tools for counting steps and events (counter.h)
+       	    * tool for parsing command line arguments (arg_parser.h)
+       	    * tool for visualizing graphs (graph_to_eps.h)
+       	    * tools for reading and writing data in LEMON Graph Format
+              (lgf_reader.h, lgf_writer.h)
+            * tools to handle the anomalies of calculations with
+	      floating point numbers (tolerance.h)
+            * tools to manage RGB colors (color.h)
+    	  * Infrastructure
+       	    * extended assertion handling (assert.h)
+       	    * exception classes and error handling (error.h)
+      	    * concept checking (concept_check.h)
+       	    * commonly used mathematical constants (math.h)
Index: README
===================================================================
--- README	(revision 246)
+++ README	(revision 318)
@@ -36,9 +36,5 @@
 test/
 
-   Contains programs to check the integrity and correctness of LEMON.
-
-benchmark/
-  
-   Contains programs for measuring the performance of algorithms.
+   Programs to check the integrity and correctness of LEMON.
 
 tools/
Index: nchmark/Makefile.am
===================================================================
--- benchmark/Makefile.am	(revision 146)
+++ 	(revision )
@@ -1,7 +1,0 @@
-if WANT_BENCHMARK
-
-noinst_HEADERS +=
-
-noinst_PROGRAMS +=
-
-endif WANT_BENCHMARK
Index: configure.ac
===================================================================
--- configure.ac	(revision 236)
+++ configure.ac	(revision 310)
@@ -2,7 +2,13 @@
 
 dnl Version information.
-m4_define([lemon_version_number], [])
+m4_define([lemon_version_number],
+	[m4_normalize(esyscmd([echo ${LEMON_VERSION}]))])
+dnl m4_define([lemon_version_number], [])
+m4_define([lemon_hg_path], [m4_normalize(esyscmd([./scripts/chg-len.py]))])
 m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i]))])
-m4_define([lemon_version], [ifelse(lemon_version_number(), [], [lemon_hg_revision()], [lemon_version_number()])])
+m4_define([lemon_version], [ifelse(lemon_version_number(),
+			   [],
+			   [lemon_hg_path().lemon_hg_revision()],
+			   [lemon_version_number()])])
 
 AC_PREREQ([2.59])
@@ -16,4 +22,7 @@
 lx_cmdline_cxxflags_set=${CXXFLAGS+set}
 
+dnl Do compilation tests using the C++ compiler.
+AC_LANG([C++])
+
 dnl Checks for programs.
 AC_PROG_CXX
@@ -26,13 +35,24 @@
 AC_CHECK_PROG([gs_found],[gs],[yes],[no])
 
+dnl Detect Intel compiler.
+AC_MSG_CHECKING([whether we are using the Intel C++ compiler])
+AC_COMPILE_IFELSE([#ifndef __INTEL_COMPILER
+choke me
+#endif], [ICC=[yes]], [ICC=[no]])
+if test x"$ICC" = x"yes"; then
+  AC_MSG_RESULT([yes])
+else
+  AC_MSG_RESULT([no])
+fi
+
 dnl Set custom compiler flags when using g++.
-if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes; then
+if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes -a "$ICC" = no; then
   CXXFLAGS="$CXXFLAGS -Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas"
 fi
 
 dnl Checks for libraries.
-LX_CHECK_GLPK
-LX_CHECK_CPLEX
-LX_CHECK_SOPLEX
+#LX_CHECK_GLPK
+#LX_CHECK_CPLEX
+#LX_CHECK_SOPLEX
 
 dnl Disable/enable building the demo programs.
@@ -61,17 +81,4 @@
 fi
 AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"])
-
-dnl Disable/enable building the benchmarks.
-AC_ARG_ENABLE([benchmark],
-AS_HELP_STRING([--enable-benchmark], [build the benchmarks])
-AS_HELP_STRING([--disable-benchmark], [do not build the benchmarks @<:@default@:>@]),
-              [], [enable_benchmark=no])
-AC_MSG_CHECKING([whether to build the benchmarks])
-if test x"$enable_benchmark" != x"no"; then
-  AC_MSG_RESULT([yes])
-else
-  AC_MSG_RESULT([no])
-fi
-AM_CONDITIONAL([WANT_BENCHMARK], [test x"$enable_benchmark" != x"no"])
 
 dnl Checks for header files.
@@ -109,9 +116,8 @@
 echo C++ compiles flags............ : $CXXFLAGS
 echo
-echo GLPK support.................. : $lx_glpk_found
-echo CPLEX support................. : $lx_cplex_found
-echo SOPLEX support................ : $lx_soplex_found
-echo
-echo Build benchmarks.............. : $enable_benchmark
+#echo GLPK support.................. : $lx_glpk_found
+#echo CPLEX support................. : $lx_cplex_found
+#echo SOPLEX support................ : $lx_soplex_found
+#echo
 echo Build demo programs........... : $enable_demo
 echo Build additional tools........ : $enable_tools
Index: demo/arg_parser_demo.cc
===================================================================
--- demo/arg_parser_demo.cc	(revision 209)
+++ demo/arg_parser_demo.cc	(revision 311)
@@ -28,5 +28,5 @@
 
 using namespace lemon;
-int main(int argc, const char **argv)
+int main(int argc, char **argv)
 {
   // Initialize the argument parser
Index: demo/graph_to_eps_demo.cc
===================================================================
--- demo/graph_to_eps_demo.cc	(revision 220)
+++ demo/graph_to_eps_demo.cc	(revision 313)
@@ -27,5 +27,5 @@
 /// how to handle parallel egdes, how to change the properties (like
 /// color, shape, size, title etc.) of nodes and arcs individually
-/// using appropriate \ref maps-page "graph maps".
+/// using appropriate graph maps.
 ///
 /// \include graph_to_eps_demo.cc
Index: demo/lgf_demo.cc
===================================================================
--- demo/lgf_demo.cc	(revision 209)
+++ demo/lgf_demo.cc	(revision 294)
@@ -45,10 +45,10 @@
 
   try {
-    digraphReader("digraph.lgf", g). // read the directed graph into g
+    digraphReader(g, "digraph.lgf"). // read the directed graph into g
       arcMap("capacity", cap).       // read the 'capacity' arc map into cap
       node("source", s).             // read 'source' node to s
       node("target", t).             // read 'target' node to t
       run();
-  } catch (DataFormatError& error) { // check if there was any error
+  } catch (Exception& error) { // check if there was any error
     std::cerr << "Error: " << error.what() << std::endl;
     return -1;
@@ -61,5 +61,5 @@
   std::cout << "We can write it to the standard output:" << std::endl;
 
-  digraphWriter(std::cout, g).     // write g to the standard output
+  digraphWriter(g).                // write g to the standard output
     arcMap("capacity", cap).       // write cap into 'capacity'
     node("source", s).             // write s to 'source'
Index: doc/Doxyfile.in
===================================================================
--- doc/Doxyfile.in	(revision 226)
+++ doc/Doxyfile.in	(revision 316)
@@ -1,3 +1,3 @@
-# Doxyfile 1.5.5
+# Doxyfile 1.5.7.1
 
 #---------------------------------------------------------------------------
@@ -34,7 +34,9 @@
 CPP_CLI_SUPPORT        = NO
 SIP_SUPPORT            = NO
+IDL_PROPERTY_SUPPORT   = YES
 DISTRIBUTE_GROUP_DOC   = NO
 SUBGROUPING            = YES
 TYPEDEF_HIDES_STRUCT   = NO
+SYMBOL_CACHE_SIZE      = 0
 #---------------------------------------------------------------------------
 # Build related configuration options
@@ -67,5 +69,8 @@
 SHOW_USED_FILES        = YES
 SHOW_DIRECTORIES       = YES
+SHOW_FILES             = YES
+SHOW_NAMESPACES        = YES
 FILE_VERSION_FILTER    = 
+LAYOUT_FILE            = DoxygenLayout.xml
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
@@ -76,5 +81,5 @@
 WARN_IF_DOC_ERROR      = YES
 WARN_NO_PARAMDOC       = NO
-WARN_FORMAT            = "$file:$line: $text  "
+WARN_FORMAT            = "$file:$line: $text"
 WARN_LOGFILE           = doxygen.log
 #---------------------------------------------------------------------------
@@ -134,18 +139,25 @@
 HTML_STYLESHEET        = 
 HTML_ALIGN_MEMBERS     = YES
-GENERATE_HTMLHELP      = NO
+HTML_DYNAMIC_SECTIONS  = NO
 GENERATE_DOCSET        = NO
 DOCSET_FEEDNAME        = "Doxygen generated docs"
 DOCSET_BUNDLE_ID       = org.doxygen.Project
-HTML_DYNAMIC_SECTIONS  = NO
+GENERATE_HTMLHELP      = NO
 CHM_FILE               = 
 HHC_LOCATION           = 
 GENERATE_CHI           = NO
+CHM_INDEX_ENCODING     = 
 BINARY_TOC             = NO
 TOC_EXPAND             = NO
+GENERATE_QHP           = NO
+QCH_FILE               = 
+QHP_NAMESPACE          = org.doxygen.Project
+QHP_VIRTUAL_FOLDER     = doc
+QHG_LOCATION           = 
 DISABLE_INDEX          = NO
 ENUM_VALUES_PER_LINE   = 4
 GENERATE_TREEVIEW      = NO
 TREEVIEW_WIDTH         = 250
+FORMULA_FONTSIZE       = 10
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
@@ -222,8 +234,11 @@
 # Configuration options related to the dot tool   
 #---------------------------------------------------------------------------
-CLASS_DIAGRAMS         = NO
+CLASS_DIAGRAMS         = YES
 MSCGEN_PATH            = 
 HIDE_UNDOC_RELATIONS   = YES
 HAVE_DOT               = YES
+DOT_FONTNAME           = FreeSans
+DOT_FONTSIZE           = 10
+DOT_FONTPATH           = 
 CLASS_GRAPH            = YES
 COLLABORATION_GRAPH    = NO
Index: doc/DoxygenLayout.xml
===================================================================
--- doc/DoxygenLayout.xml	(revision 316)
+++ doc/DoxygenLayout.xml	(revision 316)
@@ -0,0 +1,182 @@
+<doxygenlayout version="1.0">
+  <!-- Navigation index tabs for HTML output -->
+  <navindex>
+    <tab type="mainpage" visible="yes" title=""/>
+    <tab type="modules" visible="yes" title=""/>
+    <tab type="classes" visible="yes" title="">
+      <tab type="classes" visible="yes" title=""/>
+      <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/> 
+      <tab type="hierarchy" visible="yes" title=""/>
+      <tab type="classmembers" visible="yes" title=""/>
+    </tab>
+    <tab type="namespaces" visible="yes" title="">
+      <tab type="namespaces" visible="yes" title=""/>
+      <tab type="namespacemembers" visible="yes" title=""/>
+    </tab>
+    <tab type="files" visible="yes" title="">
+      <tab type="files" visible="yes" title=""/>
+      <tab type="globals" visible="yes" title=""/>
+    </tab>
+    <tab type="dirs" visible="yes" title=""/>
+    <tab type="examples" visible="yes" title=""/>  
+    <tab type="pages" visible="yes" title=""/>
+  </navindex>
+
+  <!-- Layout definition for a class page -->
+  <class>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <inheritancegraph visible="$CLASS_GRAPH"/>
+    <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+    <allmemberslink visible="yes"/>
+    <memberdecl>
+      <membergroups visible="yes"/>
+      <nestedclasses visible="yes" title=""/>
+      <publictypes title=""/>
+      <publicslots title=""/>
+      <signals title=""/>
+      <publicmethods title=""/>
+      <publicstaticmethods title=""/>
+      <publicattributes title=""/>
+      <publicstaticattributes title=""/>
+      <protectedtypes title=""/>
+      <protectedslots title=""/>
+      <protectedmethods title=""/>
+      <protectedstaticmethods title=""/>
+      <protectedattributes title=""/>
+      <protectedstaticattributes title=""/>
+      <packagetypes title=""/>
+      <packagemethods title=""/>
+      <packagestaticmethods title=""/>
+      <packageattributes title=""/>
+      <packagestaticattributes title=""/>
+      <properties title=""/>
+      <events title=""/>
+      <privatetypes title=""/>
+      <privateslots title=""/>
+      <privatemethods title=""/>
+      <privatestaticmethods title=""/>
+      <privateattributes title=""/>
+      <privatestaticattributes title=""/>
+      <friends title=""/>
+      <related title="" subtitle=""/>
+    </memberdecl>
+    <memberdef>
+      <typedefs title=""/>
+      <enums title=""/>
+      <constructors title=""/>
+      <functions title=""/>
+      <related title=""/>
+      <variables title=""/>
+      <properties title=""/>
+      <events title=""/>
+    </memberdef>
+    <usedfiles visible="$SHOW_USED_FILES"/>
+    <authorsection visible="yes"/>
+  </class>
+
+  <!-- Layout definition for a namespace page -->
+  <namespace>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <memberdecl>
+      <nestednamespaces visible="yes" title=""/>
+      <classes visible="yes" title=""/>
+      <membergroups visible="yes"/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdecl>
+    <memberdef>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </namespace>
+
+  <!-- Layout definition for a file page -->
+  <file>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <includes visible="$SHOW_INCLUDE_FILES"/>
+    <includegraph visible="$INCLUDE_GRAPH"/>
+    <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+    <sourcelink visible="yes"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdecl>
+    <memberdef>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <functions title=""/>
+      <variables title=""/>
+    </memberdef>
+    <authorsection/>
+  </file>
+
+  <!-- Layout definition for a group page -->
+  <group>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <groupgraph visible="$GROUP_GRAPHS"/>
+    <memberdecl>
+      <classes visible="yes" title=""/>
+      <namespaces visible="yes" title=""/>
+      <dirs visible="yes" title=""/>
+      <nestedgroups visible="yes" title=""/>
+      <files visible="yes" title=""/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+    </memberdecl>
+    <memberdef>
+      <pagedocs/>
+      <defines title=""/>
+      <typedefs title=""/>
+      <enums title=""/>
+      <enumvalues title=""/>
+      <functions title=""/>
+      <variables title=""/>
+      <signals title=""/>
+      <publicslots title=""/>
+      <protectedslots title=""/>
+      <privateslots title=""/>
+      <events title=""/>
+      <properties title=""/>
+      <friends title=""/>
+    </memberdef>
+    <authorsection visible="yes"/>
+  </group>
+
+  <!-- Layout definition for a directory page -->
+  <directory>
+    <briefdescription visible="no"/>
+    <detaileddescription title=""/>
+    <directorygraph visible="yes"/>
+    <memberdecl>
+      <dirs visible="yes"/>
+      <files visible="yes"/>
+    </memberdecl>
+  </directory>
+</doxygenlayout>
Index: doc/Makefile.am
===================================================================
--- doc/Makefile.am	(revision 347)
+++ doc/Makefile.am	(revision 349)
@@ -1,4 +1,5 @@
 EXTRA_DIST += \
 	doc/Doxyfile.in \
+	doc/DoxygenLayout.xml \
 	doc/coding_style.dox \
 	doc/dirs.dox \
@@ -7,4 +8,6 @@
 	doc/license.dox \
 	doc/mainpage.dox \
+	doc/migration.dox \
+	doc/named-param.dox \
 	doc/namespaces.dox \
 	doc/html \
Index: doc/dirs.dox
===================================================================
--- doc/dirs.dox	(revision 209)
+++ doc/dirs.dox	(revision 318)
@@ -19,7 +19,7 @@
 /**
 \dir demo
-\brief A collection of demo application.
+\brief A collection of demo applications.
 
-This directory contains several simple demo application, mainly
+This directory contains several simple demo applications, mainly
 for educational purposes.
 */
@@ -29,5 +29,6 @@
 \brief Auxiliary (and the whole generated) documentation.
 
-Auxiliary (and the whole generated) documentation.
+This directory contains some auxiliary pages and the whole generated
+documentation.
 */
 
@@ -42,17 +43,14 @@
 /**
 \dir tools
-\brief Some useful executables
+\brief Some useful executables.
 
 This directory contains the sources of some useful complete executables.
-
 */
-
-
 
 /**
 \dir lemon
-\brief Base include directory of LEMON
+\brief Base include directory of LEMON.
 
-This is the base directory of lemon includes, so each include file must be
+This is the base directory of LEMON includes, so each include file must be
 prefixed with this, e.g.
 \code
@@ -64,16 +62,16 @@
 /**
 \dir concepts
-\brief Concept descriptors and checking classes
+\brief Concept descriptors and checking classes.
 
-This directory contains the concept descriptors and concept checkers. As a user
-you typically don't have to deal with these files.
+This directory contains the concept descriptors and concept checking tools.
+For more information see the \ref concept "Concepts" module.
 */
 
 /**
 \dir bits
-\brief Implementation helper files
+\brief Auxiliary tools for implementation.
 
-This directory contains some helper classes to implement graphs, maps and
-some other classes. As a user you typically don't have to deal with these
-files.
+This directory contains some auxiliary classes for implementing graphs, 
+maps and some other classes.
+As a user you typically don't have to deal with these files.
 */
Index: doc/groups.dox
===================================================================
--- doc/groups.dox	(revision 236)
+++ doc/groups.dox	(revision 318)
@@ -55,5 +55,7 @@
 You are free to use the graph structure that fit your requirements
 the best, most graph algorithms and auxiliary data structures can be used
-with any graph structures.
+with any graph structure.
+
+<b>See also:</b> \ref graph_concepts "Graph Structure Concepts".
 */
 
@@ -75,6 +77,8 @@
 This group describes the map structures implemented in LEMON.
 
-LEMON provides several special purpose maps that e.g. combine
+LEMON provides several special purpose maps and map adaptors that e.g. combine
 new maps from existing ones.
+
+<b>See also:</b> \ref map_concepts "Map Concepts".
 */
 
@@ -87,5 +91,4 @@
 values to the nodes and arcs of graphs.
 */
-
 
 /**
@@ -105,5 +108,5 @@
 algorithms.  If a function type algorithm is called then the function
 type map adaptors can be used comfortable. For example let's see the
-usage of map adaptors with the \c digraphToEps() function.
+usage of map adaptors with the \c graphToEps() function.
 \code
   Color nodeColor(int deg) {
@@ -119,5 +122,5 @@
   Digraph::NodeMap<int> degree_map(graph);
 
-  digraphToEps(graph, "graph.eps")
+  graphToEps(graph, "graph.eps")
     .coords(coords).scaleToA4().undirected()
     .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
@@ -125,5 +128,5 @@
 \endcode
 The \c functorToMap() function makes an \c int to \c Color map from the
-\e nodeColor() function. The \c composeMap() compose the \e degree_map
+\c nodeColor() function. The \c composeMap() compose the \c degree_map
 and the previously created map. The composed map is a proper function to
 get the color of each node.
@@ -163,5 +166,5 @@
 @defgroup paths Path Structures
 @ingroup datas
-\brief Path structures implemented in LEMON.
+\brief %Path structures implemented in LEMON.
 
 This group describes the path structures implemented in LEMON.
@@ -174,5 +177,4 @@
 
 \sa lemon::concepts::Path
-
 */
 
@@ -186,5 +188,4 @@
 */
 
-
 /**
 @defgroup algs Algorithms
@@ -202,9 +203,9 @@
 
 This group describes the common graph search algorithms like
-Breadth-first search (Bfs) and Depth-first search (Dfs).
-*/
-
-/**
-@defgroup shortest_path Shortest Path algorithms
+Breadth-First Search (BFS) and Depth-First Search (DFS).
+*/
+
+/**
+@defgroup shortest_path Shortest Path Algorithms
 @ingroup algs
 \brief Algorithms for finding shortest paths.
@@ -214,5 +215,5 @@
 
 /**
-@defgroup max_flow Maximum Flow algorithms
+@defgroup max_flow Maximum Flow Algorithms
 @ingroup algs
 \brief Algorithms for finding maximum flows.
@@ -242,9 +243,8 @@
 provides functions to query the minimum cut, which is the dual linear
 programming problem of the maximum flow.
-
-*/
-
-/**
-@defgroup min_cost_flow Minimum Cost Flow algorithms
+*/
+
+/**
+@defgroup min_cost_flow Minimum Cost Flow Algorithms
 @ingroup algs
 
@@ -256,5 +256,5 @@
 
 /**
-@defgroup min_cut Minimum Cut algorithms
+@defgroup min_cut Minimum Cut Algorithms
 @ingroup algs
 
@@ -283,9 +283,8 @@
 If you want to find minimum cut just between two distinict nodes,
 please see the \ref max_flow "Maximum Flow page".
-
-*/
-
-/**
-@defgroup graph_prop Connectivity and other graph properties
+*/
+
+/**
+@defgroup graph_prop Connectivity and Other Graph Properties
 @ingroup algs
 \brief Algorithms for discovering the graph properties
@@ -299,5 +298,5 @@
 
 /**
-@defgroup planar Planarity embedding and drawing
+@defgroup planar Planarity Embedding and Drawing
 @ingroup algs
 \brief Algorithms for planarity checking, embedding and drawing
@@ -311,5 +310,5 @@
 
 /**
-@defgroup matching Matching algorithms
+@defgroup matching Matching Algorithms
 @ingroup algs
 \brief Algorithms for finding matchings in graphs and bipartite graphs.
@@ -349,9 +348,8 @@
 \image html bipartite_matching.png
 \image latex bipartite_matching.eps "Bipartite Matching" width=\textwidth
-
-*/
-
-/**
-@defgroup spantree Minimum Spanning Tree algorithms
+*/
+
+/**
+@defgroup spantree Minimum Spanning Tree Algorithms
 @ingroup algs
 \brief Algorithms for finding a minimum cost spanning tree in a graph.
@@ -361,7 +359,6 @@
 */
 
-
-/**
-@defgroup auxalg Auxiliary algorithms
+/**
+@defgroup auxalg Auxiliary Algorithms
 @ingroup algs
 \brief Auxiliary algorithms implemented in LEMON.
@@ -372,5 +369,6 @@
 
 /**
-@defgroup approx Approximation algorithms
+@defgroup approx Approximation Algorithms
+@ingroup algs
 \brief Approximation algorithms.
 
@@ -386,9 +384,8 @@
 This group describes some general optimization frameworks
 implemented in LEMON.
-
-*/
-
-/**
-@defgroup lp_group Lp and Mip solvers
+*/
+
+/**
+@defgroup lp_group Lp and Mip Solvers
 @ingroup gen_opt_group
 \brief Lp and Mip solver interfaces for LEMON.
@@ -397,9 +394,8 @@
 various LP solvers could be used in the same manner with this
 interface.
-
-*/
-
-/**
-@defgroup lp_utils Tools for Lp and Mip solvers
+*/
+
+/**
+@defgroup lp_utils Tools for Lp and Mip Solvers
 @ingroup lp_group
 \brief Helper tools to the Lp and Mip solvers.
@@ -442,5 +438,5 @@
 
 /**
-@defgroup timecount Time measuring and Counting
+@defgroup timecount Time Measuring and Counting
 @ingroup misc
 \brief Simple tools for measuring the performance of algorithms.
@@ -448,13 +444,4 @@
 This group describes simple tools for measuring the performance
 of algorithms.
-*/
-
-/**
-@defgroup graphbits Tools for Graph Implementation
-@ingroup utils
-\brief Tools to make it easier to create graphs.
-
-This group describes the tools that makes it easier to create graphs and
-the maps that dynamically update with the graph changes.
 */
 
@@ -472,6 +459,7 @@
 
 This group describes the tools for importing and exporting graphs
-and graph related data. Now it supports the LEMON format, the
-\c DIMACS format and the encapsulated postscript (EPS) format.
+and graph related data. Now it supports the \ref lgf-format
+"LEMON Graph Format", the \c DIMACS format and the encapsulated
+postscript (EPS) format.
 */
 
@@ -479,5 +467,5 @@
 @defgroup lemon_io LEMON Input-Output
 @ingroup io_group
-\brief Reading and writing \ref lgf-format "LEMON Graph Format".
+\brief Reading and writing LEMON Graph Format.
 
 This group describes methods for reading and writing
@@ -486,5 +474,5 @@
 
 /**
-@defgroup eps_io Postscript exporting
+@defgroup eps_io Postscript Exporting
 @ingroup io_group
 \brief General \c EPS drawer and graph exporter
@@ -494,5 +482,4 @@
 */
 
-
 /**
 @defgroup concept Concepts
@@ -504,10 +491,10 @@
 The purpose of the classes in this group is fourfold.
 
-- These classes contain the documentations of the concepts. In order
+- These classes contain the documentations of the %concepts. In order
   to avoid document multiplications, an implementation of a concept
   simply refers to the corresponding concept class.
 
 - These classes declare every functions, <tt>typedef</tt>s etc. an
-  implementation of the concepts should provide, however completely
+  implementation of the %concepts should provide, however completely
   without implementations and real data structures behind the
   interface. On the other hand they should provide nothing else. All
@@ -522,7 +509,5 @@
 
 - Finally, They can serve as a skeleton of a new implementation of a concept.
-
-*/
-
+*/
 
 /**
@@ -535,8 +520,10 @@
 */
 
-/* --- Unused group
-@defgroup experimental Experimental Structures and Algorithms
-This group describes some Experimental structures and algorithms.
-The stuff here is subject to change.
+/**
+@defgroup map_concepts Map Concepts
+@ingroup concept
+\brief Skeleton and concept checking classes for maps
+
+This group describes the skeletons and concept checking classes of maps.
 */
 
Index: doc/lgf.dox
===================================================================
--- doc/lgf.dox	(revision 236)
+++ doc/lgf.dox	(revision 313)
@@ -79,5 +79,5 @@
 \endcode
 
-The \c \@edges is just a synonym of \c \@arcs. The @arcs section can
+The \c \@edges is just a synonym of \c \@arcs. The \@arcs section can
 also store the edge set of an undirected graph. In such case there is
 a conventional method for store arc maps in the file, if two columns
Index: doc/mainpage.dox
===================================================================
--- doc/mainpage.dox	(revision 209)
+++ doc/mainpage.dox	(revision 314)
@@ -51,5 +51,5 @@
 If you
 want to see how LEMON works, see
-some \ref demoprograms "demo programs"!
+some \ref demoprograms "demo programs".
 
 If you know what you are looking for then try to find it under the
@@ -57,4 +57,5 @@
 section.
 
-
+If you are a user of the old (0.x) series of LEMON, please check out the
+\ref migration "Migration Guide" for the backward incompatibilities.
 */
Index: doc/migration.dox
===================================================================
--- doc/migration.dox	(revision 314)
+++ doc/migration.dox	(revision 314)
@@ -0,0 +1,143 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2008
+ * 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.
+ *
+ */
+
+namespace lemon {
+/*!
+
+\page migration Migration from the 0.x Series
+
+This guide gives an in depth description on what has changed compared
+to the 0.x release series.
+
+Many of these changes adjusted automatically by the
+<tt>script/lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual
+update are typeset <b>boldface</b>.
+
+\section migration-graph Graph Related Name Changes
+
+- \ref concepts::Digraph "Directed graphs" are called \c Digraph and
+  they have <tt>Arc</tt>s (instead of <tt>Edge</tt>s), while
+  \ref concepts::Graph "undirected graphs" are called \c Graph
+  (instead of \c UGraph) and they have <tt>Edge</tt>s (instead of
+  <tt>UEdge</tt>s). These changes reflected thoroughly everywhere in
+  the library. Namely,
+  - \c Graph -> \c Digraph
+    - \c %ListGraph -> \c ListDigraph, \c %SmartGraph -> \c SmartDigraph etc.
+  - \c UGraph -> \c Graph
+    - \c ListUGraph -> \c ListGraph, \c SmartUGraph -> \c SmartGraph etc.
+  - \c Edge -> \c Arc, \c UEdge -> \c Edge
+  - \c EdgeMap -> \c ArcMap, \c UEdgeMap -> \c EdgeMap
+  - \c EdgeIt -> \c ArcIt, \c UEdgeIt -> \c EdgeIt
+  - Class names and function names containing the words \c graph,
+    \c ugraph, \e edge or \e arc should also be updated.
+- <b>The two endpoints of an (\e undirected) \c Edge can be obtained by the
+  <tt>u()</tt> and <tt>v()</tt> member function of the graph
+  (instead of <tt>source()</tt> and <tt>target()</tt>). This change
+  must be done by hand.</b>
+  \n Of course, you can still use <tt>source()</tt> and <tt>target()</tt>
+  for <tt>Arc</tt>s (directed edges).
+
+\warning
+<b>The <tt>script/lemon-0.x-to-1.x.sh</tt> tool replaces all instances of
+the words \c graph, \c digraph, \c edge and \c arc, so it replaces them
+in strings, comments etc. as well as in all identifiers.</b>
+
+\section migration-lgf LGF tools
+ - The \ref lgf-format "LGF file format" has changed,
+   <tt>\@nodeset</tt> has changed to <tt>\@nodes</tt>,
+   <tt>\@edgeset</tt> and <tt>\@uedgeset</tt> to <tt>\@arcs</tt> or
+   <tt>\@edges</tt>, which become completely equivalents. The
+   <tt>\@nodes</tt>, <tt>\@edges</tt> and <tt>\@uedges</tt> sections are
+   removed from the format, the content of them should be
+   the part of <tt>\@attributes</tt> section. The data fields in
+   the sections must follow a strict format, they must be either character
+   sequences without whitespaces or quoted strings.
+ - The <tt>LemonReader</tt> and <tt>LemonWriter</tt> core interfaces
+   are no longer available.
+ - The implementation of the general section readers and writers has changed
+   they are simple functors now. Beside the old
+   stream based section handling, currently line oriented section
+   reading and writing are also supported. In the
+   section readers the lines must be counted manually. The sections
+   should be read and written with the SectionWriter and SectionReader
+   classes.
+ - Instead of the item readers and writers, item converters should be
+   used. The converters are functors, which map the type to
+   std::string or std::string to the type. The converters for standard
+   containers hasn't yet been implemented in the new LEMON. The converters
+   can return strings in any format, because if it is necessary, the LGF
+   writer and reader will quote and unquote the given value.
+ - The DigraphReader and DigraphWriter can used similarly to the
+   0.x series, however the <tt>read</tt> or <tt>write</tt> prefix of
+   the member functions are removed.
+ - The new LEMON supports the function like interface, the \c
+   digraphReader and \c digraphWriter functions are more convenient than
+   using the classes directly.
+
+\section migration-search BFS, DFS and Dijkstra
+- <b>Using the function interface of BFS, DFS and %Dijkstra both source and
+  target nodes can be given as parameters of the <tt>run()</tt> function
+  (instead of \c bfs(), \c dfs() or \c dijkstra() itself).</b>
+- \ref named-templ-param "Named class template parameters" of \c Bfs,
+  \c Dfs, \c Dijkstra, \c BfsVisit, \c DfsVisit are renamed to start
+  with "Set" instead of "Def". Namely,
+  - \c DefPredMap -> \c SetPredMap
+  - \c DefDistMap -> \c SetDistMap
+  - \c DefReachedMap -> \c SetReachedMap
+  - \c DefProcessedMap -> \c SetProcessedMap
+  - \c DefHeap -> \c SetHeap
+  - \c DefStandardHeap -> \c SetStandardHeap
+  - \c DefOperationTraits -> \c SetOperationTraits
+  - \c DefProcessedMapToBeDefaultMap -> \c SetStandardProcessedMap
+
+\section migration-error Exceptions and Debug tools
+
+<b>The class hierarchy of exceptions has largely been simplified. Now,
+only the i/o related tools may throw exceptions. All other exceptions
+have been replaced with either the \c LEMON_ASSERT or the \c LEMON_DEBUG
+macros.</b>
+
+<b>On the other hand, the parameter order of constructors of the
+exceptions has been changed. See \ref IoError and \ref FormatError for
+more details.</b>
+
+\section migration-other Others
+- <b>The contents of <tt>graph_utils.h</tt> are moved to <tt>core.h</tt>
+  and <tt>maps.h</tt>. <tt>core.h</tt> is included by all graph types,
+  therefore it usually do not have to be included directly.</b>
+- <b><tt>path_utils.h</tt> is merged to \c path.h.</b>
+- <b>The semantic of the assignment operations and copy constructors of maps
+  are still under discussion. So, you must copy them by hand (i.e. copy
+  each entry one-by-one)</b>
+- <b>The parameters of the graph copying tools (i.e. \c GraphCopy,
+  \c DigraphCopy) have to be given in the from-to order.</b>
+- \c copyDigraph() and \c copyGraph() are renamed to \c digraphCopy()
+  and \c graphCopy(), respectively.
+- <b>The interface of \ref DynArcLookUp has changed. It is now the same as
+  of \ref ArcLookUp and \ref AllArcLookUp</b>
+- Some map types should also been renamed. Namely,
+  - \c IntegerMap -> \c RangeMap
+  - \c StdMap -> \c SparseMap
+  - \c FunctorMap -> \c FunctorToMap
+  - \c MapFunctor -> \c MapToFunctor
+  - \c ForkWriteMap -> \c ForkMap
+  - \c StoreBoolMap -> \c LoggerBoolMap
+- \c dim2::BoundingBox -> \c dim2::Box
+
+*/
+}
Index: doc/named-param.dox
===================================================================
--- doc/named-param.dox	(revision 269)
+++ doc/named-param.dox	(revision 269)
@@ -0,0 +1,119 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2008
+ * 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.
+ *
+ */
+
+/*!
+
+\page named-param Named Parameters
+
+\section named-func-param Named Function Parameters
+
+Several modern languages provide a convenient way to refer the
+function parameters by name also when you call the function. It is
+especially comfortable in case of a function having tons of parameters
+with natural default values. Sadly, C++ lack this amenity.
+
+However, with a crafty trick and with some little
+inconvenience, it is possible to emulate is.
+The example below shows how to do it.
+
+\code
+class namedFn
+{
+  int _id;
+  double _val;
+  int _dim;
+
+  public:
+  namedFn() : _id(0), _val(1), _dim(2) {}
+  namedFn& id(int p)     { _id  = p ; return *this; }
+  namedFn& val(double p) { _val = p ; return *this; }
+  namedFn& dim(int p)    { _dim = p ; return *this; }
+
+  run() {
+    std::cout << "Here comes the function itself\n" <<
+              << "With parameters "
+              << _id << ", " << _val << ", " << _dim << std::endl;
+  }
+};
+\endcode
+
+Then you can use it like this.
+
+\code
+namedFn().id(3).val(2).run();
+\endcode
+
+The trick is obvious, each "named parameter" changes one component of
+the underlying class, then gives back a reference to it. Finally,
+<tt>run()</tt> executes the algorithm itself.
+
+\note Although it is a class, namedFn is used pretty much like as it were
+a function. That it why we called it namedFn instead of \c NamedFn.
+
+\note In fact, the final <tt>.run()</tt> could be made unnecessary,
+because the algorithm could also be implemented in the destructor of
+\c namedFn instead. This however would make it impossible to implement
+functions with return values, and would also cause serious problems when
+implementing \ref named-templ-func-param "named template parameters".
+<b>Therefore, by convention, <tt>.run()</tt> must be used
+explicitly to execute a function having named parameters
+everywhere in LEMON.</b>
+
+\section named-templ-func-param Named Function Template Parameters
+
+A named parameter can also be a template function. The usage is
+exactly the same, but the implementation behind is a kind of black
+magic and they are the dirtiest part of the LEMON code.
+
+You will probably never need to know how it works, but if you really
+committed, have a look at \ref lemon/graph_to_eps.h for an example.
+
+\section traits-classes Traits Classes
+
+A similar game can also be played when defining classes. In this case
+the type of the class attributes can be changed. Initially we have to
+define a special class called <em>Traits Class</em> defining the
+default type of the attributes. Then the types of these attributes can
+be changed in the same way as described in the next section.
+
+See \ref lemon::DijkstraDefaultTraits for an
+example how a traits class implementation looks like.
+
+\section named-templ-param Named Class Template Parameters
+
+If we would like to change the type of an attribute in a class that
+was instantiated by using a traits class as a template parameter, and
+the class contains named parameters, we do not have to instantiate again
+the class with new traits class, but instead adaptor classes can
+be used as shown in the following example.
+
+\code
+Dijkstra<>::SetPredMap<NullMap<Node,Arc> >::Create
+\endcode
+
+It can also be used in conjunction with other named template
+parameters in arbitrary order.
+
+\code
+Dijkstra<>::SetDistMap<MyMap>::SetPredMap<NullMap<Node,Arc> >::Create
+\endcode
+
+The result will be an instantiated Dijkstra class, in which the
+DistMap and the PredMap is modified.
+
+*/
Index: lemon/Makefile.am
===================================================================
--- lemon/Makefile.am	(revision 346)
+++ lemon/Makefile.am	(revision 349)
@@ -13,7 +13,6 @@
         lemon/random.cc
 
-
-lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS)
-lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
+#lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS)
+#lemon_libemon_la_LDFLAGS = $(GLPK_LIBS) $(CPLEX_LIBS) $(SOPLEX_LIBS)
 
 lemon_HEADERS += \
@@ -38,4 +37,5 @@
 	lemon/maps.h \
 	lemon/math.h \
+	lemon/max_matching.h \
 	lemon/path.h \
         lemon/random.h \
Index: lemon/arg_parser.cc
===================================================================
--- lemon/arg_parser.cc	(revision 214)
+++ lemon/arg_parser.cc	(revision 311)
@@ -27,10 +27,9 @@
   }
 
-  ArgParser::ArgParser(int argc, const char **argv) :_argc(argc), _argv(argv),
-                                                     _command_name(argv[0]) {
+  ArgParser::ArgParser(int argc, const char * const *argv)
+    :_argc(argc), _argv(argv), _command_name(argv[0]) {
     funcOption("-help","Print a short help message",_showHelp,this);
     synonym("help","-help");
     synonym("h","-help");
-
   }
 
Index: lemon/arg_parser.h
===================================================================
--- lemon/arg_parser.h	(revision 214)
+++ lemon/arg_parser.h	(revision 311)
@@ -17,6 +17,6 @@
  */
 
-#ifndef LEMON_ARG_PARSER
-#define LEMON_ARG_PARSER
+#ifndef LEMON_ARG_PARSER_H
+#define LEMON_ARG_PARSER_H
 
 #include <vector>
@@ -47,5 +47,5 @@
 
     int _argc;
-    const char **_argv;
+    const char * const *_argv;
 
     enum OptType { UNKNOWN=0, BOOL=1, STRING=2, DOUBLE=3, INTEGER=4, FUNC=5 };
@@ -120,5 +120,5 @@
 
     ///Constructor
-    ArgParser(int argc, const char **argv);
+    ArgParser(int argc, const char * const *argv);
 
     ~ArgParser();
@@ -311,6 +311,7 @@
     ///This is the type of the return value of ArgParser::operator[]().
     ///It automatically converts to \c int, \c double, \c bool or
-    ///\c std::string if the type of the option matches, otherwise it
-    ///throws an exception (i.e. it performs runtime type checking).
+    ///\c std::string if the type of the option matches, which is checked
+    ///with an \ref LEMON_ASSERT "assertion" (i.e. it performs runtime
+    ///type checking).
     class RefType
     {
@@ -383,3 +384,3 @@
 }
 
-#endif // LEMON_ARG_PARSER
+#endif // LEMON_ARG_PARSER_H
Index: lemon/assert.h
===================================================================
--- lemon/assert.h	(revision 218)
+++ lemon/assert.h	(revision 290)
@@ -28,6 +28,7 @@
 namespace lemon {
 
-  inline void assert_fail_log(const char *file, int line, const char *function,
-                              const char *message, const char *assertion)
+  inline void assert_fail_abort(const char *file, int line,
+                                const char *function, const char* message,
+                                const char *assertion)
   {
     std::cerr << file << ":" << line << ": ";
@@ -38,11 +39,4 @@
       std::cerr << " (assertion '" << assertion << "' failed)";
     std::cerr << std::endl;
-  }
-
-  inline void assert_fail_abort(const char *file, int line,
-                                const char *function, const char* message,
-                                const char *assertion)
-  {
-    assert_fail_log(file, line, function, message, assertion);
     std::abort();
   }
@@ -64,15 +58,12 @@
 
 #undef LEMON_ASSERT
-#undef LEMON_FIXME
 #undef LEMON_DEBUG
 
-#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) +               \
-  (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
+#if (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +               \
   (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
 #error "LEMON assertion system is not set properly"
 #endif
 
-#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) +              \
-     (defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
+#if ((defined(LEMON_ASSERT_ABORT) ? 1 : 0) +            \
      (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 ||     \
      defined(LEMON_ENABLE_ASSERTS)) &&                  \
@@ -83,8 +74,5 @@
 
 
-#if defined LEMON_ASSERT_LOG
-#  undef LEMON_ASSERT_HANDLER
-#  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_log
-#elif defined LEMON_ASSERT_ABORT
+#if defined LEMON_ASSERT_ABORT
 #  undef LEMON_ASSERT_HANDLER
 #  define LEMON_ASSERT_HANDLER ::lemon::assert_fail_abort
@@ -108,6 +96,8 @@
 #  elif defined _MSC_VER
 #    define LEMON_FUNCTION_NAME (__FUNCSIG__)
+#  elif __STDC_VERSION__ >= 199901L
+#    define LEMON_FUNCTION_NAME (__func__)
 #  else
-#    define LEMON_FUNCTION_NAME (__func__)
+#    define LEMON_FUNCTION_NAME ("<unknown>")
 #  endif
 #endif
@@ -119,10 +109,10 @@
 /// \brief Macro for assertion with customizable message
 ///
-/// Macro for assertion with customizable message.  \param exp An
-/// expression that must be convertible to \c bool.  If it is \c
-/// false, then an assertion is raised. The concrete behaviour depends
-/// on the settings of the assertion system.  \param msg A <tt>const
-/// char*</tt> parameter, which can be used to provide information
-/// about the circumstances of the failed assertion.
+/// Macro for assertion with customizable message.
+/// \param exp An expression that must be convertible to \c bool.  If it is \c
+/// false, then an assertion is raised. The concrete behaviour depends on the
+/// settings of the assertion system.
+/// \param msg A <tt>const char*</tt> parameter, which can be used to provide
+/// information about the circumstances of the failed assertion.
 ///
 /// The assertions are enabled in the default behaviour.
@@ -138,15 +128,10 @@
 /// The checking is also disabled when the standard macro \c NDEBUG is defined.
 ///
-/// The LEMON assertion system has a wide range of customization
-/// properties. As a default behaviour the failed assertion prints a
-/// short log message to the standard error and aborts the execution.
-///
-/// The following modes can be used in the assertion system:
-///
-/// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
-///   message to the standard error and continues the execution.
-/// - \c LEMON_ASSERT_ABORT This mode is similar to the \c
-///   LEMON_ASSERT_LOG, but it aborts the program. It is the default
-///   behaviour.
+/// As a default behaviour the failed assertion prints a short log message to
+/// the standard error and aborts the execution.
+///
+/// However, the following modes can be used in the assertion system:
+/// - \c LEMON_ASSERT_ABORT The failed assertion prints a short log message to
+///   the standard error and aborts the program. It is the default behaviour.
 /// - \c LEMON_ASSERT_CUSTOM The user can define own assertion handler
 ///   function.
@@ -176,20 +161,4 @@
 /// \ingroup exceptions
 ///
-/// \brief Macro for mark not yet implemented features.
-///
-/// Macro for mark not yet implemented features and outstanding bugs.
-/// It is close to be the shortcut of the following code:
-/// \code
-///   LEMON_ASSERT(false, msg);
-/// \endcode
-///
-/// \see LEMON_ASSERT
-#  define LEMON_FIXME(msg)                                              \
-  (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,        \
-                        ::lemon::_assert_bits::cstringify(msg),         \
-                        static_cast<const char*>(0)))
-
-/// \ingroup exceptions
-///
 /// \brief Macro for internal assertions
 ///
@@ -223,5 +192,4 @@
 #  ifndef LEMON_ASSERT_HANDLER
 #    define LEMON_ASSERT(exp, msg)  (static_cast<void>(0))
-#    define LEMON_FIXME(msg) (static_cast<void>(0))
 #    define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
 #  else
@@ -232,9 +200,4 @@
                              ::lemon::_assert_bits::cstringify(msg),    \
                              #exp), 0)))
-#    define LEMON_FIXME(msg)                                            \
-       (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME,   \
-                             ::lemon::_assert_bits::cstringify(msg),    \
-                             static_cast<const char*>(0)))
-
 #    if LEMON_ENABLE_DEBUG
 #      define LEMON_DEBUG(exp, msg)                                     \
Index: lemon/bfs.h
===================================================================
--- lemon/bfs.h	(revision 252)
+++ lemon/bfs.h	(revision 341)
@@ -29,4 +29,5 @@
 #include <lemon/error.h>
 #include <lemon/maps.h>
+#include <lemon/path.h>
 
 namespace lemon {
@@ -49,10 +50,9 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
-    ///Instantiates a \ref PredMap.
-
-    ///This function instantiates a \ref PredMap.
+    ///Instantiates a PredMap.
+
+    ///This function instantiates a PredMap.  
     ///\param g is the digraph, to which we would like to define the
-    ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient to initialize
+    ///PredMap.
     static PredMap *createPredMap(const Digraph &g)
     {
@@ -64,11 +64,10 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a \ref ProcessedMap.
-
-    ///This function instantiates a \ref ProcessedMap.
+    ///Instantiates a ProcessedMap.
+
+    ///This function instantiates a ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap
+    ///we would like to define the ProcessedMap
 #ifdef DOXYGEN
     static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -82,12 +81,11 @@
     ///The type of the map that indicates which nodes are reached.
 
-    ///The type of the map that indicates which nodes are reached.
-    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
+    ///The type of the map that indicates which nodes are reached.///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a \ref ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
+    ///Instantiates a ReachedMap.
+
+    ///This function instantiates a ReachedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
+    ///we would like to define the ReachedMap.
     static ReachedMap *createReachedMap(const Digraph &g)
     {
@@ -100,9 +98,9 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     typedef typename Digraph::template NodeMap<int> DistMap;
-    ///Instantiates a \ref DistMap.
-
-    ///This function instantiates a \ref DistMap.
+    ///Instantiates a DistMap.
+
+    ///This function instantiates a DistMap.
     ///\param g is the digraph, to which we would like to define the
-    ///\ref DistMap.
+    ///DistMap.
     static DistMap *createDistMap(const Digraph &g)
     {
@@ -116,5 +114,5 @@
   ///This class provides an efficient implementation of the %BFS algorithm.
   ///
-  ///There is also a \ref bfs() "function type interface" for the BFS
+  ///There is also a \ref bfs() "function-type interface" for the BFS
   ///algorithm, which is convenient in the simplier cases and it can be
   ///used easier.
@@ -137,14 +135,4 @@
   class Bfs {
   public:
-    ///\ref Exception for uninitialized parameters.
-
-    ///This error represents problems in the initialization of the
-    ///parameters of the algorithm.
-    class UninitializedParameter : public lemon::UninitializedParameter {
-    public:
-      virtual const char* what() const throw() {
-        return "lemon::Bfs::UninitializedParameter";
-      }
-    };
 
     ///The type of the digraph the algorithm runs on.
@@ -196,6 +184,5 @@
     int _curr_dist;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps()
     {
@@ -231,92 +218,96 @@
 
     template <class T>
-    struct DefPredMapTraits : public Traits {
+    struct SetPredMapTraits : public Traits {
       typedef T PredMap;
       static PredMap *createPredMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "PredMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref PredMap type.
+    ///PredMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref PredMap type.
+    ///PredMap type.
     template <class T>
-    struct DefPredMap : public Bfs< Digraph, DefPredMapTraits<T> > {
-      typedef Bfs< Digraph, DefPredMapTraits<T> > Create;
+    struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
+      typedef Bfs< Digraph, SetPredMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefDistMapTraits : public Traits {
+    struct SetDistMapTraits : public Traits {
       typedef T DistMap;
       static DistMap *createDistMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "DistMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref DistMap type.
+    ///DistMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref DistMap type.
+    ///DistMap type.
     template <class T>
-    struct DefDistMap : public Bfs< Digraph, DefDistMapTraits<T> > {
-      typedef Bfs< Digraph, DefDistMapTraits<T> > Create;
+    struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
+      typedef Bfs< Digraph, SetDistMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefReachedMapTraits : public Traits {
+    struct SetReachedMapTraits : public Traits {
       typedef T ReachedMap;
       static ReachedMap *createReachedMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "ReachedMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ReachedMap type.
+    ///ReachedMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ReachedMap type.
+    ///ReachedMap type.
     template <class T>
-    struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits<T> > {
-      typedef Bfs< Digraph, DefReachedMapTraits<T> > Create;
+    struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
+      typedef Bfs< Digraph, SetReachedMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefProcessedMapTraits : public Traits {
+    struct SetProcessedMapTraits : public Traits {
       typedef T ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "ProcessedMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type.
+    ///ProcessedMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type.
+    ///ProcessedMap type.
     template <class T>
-    struct DefProcessedMap : public Bfs< Digraph, DefProcessedMapTraits<T> > {
-      typedef Bfs< Digraph, DefProcessedMapTraits<T> > Create;
+    struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
+      typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create;
     };
 
-    struct DefDigraphProcessedMapTraits : public Traits {
+    struct SetStandardProcessedMapTraits : public Traits {
       typedef typename Digraph::template NodeMap<bool> ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &g)
       {
         return new ProcessedMap(g);
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
+    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
+    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     ///If you don't set it explicitly, it will be automatically allocated.
-    template <class T>
-    struct DefProcessedMapToBeDefaultMap :
-      public Bfs< Digraph, DefDigraphProcessedMapTraits> {
-      typedef Bfs< Digraph, DefDigraphProcessedMapTraits> Create;
+    struct SetStandardProcessedMap :
+      public Bfs< Digraph, SetStandardProcessedMapTraits > {
+      typedef Bfs< Digraph, SetStandardProcessedMapTraits > Create;
     };
 
@@ -608,9 +599,9 @@
     ///
     ///This method runs the %BFS algorithm from the root node(s)
-    ///in order to compute the shortest path to \c dest.
+    ///in order to compute the shortest path to \c t.
     ///
     ///The algorithm computes
-    ///- the shortest path to \c dest,
-    ///- the distance of \c dest from the root(s).
+    ///- the shortest path to \c t,
+    ///- the distance of \c t from the root(s).
     ///
     ///\pre init() must be called and at least one root node should be
@@ -624,8 +615,8 @@
     ///  }
     ///\endcode
-    void start(Node dest)
+    void start(Node t)
     {
       bool reach = false;
-      while ( !emptyQueue() && !reach ) processNextNode(dest, reach);
+      while ( !emptyQueue() && !reach ) processNextNode(t, reach);
     }
 
@@ -665,5 +656,5 @@
     }
 
-    ///Runs the algorithm from the given node.
+    ///Runs the algorithm from the given source node.
 
     ///This method runs the %BFS algorithm from node \c s
@@ -689,8 +680,8 @@
 
     ///This method runs the %BFS algorithm from node \c s
-    ///in order to compute the shortest path to \c t.
-    ///
-    ///\return The length of the shortest <tt>s</tt>--<tt>t</tt> path,
-    ///if \c t is reachable form \c s, \c 0 otherwise.
+    ///in order to compute the shortest path to node \c t
+    ///(it stops searching when \c t is processed).
+    ///
+    ///\return \c true if \c t is reachable form \c s.
     ///
     ///\note Apart from the return value, <tt>b.run(s,t)</tt> is just a
@@ -701,9 +692,9 @@
     ///  b.start(t);
     ///\endcode
-    int run(Node s,Node t) {
+    bool run(Node s,Node t) {
       init();
       addSource(s);
       start(t);
-      return reached(t) ? _curr_dist : 0;
+      return reached(t);
     }
 
@@ -843,18 +834,13 @@
     ///arcs of the shortest paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    typedef NullMap<typename Digraph::Node,typename Digraph::Arc> PredMap;
-    ///Instantiates a \ref PredMap.
-
-    ///This function instantiates a \ref PredMap.
+    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+    ///Instantiates a PredMap.
+
+    ///This function instantiates a PredMap.
     ///\param g is the digraph, to which we would like to define the
-    ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient to initialize
-#ifdef DOXYGEN
+    ///PredMap.
     static PredMap *createPredMap(const Digraph &g)
-#else
-    static PredMap *createPredMap(const Digraph &)
-#endif
-    {
-      return new PredMap();
+    {
+      return new PredMap(g);
     }
 
@@ -863,10 +849,11 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
+    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a \ref ProcessedMap.
-
-    ///This function instantiates a \ref ProcessedMap.
+    ///Instantiates a ProcessedMap.
+
+    ///This function instantiates a ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap.
+    ///we would like to define the ProcessedMap.
 #ifdef DOXYGEN
     static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -883,9 +870,9 @@
     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a \ref ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
+    ///Instantiates a ReachedMap.
+
+    ///This function instantiates a ReachedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
+    ///we would like to define the ReachedMap.
     static ReachedMap *createReachedMap(const Digraph &g)
     {
@@ -897,22 +884,23 @@
     ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef NullMap<typename Digraph::Node,int> DistMap;
-    ///Instantiates a \ref DistMap.
-
-    ///This function instantiates a \ref DistMap.
+    typedef typename Digraph::template NodeMap<int> DistMap;
+    ///Instantiates a DistMap.
+
+    ///This function instantiates a DistMap.
     ///\param g is the digraph, to which we would like to define
-    ///the \ref DistMap
-#ifdef DOXYGEN
+    ///the DistMap
     static DistMap *createDistMap(const Digraph &g)
-#else
-    static DistMap *createDistMap(const Digraph &)
-#endif
-    {
-      return new DistMap();
-    }
+    {
+      return new DistMap(g);
+    }
+
+    ///The type of the shortest paths.
+
+    ///The type of the shortest paths.
+    ///It must meet the \ref concepts::Path "Path" concept.
+    typedef lemon::Path<Digraph> Path;
   };
 
-  /// Default traits class used by \ref BfsWizard
+  /// Default traits class used by BfsWizard
 
   /// To make it easier to use Bfs algorithm
@@ -941,6 +929,8 @@
     //Pointer to the map of distances.
     void *_dist;
-    //Pointer to the source node.
-    Node _source;
+    //Pointer to the shortest path to the target node.
+    void *_path;
+    //Pointer to the distance of the target node.
+    int *_di;
 
     public:
@@ -948,42 +938,28 @@
 
     /// This constructor does not require parameters, therefore it initiates
-    /// all of the attributes to default values (0, INVALID).
+    /// all of the attributes to \c 0.
     BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
-                      _dist(0), _source(INVALID) {}
+                      _dist(0), _path(0), _di(0) {}
 
     /// Constructor.
 
-    /// This constructor requires some parameters,
-    /// listed in the parameters list.
-    /// Others are initiated to 0.
+    /// This constructor requires one parameter,
+    /// others are initiated to \c 0.
     /// \param g The digraph the algorithm runs on.
-    /// \param s The source node.
-    BfsWizardBase(const GR &g, Node s=INVALID) :
+    BfsWizardBase(const GR &g) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
-      _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {}
+      _reached(0), _processed(0), _pred(0), _dist(0),  _path(0), _di(0) {}
 
   };
 
-  /// Auxiliary class for the function type interface of BFS algorithm.
-
-  /// This auxiliary class is created to implement the function type
-  /// interface of \ref Bfs algorithm. It uses the functions and features
-  /// of the plain \ref Bfs, but it is much simpler to use it.
-  /// It should only be used through the \ref bfs() function, which makes
-  /// it easier to use the algorithm.
+  /// Auxiliary class for the function-type interface of BFS algorithm.
+
+  /// This auxiliary class is created to implement the
+  /// \ref bfs() "function-type interface" of \ref Bfs algorithm.
+  /// It does not have own \ref run() method, it uses the functions
+  /// and features of the plain \ref Bfs.
   ///
-  /// Simplicity means that the way to change the types defined
-  /// in the traits class is based on functions that returns the new class
-  /// and not on templatable built-in classes.
-  /// When using the plain \ref Bfs
-  /// the new class with the modified type comes from
-  /// the original class by using the ::
-  /// operator. In the case of \ref BfsWizard only
-  /// a function have to be called, and it will
-  /// return the needed class.
-  ///
-  /// It does not have own \ref run() method. When its \ref run() method
-  /// is called, it initiates a plain \ref Bfs object, and calls the
-  /// \ref Bfs::run() method of it.
+  /// This class should only be used through the \ref bfs() function,
+  /// which makes it easier to use the algorithm.
   template<class TR>
   class BfsWizard : public TR
@@ -1008,4 +984,6 @@
     ///\brief The type of the map that indicates which nodes are processed.
     typedef typename TR::ProcessedMap ProcessedMap;
+    ///The type of the shortest paths
+    typedef typename TR::Path Path;
 
   public:
@@ -1018,6 +996,7 @@
     /// Constructor that requires parameters.
     /// These parameters will be the default values for the traits class.
-    BfsWizard(const Digraph &g, Node s=INVALID) :
-      TR(g,s) {}
+    /// \param g The digraph the algorithm runs on.
+    BfsWizard(const Digraph &g) :
+      TR(g) {}
 
     ///Copy constructor
@@ -1026,129 +1005,176 @@
     ~BfsWizard() {}
 
-    ///Runs BFS algorithm from a source node.
-
-    ///Runs BFS algorithm from a source node.
-    ///The node can be given with the \ref source() function.
+    ///Runs BFS algorithm from the given source node.
+
+    ///This method runs BFS algorithm from node \c s
+    ///in order to compute the shortest path to each node.
+    void run(Node s)
+    {
+      Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
+      if (Base::_pred)
+        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if (Base::_dist)
+        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      if (Base::_reached)
+        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
+      if (Base::_processed)
+        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      if (s!=INVALID)
+        alg.run(s);
+      else
+        alg.run();
+    }
+
+    ///Finds the shortest path between \c s and \c t.
+
+    ///This method runs BFS algorithm from node \c s
+    ///in order to compute the shortest path to node \c t
+    ///(it stops searching when \c t is processed).
+    ///
+    ///\return \c true if \c t is reachable form \c s.
+    bool run(Node s, Node t)
+    {
+      Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
+      if (Base::_pred)
+        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if (Base::_dist)
+        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      if (Base::_reached)
+        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
+      if (Base::_processed)
+        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      alg.run(s,t);
+      if (Base::_path)
+        *reinterpret_cast<Path*>(Base::_path) = alg.path(t);
+      if (Base::_di)
+        *Base::_di = alg.dist(t);
+      return alg.reached(t);
+    }
+
+    ///Runs BFS algorithm to visit all nodes in the digraph.
+
+    ///This method runs BFS algorithm in order to compute
+    ///the shortest path to each node.
     void run()
     {
-      if(Base::_source==INVALID) throw UninitializedParameter();
-      Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
-      if(Base::_reached)
-        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
-      if(Base::_processed)
-        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
-      if(Base::_pred)
-        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
-      if(Base::_dist)
-        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
-      alg.run(Base::_source);
-    }
-
-    ///Runs BFS algorithm from the given node.
-
-    ///Runs BFS algorithm from the given node.
-    ///\param s is the given source.
-    void run(Node s)
-    {
-      Base::_source=s;
-      run();
-    }
-
-    /// Sets the source node, from which the Bfs algorithm runs.
-
-    /// Sets the source node, from which the Bfs algorithm runs.
-    /// \param s is the source node.
-    BfsWizard<TR> &source(Node s)
-    {
-      Base::_source=s;
-      return *this;
+      run(INVALID);
     }
 
     template<class T>
-    struct DefPredMapBase : public Base {
+    struct SetPredMapBase : public Base {
       typedef T PredMap;
       static PredMap *createPredMap(const Digraph &) { return 0; };
-      DefPredMapBase(const TR &b) : TR(b) {}
+      SetPredMapBase(const TR &b) : TR(b) {}
     };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref PredMap object.
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///for setting \ref PredMap object.
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting PredMap object.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for setting PredMap object.
     template<class T>
-    BfsWizard<DefPredMapBase<T> > predMap(const T &t)
+    BfsWizard<SetPredMapBase<T> > predMap(const T &t)
     {
       Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return BfsWizard<DefPredMapBase<T> >(*this);
+      return BfsWizard<SetPredMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefReachedMapBase : public Base {
+    struct SetReachedMapBase : public Base {
       typedef T ReachedMap;
       static ReachedMap *createReachedMap(const Digraph &) { return 0; };
-      DefReachedMapBase(const TR &b) : TR(b) {}
+      SetReachedMapBase(const TR &b) : TR(b) {}
     };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref ReachedMap object.
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///for setting \ref ReachedMap object.
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting ReachedMap object.
+    ///
+    /// \ref named-func-param "Named parameter"
+    ///for setting ReachedMap object.
     template<class T>
-    BfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
+    BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     {
       Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return BfsWizard<DefReachedMapBase<T> >(*this);
+      return BfsWizard<SetReachedMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefProcessedMapBase : public Base {
+    struct SetDistMapBase : public Base {
+      typedef T DistMap;
+      static DistMap *createDistMap(const Digraph &) { return 0; };
+      SetDistMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting DistMap object.
+    ///
+    /// \ref named-func-param "Named parameter"
+    ///for setting DistMap object.
+    template<class T>
+    BfsWizard<SetDistMapBase<T> > distMap(const T &t)
+    {
+      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return BfsWizard<SetDistMapBase<T> >(*this);
+    }
+
+    template<class T>
+    struct SetProcessedMapBase : public Base {
       typedef T ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
-      DefProcessedMapBase(const TR &b) : TR(b) {}
+      SetProcessedMapBase(const TR &b) : TR(b) {}
     };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting ProcessedMap object.
+    ///
+    /// \ref named-func-param "Named parameter"
+    ///for setting ProcessedMap object.
     template<class T>
-    BfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
+    BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     {
       Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return BfsWizard<DefProcessedMapBase<T> >(*this);
+      return BfsWizard<SetProcessedMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefDistMapBase : public Base {
-      typedef T DistMap;
-      static DistMap *createDistMap(const Digraph &) { return 0; };
-      DefDistMapBase(const TR &b) : TR(b) {}
+    struct SetPathBase : public Base {
+      typedef T Path;
+      SetPathBase(const TR &b) : TR(b) {}
     };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref DistMap object.
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///for setting \ref DistMap object.
+    ///\brief \ref named-func-param "Named parameter"
+    ///for getting the shortest path to the target node.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for getting the shortest path to the target node.
     template<class T>
-    BfsWizard<DefDistMapBase<T> > distMap(const T &t)
-    {
-      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return BfsWizard<DefDistMapBase<T> >(*this);
+    BfsWizard<SetPathBase<T> > path(const T &t)
+    {
+      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return BfsWizard<SetPathBase<T> >(*this);
+    }
+
+    ///\brief \ref named-func-param "Named parameter"
+    ///for getting the distance of the target node.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for getting the distance of the target node.
+    BfsWizard dist(const int &d)
+    {
+      Base::_di=const_cast<int*>(&d);
+      return *this;
     }
 
   };
 
-  ///Function type interface for Bfs algorithm.
+  ///Function-type interface for BFS algorithm.
 
   /// \ingroup search
-  ///Function type interface for Bfs algorithm.
+  ///Function-type interface for BFS algorithm.
   ///
-  ///This function also has several
-  ///\ref named-templ-func-param "named parameters",
+  ///This function also has several \ref named-func-param "named parameters",
   ///they are declared as the members of class \ref BfsWizard.
-  ///The following
-  ///example shows how to use these parameters.
+  ///The following examples show how to use these parameters.
   ///\code
-  ///  bfs(g,source).predMap(preds).run();
+  ///  // Compute shortest path from node s to each node
+  ///  bfs(g).predMap(preds).distMap(dists).run(s);
+  ///
+  ///  // Compute shortest path from s to t
+  ///  bool reached = bfs(g).path(p).dist(d).run(s,t);
   ///\endcode
   ///\warning Don't forget to put the \ref BfsWizard::run() "run()"
@@ -1158,7 +1184,7 @@
   template<class GR>
   BfsWizard<BfsWizardBase<GR> >
-  bfs(const GR &g,typename GR::Node s=INVALID)
+  bfs(const GR &digraph)
   {
-    return BfsWizard<BfsWizardBase<GR> >(g,s);
+    return BfsWizard<BfsWizardBase<GR> >(digraph);
   }
 
@@ -1241,9 +1267,9 @@
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
 
-    /// \brief Instantiates a \ref ReachedMap.
-    ///
-    /// This function instantiates a \ref ReachedMap.
+    /// \brief Instantiates a ReachedMap.
+    ///
+    /// This function instantiates a ReachedMap.
     /// \param digraph is the digraph, to which
-    /// we would like to define the \ref ReachedMap.
+    /// we would like to define the ReachedMap.
     static ReachedMap *createReachedMap(const Digraph &digraph) {
       return new ReachedMap(digraph);
@@ -1286,20 +1312,8 @@
   template <typename _Digraph = ListDigraph,
             typename _Visitor = BfsVisitor<_Digraph>,
-            typename _Traits = BfsDefaultTraits<_Digraph> >
+            typename _Traits = BfsVisitDefaultTraits<_Digraph> >
 #endif
   class BfsVisit {
   public:
-
-    /// \brief \ref Exception for uninitialized parameters.
-    ///
-    /// This error represents problems in the initialization
-    /// of the parameters of the algorithm.
-    class UninitializedParameter : public lemon::UninitializedParameter {
-    public:
-      virtual const char* what() const throw()
-      {
-        return "lemon::BfsVisit::UninitializedParameter";
-      }
-    };
 
     ///The traits class.
@@ -1334,6 +1348,5 @@
     int _list_front, _list_back;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps() {
       if(!_reached) {
@@ -1355,8 +1368,9 @@
     ///@{
     template <class T>
-    struct DefReachedMapTraits : public Traits {
+    struct SetReachedMapTraits : public Traits {
       typedef T ReachedMap;
       static ReachedMap *createReachedMap(const Digraph &digraph) {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "ReachedMap is not initialized");
+        return 0; // ignore warnings
       }
     };
@@ -1366,7 +1380,7 @@
     /// \ref named-templ-param "Named parameter" for setting ReachedMap type.
     template <class T>
-    struct DefReachedMap : public BfsVisit< Digraph, Visitor,
-                                            DefReachedMapTraits<T> > {
-      typedef BfsVisit< Digraph, Visitor, DefReachedMapTraits<T> > Create;
+    struct SetReachedMap : public BfsVisit< Digraph, Visitor,
+                                            SetReachedMapTraits<T> > {
+      typedef BfsVisit< Digraph, Visitor, SetReachedMapTraits<T> > Create;
     };
     ///@}
@@ -1585,9 +1599,9 @@
     ///
     /// This method runs the %BFS algorithm from the root node(s)
-    /// in order to compute the shortest path to \c dest.
+    /// in order to compute the shortest path to \c t.
     ///
     /// The algorithm computes
-    /// - the shortest path to \c dest,
-    /// - the distance of \c dest from the root(s).
+    /// - the shortest path to \c t,
+    /// - the distance of \c t from the root(s).
     ///
     /// \pre init() must be called and at least one root node should be
@@ -1601,7 +1615,7 @@
     ///   }
     /// \endcode
-    void start(Node dest) {
+    void start(Node t) {
       bool reach = false;
-      while ( !emptyQueue() && !reach ) processNextNode(dest, reach);
+      while ( !emptyQueue() && !reach ) processNextNode(t, reach);
     }
 
@@ -1641,5 +1655,5 @@
     }
 
-    /// \brief Runs the algorithm from the given node.
+    /// \brief Runs the algorithm from the given source node.
     ///
     /// This method runs the %BFS algorithm from node \c s
@@ -1660,4 +1674,26 @@
       addSource(s);
       start();
+    }
+
+    /// \brief Finds the shortest path between \c s and \c t.
+    ///
+    /// This method runs the %BFS algorithm from node \c s
+    /// in order to compute the shortest path to node \c t
+    /// (it stops searching when \c t is processed).
+    ///
+    /// \return \c true if \c t is reachable form \c s.
+    ///
+    /// \note Apart from the return value, <tt>b.run(s,t)</tt> is just a
+    /// shortcut of the following code.
+    ///\code
+    ///   b.init();
+    ///   b.addSource(s);
+    ///   b.start(t);
+    ///\endcode
+    bool run(Node s,Node t) {
+      init();
+      addSource(s);
+      start(t);
+      return reached(t);
     }
 
Index: lemon/bits/alteration_notifier.h
===================================================================
--- lemon/bits/alteration_notifier.h	(revision 236)
+++ lemon/bits/alteration_notifier.h	(revision 314)
@@ -25,74 +25,73 @@
 #include <lemon/core.h>
 
-///\ingroup graphbits
-///\file
-///\brief Observer notifier for graph alteration observers.
+//\ingroup graphbits
+//\file
+//\brief Observer notifier for graph alteration observers.
 
 namespace lemon {
 
-  /// \ingroup graphbits
-  ///
-  /// \brief Notifier class to notify observes about alterations in
-  /// a container.
-  ///
-  /// The simple graph's can be refered as two containers, one node container
-  /// and one edge container. But they are not standard containers they
-  /// does not store values directly they are just key continars for more
-  /// value containers which are the node and edge maps.
-  ///
-  /// The graph's node and edge sets can be changed as we add or erase
-  /// nodes and edges in the graph. LEMON would like to handle easily
-  /// that the node and edge maps should contain values for all nodes or
-  /// edges. If we want to check on every indicing if the map contains
-  /// the current indicing key that cause a drawback in the performance
-  /// in the library. We use another solution we notify all maps about
-  /// an alteration in the graph, which cause only drawback on the
-  /// alteration of the graph.
-  ///
-  /// This class provides an interface to the container. The \e first() and \e
-  /// next() member functions make possible to iterate on the keys of the
-  /// container. The \e id() function returns an integer id for each key.
-  /// The \e maxId() function gives back an upper bound of the ids.
-  ///
-  /// For the proper functonality of this class, we should notify it
-  /// about each alteration in the container. The alterations have four type
-  /// as \e add(), \e erase(), \e build() and \e clear(). The \e add() and
-  /// \e erase() signals that only one or few items added or erased to or
-  /// from the graph. If all items are erased from the graph or from an empty
-  /// graph a new graph is builded then it can be signaled with the
-  /// clear() and build() members. Important rule that if we erase items
-  /// from graph we should first signal the alteration and after that erase
-  /// them from the container, on the other way on item addition we should
-  /// first extend the container and just after that signal the alteration.
-  ///
-  /// The alteration can be observed with a class inherited from the
-  /// \e ObserverBase nested class. The signals can be handled with
-  /// overriding the virtual functions defined in the base class.  The
-  /// observer base can be attached to the notifier with the
-  /// \e attach() member and can be detached with detach() function. The
-  /// alteration handlers should not call any function which signals
-  /// an other alteration in the same notifier and should not
-  /// detach any observer from the notifier.
-  ///
-  /// Alteration observers try to be exception safe. If an \e add() or
-  /// a \e clear() function throws an exception then the remaining
-  /// observeres will not be notified and the fulfilled additions will
-  /// be rolled back by calling the \e erase() or \e clear()
-  /// functions. Thence the \e erase() and \e clear() should not throw
-  /// exception. Actullay, it can be throw only
-  /// \ref AlterationObserver::ImmediateDetach ImmediateDetach
-  /// exception which detach the observer from the notifier.
-  ///
-  /// There are some place when the alteration observing is not completly
-  /// reliable. If we want to carry out the node degree in the graph
-  /// as in the \ref InDegMap and we use the reverseEdge that cause
-  /// unreliable functionality. Because the alteration observing signals
-  /// only erasing and adding but not the reversing it will stores bad
-  /// degrees. The sub graph adaptors cannot signal the alterations because
-  /// just a setting in the filter map can modify the graph and this cannot
-  /// be watched in any way.
-  ///
-  /// \param _Container The container which is observed.
-  /// \param _Item The item type which is obserbved.
+  // \ingroup graphbits
+  //
+  // \brief Notifier class to notify observes about alterations in
+  // a container.
+  //
+  // The simple graph's can be refered as two containers, one node container
+  // and one edge container. But they are not standard containers they
+  // does not store values directly they are just key continars for more
+  // value containers which are the node and edge maps.
+  //
+  // The graph's node and edge sets can be changed as we add or erase
+  // nodes and edges in the graph. LEMON would like to handle easily
+  // that the node and edge maps should contain values for all nodes or
+  // edges. If we want to check on every indicing if the map contains
+  // the current indicing key that cause a drawback in the performance
+  // in the library. We use another solution we notify all maps about
+  // an alteration in the graph, which cause only drawback on the
+  // alteration of the graph.
+  //
+  // This class provides an interface to the container. The \e first() and \e
+  // next() member functions make possible to iterate on the keys of the
+  // container. The \e id() function returns an integer id for each key.
+  // The \e maxId() function gives back an upper bound of the ids.
+  //
+  // For the proper functonality of this class, we should notify it
+  // about each alteration in the container. The alterations have four type
+  // as \e add(), \e erase(), \e build() and \e clear(). The \e add() and
+  // \e erase() signals that only one or few items added or erased to or
+  // from the graph. If all items are erased from the graph or from an empty
+  // graph a new graph is builded then it can be signaled with the
+  // clear() and build() members. Important rule that if we erase items
+  // from graph we should first signal the alteration and after that erase
+  // them from the container, on the other way on item addition we should
+  // first extend the container and just after that signal the alteration.
+  //
+  // The alteration can be observed with a class inherited from the
+  // \e ObserverBase nested class. The signals can be handled with
+  // overriding the virtual functions defined in the base class.  The
+  // observer base can be attached to the notifier with the
+  // \e attach() member and can be detached with detach() function. The
+  // alteration handlers should not call any function which signals
+  // an other alteration in the same notifier and should not
+  // detach any observer from the notifier.
+  //
+  // Alteration observers try to be exception safe. If an \e add() or
+  // a \e clear() function throws an exception then the remaining
+  // observeres will not be notified and the fulfilled additions will
+  // be rolled back by calling the \e erase() or \e clear()
+  // functions. Thence the \e erase() and \e clear() should not throw
+  // exception. Actullay, it can be throw only \ref ImmediateDetach
+  // exception which detach the observer from the notifier.
+  //
+  // There are some place when the alteration observing is not completly
+  // reliable. If we want to carry out the node degree in the graph
+  // as in the \ref InDegMap and we use the reverseEdge that cause
+  // unreliable functionality. Because the alteration observing signals
+  // only erasing and adding but not the reversing it will stores bad
+  // degrees. The sub graph adaptors cannot signal the alterations because
+  // just a setting in the filter map can modify the graph and this cannot
+  // be watched in any way.
+  //
+  // \param _Container The container which is observed.
+  // \param _Item The item type which is obserbved.
 
   template <typename _Container, typename _Item>
@@ -105,29 +104,28 @@
     typedef _Item Item;
 
-    /// \brief Exception which can be called from \e clear() and
-    /// \e erase().
-    ///
-    /// From the \e clear() and \e erase() function only this
-    /// exception is allowed to throw. The exception immediatly
-    /// detaches the current observer from the notifier. Because the
-    /// \e clear() and \e erase() should not throw other exceptions
-    /// it can be used to invalidate the observer.
+    // \brief Exception which can be called from \e clear() and
+    // \e erase().
+    //
+    // From the \e clear() and \e erase() function only this
+    // exception is allowed to throw. The exception immediatly
+    // detaches the current observer from the notifier. Because the
+    // \e clear() and \e erase() should not throw other exceptions
+    // it can be used to invalidate the observer.
     struct ImmediateDetach {};
 
-    /// \brief ObserverBase is the base class for the observers.
-    ///
-    /// ObserverBase is the abstract base class for the observers.
-    /// It will be notified about an item was inserted into or
-    /// erased from the graph.
-    ///
-    /// The observer interface contains some pure virtual functions
-    /// to override. The add() and erase() functions are
-    /// to notify the oberver when one item is added or
-    /// erased.
-    ///
-    /// The build() and clear() members are to notify the observer
-    /// about the container is built from an empty container or
-    /// is cleared to an empty container.
-
+    // \brief ObserverBase is the base class for the observers.
+    //
+    // ObserverBase is the abstract base class for the observers.
+    // It will be notified about an item was inserted into or
+    // erased from the graph.
+    //
+    // The observer interface contains some pure virtual functions
+    // to override. The add() and erase() functions are
+    // to notify the oberver when one item is added or
+    // erased.
+    //
+    // The build() and clear() members are to notify the observer
+    // about the container is built from an empty container or
+    // is cleared to an empty container.
     class ObserverBase {
     protected:
@@ -136,21 +134,20 @@
       friend class AlterationNotifier;
 
-      /// \brief Default constructor.
-      ///
-      /// Default constructor for ObserverBase.
-      ///
+      // \brief Default constructor.
+      //
+      // Default constructor for ObserverBase.
       ObserverBase() : _notifier(0) {}
 
-      /// \brief Constructor which attach the observer into notifier.
-      ///
-      /// Constructor which attach the observer into notifier.
+      // \brief Constructor which attach the observer into notifier.
+      //
+      // Constructor which attach the observer into notifier.
       ObserverBase(AlterationNotifier& nf) {
         attach(nf);
       }
 
-      /// \brief Constructor which attach the obserever to the same notifier.
-      ///
-      /// Constructor which attach the obserever to the same notifier as
-      /// the other observer is attached to.
+      // \brief Constructor which attach the obserever to the same notifier.
+      //
+      // Constructor which attach the obserever to the same notifier as
+      // the other observer is attached to.
       ObserverBase(const ObserverBase& copy) {
         if (copy.attached()) {
@@ -159,5 +156,5 @@
       }
 
-      /// \brief Destructor
+      // \brief Destructor
       virtual ~ObserverBase() {
         if (attached()) {
@@ -166,29 +163,26 @@
       }
 
-      /// \brief Attaches the observer into an AlterationNotifier.
-      ///
-      /// This member attaches the observer into an AlterationNotifier.
-      ///
+      // \brief Attaches the observer into an AlterationNotifier.
+      //
+      // This member attaches the observer into an AlterationNotifier.
       void attach(AlterationNotifier& nf) {
         nf.attach(*this);
       }
 
-      /// \brief Detaches the observer into an AlterationNotifier.
-      ///
-      /// This member detaches the observer from an AlterationNotifier.
-      ///
+      // \brief Detaches the observer into an AlterationNotifier.
+      //
+      // This member detaches the observer from an AlterationNotifier.
       void detach() {
         _notifier->detach(*this);
       }
 
-      /// \brief Gives back a pointer to the notifier which the map
-      /// attached into.
-      ///
-      /// This function gives back a pointer to the notifier which the map
-      /// attached into.
-      ///
+      // \brief Gives back a pointer to the notifier which the map
+      // attached into.
+      //
+      // This function gives back a pointer to the notifier which the map
+      // attached into.
       Notifier* notifier() const { return const_cast<Notifier*>(_notifier); }
 
-      /// Gives back true when the observer is attached into a notifier.
+      // Gives back true when the observer is attached into a notifier.
       bool attached() const { return _notifier != 0; }
 
@@ -202,51 +196,50 @@
       typename std::list<ObserverBase*>::iterator _index;
 
-      /// \brief The member function to notificate the observer about an
-      /// item is added to the container.
-      ///
-      /// The add() member function notificates the observer about an item
-      /// is added to the container. It have to be overrided in the
-      /// subclasses.
+      // \brief The member function to notificate the observer about an
+      // item is added to the container.
+      //
+      // The add() member function notificates the observer about an item
+      // is added to the container. It have to be overrided in the
+      // subclasses.
       virtual void add(const Item&) = 0;
 
-      /// \brief The member function to notificate the observer about
-      /// more item is added to the container.
-      ///
-      /// The add() member function notificates the observer about more item
-      /// is added to the container. It have to be overrided in the
-      /// subclasses.
+      // \brief The member function to notificate the observer about
+      // more item is added to the container.
+      //
+      // The add() member function notificates the observer about more item
+      // is added to the container. It have to be overrided in the
+      // subclasses.
       virtual void add(const std::vector<Item>& items) = 0;
 
-      /// \brief The member function to notificate the observer about an
-      /// item is erased from the container.
-      ///
-      /// The erase() member function notificates the observer about an
-      /// item is erased from the container. It have to be overrided in
-      /// the subclasses.
+      // \brief The member function to notificate the observer about an
+      // item is erased from the container.
+      //
+      // The erase() member function notificates the observer about an
+      // item is erased from the container. It have to be overrided in
+      // the subclasses.
       virtual void erase(const Item&) = 0;
 
-      /// \brief The member function to notificate the observer about
-      /// more item is erased from the container.
-      ///
-      /// The erase() member function notificates the observer about more item
-      /// is erased from the container. It have to be overrided in the
-      /// subclasses.
+      // \brief The member function to notificate the observer about
+      // more item is erased from the container.
+      //
+      // The erase() member function notificates the observer about more item
+      // is erased from the container. It have to be overrided in the
+      // subclasses.
       virtual void erase(const std::vector<Item>& items) = 0;
 
-      /// \brief The member function to notificate the observer about the
-      /// container is built.
-      ///
-      /// The build() member function notificates the observer about the
-      /// container is built from an empty container. It have to be
-      /// overrided in the subclasses.
-
+      // \brief The member function to notificate the observer about the
+      // container is built.
+      //
+      // The build() member function notificates the observer about the
+      // container is built from an empty container. It have to be
+      // overrided in the subclasses.
       virtual void build() = 0;
 
-      /// \brief The member function to notificate the observer about all
-      /// items are erased from the container.
-      ///
-      /// The clear() member function notificates the observer about all
-      /// items are erased from the container. It have to be overrided in
-      /// the subclasses.
+      // \brief The member function to notificate the observer about all
+      // items are erased from the container.
+      //
+      // The clear() member function notificates the observer about all
+      // items are erased from the container. It have to be overrided in
+      // the subclasses.
       virtual void clear() = 0;
 
@@ -263,29 +256,28 @@
   public:
 
-    /// \brief Default constructor.
-    ///
-    /// The default constructor of the AlterationNotifier.
-    /// It creates an empty notifier.
+    // \brief Default constructor.
+    //
+    // The default constructor of the AlterationNotifier.
+    // It creates an empty notifier.
     AlterationNotifier()
       : container(0) {}
 
-    /// \brief Constructor.
-    ///
-    /// Constructor with the observed container parameter.
+    // \brief Constructor.
+    //
+    // Constructor with the observed container parameter.
     AlterationNotifier(const Container& _container)
       : container(&_container) {}
 
-    /// \brief Copy Constructor of the AlterationNotifier.
-    ///
-    /// Copy constructor of the AlterationNotifier.
-    /// It creates only an empty notifier because the copiable
-    /// notifier's observers have to be registered still into that notifier.
+    // \brief Copy Constructor of the AlterationNotifier.
+    //
+    // Copy constructor of the AlterationNotifier.
+    // It creates only an empty notifier because the copiable
+    // notifier's observers have to be registered still into that notifier.
     AlterationNotifier(const AlterationNotifier& _notifier)
       : container(_notifier.container) {}
 
-    /// \brief Destructor.
-    ///
-    /// Destructor of the AlterationNotifier.
-    ///
+    // \brief Destructor.
+    //
+    // Destructor of the AlterationNotifier.
     ~AlterationNotifier() {
       typename Observers::iterator it;
@@ -295,7 +287,7 @@
     }
 
-    /// \brief Sets the container.
-    ///
-    /// Sets the container.
+    // \brief Sets the container.
+    //
+    // Sets the container.
     void setContainer(const Container& _container) {
       container = &_container;
@@ -308,32 +300,30 @@
   public:
 
-
-
-    /// \brief First item in the container.
-    ///
-    /// Returns the first item in the container. It is
-    /// for start the iteration on the container.
+    // \brief First item in the container.
+    //
+    // Returns the first item in the container. It is
+    // for start the iteration on the container.
     void first(Item& item) const {
       container->first(item);
     }
 
-    /// \brief Next item in the container.
-    ///
-    /// Returns the next item in the container. It is
-    /// for iterate on the container.
+    // \brief Next item in the container.
+    //
+    // Returns the next item in the container. It is
+    // for iterate on the container.
     void next(Item& item) const {
       container->next(item);
     }
 
-    /// \brief Returns the id of the item.
-    ///
-    /// Returns the id of the item provided by the container.
+    // \brief Returns the id of the item.
+    //
+    // Returns the id of the item provided by the container.
     int id(const Item& item) const {
       return container->id(item);
     }
 
-    /// \brief Returns the maximum id of the container.
-    ///
-    /// Returns the maximum id of the container.
+    // \brief Returns the maximum id of the container.
+    //
+    // Returns the maximum id of the container.
     int maxId() const {
       return container->maxId(Item());
@@ -355,10 +345,9 @@
   public:
 
-    /// \brief Notifies all the registed observers about an item added to
-    /// the container.
-    ///
-    /// It notifies all the registed observers about an item added to
-    /// the container.
-    ///
+    // \brief Notifies all the registed observers about an item added to
+    // the container.
+    //
+    // It notifies all the registed observers about an item added to
+    // the container.
     void add(const Item& item) {
       typename Observers::reverse_iterator it;
@@ -376,10 +365,9 @@
     }
 
-    /// \brief Notifies all the registed observers about more item added to
-    /// the container.
-    ///
-    /// It notifies all the registed observers about more item added to
-    /// the container.
-    ///
+    // \brief Notifies all the registed observers about more item added to
+    // the container.
+    //
+    // It notifies all the registed observers about more item added to
+    // the container.
     void add(const std::vector<Item>& items) {
       typename Observers::reverse_iterator it;
@@ -397,10 +385,9 @@
     }
 
-    /// \brief Notifies all the registed observers about an item erased from
-    /// the container.
-    ///
-    /// It notifies all the registed observers about an item erased from
-    /// the container.
-    ///
+    // \brief Notifies all the registed observers about an item erased from
+    // the container.
+    //
+    // It notifies all the registed observers about an item erased from
+    // the container.
     void erase(const Item& item) throw() {
       typename Observers::iterator it = _observers.begin();
@@ -417,10 +404,9 @@
     }
 
-    /// \brief Notifies all the registed observers about more item erased
-    /// from the container.
-    ///
-    /// It notifies all the registed observers about more item erased from
-    /// the container.
-    ///
+    // \brief Notifies all the registed observers about more item erased
+    // from the container.
+    //
+    // It notifies all the registed observers about more item erased from
+    // the container.
     void erase(const std::vector<Item>& items) {
       typename Observers::iterator it = _observers.begin();
@@ -437,9 +423,9 @@
     }
 
-    /// \brief Notifies all the registed observers about the container is
-    /// built.
-    ///
-    /// Notifies all the registed observers about the container is built
-    /// from an empty container.
+    // \brief Notifies all the registed observers about the container is
+    // built.
+    //
+    // Notifies all the registed observers about the container is built
+    // from an empty container.
     void build() {
       typename Observers::reverse_iterator it;
@@ -457,9 +443,9 @@
     }
 
-    /// \brief Notifies all the registed observers about all items are
-    /// erased.
-    ///
-    /// Notifies all the registed observers about all items are erased
-    /// from the container.
+    // \brief Notifies all the registed observers about all items are
+    // erased.
+    //
+    // Notifies all the registed observers about all items are erased
+    // from the container.
     void clear() {
       typename Observers::iterator it = _observers.begin();
Index: lemon/bits/array_map.h
===================================================================
--- lemon/bits/array_map.h	(revision 209)
+++ lemon/bits/array_map.h	(revision 314)
@@ -27,46 +27,46 @@
 #include <lemon/concepts/maps.h>
 
-/// \ingroup graphbits
-/// \file
-/// \brief Graph map based on the array storage.
+// \ingroup graphbits
+// \file
+// \brief Graph map based on the array storage.
 
 namespace lemon {
 
-  /// \ingroup graphbits
-  ///
-  /// \brief Graph map based on the array storage.
-  ///
-  /// The ArrayMap template class is graph map structure what
-  /// automatically updates the map when a key is added to or erased from
-  /// the map. This map uses the allocators to implement
-  /// the container functionality.
-  ///
-  /// The template parameters are the Graph the current Item type and
-  /// the Value type of the map.
+  // \ingroup graphbits
+  //
+  // \brief Graph map based on the array storage.
+  //
+  // The ArrayMap template class is graph map structure what
+  // automatically updates the map when a key is added to or erased from
+  // the map. This map uses the allocators to implement
+  // the container functionality.
+  //
+  // The template parameters are the Graph the current Item type and
+  // the Value type of the map.
   template <typename _Graph, typename _Item, typename _Value>
   class ArrayMap
     : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
   public:
-    /// The graph type of the maps.
+    // The graph type of the maps.
     typedef _Graph Graph;
-    /// The item type of the map.
+    // The item type of the map.
     typedef _Item Item;
-    /// The reference map tag.
+    // The reference map tag.
     typedef True ReferenceMapTag;
 
-    /// The key type of the maps.
+    // The key type of the maps.
     typedef _Item Key;
-    /// The value type of the map.
+    // The value type of the map.
     typedef _Value Value;
 
-    /// The const reference type of the map.
+    // The const reference type of the map.
     typedef const _Value& ConstReference;
-    /// The reference type of the map.
+    // The reference type of the map.
     typedef _Value& Reference;
 
-    /// The notifier type.
+    // The notifier type.
     typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
 
-    /// The MapBase of the Map which imlements the core regisitry function.
+    // The MapBase of the Map which imlements the core regisitry function.
     typedef typename Notifier::ObserverBase Parent;
 
@@ -76,7 +76,7 @@
   public:
 
-    /// \brief Graph initialized map constructor.
-    ///
-    /// Graph initialized map constructor.
+    // \brief Graph initialized map constructor.
+    //
+    // Graph initialized map constructor.
     explicit ArrayMap(const Graph& graph) {
       Parent::attach(graph.notifier(Item()));
@@ -90,7 +90,7 @@
     }
 
-    /// \brief Constructor to use default value to initialize the map.
-    ///
-    /// It constructs a map and initialize all of the the map.
+    // \brief Constructor to use default value to initialize the map.
+    //
+    // It constructs a map and initialize all of the the map.
     ArrayMap(const Graph& graph, const Value& value) {
       Parent::attach(graph.notifier(Item()));
@@ -104,7 +104,8 @@
     }
 
-    /// \brief Constructor to copy a map of the same map type.
-    ///
-    /// Constructor to copy a map of the same map type.
+  private:
+    // \brief Constructor to copy a map of the same map type.
+    //
+    // Constructor to copy a map of the same map type.
     ArrayMap(const ArrayMap& copy) : Parent() {
       if (copy.attached()) {
@@ -122,11 +123,11 @@
     }
 
-    /// \brief Assign operator.
-    ///
-    /// This operator assigns for each item in the map the
-    /// value mapped to the same item in the copied map.
-    /// The parameter map should be indiced with the same
-    /// itemset because this assign operator does not change
-    /// the container of the map.
+    // \brief Assign operator.
+    //
+    // This operator assigns for each item in the map the
+    // value mapped to the same item in the copied map.
+    // The parameter map should be indiced with the same
+    // itemset because this assign operator does not change
+    // the container of the map.
     ArrayMap& operator=(const ArrayMap& cmap) {
       return operator=<ArrayMap>(cmap);
@@ -134,10 +135,10 @@
 
 
-    /// \brief Template assign operator.
-    ///
-    /// The given parameter should be conform to the ReadMap
-    /// concecpt and could be indiced by the current item set of
-    /// the NodeMap. In this case the value for each item
-    /// is assigned by the value of the given ReadMap.
+    // \brief Template assign operator.
+    //
+    // The given parameter should be conform to the ReadMap
+    // concecpt and could be indiced by the current item set of
+    // the NodeMap. In this case the value for each item
+    // is assigned by the value of the given ReadMap.
     template <typename CMap>
     ArrayMap& operator=(const CMap& cmap) {
@@ -151,7 +152,8 @@
     }
 
-    /// \brief The destructor of the map.
-    ///
-    /// The destructor of the map.
+  public:
+    // \brief The destructor of the map.
+    //
+    // The destructor of the map.
     virtual ~ArrayMap() {
       if (attached()) {
@@ -169,8 +171,8 @@
   public:
 
-    /// \brief The subscript operator.
-    ///
-    /// The subscript operator. The map can be subscripted by the
-    /// actual keys of the graph.
+    // \brief The subscript operator.
+    //
+    // The subscript operator. The map can be subscripted by the
+    // actual keys of the graph.
     Value& operator[](const Key& key) {
       int id = Parent::notifier()->id(key);
@@ -178,8 +180,8 @@
     }
 
-    /// \brief The const subscript operator.
-    ///
-    /// The const subscript operator. The map can be subscripted by the
-    /// actual keys of the graph.
+    // \brief The const subscript operator.
+    //
+    // The const subscript operator. The map can be subscripted by the
+    // actual keys of the graph.
     const Value& operator[](const Key& key) const {
       int id = Parent::notifier()->id(key);
@@ -187,8 +189,8 @@
     }
 
-    /// \brief Setter function of the map.
-    ///
-    /// Setter function of the map. Equivalent with map[key] = val.
-    /// This is a compatibility feature with the not dereferable maps.
+    // \brief Setter function of the map.
+    //
+    // Setter function of the map. Equivalent with map[key] = val.
+    // This is a compatibility feature with the not dereferable maps.
     void set(const Key& key, const Value& val) {
       (*this)[key] = val;
@@ -197,8 +199,8 @@
   protected:
 
-    /// \brief Adds a new key to the map.
-    ///
-    /// It adds a new key to the map. It called by the observer notifier
-    /// and it overrides the add() member function of the observer base.
+    // \brief Adds a new key to the map.
+    //
+    // It adds a new key to the map. It called by the observer notifier
+    // and it overrides the add() member function of the observer base.
     virtual void add(const Key& key) {
       Notifier* nf = Parent::notifier();
@@ -225,8 +227,8 @@
     }
 
-    /// \brief Adds more new keys to the map.
-    ///
-    /// It adds more new keys to the map. It called by the observer notifier
-    /// and it overrides the add() member function of the observer base.
+    // \brief Adds more new keys to the map.
+    //
+    // It adds more new keys to the map. It called by the observer notifier
+    // and it overrides the add() member function of the observer base.
     virtual void add(const std::vector<Key>& keys) {
       Notifier* nf = Parent::notifier();
@@ -269,8 +271,8 @@
     }
 
-    /// \brief Erase a key from the map.
-    ///
-    /// Erase a key from the map. It called by the observer notifier
-    /// and it overrides the erase() member function of the observer base.
+    // \brief Erase a key from the map.
+    //
+    // Erase a key from the map. It called by the observer notifier
+    // and it overrides the erase() member function of the observer base.
     virtual void erase(const Key& key) {
       int id = Parent::notifier()->id(key);
@@ -278,8 +280,8 @@
     }
 
-    /// \brief Erase more keys from the map.
-    ///
-    /// Erase more keys from the map. It called by the observer notifier
-    /// and it overrides the erase() member function of the observer base.
+    // \brief Erase more keys from the map.
+    //
+    // Erase more keys from the map. It called by the observer notifier
+    // and it overrides the erase() member function of the observer base.
     virtual void erase(const std::vector<Key>& keys) {
       for (int i = 0; i < int(keys.size()); ++i) {
@@ -289,8 +291,8 @@
     }
 
-    /// \brief Buildes the map.
-    ///
-    /// It buildes the map. It called by the observer notifier
-    /// and it overrides the build() member function of the observer base.
+    // \brief Buildes the map.
+    //
+    // It buildes the map. It called by the observer notifier
+    // and it overrides the build() member function of the observer base.
     virtual void build() {
       Notifier* nf = Parent::notifier();
@@ -303,8 +305,8 @@
     }
 
-    /// \brief Clear the map.
-    ///
-    /// It erase all items from the map. It called by the observer notifier
-    /// and it overrides the clear() member function of the observer base.
+    // \brief Clear the map.
+    //
+    // It erase all items from the map. It called by the observer notifier
+    // and it overrides the clear() member function of the observer base.
     virtual void clear() {
       Notifier* nf = Parent::notifier();
Index: lemon/bits/base_extender.h
===================================================================
--- lemon/bits/base_extender.h	(revision 256)
+++ lemon/bits/base_extender.h	(revision 314)
@@ -29,12 +29,12 @@
 #include <lemon/concepts/maps.h>
 
-///\ingroup digraphbits
-///\file
-///\brief Extenders for the digraph types
+//\ingroup digraphbits
+//\file
+//\brief Extenders for the digraph types
 namespace lemon {
 
-  /// \ingroup digraphbits
-  ///
-  /// \brief BaseDigraph to BaseGraph extender
+  // \ingroup digraphbits
+  //
+  // \brief BaseDigraph to BaseGraph extender
   template <typename Base>
   class UndirDigraphExtender : public Base {
@@ -75,38 +75,35 @@
     };
 
-    /// First node of the edge
+    // First node of the edge
     Node u(const Edge &e) const {
       return Parent::source(e);
     }
 
-    /// Source of the given arc
+    // Source of the given arc
     Node source(const Arc &e) const {
       return e.forward ? Parent::source(e) : Parent::target(e);
     }
 
-    /// Second node of the edge
+    // Second node of the edge
     Node v(const Edge &e) const {
       return Parent::target(e);
     }
 
-    /// Target of the given arc
+    // Target of the given arc
     Node target(const Arc &e) const {
       return e.forward ? Parent::target(e) : Parent::source(e);
     }
 
-    /// \brief Directed arc from an edge.
-    ///
-    /// Returns a directed arc corresponding to the specified edge.
-    /// If the given bool is true, the first node of the given edge and
-    /// the source node of the returned arc are the same.
+    // \brief Directed arc from an edge.
+    //
+    // Returns a directed arc corresponding to the specified edge.
+    // If the given bool is true, the first node of the given edge and
+    // the source node of the returned arc are the same.
     static Arc direct(const Edge &e, bool d) {
       return Arc(e, d);
     }
 
-    /// Returns whether the given directed arc has the same orientation
-    /// as the corresponding edge.
-    ///
-    /// \todo reference to the corresponding point of the undirected digraph
-    /// concept. "What does the direction of an edge mean?"
+    // Returns whether the given directed arc has the same orientation
+    // as the corresponding edge.
     static bool direction(const Arc &a) { return a.forward; }
 
@@ -302,10 +299,10 @@
       Red() {}
       Red(const Node& node) : Node(node) {
-        LEMON_ASSERT(Parent::red(node) || node == INVALID,
-                     typename Parent::NodeSetError());
+        LEMON_DEBUG(Parent::red(node) || node == INVALID,
+                    typename Parent::NodeSetError());
       }
       Red& operator=(const Node& node) {
-        LEMON_ASSERT(Parent::red(node) || node == INVALID,
-                     typename Parent::NodeSetError());
+        LEMON_DEBUG(Parent::red(node) || node == INVALID,
+                    typename Parent::NodeSetError());
         Node::operator=(node);
         return *this;
@@ -334,10 +331,10 @@
       Blue() {}
       Blue(const Node& node) : Node(node) {
-        LEMON_ASSERT(Parent::blue(node) || node == INVALID,
-                     typename Parent::NodeSetError());
+        LEMON_DEBUG(Parent::blue(node) || node == INVALID,
+                    typename Parent::NodeSetError());
       }
       Blue& operator=(const Node& node) {
-        LEMON_ASSERT(Parent::blue(node) || node == INVALID,
-                     typename Parent::NodeSetError());
+        LEMON_DEBUG(Parent::blue(node) || node == INVALID,
+                    typename Parent::NodeSetError());
         Node::operator=(node);
         return *this;
Index: lemon/bits/bezier.h
===================================================================
--- lemon/bits/bezier.h	(revision 209)
+++ lemon/bits/bezier.h	(revision 314)
@@ -20,9 +20,9 @@
 #define LEMON_BEZIER_H
 
-///\ingroup misc
-///\file
-///\brief Classes to compute with Bezier curves.
-///
-///Up to now this file is used internally by \ref graph_to_eps.h
+//\ingroup misc
+//\file
+//\brief Classes to compute with Bezier curves.
+//
+//Up to now this file is used internally by \ref graph_to_eps.h
 
 #include<lemon/dim2.h>
Index: lemon/bits/default_map.h
===================================================================
--- lemon/bits/default_map.h	(revision 209)
+++ lemon/bits/default_map.h	(revision 314)
@@ -20,12 +20,11 @@
 #define LEMON_BITS_DEFAULT_MAP_H
 
-
 #include <lemon/bits/array_map.h>
 #include <lemon/bits/vector_map.h>
 //#include <lemon/bits/debug_map.h>
 
-///\ingroup graphbits
-///\file
-///\brief Graph maps that construct and destruct their elements dynamically.
+//\ingroup graphbits
+//\file
+//\brief Graph maps that construct and destruct their elements dynamically.
 
 namespace lemon {
@@ -150,5 +149,5 @@
 // #endif
 
-  /// \e
+  // DefaultMap class
   template <typename _Graph, typename _Item, typename _Value>
   class DefaultMap
Index: lemon/bits/enable_if.h
===================================================================
--- lemon/bits/enable_if.h	(revision 220)
+++ lemon/bits/enable_if.h	(revision 314)
@@ -36,27 +36,27 @@
 #define LEMON_BITS_ENABLE_IF_H
 
-///\file
-///\brief Miscellaneous basic utilities
+//\file
+//\brief Miscellaneous basic utilities
 
 namespace lemon
 {
 
-  /// Basic type for defining "tags". A "YES" condition for \c enable_if.
+  // Basic type for defining "tags". A "YES" condition for \c enable_if.
 
-  /// Basic type for defining "tags". A "YES" condition for \c enable_if.
-  ///
-  ///\sa False
+  // Basic type for defining "tags". A "YES" condition for \c enable_if.
+  //
+  //\sa False
   struct True {
-    ///\e
+    //\e
     static const bool value = true;
   };
 
-  /// Basic type for defining "tags". A "NO" condition for \c enable_if.
+  // Basic type for defining "tags". A "NO" condition for \c enable_if.
 
-  /// Basic type for defining "tags". A "NO" condition for \c enable_if.
-  ///
-  ///\sa True
+  // Basic type for defining "tags". A "NO" condition for \c enable_if.
+  //
+  //\sa True
   struct False {
-    ///\e
+    //\e
     static const bool value = false;
   };
Index: lemon/bits/graph_extender.h
===================================================================
--- lemon/bits/graph_extender.h	(revision 220)
+++ lemon/bits/graph_extender.h	(revision 314)
@@ -28,12 +28,12 @@
 #include <lemon/concepts/maps.h>
 
-///\ingroup graphbits
-///\file
-///\brief Extenders for the digraph types
+//\ingroup graphbits
+//\file
+//\brief Extenders for the digraph types
 namespace lemon {
 
-  /// \ingroup graphbits
-  ///
-  /// \brief Extender for the Digraphs
+  // \ingroup graphbits
+  //
+  // \brief Extender for the Digraphs
   template <typename Base>
   class DigraphExtender : public Base {
@@ -187,28 +187,28 @@
     };
 
-    /// \brief Base node of the iterator
-    ///
-    /// Returns the base node (i.e. the source in this case) of the iterator
+    // \brief Base node of the iterator
+    //
+    // Returns the base node (i.e. the source in this case) of the iterator
     Node baseNode(const OutArcIt &arc) const {
       return Parent::source(arc);
     }
-    /// \brief Running node of the iterator
-    ///
-    /// Returns the running node (i.e. the target in this case) of the
-    /// iterator
+    // \brief Running node of the iterator
+    //
+    // Returns the running node (i.e. the target in this case) of the
+    // iterator
     Node runningNode(const OutArcIt &arc) const {
       return Parent::target(arc);
     }
 
-    /// \brief Base node of the iterator
-    ///
-    /// Returns the base node (i.e. the target in this case) of the iterator
+    // \brief Base node of the iterator
+    //
+    // Returns the base node (i.e. the target in this case) of the iterator
     Node baseNode(const InArcIt &arc) const {
       return Parent::target(arc);
     }
-    /// \brief Running node of the iterator
-    ///
-    /// Returns the running node (i.e. the source in this case) of the
-    /// iterator
+    // \brief Running node of the iterator
+    //
+    // Returns the running node (i.e. the source in this case) of the
+    // iterator
     Node runningNode(const InArcIt &arc) const {
       return Parent::source(arc);
@@ -228,4 +228,5 @@
         : Parent(digraph, value) {}
 
+    private:
       NodeMap& operator=(const NodeMap& cmap) {
         return operator=<NodeMap>(cmap);
@@ -252,4 +253,5 @@
         : Parent(digraph, value) {}
 
+    private:
       ArcMap& operator=(const ArcMap& cmap) {
         return operator=<ArcMap>(cmap);
@@ -324,7 +326,7 @@
   };
 
-  /// \ingroup _graphbits
-  ///
-  /// \brief Extender for the Graphs
+  // \ingroup _graphbits
+  //
+  // \brief Extender for the Graphs
   template <typename Base>
   class GraphExtender : public Base {
@@ -554,41 +556,41 @@
     };
 
-    /// \brief Base node of the iterator
-    ///
-    /// Returns the base node (ie. the source in this case) of the iterator
+    // \brief Base node of the iterator
+    //
+    // Returns the base node (ie. the source in this case) of the iterator
     Node baseNode(const OutArcIt &arc) const {
       return Parent::source(static_cast<const Arc&>(arc));
     }
-    /// \brief Running node of the iterator
-    ///
-    /// Returns the running node (ie. the target in this case) of the
-    /// iterator
+    // \brief Running node of the iterator
+    //
+    // Returns the running node (ie. the target in this case) of the
+    // iterator
     Node runningNode(const OutArcIt &arc) const {
       return Parent::target(static_cast<const Arc&>(arc));
     }
 
-    /// \brief Base node of the iterator
-    ///
-    /// Returns the base node (ie. the target in this case) of the iterator
+    // \brief Base node of the iterator
+    //
+    // Returns the base node (ie. the target in this case) of the iterator
     Node baseNode(const InArcIt &arc) const {
       return Parent::target(static_cast<const Arc&>(arc));
     }
-    /// \brief Running node of the iterator
-    ///
-    /// Returns the running node (ie. the source in this case) of the
-    /// iterator
+    // \brief Running node of the iterator
+    //
+    // Returns the running node (ie. the source in this case) of the
+    // iterator
     Node runningNode(const InArcIt &arc) const {
       return Parent::source(static_cast<const Arc&>(arc));
     }
 
-    /// Base node of the iterator
-    ///
-    /// Returns the base node of the iterator
+    // Base node of the iterator
+    //
+    // Returns the base node of the iterator
     Node baseNode(const IncEdgeIt &edge) const {
       return edge._direction ? u(edge) : v(edge);
     }
-    /// Running node of the iterator
-    ///
-    /// Returns the running node of the iterator
+    // Running node of the iterator
+    //
+    // Returns the running node of the iterator
     Node runningNode(const IncEdgeIt &edge) const {
       return edge._direction ? v(edge) : u(edge);
@@ -609,4 +611,5 @@
         : Parent(graph, value) {}
 
+    private:
       NodeMap& operator=(const NodeMap& cmap) {
         return operator=<NodeMap>(cmap);
@@ -633,4 +636,5 @@
         : Parent(graph, value) {}
 
+    private:
       ArcMap& operator=(const ArcMap& cmap) {
         return operator=<ArcMap>(cmap);
@@ -658,4 +662,5 @@
         : Parent(graph, value) {}
 
+    private:
       EdgeMap& operator=(const EdgeMap& cmap) {
         return operator=<EdgeMap>(cmap);
Index: lemon/bits/map_extender.h
===================================================================
--- lemon/bits/map_extender.h	(revision 209)
+++ lemon/bits/map_extender.h	(revision 314)
@@ -27,12 +27,12 @@
 #include <lemon/concepts/maps.h>
 
-///\file
-///\brief Extenders for iterable maps.
+//\file
+//\brief Extenders for iterable maps.
 
 namespace lemon {
 
-  /// \ingroup graphbits
-  ///
-  /// \brief Extender for maps
+  // \ingroup graphbits
+  //
+  // \brief Extender for maps
   template <typename _Map>
   class MapExtender : public _Map {
@@ -63,4 +63,5 @@
       : Parent(graph, value) {}
 
+  private:
     MapExtender& operator=(const MapExtender& cmap) {
       return operator=<MapExtender>(cmap);
@@ -73,4 +74,5 @@
     }
 
+  public:
     class MapIt : public Item {
     public:
@@ -170,7 +172,7 @@
   };
 
-  /// \ingroup graphbits
-  ///
-  /// \brief Extender for maps which use a subset of the items.
+  // \ingroup graphbits
+  //
+  // \brief Extender for maps which use a subset of the items.
   template <typename _Graph, typename _Map>
   class SubMapExtender : public _Map {
@@ -201,4 +203,5 @@
       : Parent(_graph, _value), graph(_graph) {}
 
+  private:
     SubMapExtender& operator=(const SubMapExtender& cmap) {
       return operator=<MapExtender>(cmap);
@@ -215,4 +218,5 @@
     }
 
+  public:
     class MapIt : public Item {
     public:
Index: lemon/bits/traits.h
===================================================================
--- lemon/bits/traits.h	(revision 220)
+++ lemon/bits/traits.h	(revision 314)
@@ -20,7 +20,7 @@
 #define LEMON_BITS_TRAITS_H
 
-///\file
-///\brief Traits for graphs and maps
-///
+//\file
+//\brief Traits for graphs and maps
+//
 
 #include <lemon/bits/enable_if.h>
Index: lemon/bits/vector_map.h
===================================================================
--- lemon/bits/vector_map.h	(revision 220)
+++ lemon/bits/vector_map.h	(revision 314)
@@ -29,22 +29,21 @@
 #include <lemon/concepts/maps.h>
 
-///\ingroup graphbits
-///
-///\file
-///\brief Vector based graph maps.
+//\ingroup graphbits
+//
+//\file
+//\brief Vector based graph maps.
 namespace lemon {
 
-  /// \ingroup graphbits
-  ///
-  /// \brief Graph map based on the std::vector storage.
-  ///
-  /// The VectorMap template class is graph map structure what
-  /// automatically updates the map when a key is added to or erased from
-  /// the map. This map type uses the std::vector to store the values.
-  ///
-  /// \tparam _Notifier The AlterationNotifier that will notify this map.
-  /// \tparam _Item The item type of the graph items.
-  /// \tparam _Value The value type of the map.
-  /// \todo Fix the doc: there is _Graph parameter instead of _Notifier.
+  // \ingroup graphbits
+  //
+  // \brief Graph map based on the std::vector storage.
+  //
+  // The VectorMap template class is graph map structure what
+  // automatically updates the map when a key is added to or erased from
+  // the map. This map type uses the std::vector to store the values.
+  //
+  // \tparam _Graph The graph this map is attached to.
+  // \tparam _Item The item type of the graph items.
+  // \tparam _Value The value type of the map.
   template <typename _Graph, typename _Item, typename _Value>
   class VectorMap
@@ -52,39 +51,39 @@
   private:
 
-    /// The container type of the map.
+    // The container type of the map.
     typedef std::vector<_Value> Container;
 
   public:
 
-    /// The graph type of the map.
+    // The graph type of the map.
     typedef _Graph Graph;
-    /// The item type of the map.
+    // The item type of the map.
     typedef _Item Item;
-    /// The reference map tag.
+    // The reference map tag.
     typedef True ReferenceMapTag;
 
-    /// The key type of the map.
+    // The key type of the map.
     typedef _Item Key;
-    /// The value type of the map.
+    // The value type of the map.
     typedef _Value Value;
 
-    /// The notifier type.
+    // The notifier type.
     typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
 
-    /// The map type.
+    // The map type.
     typedef VectorMap Map;
-    /// The base class of the map.
+    // The base class of the map.
     typedef typename Notifier::ObserverBase Parent;
 
-    /// The reference type of the map;
+    // The reference type of the map;
     typedef typename Container::reference Reference;
-    /// The const reference type of the map;
+    // The const reference type of the map;
     typedef typename Container::const_reference ConstReference;
 
 
-    /// \brief Constructor to attach the new map into the notifier.
-    ///
-    /// It constructs a map and attachs it into the notifier.
-    /// It adds all the items of the graph to the map.
+    // \brief Constructor to attach the new map into the notifier.
+    //
+    // It constructs a map and attachs it into the notifier.
+    // It adds all the items of the graph to the map.
     VectorMap(const Graph& graph) {
       Parent::attach(graph.notifier(Item()));
@@ -92,8 +91,8 @@
     }
 
-    /// \brief Constructor uses given value to initialize the map.
-    ///
-    /// It constructs a map uses a given value to initialize the map.
-    /// It adds all the items of the graph to the map.
+    // \brief Constructor uses given value to initialize the map.
+    //
+    // It constructs a map uses a given value to initialize the map.
+    // It adds all the items of the graph to the map.
     VectorMap(const Graph& graph, const Value& value) {
       Parent::attach(graph.notifier(Item()));
@@ -101,7 +100,8 @@
     }
 
-    /// \brief Copy constructor
-    ///
-    /// Copy constructor.
+  private:
+    // \brief Copy constructor
+    //
+    // Copy constructor.
     VectorMap(const VectorMap& _copy) : Parent() {
       if (_copy.attached()) {
@@ -111,11 +111,11 @@
     }
 
-    /// \brief Assign operator.
-    ///
-    /// This operator assigns for each item in the map the
-    /// value mapped to the same item in the copied map.
-    /// The parameter map should be indiced with the same
-    /// itemset because this assign operator does not change
-    /// the container of the map.
+    // \brief Assign operator.
+    //
+    // This operator assigns for each item in the map the
+    // value mapped to the same item in the copied map.
+    // The parameter map should be indiced with the same
+    // itemset because this assign operator does not change
+    // the container of the map.
     VectorMap& operator=(const VectorMap& cmap) {
       return operator=<VectorMap>(cmap);
@@ -123,10 +123,10 @@
 
 
-    /// \brief Template assign operator.
-    ///
-    /// The given parameter should be conform to the ReadMap
-    /// concecpt and could be indiced by the current item set of
-    /// the NodeMap. In this case the value for each item
-    /// is assigned by the value of the given ReadMap.
+    // \brief Template assign operator.
+    //
+    // The given parameter should be conform to the ReadMap
+    // concecpt and could be indiced by the current item set of
+    // the NodeMap. In this case the value for each item
+    // is assigned by the value of the given ReadMap.
     template <typename CMap>
     VectorMap& operator=(const CMap& cmap) {
@@ -142,16 +142,16 @@
   public:
 
-    /// \brief The subcript operator.
-    ///
-    /// The subscript operator. The map can be subscripted by the
-    /// actual items of the graph.
+    // \brief The subcript operator.
+    //
+    // The subscript operator. The map can be subscripted by the
+    // actual items of the graph.
     Reference operator[](const Key& key) {
       return container[Parent::notifier()->id(key)];
     }
 
-    /// \brief The const subcript operator.
-    ///
-    /// The const subscript operator. The map can be subscripted by the
-    /// actual items of the graph.
+    // \brief The const subcript operator.
+    //
+    // The const subscript operator. The map can be subscripted by the
+    // actual items of the graph.
     ConstReference operator[](const Key& key) const {
       return container[Parent::notifier()->id(key)];
@@ -159,7 +159,7 @@
 
 
-    /// \brief The setter function of the map.
-    ///
-    /// It the same as operator[](key) = value expression.
+    // \brief The setter function of the map.
+    //
+    // It the same as operator[](key) = value expression.
     void set(const Key& key, const Value& value) {
       (*this)[key] = value;
@@ -168,8 +168,8 @@
   protected:
 
-    /// \brief Adds a new key to the map.
-    ///
-    /// It adds a new key to the map. It called by the observer notifier
-    /// and it overrides the add() member function of the observer base.
+    // \brief Adds a new key to the map.
+    //
+    // It adds a new key to the map. It called by the observer notifier
+    // and it overrides the add() member function of the observer base.
     virtual void add(const Key& key) {
       int id = Parent::notifier()->id(key);
@@ -179,8 +179,8 @@
     }
 
-    /// \brief Adds more new keys to the map.
-    ///
-    /// It adds more new keys to the map. It called by the observer notifier
-    /// and it overrides the add() member function of the observer base.
+    // \brief Adds more new keys to the map.
+    //
+    // It adds more new keys to the map. It called by the observer notifier
+    // and it overrides the add() member function of the observer base.
     virtual void add(const std::vector<Key>& keys) {
       int max = container.size() - 1;
@@ -194,16 +194,16 @@
     }
 
-    /// \brief Erase a key from the map.
-    ///
-    /// Erase a key from the map. It called by the observer notifier
-    /// and it overrides the erase() member function of the observer base.
+    // \brief Erase a key from the map.
+    //
+    // Erase a key from the map. It called by the observer notifier
+    // and it overrides the erase() member function of the observer base.
     virtual void erase(const Key& key) {
       container[Parent::notifier()->id(key)] = Value();
     }
 
-    /// \brief Erase more keys from the map.
-    ///
-    /// Erase more keys from the map. It called by the observer notifier
-    /// and it overrides the erase() member function of the observer base.
+    // \brief Erase more keys from the map.
+    //
+    // Erase more keys from the map. It called by the observer notifier
+    // and it overrides the erase() member function of the observer base.
     virtual void erase(const std::vector<Key>& keys) {
       for (int i = 0; i < int(keys.size()); ++i) {
@@ -212,8 +212,8 @@
     }
 
-    /// \brief Buildes the map.
-    ///
-    /// It buildes the map. It called by the observer notifier
-    /// and it overrides the build() member function of the observer base.
+    // \brief Buildes the map.
+    //
+    // It buildes the map. It called by the observer notifier
+    // and it overrides the build() member function of the observer base.
     virtual void build() {
       int size = Parent::notifier()->maxId() + 1;
@@ -222,8 +222,8 @@
     }
 
-    /// \brief Clear the map.
-    ///
-    /// It erase all items from the map. It called by the observer notifier
-    /// and it overrides the clear() member function of the observer base.
+    // \brief Clear the map.
+    //
+    // It erase all items from the map. It called by the observer notifier
+    // and it overrides the clear() member function of the observer base.
     virtual void clear() {
       container.clear();
Index: lemon/color.h
===================================================================
--- lemon/color.h	(revision 209)
+++ lemon/color.h	(revision 313)
@@ -93,5 +93,5 @@
   extern const Color DARK_CYAN;
 
-  ///Map <tt>int</tt>s to different \ref Color "Color"s
+  ///Map <tt>int</tt>s to different <tt>Color</tt>s
 
   ///This map assigns one of the predefined \ref Color "Color"s to
Index: lemon/concept_check.h
===================================================================
--- lemon/concept_check.h	(revision 209)
+++ lemon/concept_check.h	(revision 285)
@@ -17,26 +17,10 @@
  */
 
-// This file contains a modified version of the concept checking
-// utility from BOOST.
-// See the appropriate copyright notice below.
-
-// (C) Copyright Jeremy Siek 2000.
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-//
-// Revision History:
-//   05 May   2001: Workarounds for HP aCC from Thomas Matelich. (Jeremy Siek)
-//   02 April 2001: Removed limits header altogether. (Jeremy Siek)
-//   01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
-//
-
-// See http://www.boost.org/libs/concept_check for documentation.
+// The contents of this file was inspired by the concept checking
+// utility of the BOOST library (http://www.boost.org).
 
 ///\file
 ///\brief Basic utilities for concept checking.
 ///
-///\todo Are we still using BOOST concept checking utility?
-///Is the BOOST copyright notice necessary?
 
 #ifndef LEMON_CONCEPT_CHECK_H
Index: lemon/concepts/digraph.h
===================================================================
--- lemon/concepts/digraph.h	(revision 220)
+++ lemon/concepts/digraph.h	(revision 263)
@@ -435,4 +435,5 @@
         NodeMap(const Digraph&, T) { }
 
+      private:
         ///Copy constructor
         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
@@ -457,4 +458,5 @@
         ///\e
         ArcMap(const Digraph&, T) { }
+      private:
         ///Copy constructor
         ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
Index: lemon/concepts/graph.h
===================================================================
--- lemon/concepts/graph.h	(revision 220)
+++ lemon/concepts/graph.h	(revision 263)
@@ -513,4 +513,5 @@
         NodeMap(const Graph&, T) { }
 
+      private:
         ///Copy constructor
         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
@@ -536,4 +537,5 @@
         ///\e
         ArcMap(const Graph&, T) { }
+      private:
         ///Copy constructor
         ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
@@ -559,4 +561,5 @@
         ///\e
         EdgeMap(const Graph&, T) { }
+      private:
         ///Copy constructor
         EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
Index: lemon/concepts/graph_components.h
===================================================================
--- lemon/concepts/graph_components.h	(revision 220)
+++ lemon/concepts/graph_components.h	(revision 313)
@@ -983,5 +983,5 @@
     ///
     /// This class describes the common interface of the graph maps
-    /// (NodeMap, ArcMap), that is \ref maps-page "maps" which can be used to
+    /// (NodeMap, ArcMap), that is maps that can be used to
     /// associate data to graph descriptors (nodes or arcs).
     template <typename _Graph, typename _Item, typename _Value>
@@ -1006,4 +1006,6 @@
       /// Construct a new map for the graph and initalise the values.
       GraphMap(const Graph&, const Value&) {}
+
+    private:
       /// \brief Copy constructor.
       ///
@@ -1022,4 +1024,5 @@
       }
 
+    public:
       template<typename _Map>
       struct Constraints {
@@ -1031,11 +1034,12 @@
           _Map a2(g,t);
           // Copy constructor.
-          _Map b(c);
-
-          ReadMap<Key, Value> cmap;
-          b = cmap;
-
+          // _Map b(c);
+
+          // ReadMap<Key, Value> cmap;
+          // b = cmap;
+
+          ignore_unused_variable_warning(a);
           ignore_unused_variable_warning(a2);
-          ignore_unused_variable_warning(b);
+          // ignore_unused_variable_warning(b);
         }
 
@@ -1083,4 +1087,5 @@
           : Parent(digraph, value) {}
 
+      private:
         /// \brief Copy constructor.
         ///
@@ -1120,4 +1125,5 @@
           : Parent(digraph, value) {}
 
+      private:
         /// \brief Copy constructor.
         ///
@@ -1216,4 +1222,5 @@
           : Parent(graph, value) {}
 
+      private:
         /// \brief Copy constructor.
         ///
Index: lemon/concepts/heap.h
===================================================================
--- lemon/concepts/heap.h	(revision 220)
+++ lemon/concepts/heap.h	(revision 290)
@@ -130,5 +130,4 @@
       /// Otherwise it inserts the given item with the given priority.
       ///
-      /// It may throw an \ref UnderflowPriorityException.
       /// \param i The item.
       /// \param p The priority.
Index: lemon/concepts/maps.h
===================================================================
--- lemon/concepts/maps.h	(revision 220)
+++ lemon/concepts/maps.h	(revision 314)
@@ -23,5 +23,5 @@
 #include <lemon/concept_check.h>
 
-///\ingroup concept
+///\ingroup map_concepts
 ///\file
 ///\brief The concept of maps.
@@ -31,5 +31,5 @@
   namespace concepts {
 
-    /// \addtogroup concept
+    /// \addtogroup map_concepts
     /// @{
 
Index: lemon/concepts/path.h
===================================================================
--- lemon/concepts/path.h	(revision 236)
+++ lemon/concepts/path.h	(revision 281)
@@ -21,5 +21,4 @@
 ///\brief Classes for representing paths in digraphs.
 ///
-///\todo Iterators have obsolete style
 
 #ifndef LEMON_CONCEPT_PATH_H
@@ -67,5 +66,8 @@
       /// \brief Template assigment
       template <typename CPath>
-      Path& operator=(const CPath& cpath) {}
+      Path& operator=(const CPath& cpath) {
+        ignore_unused_variable_warning(cpath);
+        return *this;
+      }
 
       /// Length of the path ie. the number of arcs in the path.
Index: lemon/core.h
===================================================================
--- lemon/core.h	(revision 233)
+++ lemon/core.h	(revision 319)
@@ -25,4 +25,5 @@
 #include <lemon/bits/enable_if.h>
 #include <lemon/bits/traits.h>
+#include <lemon/assert.h>
 
 ///\file
@@ -59,8 +60,8 @@
   /// @{
 
-  ///Creates convenience typedefs for the digraph types and iterators
-
-  ///This \c \#define creates convenience typedefs for the following types
-  ///of \c Digraph: \c Node,  \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
+  ///Create convenience typedefs for the digraph types and iterators
+
+  ///This \c \#define creates convenient type definitions for the following
+  ///types of \c Digraph: \c Node,  \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
   ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
   ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap.
@@ -83,5 +84,5 @@
   typedef Digraph::ArcMap<double> DoubleArcMap
 
-  ///Creates convenience typedefs for the digraph types and iterators
+  ///Create convenience typedefs for the digraph types and iterators
 
   ///\see DIGRAPH_TYPEDEFS
@@ -103,7 +104,7 @@
   typedef typename Digraph::template ArcMap<double> DoubleArcMap
 
-  ///Creates convenience typedefs for the graph types and iterators
-
-  ///This \c \#define creates the same convenience typedefs as defined
+  ///Create convenience typedefs for the graph types and iterators
+
+  ///This \c \#define creates the same convenient type definitions as defined
   ///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates
   ///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap,
@@ -111,5 +112,5 @@
   ///
   ///\note If the graph type is a dependent type, ie. the graph type depend
-  ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
+  ///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS()
   ///macro.
 #define GRAPH_TYPEDEFS(Graph)                                           \
@@ -122,5 +123,5 @@
   typedef Graph::EdgeMap<double> DoubleEdgeMap
 
-  ///Creates convenience typedefs for the graph types and iterators
+  ///Create convenience typedefs for the graph types and iterators
 
   ///\see GRAPH_TYPEDEFS
@@ -137,8 +138,8 @@
   typedef typename Graph::template EdgeMap<double> DoubleEdgeMap
 
-  /// \brief Function to count the items in the graph.
-  ///
-  /// This function counts the items (nodes, arcs etc) in the graph.
-  /// The complexity of the function is O(n) because
+  /// \brief Function to count the items in a graph.
+  ///
+  /// This function counts the items (nodes, arcs etc.) in a graph.
+  /// The complexity of the function is linear because
   /// it iterates on all of the items.
   template <typename Graph, typename Item>
@@ -177,9 +178,9 @@
   ///
   /// This function counts the nodes in the graph.
-  /// The complexity of the function is O(n) but for some
-  /// graph structures it is specialized to run in O(1).
-  ///
-  /// If the graph contains a \e nodeNum() member function and a
-  /// \e NodeNumTag tag then this function calls directly the member
+  /// The complexity of the function is <em>O</em>(<em>n</em>), but for some
+  /// graph structures it is specialized to run in <em>O</em>(1).
+  ///
+  /// \note If the graph contains a \c nodeNum() member function and a
+  /// \c NodeNumTag tag then this function calls directly the member
   /// function to query the cardinality of the node set.
   template <typename Graph>
@@ -213,9 +214,9 @@
   ///
   /// This function counts the arcs in the graph.
-  /// The complexity of the function is O(e) but for some
-  /// graph structures it is specialized to run in O(1).
-  ///
-  /// If the graph contains a \e arcNum() member function and a
-  /// \e EdgeNumTag tag then this function calls directly the member
+  /// The complexity of the function is <em>O</em>(<em>m</em>), but for some
+  /// graph structures it is specialized to run in <em>O</em>(1).
+  ///
+  /// \note If the graph contains a \c arcNum() member function and a
+  /// \c ArcNumTag tag then this function calls directly the member
   /// function to query the cardinality of the arc set.
   template <typename Graph>
@@ -225,4 +226,5 @@
 
   // Edge counting:
+
   namespace _core_bits {
 
@@ -248,9 +250,9 @@
   ///
   /// This function counts the edges in the graph.
-  /// The complexity of the function is O(m) but for some
-  /// graph structures it is specialized to run in O(1).
-  ///
-  /// If the graph contains a \e edgeNum() member function and a
-  /// \e EdgeNumTag tag then this function calls directly the member
+  /// The complexity of the function is <em>O</em>(<em>m</em>), but for some
+  /// graph structures it is specialized to run in <em>O</em>(1).
+  ///
+  /// \note If the graph contains a \c edgeNum() member function and a
+  /// \c EdgeNumTag tag then this function calls directly the member
   /// function to query the cardinality of the edge set.
   template <typename Graph>
@@ -273,8 +275,8 @@
   ///
   /// This function counts the number of the out-arcs from node \c n
-  /// in the graph.
+  /// in the graph \c g.
   template <typename Graph>
-  inline int countOutArcs(const Graph& _g,  const typename Graph::Node& _n) {
-    return countNodeDegree<Graph, typename Graph::OutArcIt>(_g, _n);
+  inline int countOutArcs(const Graph& g,  const typename Graph::Node& n) {
+    return countNodeDegree<Graph, typename Graph::OutArcIt>(g, n);
   }
 
@@ -282,8 +284,8 @@
   ///
   /// This function counts the number of the in-arcs to node \c n
-  /// in the graph.
+  /// in the graph \c g.
   template <typename Graph>
-  inline int countInArcs(const Graph& _g,  const typename Graph::Node& _n) {
-    return countNodeDegree<Graph, typename Graph::InArcIt>(_g, _n);
+  inline int countInArcs(const Graph& g,  const typename Graph::Node& n) {
+    return countNodeDegree<Graph, typename Graph::InArcIt>(g, n);
   }
 
@@ -291,8 +293,8 @@
   ///
   /// This function counts the number of the inc-edges to node \c n
-  /// in the graph.
+  /// in the undirected graph \c g.
   template <typename Graph>
-  inline int countIncEdges(const Graph& _g,  const typename Graph::Node& _n) {
-    return countNodeDegree<Graph, typename Graph::IncEdgeIt>(_g, _n);
+  inline int countIncEdges(const Graph& g,  const typename Graph::Node& n) {
+    return countNodeDegree<Graph, typename Graph::IncEdgeIt>(g, n);
   }
 
@@ -308,10 +310,10 @@
 
     template <typename Digraph, typename Item, typename RefMap,
-              typename ToMap, typename FromMap>
+              typename FromMap, typename ToMap>
     class MapCopy : public MapCopyBase<Digraph, Item, RefMap> {
     public:
 
-      MapCopy(ToMap& tmap, const FromMap& map)
-        : _tmap(tmap), _map(map) {}
+      MapCopy(const FromMap& map, ToMap& tmap)
+        : _map(map), _tmap(tmap) {}
 
       virtual void copy(const Digraph& digraph, const RefMap& refMap) {
@@ -323,6 +325,6 @@
 
     private:
+      const FromMap& _map;
       ToMap& _tmap;
-      const FromMap& _map;
     };
 
@@ -331,5 +333,5 @@
     public:
 
-      ItemCopy(It& it, const Item& item) : _it(it), _item(item) {}
+      ItemCopy(const Item& item, It& it) : _item(item), _it(it) {}
 
       virtual void copy(const Digraph&, const RefMap& refMap) {
@@ -338,6 +340,6 @@
 
     private:
+      Item _item;
       It& _it;
-      Item _item;
     };
 
@@ -380,5 +382,5 @@
     struct DigraphCopySelector {
       template <typename From, typename NodeRefMap, typename ArcRefMap>
-      static void copy(Digraph &to, const From& from,
+      static void copy(const From& from, Digraph &to,
                        NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
         for (typename From::NodeIt it(from); it != INVALID; ++it) {
@@ -398,5 +400,5 @@
     {
       template <typename From, typename NodeRefMap, typename ArcRefMap>
-      static void copy(Digraph &to, const From& from,
+      static void copy(const From& from, Digraph &to,
                        NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
         to.build(from, nodeRefMap, arcRefMap);
@@ -407,5 +409,5 @@
     struct GraphCopySelector {
       template <typename From, typename NodeRefMap, typename EdgeRefMap>
-      static void copy(Graph &to, const From& from,
+      static void copy(const From& from, Graph &to,
                        NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
         for (typename From::NodeIt it(from); it != INVALID; ++it) {
@@ -425,5 +427,5 @@
     {
       template <typename From, typename NodeRefMap, typename EdgeRefMap>
-      static void copy(Graph &to, const From& from,
+      static void copy(const From& from, Graph &to,
                        NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
         to.build(from, nodeRefMap, edgeRefMap);
@@ -436,37 +438,37 @@
   ///
   /// Class to copy a digraph to another digraph (duplicate a digraph). The
-  /// simplest way of using it is through the \c copyDigraph() function.
-  ///
-  /// This class not just make a copy of a graph, but it can create
+  /// simplest way of using it is through the \c digraphCopy() function.
+  ///
+  /// This class not only make a copy of a digraph, but it can create
   /// references and cross references between the nodes and arcs of
-  /// the two graphs, it can copy maps for use with the newly created
-  /// graph and copy nodes and arcs.
-  ///
-  /// To make a copy from a graph, first an instance of DigraphCopy
-  /// should be created, then the data belongs to the graph should
+  /// the two digraphs, and it can copy maps to use with the newly created
+  /// digraph.
+  ///
+  /// To make a copy from a digraph, first an instance of DigraphCopy
+  /// should be created, then the data belongs to the digraph should
   /// assigned to copy. In the end, the \c run() member should be
   /// called.
   ///
-  /// The next code copies a graph with several data:
+  /// The next code copies a digraph with several data:
   ///\code
-  ///  DigraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
-  ///  // create a reference for the nodes
+  ///  DigraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph);
+  ///  // Create references for the nodes
   ///  OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
-  ///  dc.nodeRef(nr);
-  ///  // create a cross reference (inverse) for the arcs
+  ///  cg.nodeRef(nr);
+  ///  // Create cross references (inverse) for the arcs
   ///  NewGraph::ArcMap<OrigGraph::Arc> acr(new_graph);
-  ///  dc.arcCrossRef(acr);
-  ///  // copy an arc map
+  ///  cg.arcCrossRef(acr);
+  ///  // Copy an arc map
   ///  OrigGraph::ArcMap<double> oamap(orig_graph);
   ///  NewGraph::ArcMap<double> namap(new_graph);
-  ///  dc.arcMap(namap, oamap);
-  ///  // copy a node
+  ///  cg.arcMap(oamap, namap);
+  ///  // Copy a node
   ///  OrigGraph::Node on;
   ///  NewGraph::Node nn;
-  ///  dc.node(nn, on);
-  ///  // Executions of copy
-  ///  dc.run();
+  ///  cg.node(on, nn);
+  ///  // Execute copying
+  ///  cg.run();
   ///\endcode
-  template <typename To, typename From>
+  template <typename From, typename To>
   class DigraphCopy {
   private:
@@ -483,18 +485,16 @@
     typedef typename From::template ArcMap<TArc> ArcRefMap;
 
-
   public:
 
-
-    /// \brief Constructor for the DigraphCopy.
-    ///
-    /// It copies the content of the \c _from digraph into the
-    /// \c _to digraph.
-    DigraphCopy(To& to, const From& from)
+    /// \brief Constructor of DigraphCopy.
+    ///
+    /// Constructor of DigraphCopy for copying the content of the
+    /// \c from digraph into the \c to digraph.
+    DigraphCopy(const From& from, To& to)
       : _from(from), _to(to) {}
 
-    /// \brief Destructor of the DigraphCopy
-    ///
-    /// Destructor of the DigraphCopy
+    /// \brief Destructor of DigraphCopy
+    ///
+    /// Destructor of DigraphCopy.
     ~DigraphCopy() {
       for (int i = 0; i < int(_node_maps.size()); ++i) {
@@ -507,10 +507,10 @@
     }
 
-    /// \brief Copies the node references into the given map.
-    ///
-    /// Copies the node references into the given map. The parameter
-    /// should be a map, which key type is the Node type of the source
-    /// graph, while the value type is the Node type of the
-    /// destination graph.
+    /// \brief Copy the node references into the given map.
+    ///
+    /// This function copies the node references into the given map.
+    /// The parameter should be a map, whose key type is the Node type of
+    /// the source digraph, while the value type is the Node type of the
+    /// destination digraph.
     template <typename NodeRef>
     DigraphCopy& nodeRef(NodeRef& map) {
@@ -520,10 +520,10 @@
     }
 
-    /// \brief Copies the node cross references into the given map.
-    ///
-    ///  Copies the node cross references (reverse references) into
-    ///  the given map. The parameter should be a map, which key type
-    ///  is the Node type of the destination graph, while the value type is
-    ///  the Node type of the source graph.
+    /// \brief Copy the node cross references into the given map.
+    ///
+    /// This function copies the node cross references (reverse references)
+    /// into the given map. The parameter should be a map, whose key type
+    /// is the Node type of the destination digraph, while the value type is
+    /// the Node type of the source digraph.
     template <typename NodeCrossRef>
     DigraphCopy& nodeCrossRef(NodeCrossRef& map) {
@@ -533,13 +533,15 @@
     }
 
-    /// \brief Make copy of the given map.
-    ///
-    /// Makes copy of the given map for the newly created digraph.
-    /// The new map's key type is the destination graph's node type,
-    /// and the copied map's key type is the source graph's node type.
-    template <typename ToMap, typename FromMap>
-    DigraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
+    /// \brief Make a copy of the given node map.
+    ///
+    /// This function makes a copy of the given node map for the newly
+    /// created digraph.
+    /// The key type of the new map \c tmap should be the Node type of the
+    /// destination digraph, and the key type of the original map \c map
+    /// should be the Node type of the source digraph.
+    template <typename FromMap, typename ToMap>
+    DigraphCopy& nodeMap(const FromMap& map, ToMap& tmap) {
       _node_maps.push_back(new _core_bits::MapCopy<From, Node,
-                           NodeRefMap, ToMap, FromMap>(tmap, map));
+                           NodeRefMap, FromMap, ToMap>(map, tmap));
       return *this;
     }
@@ -547,14 +549,17 @@
     /// \brief Make a copy of the given node.
     ///
-    /// Make a copy of the given node.
-    DigraphCopy& node(TNode& tnode, const Node& snode) {
+    /// This function makes a copy of the given node.
+    DigraphCopy& node(const Node& node, TNode& tnode) {
       _node_maps.push_back(new _core_bits::ItemCopy<From, Node,
-                           NodeRefMap, TNode>(tnode, snode));
-      return *this;
-    }
-
-    /// \brief Copies the arc references into the given map.
-    ///
-    /// Copies the arc references into the given map.
+                           NodeRefMap, TNode>(node, tnode));
+      return *this;
+    }
+
+    /// \brief Copy the arc references into the given map.
+    ///
+    /// This function copies the arc references into the given map.
+    /// The parameter should be a map, whose key type is the Arc type of
+    /// the source digraph, while the value type is the Arc type of the
+    /// destination digraph.
     template <typename ArcRef>
     DigraphCopy& arcRef(ArcRef& map) {
@@ -564,8 +569,10 @@
     }
 
-    /// \brief Copies the arc cross references into the given map.
-    ///
-    ///  Copies the arc cross references (reverse references) into
-    ///  the given map.
+    /// \brief Copy the arc cross references into the given map.
+    ///
+    /// This function copies the arc cross references (reverse references)
+    /// into the given map. The parameter should be a map, whose key type
+    /// is the Arc type of the destination digraph, while the value type is
+    /// the Arc type of the source digraph.
     template <typename ArcCrossRef>
     DigraphCopy& arcCrossRef(ArcCrossRef& map) {
@@ -575,14 +582,15 @@
     }
 
-    /// \brief Make copy of the given map.
-    ///
-    /// Makes copy of the given map for the newly created digraph.
-    /// The new map's key type is the to digraph's arc type,
-    /// and the copied map's key type is the from digraph's arc
-    /// type.
-    template <typename ToMap, typename FromMap>
-    DigraphCopy& arcMap(ToMap& tmap, const FromMap& map) {
+    /// \brief Make a copy of the given arc map.
+    ///
+    /// This function makes a copy of the given arc map for the newly
+    /// created digraph.
+    /// The key type of the new map \c tmap should be the Arc type of the
+    /// destination digraph, and the key type of the original map \c map
+    /// should be the Arc type of the source digraph.
+    template <typename FromMap, typename ToMap>
+    DigraphCopy& arcMap(const FromMap& map, ToMap& tmap) {
       _arc_maps.push_back(new _core_bits::MapCopy<From, Arc,
-                          ArcRefMap, ToMap, FromMap>(tmap, map));
+                          ArcRefMap, FromMap, ToMap>(map, tmap));
       return *this;
     }
@@ -590,19 +598,20 @@
     /// \brief Make a copy of the given arc.
     ///
-    /// Make a copy of the given arc.
-    DigraphCopy& arc(TArc& tarc, const Arc& sarc) {
+    /// This function makes a copy of the given arc.
+    DigraphCopy& arc(const Arc& arc, TArc& tarc) {
       _arc_maps.push_back(new _core_bits::ItemCopy<From, Arc,
-                          ArcRefMap, TArc>(tarc, sarc));
-      return *this;
-    }
-
-    /// \brief Executes the copies.
-    ///
-    /// Executes the copies.
+                          ArcRefMap, TArc>(arc, tarc));
+      return *this;
+    }
+
+    /// \brief Execute copying.
+    ///
+    /// This function executes the copying of the digraph along with the
+    /// copying of the assigned data.
     void run() {
       NodeRefMap nodeRefMap(_from);
       ArcRefMap arcRefMap(_from);
       _core_bits::DigraphCopySelector<To>::
-        copy(_to, _from, nodeRefMap, arcRefMap);
+        copy(_from, _to, nodeRefMap, arcRefMap);
       for (int i = 0; i < int(_node_maps.size()); ++i) {
         _node_maps[i]->copy(_from, nodeRefMap);
@@ -615,13 +624,12 @@
   protected:
 
-
     const From& _from;
     To& _to;
 
     std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* >
-    _node_maps;
+      _node_maps;
 
     std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* >
-    _arc_maps;
+      _arc_maps;
 
   };
@@ -629,20 +637,20 @@
   /// \brief Copy a digraph to another digraph.
   ///
-  /// Copy a digraph to another digraph. The complete usage of the
-  /// function is detailed in the DigraphCopy class, but a short
-  /// example shows a basic work:
+  /// This function copies a digraph to another digraph.
+  /// The complete usage of it is detailed in the DigraphCopy class, but
+  /// a short example shows a basic work:
   ///\code
-  /// copyDigraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();
+  /// digraphCopy(src, trg).nodeRef(nr).arcCrossRef(acr).run();
   ///\endcode
   ///
   /// After the copy the \c nr map will contain the mapping from the
   /// nodes of the \c from digraph to the nodes of the \c to digraph and
-  /// \c ecr will contain the mapping from the arcs of the \c to digraph
+  /// \c acr will contain the mapping from the arcs of the \c to digraph
   /// to the arcs of the \c from digraph.
   ///
   /// \see DigraphCopy
-  template <typename To, typename From>
-  DigraphCopy<To, From> copyDigraph(To& to, const From& from) {
-    return DigraphCopy<To, From>(to, from);
+  template <typename From, typename To>
+  DigraphCopy<From, To> digraphCopy(const From& from, To& to) {
+    return DigraphCopy<From, To>(from, to);
   }
 
@@ -650,10 +658,10 @@
   ///
   /// Class to copy a graph to another graph (duplicate a graph). The
-  /// simplest way of using it is through the \c copyGraph() function.
-  ///
-  /// This class not just make a copy of a graph, but it can create
+  /// simplest way of using it is through the \c graphCopy() function.
+  ///
+  /// This class not only make a copy of a graph, but it can create
   /// references and cross references between the nodes, edges and arcs of
-  /// the two graphs, it can copy maps for use with the newly created
-  /// graph and copy nodes, edges and arcs.
+  /// the two graphs, and it can copy maps for using with the newly created
+  /// graph.
   ///
   /// To make a copy from a graph, first an instance of GraphCopy
@@ -664,23 +672,23 @@
   /// The next code copies a graph with several data:
   ///\code
-  ///  GraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
-  ///  // create a reference for the nodes
+  ///  GraphCopy<OrigGraph, NewGraph> cg(orig_graph, new_graph);
+  ///  // Create references for the nodes
   ///  OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
-  ///  dc.nodeRef(nr);
-  ///  // create a cross reference (inverse) for the edges
-  ///  NewGraph::EdgeMap<OrigGraph::Arc> ecr(new_graph);
-  ///  dc.edgeCrossRef(ecr);
-  ///  // copy an arc map
-  ///  OrigGraph::ArcMap<double> oamap(orig_graph);
-  ///  NewGraph::ArcMap<double> namap(new_graph);
-  ///  dc.arcMap(namap, oamap);
-  ///  // copy a node
+  ///  cg.nodeRef(nr);
+  ///  // Create cross references (inverse) for the edges
+  ///  NewGraph::EdgeMap<OrigGraph::Edge> ecr(new_graph);
+  ///  cg.edgeCrossRef(ecr);
+  ///  // Copy an edge map
+  ///  OrigGraph::EdgeMap<double> oemap(orig_graph);
+  ///  NewGraph::EdgeMap<double> nemap(new_graph);
+  ///  cg.edgeMap(oemap, nemap);
+  ///  // Copy a node
   ///  OrigGraph::Node on;
   ///  NewGraph::Node nn;
-  ///  dc.node(nn, on);
-  ///  // Executions of copy
-  ///  dc.run();
+  ///  cg.node(on, nn);
+  ///  // Execute copying
+  ///  cg.run();
   ///\endcode
-  template <typename To, typename From>
+  template <typename From, typename To>
   class GraphCopy {
   private:
@@ -701,7 +709,7 @@
 
     struct ArcRefMap {
-      ArcRefMap(const To& to, const From& from,
+      ArcRefMap(const From& from, const To& to,
                 const EdgeRefMap& edge_ref, const NodeRefMap& node_ref)
-        : _to(to), _from(from),
+        : _from(from), _to(to),
           _edge_ref(edge_ref), _node_ref(node_ref) {}
 
@@ -717,24 +725,22 @@
       }
 
+      const From& _from;
       const To& _to;
-      const From& _from;
       const EdgeRefMap& _edge_ref;
       const NodeRefMap& _node_ref;
     };
 
-
   public:
 
-
-    /// \brief Constructor for the GraphCopy.
-    ///
-    /// It copies the content of the \c _from graph into the
-    /// \c _to graph.
-    GraphCopy(To& to, const From& from)
+    /// \brief Constructor of GraphCopy.
+    ///
+    /// Constructor of GraphCopy for copying the content of the
+    /// \c from graph into the \c to graph.
+    GraphCopy(const From& from, To& to)
       : _from(from), _to(to) {}
 
-    /// \brief Destructor of the GraphCopy
-    ///
-    /// Destructor of the GraphCopy
+    /// \brief Destructor of GraphCopy
+    ///
+    /// Destructor of GraphCopy.
     ~GraphCopy() {
       for (int i = 0; i < int(_node_maps.size()); ++i) {
@@ -747,10 +753,12 @@
         delete _edge_maps[i];
       }
-
-    }
-
-    /// \brief Copies the node references into the given map.
-    ///
-    /// Copies the node references into the given map.
+    }
+
+    /// \brief Copy the node references into the given map.
+    ///
+    /// This function copies the node references into the given map.
+    /// The parameter should be a map, whose key type is the Node type of
+    /// the source graph, while the value type is the Node type of the
+    /// destination graph.
     template <typename NodeRef>
     GraphCopy& nodeRef(NodeRef& map) {
@@ -760,8 +768,10 @@
     }
 
-    /// \brief Copies the node cross references into the given map.
-    ///
-    ///  Copies the node cross references (reverse references) into
-    ///  the given map.
+    /// \brief Copy the node cross references into the given map.
+    ///
+    /// This function copies the node cross references (reverse references)
+    /// into the given map. The parameter should be a map, whose key type
+    /// is the Node type of the destination graph, while the value type is
+    /// the Node type of the source graph.
     template <typename NodeCrossRef>
     GraphCopy& nodeCrossRef(NodeCrossRef& map) {
@@ -771,14 +781,15 @@
     }
 
-    /// \brief Make copy of the given map.
-    ///
-    /// Makes copy of the given map for the newly created graph.
-    /// The new map's key type is the to graph's node type,
-    /// and the copied map's key type is the from graph's node
-    /// type.
-    template <typename ToMap, typename FromMap>
-    GraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
+    /// \brief Make a copy of the given node map.
+    ///
+    /// This function makes a copy of the given node map for the newly
+    /// created graph.
+    /// The key type of the new map \c tmap should be the Node type of the
+    /// destination graph, and the key type of the original map \c map
+    /// should be the Node type of the source graph.
+    template <typename FromMap, typename ToMap>
+    GraphCopy& nodeMap(const FromMap& map, ToMap& tmap) {
       _node_maps.push_back(new _core_bits::MapCopy<From, Node,
-                           NodeRefMap, ToMap, FromMap>(tmap, map));
+                           NodeRefMap, FromMap, ToMap>(map, tmap));
       return *this;
     }
@@ -786,14 +797,17 @@
     /// \brief Make a copy of the given node.
     ///
-    /// Make a copy of the given node.
-    GraphCopy& node(TNode& tnode, const Node& snode) {
+    /// This function makes a copy of the given node.
+    GraphCopy& node(const Node& node, TNode& tnode) {
       _node_maps.push_back(new _core_bits::ItemCopy<From, Node,
-                           NodeRefMap, TNode>(tnode, snode));
-      return *this;
-    }
-
-    /// \brief Copies the arc references into the given map.
-    ///
-    /// Copies the arc references into the given map.
+                           NodeRefMap, TNode>(node, tnode));
+      return *this;
+    }
+
+    /// \brief Copy the arc references into the given map.
+    ///
+    /// This function copies the arc references into the given map.
+    /// The parameter should be a map, whose key type is the Arc type of
+    /// the source graph, while the value type is the Arc type of the
+    /// destination graph.
     template <typename ArcRef>
     GraphCopy& arcRef(ArcRef& map) {
@@ -803,8 +817,10 @@
     }
 
-    /// \brief Copies the arc cross references into the given map.
-    ///
-    ///  Copies the arc cross references (reverse references) into
-    ///  the given map.
+    /// \brief Copy the arc cross references into the given map.
+    ///
+    /// This function copies the arc cross references (reverse references)
+    /// into the given map. The parameter should be a map, whose key type
+    /// is the Arc type of the destination graph, while the value type is
+    /// the Arc type of the source graph.
     template <typename ArcCrossRef>
     GraphCopy& arcCrossRef(ArcCrossRef& map) {
@@ -814,14 +830,15 @@
     }
 
-    /// \brief Make copy of the given map.
-    ///
-    /// Makes copy of the given map for the newly created graph.
-    /// The new map's key type is the to graph's arc type,
-    /// and the copied map's key type is the from graph's arc
-    /// type.
-    template <typename ToMap, typename FromMap>
-    GraphCopy& arcMap(ToMap& tmap, const FromMap& map) {
+    /// \brief Make a copy of the given arc map.
+    ///
+    /// This function makes a copy of the given arc map for the newly
+    /// created graph.
+    /// The key type of the new map \c tmap should be the Arc type of the
+    /// destination graph, and the key type of the original map \c map
+    /// should be the Arc type of the source graph.
+    template <typename FromMap, typename ToMap>
+    GraphCopy& arcMap(const FromMap& map, ToMap& tmap) {
       _arc_maps.push_back(new _core_bits::MapCopy<From, Arc,
-                          ArcRefMap, ToMap, FromMap>(tmap, map));
+                          ArcRefMap, FromMap, ToMap>(map, tmap));
       return *this;
     }
@@ -829,14 +846,17 @@
     /// \brief Make a copy of the given arc.
     ///
-    /// Make a copy of the given arc.
-    GraphCopy& arc(TArc& tarc, const Arc& sarc) {
+    /// This function makes a copy of the given arc.
+    GraphCopy& arc(const Arc& arc, TArc& tarc) {
       _arc_maps.push_back(new _core_bits::ItemCopy<From, Arc,
-                          ArcRefMap, TArc>(tarc, sarc));
-      return *this;
-    }
-
-    /// \brief Copies the edge references into the given map.
-    ///
-    /// Copies the edge references into the given map.
+                          ArcRefMap, TArc>(arc, tarc));
+      return *this;
+    }
+
+    /// \brief Copy the edge references into the given map.
+    ///
+    /// This function copies the edge references into the given map.
+    /// The parameter should be a map, whose key type is the Edge type of
+    /// the source graph, while the value type is the Edge type of the
+    /// destination graph.
     template <typename EdgeRef>
     GraphCopy& edgeRef(EdgeRef& map) {
@@ -846,8 +866,10 @@
     }
 
-    /// \brief Copies the edge cross references into the given map.
-    ///
-    /// Copies the edge cross references (reverse
-    /// references) into the given map.
+    /// \brief Copy the edge cross references into the given map.
+    ///
+    /// This function copies the edge cross references (reverse references)
+    /// into the given map. The parameter should be a map, whose key type
+    /// is the Edge type of the destination graph, while the value type is
+    /// the Edge type of the source graph.
     template <typename EdgeCrossRef>
     GraphCopy& edgeCrossRef(EdgeCrossRef& map) {
@@ -857,14 +879,15 @@
     }
 
-    /// \brief Make copy of the given map.
-    ///
-    /// Makes copy of the given map for the newly created graph.
-    /// The new map's key type is the to graph's edge type,
-    /// and the copied map's key type is the from graph's edge
-    /// type.
-    template <typename ToMap, typename FromMap>
-    GraphCopy& edgeMap(ToMap& tmap, const FromMap& map) {
+    /// \brief Make a copy of the given edge map.
+    ///
+    /// This function makes a copy of the given edge map for the newly
+    /// created graph.
+    /// The key type of the new map \c tmap should be the Edge type of the
+    /// destination graph, and the key type of the original map \c map
+    /// should be the Edge type of the source graph.
+    template <typename FromMap, typename ToMap>
+    GraphCopy& edgeMap(const FromMap& map, ToMap& tmap) {
       _edge_maps.push_back(new _core_bits::MapCopy<From, Edge,
-                           EdgeRefMap, ToMap, FromMap>(tmap, map));
+                           EdgeRefMap, FromMap, ToMap>(map, tmap));
       return *this;
     }
@@ -872,20 +895,21 @@
     /// \brief Make a copy of the given edge.
     ///
-    /// Make a copy of the given edge.
-    GraphCopy& edge(TEdge& tedge, const Edge& sedge) {
+    /// This function makes a copy of the given edge.
+    GraphCopy& edge(const Edge& edge, TEdge& tedge) {
       _edge_maps.push_back(new _core_bits::ItemCopy<From, Edge,
-                           EdgeRefMap, TEdge>(tedge, sedge));
-      return *this;
-    }
-
-    /// \brief Executes the copies.
-    ///
-    /// Executes the copies.
+                           EdgeRefMap, TEdge>(edge, tedge));
+      return *this;
+    }
+
+    /// \brief Execute copying.
+    ///
+    /// This function executes the copying of the graph along with the
+    /// copying of the assigned data.
     void run() {
       NodeRefMap nodeRefMap(_from);
       EdgeRefMap edgeRefMap(_from);
-      ArcRefMap arcRefMap(_to, _from, edgeRefMap, nodeRefMap);
+      ArcRefMap arcRefMap(_from, _to, edgeRefMap, nodeRefMap);
       _core_bits::GraphCopySelector<To>::
-        copy(_to, _from, nodeRefMap, edgeRefMap);
+        copy(_from, _to, nodeRefMap, edgeRefMap);
       for (int i = 0; i < int(_node_maps.size()); ++i) {
         _node_maps[i]->copy(_from, nodeRefMap);
@@ -905,11 +929,11 @@
 
     std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* >
-    _node_maps;
+      _node_maps;
 
     std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* >
-    _arc_maps;
+      _arc_maps;
 
     std::vector<_core_bits::MapCopyBase<From, Edge, EdgeRefMap>* >
-    _edge_maps;
+      _edge_maps;
 
   };
@@ -917,21 +941,21 @@
   /// \brief Copy a graph to another graph.
   ///
-  /// Copy a graph to another graph. The complete usage of the
-  /// function is detailed in the GraphCopy class, but a short
-  /// example shows a basic work:
+  /// This function copies a graph to another graph.
+  /// The complete usage of it is detailed in the GraphCopy class,
+  /// but a short example shows a basic work:
   ///\code
-  /// copyGraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();
+  /// graphCopy(src, trg).nodeRef(nr).edgeCrossRef(ecr).run();
   ///\endcode
   ///
   /// After the copy the \c nr map will contain the mapping from the
   /// nodes of the \c from graph to the nodes of the \c to graph and
-  /// \c ecr will contain the mapping from the arcs of the \c to graph
-  /// to the arcs of the \c from graph.
+  /// \c ecr will contain the mapping from the edges of the \c to graph
+  /// to the edges of the \c from graph.
   ///
   /// \see GraphCopy
-  template <typename To, typename From>
-  GraphCopy<To, From>
-  copyGraph(To& to, const From& from) {
-    return GraphCopy<To, From>(to, from);
+  template <typename From, typename To>
+  GraphCopy<From, To>
+  graphCopy(const From& from, To& to) {
+    return GraphCopy<From, To>(from, to);
   }
 
@@ -958,5 +982,5 @@
     struct FindArcSelector<
       Graph,
-      typename enable_if<typename Graph::FindEdgeTag, void>::type>
+      typename enable_if<typename Graph::FindArcTag, void>::type>
     {
       typedef typename Graph::Node Node;
@@ -968,7 +992,8 @@
   }
 
-  /// \brief Finds an arc between two nodes of a graph.
-  ///
-  /// Finds an arc from node \c u to node \c v in graph \c g.
+  /// \brief Find an arc between two nodes of a digraph.
+  ///
+  /// This function finds an arc from node \c u to node \c v in the
+  /// digraph \c g.
   ///
   /// If \c prev is \ref INVALID (this is the default value), then
@@ -979,13 +1004,14 @@
   /// Thus you can iterate through each arc from \c u to \c v as it follows.
   ///\code
-  /// for(Arc e=findArc(g,u,v);e!=INVALID;e=findArc(g,u,v,e)) {
+  /// for(Arc e = findArc(g,u,v); e != INVALID; e = findArc(g,u,v,e)) {
   ///   ...
   /// }
   ///\endcode
   ///
-  ///\sa ArcLookUp
-  ///\sa AllArcLookUp
-  ///\sa DynArcLookUp
+  /// \note \ref ConArcIt provides iterator interface for the same
+  /// functionality.
+  ///
   ///\sa ConArcIt
+  ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp
   template <typename Graph>
   inline typename Graph::Arc
@@ -995,8 +1021,8 @@
   }
 
-  /// \brief Iterator for iterating on arcs connected the same nodes.
-  ///
-  /// Iterator for iterating on arcs connected the same nodes. It is
-  /// higher level interface for the findArc() function. You can
+  /// \brief Iterator for iterating on parallel arcs connecting the same nodes.
+  ///
+  /// Iterator for iterating on parallel arcs connecting the same nodes. It is
+  /// a higher level interface for the \ref findArc() function. You can
   /// use it the following way:
   ///\code
@@ -1007,7 +1033,5 @@
   ///
   ///\sa findArc()
-  ///\sa ArcLookUp
-  ///\sa AllArcLookUp
-  ///\sa DynArcLookUp
+  ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp
   template <typename _Graph>
   class ConArcIt : public _Graph::Arc {
@@ -1022,6 +1046,6 @@
     /// \brief Constructor.
     ///
-    /// Construct a new ConArcIt iterating on the arcs which
-    /// connects the \c u and \c v node.
+    /// Construct a new ConArcIt iterating on the arcs that
+    /// connects nodes \c u and \c v.
     ConArcIt(const Graph& g, Node u, Node v) : _graph(g) {
       Parent::operator=(findArc(_graph, u, v));
@@ -1030,6 +1054,5 @@
     /// \brief Constructor.
     ///
-    /// Construct a new ConArcIt which continues the iterating from
-    /// the \c e arc.
+    /// Construct a new ConArcIt that continues the iterating from arc \c a.
     ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
 
@@ -1092,25 +1115,27 @@
   }
 
-  /// \brief Finds an edge between two nodes of a graph.
-  ///
-  /// Finds an edge from node \c u to node \c v in graph \c g.
-  /// If the node \c u and node \c v is equal then each loop edge
+  /// \brief Find an edge between two nodes of a graph.
+  ///
+  /// This function finds an edge from node \c u to node \c v in graph \c g.
+  /// If node \c u and node \c v is equal then each loop edge
   /// will be enumerated once.
   ///
   /// If \c prev is \ref INVALID (this is the default value), then
-  /// it finds the first arc from \c u to \c v. Otherwise it looks for
-  /// the next arc from \c u to \c v after \c prev.
-  /// \return The found arc or \ref INVALID if there is no such an arc.
-  ///
-  /// Thus you can iterate through each arc from \c u to \c v as it follows.
+  /// it finds the first edge from \c u to \c v. Otherwise it looks for
+  /// the next edge from \c u to \c v after \c prev.
+  /// \return The found edge or \ref INVALID if there is no such an edge.
+  ///
+  /// Thus you can iterate through each edge between \c u and \c v
+  /// as it follows.
   ///\code
-  /// for(Edge e = findEdge(g,u,v); e != INVALID;
-  ///     e = findEdge(g,u,v,e)) {
+  /// for(Edge e = findEdge(g,u,v); e != INVALID; e = findEdge(g,u,v,e)) {
   ///   ...
   /// }
   ///\endcode
   ///
+  /// \note \ref ConEdgeIt provides iterator interface for the same
+  /// functionality.
+  ///
   ///\sa ConEdgeIt
-
   template <typename Graph>
   inline typename Graph::Edge
@@ -1120,11 +1145,11 @@
   }
 
-  /// \brief Iterator for iterating on edges connected the same nodes.
-  ///
-  /// Iterator for iterating on edges connected the same nodes. It is
-  /// higher level interface for the findEdge() function. You can
+  /// \brief Iterator for iterating on parallel edges connecting the same nodes.
+  ///
+  /// Iterator for iterating on parallel edges connecting the same nodes.
+  /// It is a higher level interface for the findEdge() function. You can
   /// use it the following way:
   ///\code
-  /// for (ConEdgeIt<Graph> it(g, src, trg); it != INVALID; ++it) {
+  /// for (ConEdgeIt<Graph> it(g, u, v); it != INVALID; ++it) {
   ///   ...
   /// }
@@ -1144,6 +1169,6 @@
     /// \brief Constructor.
     ///
-    /// Construct a new ConEdgeIt iterating on the edges which
-    /// connects the \c u and \c v node.
+    /// Construct a new ConEdgeIt iterating on the edges that
+    /// connects nodes \c u and \c v.
     ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) {
       Parent::operator=(findEdge(_graph, u, v));
@@ -1152,6 +1177,5 @@
     /// \brief Constructor.
     ///
-    /// Construct a new ConEdgeIt which continues the iterating from
-    /// the \c e edge.
+    /// Construct a new ConEdgeIt that continues iterating from edge \c e.
     ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
 
@@ -1169,8 +1193,8 @@
 
 
-  ///Dynamic arc look up between given endpoints.
+  ///Dynamic arc look-up between given endpoints.
 
   ///Using this class, you can find an arc in a digraph from a given
-  ///source to a given target in amortized time <em>O(log</em>d<em>)</em>,
+  ///source to a given target in amortized time <em>O</em>(log<em>d</em>),
   ///where <em>d</em> is the out-degree of the source node.
   ///
@@ -1178,10 +1202,10 @@
   ///the \c operator() member.
   ///
-  ///See the \ref ArcLookUp and \ref AllArcLookUp classes if your
-  ///digraph is not changed so frequently.
-  ///
-  ///This class uses a self-adjusting binary search tree, Sleator's
-  ///and Tarjan's Splay tree for guarantee the logarithmic amortized
-  ///time bound for arc lookups. This class also guarantees the
+  ///This is a dynamic data structure. Consider to use \ref ArcLookUp or
+  ///\ref AllArcLookUp if your digraph is not changed so frequently.
+  ///
+  ///This class uses a self-adjusting binary search tree, the Splay tree
+  ///of Sleator and Tarjan to guarantee the logarithmic amortized
+  ///time bound for arc look-ups. This class also guarantees the
   ///optimal time bound in a constant factor for any distribution of
   ///queries.
@@ -1508,6 +1532,6 @@
 
     ///Find an arc between two nodes.
-    ///\param s The source node
-    ///\param t The target node
+    ///\param s The source node.
+    ///\param t The target node.
     ///\param p The previous arc between \c s and \c t. It it is INVALID or
     ///not given, the operator finds the first appropriate arc.
@@ -1520,9 +1544,9 @@
     ///DynArcLookUp<ListDigraph> ae(g);
     ///...
-    ///int n=0;
-    ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++;
+    ///int n = 0;
+    ///for(Arc a = ae(u,v); a != INVALID; a = ae(u,v,a)) n++;
     ///\endcode
     ///
-    ///Finding the arcs take at most <em>O(</em>log<em>d)</em>
+    ///Finding the arcs take at most <em>O</em>(log<em>d</em>)
     ///amortized time, specifically, the time complexity of the lookups
     ///is equal to the optimal search tree implementation for the
@@ -1530,9 +1554,8 @@
     ///
     ///\note This is a dynamic data structure, therefore the data
-    ///structure is updated after each graph alteration. However,
-    ///theoretically this data structure is faster than \c ArcLookUp
-    ///or AllEdgeLookup, but it often provides worse performance than
+    ///structure is updated after each graph alteration. Thus although
+    ///this data structure is theoretically faster than \ref ArcLookUp
+    ///and \ref AllArcLookUp, it often provides worse performance than
     ///them.
-    ///
     Arc operator()(Node s, Node t, Arc p = INVALID) const  {
       if (p == INVALID) {
@@ -1586,8 +1609,8 @@
   };
 
-  ///Fast arc look up between given endpoints.
+  ///Fast arc look-up between given endpoints.
 
   ///Using this class, you can find an arc in a digraph from a given
-  ///source to a given target in time <em>O(log d)</em>,
+  ///source to a given target in time <em>O</em>(log<em>d</em>),
   ///where <em>d</em> is the out-degree of the source node.
   ///
@@ -1595,8 +1618,8 @@
   ///Use \ref AllArcLookUp for this purpose.
   ///
-  ///\warning This class is static, so you should refresh() (or at least
-  ///refresh(Node)) this data structure
-  ///whenever the digraph changes. This is a time consuming (superlinearly
-  ///proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs).
+  ///\warning This class is static, so you should call refresh() (or at
+  ///least refresh(Node)) to refresh this data structure whenever the
+  ///digraph changes. This is a time consuming (superlinearly proportional
+  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
   ///
   ///\tparam G The type of the underlying digraph.
@@ -1647,10 +1670,10 @@
     }
   public:
-    ///Refresh the data structure at a node.
+    ///Refresh the search data structure at a node.
 
     ///Build up the search database of node \c n.
     ///
-    ///It runs in time <em>O(d</em>log<em>d)</em>, where <em>d</em> is
-    ///the number of the outgoing arcs of \c n.
+    ///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em>
+    ///is the number of the outgoing arcs of \c n.
     void refresh(Node n)
     {
@@ -1668,8 +1691,7 @@
     ///\ref refresh(Node) "refresh(n)" for each node \c n.
     ///
-    ///It runs in time <em>O(m</em>log<em>D)</em>, where <em>m</em> is
-    ///the number of the arcs of \c n and <em>D</em> is the maximum
+    ///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is
+    ///the number of the arcs in the digraph and <em>D</em> is the maximum
     ///out-degree of the digraph.
-
     void refresh()
     {
@@ -1679,8 +1701,8 @@
     ///Find an arc between two nodes.
 
-    ///Find an arc between two nodes in time <em>O(</em>log<em>d)</em>, where
-    /// <em>d</em> is the number of outgoing arcs of \c s.
-    ///\param s The source node
-    ///\param t The target node
+    ///Find an arc between two nodes in time <em>O</em>(log<em>d</em>),
+    ///where <em>d</em> is the number of outgoing arcs of \c s.
+    ///\param s The source node.
+    ///\param t The target node.
     ///\return An arc from \c s to \c t if there exists,
     ///\ref INVALID otherwise.
@@ -1688,7 +1710,5 @@
     ///\warning If you change the digraph, refresh() must be called before using
     ///this operator. If you change the outgoing arcs of
-    ///a single node \c n, then
-    ///\ref refresh(Node) "refresh(n)" is enough.
-    ///
+    ///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough.
     Arc operator()(Node s, Node t) const
     {
@@ -1702,13 +1722,14 @@
   };
 
-  ///Fast look up of all arcs between given endpoints.
+  ///Fast look-up of all arcs between given endpoints.
 
   ///This class is the same as \ref ArcLookUp, with the addition
-  ///that it makes it possible to find all arcs between given endpoints.
-  ///
-  ///\warning This class is static, so you should refresh() (or at least
-  ///refresh(Node)) this data structure
-  ///whenever the digraph changes. This is a time consuming (superlinearly
-  ///proportional (<em>O(m</em>log<em>m)</em>) to the number of arcs).
+  ///that it makes it possible to find all parallel arcs between given
+  ///endpoints.
+  ///
+  ///\warning This class is static, so you should call refresh() (or at
+  ///least refresh(Node)) to refresh this data structure whenever the
+  ///digraph changes. This is a time consuming (superlinearly proportional
+  ///(<em>O</em>(<em>m</em> log<em>m</em>)) to the number of arcs).
   ///
   ///\tparam G The type of the underlying digraph.
@@ -1734,5 +1755,4 @@
       else {
         next=refreshNext(_right[head],next);
-//         _next[head]=next;
         _next[head]=( next!=INVALID && _g.target(next)==_g.target(head))
           ? next : INVALID;
@@ -1759,7 +1779,6 @@
     ///Build up the search database of node \c n.
     ///
-    ///It runs in time <em>O(d</em>log<em>d)</em>, where <em>d</em> is
+    ///It runs in time <em>O</em>(<em>d</em> log<em>d</em>), where <em>d</em> is
     ///the number of the outgoing arcs of \c n.
-
     void refresh(Node n)
     {
@@ -1773,8 +1792,7 @@
     ///\ref refresh(Node) "refresh(n)" for each node \c n.
     ///
-    ///It runs in time <em>O(m</em>log<em>D)</em>, where <em>m</em> is
-    ///the number of the arcs of \c n and <em>D</em> is the maximum
+    ///It runs in time <em>O</em>(<em>m</em> log<em>D</em>), where <em>m</em> is
+    ///the number of the arcs in the digraph and <em>D</em> is the maximum
     ///out-degree of the digraph.
-
     void refresh()
     {
@@ -1785,6 +1803,6 @@
 
     ///Find an arc between two nodes.
-    ///\param s The source node
-    ///\param t The target node
+    ///\param s The source node.
+    ///\param t The target node.
     ///\param prev The previous arc between \c s and \c t. It it is INVALID or
     ///not given, the operator finds the first appropriate arc.
@@ -1797,16 +1815,15 @@
     ///AllArcLookUp<ListDigraph> ae(g);
     ///...
-    ///int n=0;
-    ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++;
+    ///int n = 0;
+    ///for(Arc a = ae(u,v); a != INVALID; a=ae(u,v,a)) n++;
     ///\endcode
     ///
-    ///Finding the first arc take <em>O(</em>log<em>d)</em> time, where
-    /// <em>d</em> is the number of outgoing arcs of \c s. Then, the
+    ///Finding the first arc take <em>O</em>(log<em>d</em>) time,
+    ///where <em>d</em> is the number of outgoing arcs of \c s. Then the
     ///consecutive arcs are found in constant time.
     ///
     ///\warning If you change the digraph, refresh() must be called before using
     ///this operator. If you change the outgoing arcs of
-    ///a single node \c n, then
-    ///\ref refresh(Node) "refresh(n)" is enough.
+    ///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough.
     ///
 #ifdef DOXYGEN
Index: lemon/dfs.h
===================================================================
--- lemon/dfs.h	(revision 252)
+++ lemon/dfs.h	(revision 319)
@@ -28,6 +28,6 @@
 #include <lemon/core.h>
 #include <lemon/error.h>
-#include <lemon/assert.h>
 #include <lemon/maps.h>
+#include <lemon/path.h>
 
 namespace lemon {
@@ -50,10 +50,9 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
-    ///Instantiates a \ref PredMap.
-
-    ///This function instantiates a \ref PredMap.
+    ///Instantiates a PredMap.
+
+    ///This function instantiates a PredMap.
     ///\param g is the digraph, to which we would like to define the
-    ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient to initialize
+    ///PredMap.
     static PredMap *createPredMap(const Digraph &g)
     {
@@ -65,11 +64,10 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a \ref ProcessedMap.
-
-    ///This function instantiates a \ref ProcessedMap.
+    ///Instantiates a ProcessedMap.
+
+    ///This function instantiates a ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap
+    ///we would like to define the ProcessedMap
 #ifdef DOXYGEN
     static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -86,9 +84,9 @@
     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a \ref ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
+    ///Instantiates a ReachedMap.
+
+    ///This function instantiates a ReachedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
+    ///we would like to define the ReachedMap.
     static ReachedMap *createReachedMap(const Digraph &g)
     {
@@ -101,9 +99,9 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     typedef typename Digraph::template NodeMap<int> DistMap;
-    ///Instantiates a \ref DistMap.
-
-    ///This function instantiates a \ref DistMap.
+    ///Instantiates a DistMap.
+
+    ///This function instantiates a DistMap.
     ///\param g is the digraph, to which we would like to define the
-    ///\ref DistMap.
+    ///DistMap.
     static DistMap *createDistMap(const Digraph &g)
     {
@@ -117,5 +115,5 @@
   ///This class provides an efficient implementation of the %DFS algorithm.
   ///
-  ///There is also a \ref dfs() "function type interface" for the DFS
+  ///There is also a \ref dfs() "function-type interface" for the DFS
   ///algorithm, which is convenient in the simplier cases and it can be
   ///used easier.
@@ -138,14 +136,4 @@
   class Dfs {
   public:
-    ///\ref Exception for uninitialized parameters.
-
-    ///This error represents problems in the initialization of the
-    ///parameters of the algorithm.
-    class UninitializedParameter : public lemon::UninitializedParameter {
-    public:
-      virtual const char* what() const throw() {
-        return "lemon::Dfs::UninitializedParameter";
-      }
-    };
 
     ///The type of the digraph the algorithm runs on.
@@ -196,6 +184,5 @@
     int _stack_head;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps()
     {
@@ -231,76 +218,80 @@
 
     template <class T>
-    struct DefPredMapTraits : public Traits {
+    struct SetPredMapTraits : public Traits {
       typedef T PredMap;
       static PredMap *createPredMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "PredMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref PredMap type.
+    ///PredMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref PredMap type.
+    ///PredMap type.
     template <class T>
-    struct DefPredMap : public Dfs<Digraph, DefPredMapTraits<T> > {
-      typedef Dfs<Digraph, DefPredMapTraits<T> > Create;
+    struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > {
+      typedef Dfs<Digraph, SetPredMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefDistMapTraits : public Traits {
+    struct SetDistMapTraits : public Traits {
       typedef T DistMap;
       static DistMap *createDistMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "DistMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref DistMap type.
+    ///DistMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref DistMap type.
+    ///DistMap type.
     template <class T>
-    struct DefDistMap : public Dfs< Digraph, DefDistMapTraits<T> > {
-      typedef Dfs<Digraph, DefDistMapTraits<T> > Create;
+    struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > {
+      typedef Dfs<Digraph, SetDistMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefReachedMapTraits : public Traits {
+    struct SetReachedMapTraits : public Traits {
       typedef T ReachedMap;
       static ReachedMap *createReachedMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "ReachedMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ReachedMap type.
+    ///ReachedMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ReachedMap type.
+    ///ReachedMap type.
     template <class T>
-    struct DefReachedMap : public Dfs< Digraph, DefReachedMapTraits<T> > {
-      typedef Dfs< Digraph, DefReachedMapTraits<T> > Create;
+    struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > {
+      typedef Dfs< Digraph, SetReachedMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefProcessedMapTraits : public Traits {
+    struct SetProcessedMapTraits : public Traits {
       typedef T ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "ProcessedMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type.
+    ///ProcessedMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type.
+    ///ProcessedMap type.
     template <class T>
-    struct DefProcessedMap : public Dfs< Digraph, DefProcessedMapTraits<T> > {
-      typedef Dfs< Digraph, DefProcessedMapTraits<T> > Create;
-    };
-
-    struct DefDigraphProcessedMapTraits : public Traits {
+    struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > {
+      typedef Dfs< Digraph, SetProcessedMapTraits<T> > Create;
+    };
+
+    struct SetStandardProcessedMapTraits : public Traits {
       typedef typename Digraph::template NodeMap<bool> ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -310,13 +301,12 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
+    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
+    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     ///If you don't set it explicitly, it will be automatically allocated.
-    template <class T>
-    struct DefProcessedMapToBeDefaultMap :
-      public Dfs< Digraph, DefDigraphProcessedMapTraits> {
-      typedef Dfs< Digraph, DefDigraphProcessedMapTraits> Create;
+    struct SetStandardProcessedMap :
+      public Dfs< Digraph, SetStandardProcessedMapTraits > {
+      typedef Dfs< Digraph, SetStandardProcessedMapTraits > Create;
     };
 
@@ -559,15 +549,15 @@
     ///
     ///This method runs the %DFS algorithm from the root node
-    ///in order to compute the DFS path to \c dest.
+    ///in order to compute the DFS path to \c t.
     ///
     ///The algorithm computes
-    ///- the %DFS path to \c dest,
-    ///- the distance of \c dest from the root in the %DFS tree.
+    ///- the %DFS path to \c t,
+    ///- the distance of \c t from the root in the %DFS tree.
     ///
     ///\pre init() must be called and a root node should be
     ///added with addSource() before using this function.
-    void start(Node dest)
-    {
-      while ( !emptyQueue() && G->target(_stack[_stack_head])!=dest )
+    void start(Node t)
+    {
+      while ( !emptyQueue() && G->target(_stack[_stack_head])!=t )
         processNextArc();
     }
@@ -599,5 +589,5 @@
     }
 
-    ///Runs the algorithm from the given node.
+    ///Runs the algorithm from the given source node.
 
     ///This method runs the %DFS algorithm from node \c s
@@ -623,8 +613,8 @@
 
     ///This method runs the %DFS algorithm from node \c s
-    ///in order to compute the DFS path to \c t.
-    ///
-    ///\return The length of the <tt>s</tt>--<tt>t</tt> DFS path,
-    ///if \c t is reachable form \c s, \c 0 otherwise.
+    ///in order to compute the DFS path to node \c t
+    ///(it stops searching when \c t is processed)
+    ///
+    ///\return \c true if \c t is reachable form \c s.
     ///
     ///\note Apart from the return value, <tt>d.run(s,t)</tt> is
@@ -635,9 +625,9 @@
     ///  d.start(t);
     ///\endcode
-    int run(Node s,Node t) {
+    bool run(Node s,Node t) {
       init();
       addSource(s);
       start(t);
-      return reached(t)?_stack_head+1:0;
+      return reached(t);
     }
 
@@ -777,19 +767,13 @@
     ///arcs of the %DFS paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef NullMap<typename Digraph::Node,typename Digraph::Arc> PredMap;
-    ///Instantiates a \ref PredMap.
-
-    ///This function instantiates a \ref PredMap.
+    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+    ///Instantiates a PredMap.
+
+    ///This function instantiates a PredMap.
     ///\param g is the digraph, to which we would like to define the
-    ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient to initialize
-#ifdef DOXYGEN
+    ///PredMap.
     static PredMap *createPredMap(const Digraph &g)
-#else
-    static PredMap *createPredMap(const Digraph &)
-#endif
-    {
-      return new PredMap();
+    {
+      return new PredMap(g);
     }
 
@@ -798,10 +782,11 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
+    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a \ref ProcessedMap.
-
-    ///This function instantiates a \ref ProcessedMap.
+    ///Instantiates a ProcessedMap.
+
+    ///This function instantiates a ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap.
+    ///we would like to define the ProcessedMap.
 #ifdef DOXYGEN
     static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -818,9 +803,9 @@
     ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a \ref ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
+    ///Instantiates a ReachedMap.
+
+    ///This function instantiates a ReachedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
+    ///we would like to define the ReachedMap.
     static ReachedMap *createReachedMap(const Digraph &g)
     {
@@ -832,22 +817,23 @@
     ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef NullMap<typename Digraph::Node,int> DistMap;
-    ///Instantiates a \ref DistMap.
-
-    ///This function instantiates a \ref DistMap.
+    typedef typename Digraph::template NodeMap<int> DistMap;
+    ///Instantiates a DistMap.
+
+    ///This function instantiates a DistMap.
     ///\param g is the digraph, to which we would like to define
-    ///the \ref DistMap
-#ifdef DOXYGEN
+    ///the DistMap
     static DistMap *createDistMap(const Digraph &g)
-#else
-    static DistMap *createDistMap(const Digraph &)
-#endif
-    {
-      return new DistMap();
-    }
+    {
+      return new DistMap(g);
+    }
+
+    ///The type of the DFS paths.
+
+    ///The type of the DFS paths.
+    ///It must meet the \ref concepts::Path "Path" concept.
+    typedef lemon::Path<Digraph> Path;
   };
 
-  /// Default traits class used by \ref DfsWizard
+  /// Default traits class used by DfsWizard
 
   /// To make it easier to use Dfs algorithm
@@ -876,6 +862,8 @@
     //Pointer to the map of distances.
     void *_dist;
-    //Pointer to the source node.
-    Node _source;
+    //Pointer to the DFS path to the target node.
+    void *_path;
+    //Pointer to the distance of the target node.
+    int *_di;
 
     public:
@@ -883,42 +871,28 @@
 
     /// This constructor does not require parameters, therefore it initiates
-    /// all of the attributes to default values (0, INVALID).
+    /// all of the attributes to \c 0.
     DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
-                      _dist(0), _source(INVALID) {}
+                      _dist(0), _path(0), _di(0) {}
 
     /// Constructor.
 
-    /// This constructor requires some parameters,
-    /// listed in the parameters list.
-    /// Others are initiated to 0.
+    /// This constructor requires one parameter,
+    /// others are initiated to \c 0.
     /// \param g The digraph the algorithm runs on.
-    /// \param s The source node.
-    DfsWizardBase(const GR &g, Node s=INVALID) :
+    DfsWizardBase(const GR &g) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
-      _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {}
+      _reached(0), _processed(0), _pred(0), _dist(0),  _path(0), _di(0) {}
 
   };
 
-  /// Auxiliary class for the function type interface of DFS algorithm.
-
-  /// This auxiliary class is created to implement the function type
-  /// interface of \ref Dfs algorithm. It uses the functions and features
-  /// of the plain \ref Dfs, but it is much simpler to use it.
-  /// It should only be used through the \ref dfs() function, which makes
-  /// it easier to use the algorithm.
+  /// Auxiliary class for the function-type interface of DFS algorithm.
+
+  /// This auxiliary class is created to implement the
+  /// \ref dfs() "function-type interface" of \ref Dfs algorithm.
+  /// It does not have own \ref run() method, it uses the functions
+  /// and features of the plain \ref Dfs.
   ///
-  /// Simplicity means that the way to change the types defined
-  /// in the traits class is based on functions that returns the new class
-  /// and not on templatable built-in classes.
-  /// When using the plain \ref Dfs
-  /// the new class with the modified type comes from
-  /// the original class by using the ::
-  /// operator. In the case of \ref DfsWizard only
-  /// a function have to be called, and it will
-  /// return the needed class.
-  ///
-  /// It does not have own \ref run() method. When its \ref run() method
-  /// is called, it initiates a plain \ref Dfs object, and calls the
-  /// \ref Dfs::run() method of it.
+  /// This class should only be used through the \ref dfs() function,
+  /// which makes it easier to use the algorithm.
   template<class TR>
   class DfsWizard : public TR
@@ -935,5 +909,5 @@
 
     ///\brief The type of the map that stores the predecessor
-    ///arcs of the shortest paths.
+    ///arcs of the DFS paths.
     typedef typename TR::PredMap PredMap;
     ///\brief The type of the map that stores the distances of the nodes.
@@ -943,4 +917,6 @@
     ///\brief The type of the map that indicates which nodes are processed.
     typedef typename TR::ProcessedMap ProcessedMap;
+    ///The type of the DFS paths
+    typedef typename TR::Path Path;
 
   public:
@@ -953,6 +929,7 @@
     /// Constructor that requires parameters.
     /// These parameters will be the default values for the traits class.
-    DfsWizard(const Digraph &g, Node s=INVALID) :
-      TR(g,s) {}
+    /// \param g The digraph the algorithm runs on.
+    DfsWizard(const Digraph &g) :
+      TR(g) {}
 
     ///Copy constructor
@@ -961,130 +938,178 @@
     ~DfsWizard() {}
 
-    ///Runs DFS algorithm from a source node.
-
-    ///Runs DFS algorithm from a source node.
-    ///The node can be given with the \ref source() function.
+    ///Runs DFS algorithm from the given source node.
+
+    ///This method runs DFS algorithm from node \c s
+    ///in order to compute the DFS path to each node.
+    void run(Node s)
+    {
+      Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
+      if (Base::_pred)
+        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if (Base::_dist)
+        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      if (Base::_reached)
+        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
+      if (Base::_processed)
+        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      if (s!=INVALID)
+        alg.run(s);
+      else
+        alg.run();
+    }
+
+    ///Finds the DFS path between \c s and \c t.
+
+    ///This method runs DFS algorithm from node \c s
+    ///in order to compute the DFS path to node \c t
+    ///(it stops searching when \c t is processed).
+    ///
+    ///\return \c true if \c t is reachable form \c s.
+    bool run(Node s, Node t)
+    {
+      Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
+      if (Base::_pred)
+        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if (Base::_dist)
+        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      if (Base::_reached)
+        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
+      if (Base::_processed)
+        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      alg.run(s,t);
+      if (Base::_path)
+        *reinterpret_cast<Path*>(Base::_path) = alg.path(t);
+      if (Base::_di)
+        *Base::_di = alg.dist(t);
+      return alg.reached(t);
+      }
+
+    ///Runs DFS algorithm to visit all nodes in the digraph.
+
+    ///This method runs DFS algorithm in order to compute
+    ///the DFS path to each node.
     void run()
     {
-      if(Base::_source==INVALID) throw UninitializedParameter();
-      Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
-      if(Base::_reached)
-        alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
-      if(Base::_processed)
-        alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
-      if(Base::_pred)
-        alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
-      if(Base::_dist)
-        alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
-      alg.run(Base::_source);
-    }
-
-    ///Runs DFS algorithm from the given node.
-
-    ///Runs DFS algorithm from the given node.
-    ///\param s is the given source.
-    void run(Node s)
-    {
-      Base::_source=s;
-      run();
-    }
-
-    /// Sets the source node, from which the Dfs algorithm runs.
-
-    /// Sets the source node, from which the Dfs algorithm runs.
-    /// \param s is the source node.
-    DfsWizard<TR> &source(Node s)
-    {
-      Base::_source=s;
-      return *this;
+      run(INVALID);
     }
 
     template<class T>
-    struct DefPredMapBase : public Base {
+    struct SetPredMapBase : public Base {
       typedef T PredMap;
       static PredMap *createPredMap(const Digraph &) { return 0; };
-      DefPredMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref PredMap object.
-    ///
-    ///\ref named-templ-param "Named parameter"
-    ///for setting \ref PredMap object.
+      SetPredMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting PredMap object.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for setting PredMap object.
     template<class T>
-    DfsWizard<DefPredMapBase<T> > predMap(const T &t)
+    DfsWizard<SetPredMapBase<T> > predMap(const T &t)
     {
       Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DfsWizard<DefPredMapBase<T> >(*this);
+      return DfsWizard<SetPredMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefReachedMapBase : public Base {
+    struct SetReachedMapBase : public Base {
       typedef T ReachedMap;
       static ReachedMap *createReachedMap(const Digraph &) { return 0; };
-      DefReachedMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref ReachedMap object.
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///for setting \ref ReachedMap object.
+      SetReachedMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting ReachedMap object.
+    ///
+    /// \ref named-func-param "Named parameter"
+    ///for setting ReachedMap object.
     template<class T>
-    DfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
+    DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
     {
       Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DfsWizard<DefReachedMapBase<T> >(*this);
+      return DfsWizard<SetReachedMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefProcessedMapBase : public Base {
+    struct SetDistMapBase : public Base {
+      typedef T DistMap;
+      static DistMap *createDistMap(const Digraph &) { return 0; };
+      SetDistMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting DistMap object.
+    ///
+    /// \ref named-func-param "Named parameter"
+    ///for setting DistMap object.
+    template<class T>
+    DfsWizard<SetDistMapBase<T> > distMap(const T &t)
+    {
+      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return DfsWizard<SetDistMapBase<T> >(*this);
+    }
+
+    template<class T>
+    struct SetProcessedMapBase : public Base {
       typedef T ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
-      DefProcessedMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
+      SetProcessedMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting ProcessedMap object.
+    ///
+    /// \ref named-func-param "Named parameter"
+    ///for setting ProcessedMap object.
     template<class T>
-    DfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
+    DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     {
       Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DfsWizard<DefProcessedMapBase<T> >(*this);
+      return DfsWizard<SetProcessedMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefDistMapBase : public Base {
-      typedef T DistMap;
-      static DistMap *createDistMap(const Digraph &) { return 0; };
-      DefDistMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref DistMap object.
-    ///
-    ///\ref named-templ-param "Named parameter"
-    ///for setting \ref DistMap object.
+    struct SetPathBase : public Base {
+      typedef T Path;
+      SetPathBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for getting the DFS path to the target node.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for getting the DFS path to the target node.
     template<class T>
-    DfsWizard<DefDistMapBase<T> > distMap(const T &t)
-    {
-      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DfsWizard<DefDistMapBase<T> >(*this);
+    DfsWizard<SetPathBase<T> > path(const T &t)
+    {
+      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return DfsWizard<SetPathBase<T> >(*this);
+    }
+
+    ///\brief \ref named-func-param "Named parameter"
+    ///for getting the distance of the target node.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for getting the distance of the target node.
+    DfsWizard dist(const int &d)
+    {
+      Base::_di=const_cast<int*>(&d);
+      return *this;
     }
 
   };
 
-  ///Function type interface for Dfs algorithm.
+  ///Function-type interface for DFS algorithm.
 
   ///\ingroup search
-  ///Function type interface for Dfs algorithm.
+  ///Function-type interface for DFS algorithm.
   ///
-  ///This function also has several
-  ///\ref named-templ-func-param "named parameters",
+  ///This function also has several \ref named-func-param "named parameters",
   ///they are declared as the members of class \ref DfsWizard.
-  ///The following
-  ///example shows how to use these parameters.
+  ///The following examples show how to use these parameters.
   ///\code
-  ///  dfs(g,source).predMap(preds).run();
+  ///  // Compute the DFS tree
+  ///  dfs(g).predMap(preds).distMap(dists).run(s);
+  ///
+  ///  // Compute the DFS path from s to t
+  ///  bool reached = dfs(g).path(p).dist(d).run(s,t);
   ///\endcode
+
   ///\warning Don't forget to put the \ref DfsWizard::run() "run()"
   ///to the end of the parameter list.
@@ -1093,7 +1118,7 @@
   template<class GR>
   DfsWizard<DfsWizardBase<GR> >
-  dfs(const GR &g,typename GR::Node s=INVALID)
+  dfs(const GR &digraph)
   {
-    return DfsWizard<DfsWizardBase<GR> >(g,s);
+    return DfsWizard<DfsWizardBase<GR> >(digraph);
   }
 
@@ -1188,9 +1213,9 @@
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
 
-    /// \brief Instantiates a \ref ReachedMap.
-    ///
-    /// This function instantiates a \ref ReachedMap.
+    /// \brief Instantiates a ReachedMap.
+    ///
+    /// This function instantiates a ReachedMap.
     /// \param digraph is the digraph, to which
-    /// we would like to define the \ref ReachedMap.
+    /// we would like to define the ReachedMap.
     static ReachedMap *createReachedMap(const Digraph &digraph) {
       return new ReachedMap(digraph);
@@ -1233,20 +1258,8 @@
   template <typename _Digraph = ListDigraph,
             typename _Visitor = DfsVisitor<_Digraph>,
-            typename _Traits = DfsDefaultTraits<_Digraph> >
+            typename _Traits = DfsVisitDefaultTraits<_Digraph> >
 #endif
   class DfsVisit {
   public:
-
-    /// \brief \ref Exception for uninitialized parameters.
-    ///
-    /// This error represents problems in the initialization
-    /// of the parameters of the algorithm.
-    class UninitializedParameter : public lemon::UninitializedParameter {
-    public:
-      virtual const char* what() const throw()
-      {
-        return "lemon::DfsVisit::UninitializedParameter";
-      }
-    };
 
     ///The traits class.
@@ -1281,6 +1294,5 @@
     int _stack_head;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps() {
       if(!_reached) {
@@ -1302,8 +1314,9 @@
     ///@{
     template <class T>
-    struct DefReachedMapTraits : public Traits {
+    struct SetReachedMapTraits : public Traits {
       typedef T ReachedMap;
       static ReachedMap *createReachedMap(const Digraph &digraph) {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "ReachedMap is not initialized");
+        return 0; // ignore warnings
       }
     };
@@ -1313,7 +1326,7 @@
     /// \ref named-templ-param "Named parameter" for setting ReachedMap type.
     template <class T>
-    struct DefReachedMap : public DfsVisit< Digraph, Visitor,
-                                            DefReachedMapTraits<T> > {
-      typedef DfsVisit< Digraph, Visitor, DefReachedMapTraits<T> > Create;
+    struct SetReachedMap : public DfsVisit< Digraph, Visitor,
+                                            SetReachedMapTraits<T> > {
+      typedef DfsVisit< Digraph, Visitor, SetReachedMapTraits<T> > Create;
     };
     ///@}
@@ -1490,14 +1503,14 @@
     ///
     /// This method runs the %DFS algorithm from the root node
-    /// in order to compute the DFS path to \c dest.
+    /// in order to compute the DFS path to \c t.
     ///
     /// The algorithm computes
-    /// - the %DFS path to \c dest,
-    /// - the distance of \c dest from the root in the %DFS tree.
+    /// - the %DFS path to \c t,
+    /// - the distance of \c t from the root in the %DFS tree.
     ///
     /// \pre init() must be called and a root node should be added
     /// with addSource() before using this function.
-    void start(Node dest) {
-      while ( !emptyQueue() && _digraph->target(_stack[_stack_head]) != dest )
+    void start(Node t) {
+      while ( !emptyQueue() && _digraph->target(_stack[_stack_head]) != t )
         processNextArc();
     }
@@ -1528,5 +1541,5 @@
     }
 
-    /// \brief Runs the algorithm from the given node.
+    /// \brief Runs the algorithm from the given source node.
     ///
     /// This method runs the %DFS algorithm from node \c s.
@@ -1552,8 +1565,8 @@
 
     /// This method runs the %DFS algorithm from node \c s
-    /// in order to compute the DFS path to \c t.
-    ///
-    /// \return The length of the <tt>s</tt>--<tt>t</tt> DFS path,
-    /// if \c t is reachable form \c s, \c 0 otherwise.
+    /// in order to compute the DFS path to node \c t
+    /// (it stops searching when \c t is processed).
+    ///
+    /// \return \c true if \c t is reachable form \c s.
     ///
     /// \note Apart from the return value, <tt>d.run(s,t)</tt> is
@@ -1564,9 +1577,9 @@
     ///   d.start(t);
     ///\endcode
-    int run(Node s,Node t) {
+    bool run(Node s,Node t) {
       init();
       addSource(s);
       start(t);
-      return reached(t)?_stack_head+1:0;
+      return reached(t);
     }
 
Index: lemon/dijkstra.h
===================================================================
--- lemon/dijkstra.h	(revision 251)
+++ lemon/dijkstra.h	(revision 313)
@@ -31,4 +31,5 @@
 #include <lemon/error.h>
 #include <lemon/maps.h>
+#include <lemon/path.h>
 
 namespace lemon {
@@ -139,10 +140,9 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
-    ///Instantiates a \ref PredMap.
-
-    ///This function instantiates a \ref PredMap.
+    ///Instantiates a PredMap.
+
+    ///This function instantiates a PredMap.
     ///\param g is the digraph, to which we would like to define the
-    ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient for the initialization
+    ///PredMap.
     static PredMap *createPredMap(const Digraph &g)
     {
@@ -155,12 +155,10 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     ///By default it is a NullMap.
-    ///\todo If it is set to a real map,
-    ///Dijkstra::processed() should read this.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a \ref ProcessedMap.
-
-    ///This function instantiates a \ref ProcessedMap.
+    ///Instantiates a ProcessedMap.
+
+    ///This function instantiates a ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap
+    ///we would like to define the ProcessedMap
 #ifdef DOXYGEN
     static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -177,9 +175,9 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     typedef typename Digraph::template NodeMap<typename LM::Value> DistMap;
-    ///Instantiates a \ref DistMap.
-
-    ///This function instantiates a \ref DistMap.
+    ///Instantiates a DistMap.
+
+    ///This function instantiates a DistMap.
     ///\param g is the digraph, to which we would like to define
-    ///the \ref DistMap
+    ///the DistMap
     static DistMap *createDistMap(const Digraph &g)
     {
@@ -200,5 +198,5 @@
   ///It is also possible to change the underlying priority heap.
   ///
-  ///There is also a \ref dijkstra() "function type interface" for the
+  ///There is also a \ref dijkstra() "function-type interface" for the
   ///%Dijkstra algorithm, which is convenient in the simplier cases and
   ///it can be used easier.
@@ -228,14 +226,4 @@
   class Dijkstra {
   public:
-    ///\ref Exception for uninitialized parameters.
-
-    ///This error represents problems in the initialization of the
-    ///parameters of the algorithm.
-    class UninitializedParameter : public lemon::UninitializedParameter {
-    public:
-      virtual const char* what() const throw() {
-        return "lemon::Dijkstra::UninitializedParameter";
-      }
-    };
 
     ///The type of the digraph the algorithm runs on.
@@ -297,6 +285,5 @@
     bool local_heap;
 
-    ///Creates the maps if necessary.
-    ///\todo Better memory allocation (instead of new).
+    //Creates the maps if necessary.
     void create_maps()
     {
@@ -332,61 +319,64 @@
 
     template <class T>
-    struct DefPredMapTraits : public Traits {
+    struct SetPredMapTraits : public Traits {
       typedef T PredMap;
       static PredMap *createPredMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "PredMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref PredMap type.
+    ///PredMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref PredMap type.
+    ///PredMap type.
     template <class T>
-    struct DefPredMap
-      : public Dijkstra< Digraph, LengthMap, DefPredMapTraits<T> > {
-      typedef Dijkstra< Digraph, LengthMap, DefPredMapTraits<T> > Create;
+    struct SetPredMap
+      : public Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > {
+      typedef Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefDistMapTraits : public Traits {
+    struct SetDistMapTraits : public Traits {
       typedef T DistMap;
       static DistMap *createDistMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "DistMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref DistMap type.
+    ///DistMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref DistMap type.
+    ///DistMap type.
     template <class T>
-    struct DefDistMap
-      : public Dijkstra< Digraph, LengthMap, DefDistMapTraits<T> > {
-      typedef Dijkstra< Digraph, LengthMap, DefDistMapTraits<T> > Create;
+    struct SetDistMap
+      : public Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > {
+      typedef Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > Create;
     };
 
     template <class T>
-    struct DefProcessedMapTraits : public Traits {
+    struct SetProcessedMapTraits : public Traits {
       typedef T ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "ProcessedMap is not initialized");
+        return 0; // ignore warnings
       }
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type.
+    ///ProcessedMap type.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type.
+    ///ProcessedMap type.
     template <class T>
-    struct DefProcessedMap
-      : public Dijkstra< Digraph, LengthMap, DefProcessedMapTraits<T> > {
-      typedef Dijkstra< Digraph, LengthMap, DefProcessedMapTraits<T> > Create;
-    };
-
-    struct DefDigraphProcessedMapTraits : public Traits {
+    struct SetProcessedMap
+      : public Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > {
+      typedef Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > Create;
+    };
+
+    struct SetStandardProcessedMapTraits : public Traits {
       typedef typename Digraph::template NodeMap<bool> ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -396,26 +386,27 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
+    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     ///
     ///\ref named-templ-param "Named parameter" for setting
-    ///\ref ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
+    ///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>.
     ///If you don't set it explicitly, it will be automatically allocated.
-    template <class T>
-    struct DefProcessedMapToBeDefaultMap
-      : public Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits> {
-      typedef Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits>
+    struct SetStandardProcessedMap
+      : public Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > {
+      typedef Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits >
       Create;
     };
 
     template <class H, class CR>
-    struct DefHeapTraits : public Traits {
+    struct SetHeapTraits : public Traits {
       typedef CR HeapCrossRef;
       typedef H Heap;
       static HeapCrossRef *createHeapCrossRef(const Digraph &) {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "HeapCrossRef is not initialized");
+        return 0; // ignore warnings
       }
       static Heap *createHeap(HeapCrossRef &)
       {
-        throw UninitializedParameter();
+        LEMON_ASSERT(false, "Heap is not initialized");
+        return 0; // ignore warnings
       }
     };
@@ -426,11 +417,11 @@
     ///reference type.
     template <class H, class CR = typename Digraph::template NodeMap<int> >
-    struct DefHeap
-      : public Dijkstra< Digraph, LengthMap, DefHeapTraits<H, CR> > {
-      typedef Dijkstra< Digraph, LengthMap, DefHeapTraits<H, CR> > Create;
+    struct SetHeap
+      : public Dijkstra< Digraph, LengthMap, SetHeapTraits<H, CR> > {
+      typedef Dijkstra< Digraph, LengthMap, SetHeapTraits<H, CR> > Create;
     };
 
     template <class H, class CR>
-    struct DefStandardHeapTraits : public Traits {
+    struct SetStandardHeapTraits : public Traits {
       typedef CR HeapCrossRef;
       typedef H Heap;
@@ -451,24 +442,24 @@
     ///parameter and the heap's constructor waits for the cross reference.
     template <class H, class CR = typename Digraph::template NodeMap<int> >
-    struct DefStandardHeap
-      : public Dijkstra< Digraph, LengthMap, DefStandardHeapTraits<H, CR> > {
-      typedef Dijkstra< Digraph, LengthMap, DefStandardHeapTraits<H, CR> >
+    struct SetStandardHeap
+      : public Dijkstra< Digraph, LengthMap, SetStandardHeapTraits<H, CR> > {
+      typedef Dijkstra< Digraph, LengthMap, SetStandardHeapTraits<H, CR> >
       Create;
     };
 
     template <class T>
-    struct DefOperationTraitsTraits : public Traits {
+    struct SetOperationTraitsTraits : public Traits {
       typedef T OperationTraits;
     };
 
     /// \brief \ref named-templ-param "Named parameter" for setting
-    ///\ref OperationTraits type
+    ///\c OperationTraits type
     ///
     ///\ref named-templ-param "Named parameter" for setting
     ///\ref OperationTraits type.
     template <class T>
-    struct DefOperationTraits
-      : public Dijkstra<Digraph, LengthMap, DefOperationTraitsTraits<T> > {
-      typedef Dijkstra<Digraph, LengthMap, DefOperationTraitsTraits<T> >
+    struct SetOperationTraits
+      : public Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> > {
+      typedef Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> >
       Create;
     };
@@ -729,21 +720,24 @@
     }
 
-    ///Executes the algorithm until the given target node is reached.
-
-    ///Executes the algorithm until the given target node is reached.
+    ///Executes the algorithm until the given target node is processed.
+
+    ///Executes the algorithm until the given target node is processed.
     ///
     ///This method runs the %Dijkstra algorithm from the root node(s)
-    ///in order to compute the shortest path to \c dest.
+    ///in order to compute the shortest path to \c t.
     ///
     ///The algorithm computes
-    ///- the shortest path to \c dest,
-    ///- the distance of \c dest from the root(s).
+    ///- the shortest path to \c t,
+    ///- the distance of \c t from the root(s).
     ///
     ///\pre init() must be called and at least one root node should be
     ///added with addSource() before using this function.
-    void start(Node dest)
-    {
-      while ( !_heap->empty() && _heap->top()!=dest ) processNextNode();
-      if ( !_heap->empty() ) finalizeNodeData(_heap->top(),_heap->prio());
+    void start(Node t)
+    {
+      while ( !_heap->empty() && _heap->top()!=t ) processNextNode();
+      if ( !_heap->empty() ) {
+        finalizeNodeData(_heap->top(),_heap->prio());
+        _heap->pop();
+      }
     }
 
@@ -773,5 +767,5 @@
     }
 
-    ///Runs the algorithm from the given node.
+    ///Runs the algorithm from the given source node.
 
     ///This method runs the %Dijkstra algorithm from node \c s
@@ -797,8 +791,8 @@
 
     ///This method runs the %Dijkstra algorithm from node \c s
-    ///in order to compute the shortest path to \c t.
-    ///
-    ///\return The length of the shortest <tt>s</tt>--<tt>t</tt> path,
-    ///if \c t is reachable form \c s, \c 0 otherwise.
+    ///in order to compute the shortest path to node \c t
+    ///(it stops searching when \c t is processed).
+    ///
+    ///\return \c true if \c t is reachable form \c s.
     ///
     ///\note Apart from the return value, <tt>d.run(s,t)</tt> is just a
@@ -809,9 +803,9 @@
     ///  d.start(t);
     ///\endcode
-    Value run(Node s,Node t) {
+    bool run(Node s,Node t) {
       init();
       addSource(s);
       start(t);
-      return (*_pred)[t]==INVALID?OperationTraits::zero():(*_dist)[t];
+      return (*_heap_cross_ref)[t] == Heap::POST_HEAP;
     }
 
@@ -909,5 +903,5 @@
     ///Returns \c true if \c v is processed, i.e. the shortest
     ///path to \c v has already found.
-    ///\pre Either \ref run() or \ref start()
+    ///\pre Either \ref run() or \ref init()
     ///must be called before using this function.
     bool processed(Node v) const { return (*_heap_cross_ref)[v] ==
@@ -918,6 +912,10 @@
     ///Returns the current distance of a node from the root(s).
     ///It may be decreased in the following processes.
-    ///\pre \c v should be reached but not processed.
-    Value currentDist(Node v) const { return (*_heap)[v]; }
+    ///\pre Either \ref run() or \ref init()
+    ///must be called before using this function and
+    ///node \c v must be reached but not necessarily processed.
+    Value currentDist(Node v) const {
+      return processed(v) ? (*_dist)[v] : (*_heap)[v];
+    }
 
     ///@}
@@ -959,5 +957,4 @@
     /// \param g is the digraph, to which we would like to define the
     /// HeapCrossRef.
-    /// \todo The digraph alone may be insufficient for the initialization
     static HeapCrossRef *createHeapCrossRef(const Digraph &g)
     {
@@ -989,18 +986,13 @@
     ///arcs of the shortest paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    typedef NullMap <typename Digraph::Node,typename Digraph::Arc> PredMap;
-    ///Instantiates a \ref PredMap.
-
-    ///This function instantiates a \ref PredMap.
+    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+    ///Instantiates a PredMap.
+
+    ///This function instantiates a PredMap.
     ///\param g is the digraph, to which we would like to define the
-    ///\ref PredMap.
-    ///\todo The digraph alone may be insufficient to initialize
-#ifdef DOXYGEN
+    ///PredMap.
     static PredMap *createPredMap(const Digraph &g)
-#else
-    static PredMap *createPredMap(const Digraph &)
-#endif
-    {
-      return new PredMap();
+    {
+      return new PredMap(g);
     }
 
@@ -1010,13 +1002,10 @@
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     ///By default it is a NullMap.
-    ///\todo If it is set to a real map,
-    ///Dijkstra::processed() should read this.
-    ///\todo named parameter to set this type, function to read and write.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a \ref ProcessedMap.
-
-    ///This function instantiates a \ref ProcessedMap.
+    ///Instantiates a ProcessedMap.
+
+    ///This function instantiates a ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap.
+    ///we would like to define the ProcessedMap.
 #ifdef DOXYGEN
     static ProcessedMap *createProcessedMap(const Digraph &g)
@@ -1032,21 +1021,23 @@
     ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    typedef NullMap<typename Digraph::Node,Value> DistMap;
-    ///Instantiates a \ref DistMap.
-
-    ///This function instantiates a \ref DistMap.
+    typedef typename Digraph::template NodeMap<typename LM::Value> DistMap;
+    ///Instantiates a DistMap.
+
+    ///This function instantiates a DistMap.
     ///\param g is the digraph, to which we would like to define
-    ///the \ref DistMap
-#ifdef DOXYGEN
+    ///the DistMap
     static DistMap *createDistMap(const Digraph &g)
-#else
-    static DistMap *createDistMap(const Digraph &)
-#endif
-    {
-      return new DistMap();
-    }
+    {
+      return new DistMap(g);
+    }
+
+    ///The type of the shortest paths.
+
+    ///The type of the shortest paths.
+    ///It must meet the \ref concepts::Path "Path" concept.
+    typedef lemon::Path<Digraph> Path;
   };
 
-  /// Default traits class used by \ref DijkstraWizard
+  /// Default traits class used by DijkstraWizard
 
   /// To make it easier to use Dijkstra algorithm
@@ -1056,5 +1047,4 @@
   /// The \ref DijkstraWizardBase is a class to be the default traits of the
   /// \ref DijkstraWizard class.
-  /// \todo More named parameters are required...
   template<class GR,class LM>
   class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LM>
@@ -1067,5 +1057,5 @@
     //Pointer to the digraph the algorithm runs on.
     void *_g;
-    //Pointer to the length map
+    //Pointer to the length map.
     void *_length;
     //Pointer to the map of processed nodes.
@@ -1075,6 +1065,8 @@
     //Pointer to the map of distances.
     void *_dist;
-    //Pointer to the source node.
-    Node _source;
+    //Pointer to the shortest path to the target node.
+    void *_path;
+    //Pointer to the distance of the target node.
+    void *_di;
 
   public:
@@ -1082,44 +1074,30 @@
 
     /// This constructor does not require parameters, therefore it initiates
-    /// all of the attributes to default values (0, INVALID).
+    /// all of the attributes to \c 0.
     DijkstraWizardBase() : _g(0), _length(0), _processed(0), _pred(0),
-                           _dist(0), _source(INVALID) {}
+                           _dist(0), _path(0), _di(0) {}
 
     /// Constructor.
 
-    /// This constructor requires some parameters,
-    /// listed in the parameters list.
-    /// Others are initiated to 0.
+    /// This constructor requires two parameters,
+    /// others are initiated to \c 0.
     /// \param g The digraph the algorithm runs on.
     /// \param l The length map.
-    /// \param s The source node.
-    DijkstraWizardBase(const GR &g,const LM &l, Node s=INVALID) :
+    DijkstraWizardBase(const GR &g,const LM &l) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
       _length(reinterpret_cast<void*>(const_cast<LM*>(&l))),
-      _processed(0), _pred(0), _dist(0), _source(s) {}
+      _processed(0), _pred(0), _dist(0), _path(0), _di(0) {}
 
   };
 
-  /// Auxiliary class for the function type interface of Dijkstra algorithm.
-
-  /// This auxiliary class is created to implement the function type
-  /// interface of \ref Dijkstra algorithm. It uses the functions and features
-  /// of the plain \ref Dijkstra, but it is much simpler to use it.
-  /// It should only be used through the \ref dijkstra() function, which makes
-  /// it easier to use the algorithm.
+  /// Auxiliary class for the function-type interface of Dijkstra algorithm.
+
+  /// This auxiliary class is created to implement the
+  /// \ref dijkstra() "function-type interface" of \ref Dijkstra algorithm.
+  /// It does not have own \ref run() method, it uses the functions
+  /// and features of the plain \ref Dijkstra.
   ///
-  /// Simplicity means that the way to change the types defined
-  /// in the traits class is based on functions that returns the new class
-  /// and not on templatable built-in classes.
-  /// When using the plain \ref Dijkstra
-  /// the new class with the modified type comes from
-  /// the original class by using the ::
-  /// operator. In the case of \ref DijkstraWizard only
-  /// a function have to be called, and it will
-  /// return the needed class.
-  ///
-  /// It does not have own \ref run() method. When its \ref run() method
-  /// is called, it initiates a plain \ref Dijkstra object, and calls the
-  /// \ref Dijkstra::run() method of it.
+  /// This class should only be used through the \ref dijkstra() function,
+  /// which makes it easier to use the algorithm.
   template<class TR>
   class DijkstraWizard : public TR
@@ -1146,4 +1124,6 @@
     ///The type of the map that indicates which nodes are processed.
     typedef typename TR::ProcessedMap ProcessedMap;
+    ///The type of the shortest paths
+    typedef typename TR::Path Path;
     ///The heap type used by the dijkstra algorithm.
     typedef typename TR::Heap Heap;
@@ -1158,6 +1138,8 @@
     /// Constructor that requires parameters.
     /// These parameters will be the default values for the traits class.
-    DijkstraWizard(const Digraph &g,const LengthMap &l, Node s=INVALID) :
-      TR(g,l,s) {}
+    /// \param g The digraph the algorithm runs on.
+    /// \param l The length map.
+    DijkstraWizard(const Digraph &g, const LengthMap &l) :
+      TR(g,l) {}
 
     ///Copy constructor
@@ -1166,111 +1148,146 @@
     ~DijkstraWizard() {}
 
-    ///Runs Dijkstra algorithm from a source node.
-
-    ///Runs Dijkstra algorithm from a source node.
-    ///The node can be given with the \ref source() function.
-    void run()
-    {
-      if(Base::_source==INVALID) throw UninitializedParameter();
+    ///Runs Dijkstra algorithm from the given source node.
+
+    ///This method runs %Dijkstra algorithm from the given source node
+    ///in order to compute the shortest path to each node.
+    void run(Node s)
+    {
       Dijkstra<Digraph,LengthMap,TR>
-        dij(*reinterpret_cast<const Digraph*>(Base::_g),
-            *reinterpret_cast<const LengthMap*>(Base::_length));
-      if(Base::_processed)
-        dij.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
-      if(Base::_pred)
-        dij.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
-      if(Base::_dist)
-        dij.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
-      dij.run(Base::_source);
-    }
-
-    ///Runs Dijkstra algorithm from the given node.
-
-    ///Runs Dijkstra algorithm from the given node.
-    ///\param s is the given source.
-    void run(Node s)
-    {
-      Base::_source=s;
-      run();
-    }
-
-    /// Sets the source node, from which the Dijkstra algorithm runs.
-
-    /// Sets the source node, from which the Dijkstra algorithm runs.
-    /// \param s is the source node.
-    DijkstraWizard<TR> &source(Node s)
-    {
-      Base::_source=s;
-      return *this;
+        dijk(*reinterpret_cast<const Digraph*>(Base::_g),
+             *reinterpret_cast<const LengthMap*>(Base::_length));
+      if (Base::_pred)
+        dijk.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if (Base::_dist)
+        dijk.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      if (Base::_processed)
+        dijk.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      dijk.run(s);
+    }
+
+    ///Finds the shortest path between \c s and \c t.
+
+    ///This method runs the %Dijkstra algorithm from node \c s
+    ///in order to compute the shortest path to node \c t
+    ///(it stops searching when \c t is processed).
+    ///
+    ///\return \c true if \c t is reachable form \c s.
+    bool run(Node s, Node t)
+    {
+      Dijkstra<Digraph,LengthMap,TR>
+        dijk(*reinterpret_cast<const Digraph*>(Base::_g),
+             *reinterpret_cast<const LengthMap*>(Base::_length));
+      if (Base::_pred)
+        dijk.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
+      if (Base::_dist)
+        dijk.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
+      if (Base::_processed)
+        dijk.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
+      dijk.run(s,t);
+      if (Base::_path)
+        *reinterpret_cast<Path*>(Base::_path) = dijk.path(t);
+      if (Base::_di)
+        *reinterpret_cast<Value*>(Base::_di) = dijk.dist(t);
+      return dijk.reached(t);
     }
 
     template<class T>
-    struct DefPredMapBase : public Base {
+    struct SetPredMapBase : public Base {
       typedef T PredMap;
       static PredMap *createPredMap(const Digraph &) { return 0; };
-      DefPredMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref PredMap object.
-    ///
-    ///\ref named-templ-param "Named parameter"
-    ///for setting \ref PredMap object.
+      SetPredMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting PredMap object.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for setting PredMap object.
     template<class T>
-    DijkstraWizard<DefPredMapBase<T> > predMap(const T &t)
+    DijkstraWizard<SetPredMapBase<T> > predMap(const T &t)
     {
       Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DijkstraWizard<DefPredMapBase<T> >(*this);
+      return DijkstraWizard<SetPredMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefProcessedMapBase : public Base {
+    struct SetDistMapBase : public Base {
+      typedef T DistMap;
+      static DistMap *createDistMap(const Digraph &) { return 0; };
+      SetDistMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting DistMap object.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for setting DistMap object.
+    template<class T>
+    DijkstraWizard<SetDistMapBase<T> > distMap(const T &t)
+    {
+      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return DijkstraWizard<SetDistMapBase<T> >(*this);
+    }
+
+    template<class T>
+    struct SetProcessedMapBase : public Base {
       typedef T ProcessedMap;
       static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
-      DefProcessedMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///for setting \ref ProcessedMap object.
+      SetProcessedMapBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for setting ProcessedMap object.
+    ///
+    /// \ref named-func-param "Named parameter"
+    ///for setting ProcessedMap object.
     template<class T>
-    DijkstraWizard<DefProcessedMapBase<T> > processedMap(const T &t)
+    DijkstraWizard<SetProcessedMapBase<T> > processedMap(const T &t)
     {
       Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DijkstraWizard<DefProcessedMapBase<T> >(*this);
+      return DijkstraWizard<SetProcessedMapBase<T> >(*this);
     }
 
     template<class T>
-    struct DefDistMapBase : public Base {
-      typedef T DistMap;
-      static DistMap *createDistMap(const Digraph &) { return 0; };
-      DefDistMapBase(const TR &b) : TR(b) {}
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting \ref DistMap object.
-    ///
-    ///\ref named-templ-param "Named parameter"
-    ///for setting \ref DistMap object.
+    struct SetPathBase : public Base {
+      typedef T Path;
+      SetPathBase(const TR &b) : TR(b) {}
+    };
+    ///\brief \ref named-func-param "Named parameter"
+    ///for getting the shortest path to the target node.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for getting the shortest path to the target node.
     template<class T>
-    DijkstraWizard<DefDistMapBase<T> > distMap(const T &t)
-    {
-      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
-      return DijkstraWizard<DefDistMapBase<T> >(*this);
+    DijkstraWizard<SetPathBase<T> > path(const T &t)
+    {
+      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return DijkstraWizard<SetPathBase<T> >(*this);
+    }
+
+    ///\brief \ref named-func-param "Named parameter"
+    ///for getting the distance of the target node.
+    ///
+    ///\ref named-func-param "Named parameter"
+    ///for getting the distance of the target node.
+    DijkstraWizard dist(const Value &d)
+    {
+      Base::_di=reinterpret_cast<void*>(const_cast<Value*>(&d));
+      return *this;
     }
 
   };
 
-  ///Function type interface for Dijkstra algorithm.
+  ///Function-type interface for Dijkstra algorithm.
 
   /// \ingroup shortest_path
-  ///Function type interface for Dijkstra algorithm.
+  ///Function-type interface for Dijkstra algorithm.
   ///
-  ///This function also has several
-  ///\ref named-templ-func-param "named parameters",
+  ///This function also has several \ref named-func-param "named parameters",
   ///they are declared as the members of class \ref DijkstraWizard.
-  ///The following
-  ///example shows how to use these parameters.
+  ///The following examples show how to use these parameters.
   ///\code
-  ///  dijkstra(g,length,source).predMap(preds).run();
+  ///  // Compute shortest path from node s to each node
+  ///  dijkstra(g,length).predMap(preds).distMap(dists).run(s);
+  ///
+  ///  // Compute shortest path from s to t
+  ///  bool reached = dijkstra(g,length).path(p).dist(d).run(s,t);
   ///\endcode
   ///\warning Don't forget to put the \ref DijkstraWizard::run() "run()"
@@ -1280,7 +1297,7 @@
   template<class GR, class LM>
   DijkstraWizard<DijkstraWizardBase<GR,LM> >
-  dijkstra(const GR &g,const LM &l,typename GR::Node s=INVALID)
+  dijkstra(const GR &digraph, const LM &length)
   {
-    return DijkstraWizard<DijkstraWizardBase<GR,LM> >(g,l,s);
+    return DijkstraWizard<DijkstraWizardBase<GR,LM> >(digraph,length);
   }
 
Index: lemon/dim2.h
===================================================================
--- lemon/dim2.h	(revision 253)
+++ lemon/dim2.h	(revision 314)
@@ -260,8 +260,8 @@
 
 
-  /// Bounding box of plain vectors (\ref Point points).
+  /// Bounding box of plain vectors (points).
 
   /// A class to calculate or store the bounding box of plain vectors
-  /// (\ref Point points).
+  /// (\ref Point "points").
   template<typename T>
   class Box {
@@ -574,7 +574,6 @@
   }
 
-  ///Map of x-coordinates of a \ref Point "Point"-map
-
-  ///\ingroup maps
+  ///Map of x-coordinates of a <tt>Point</tt>-map
+
   ///Map of x-coordinates of a \ref Point "Point"-map.
   ///
@@ -593,9 +592,7 @@
   };
 
-  ///Returns an \ref XMap class
-
-  ///This function just returns an \ref XMap class.
-  ///
-  ///\ingroup maps
+  ///Returns an XMap class
+
+  ///This function just returns an XMap class.
   ///\relates XMap
   template<class M>
@@ -611,8 +608,7 @@
   }
 
-  ///Constant (read only) version of \ref XMap
-
-  ///\ingroup maps
-  ///Constant (read only) version of \ref XMap
+  ///Constant (read only) version of XMap
+
+  ///Constant (read only) version of XMap.
   ///
   template<class M>
@@ -629,9 +625,7 @@
   };
 
-  ///Returns a \ref ConstXMap class
-
-  ///This function just returns a \ref ConstXMap class.
-  ///
-  ///\ingroup maps
+  ///Returns a ConstXMap class
+
+  ///This function just returns a ConstXMap class.
   ///\relates ConstXMap
   template<class M>
@@ -641,7 +635,6 @@
   }
 
-  ///Map of y-coordinates of a \ref Point "Point"-map
-
-  ///\ingroup maps
+  ///Map of y-coordinates of a <tt>Point</tt>-map
+
   ///Map of y-coordinates of a \ref Point "Point"-map.
   ///
@@ -660,9 +653,7 @@
   };
 
-  ///Returns a \ref YMap class
-
-  ///This function just returns a \ref YMap class.
-  ///
-  ///\ingroup maps
+  ///Returns a YMap class
+
+  ///This function just returns a YMap class.
   ///\relates YMap
   template<class M>
@@ -678,8 +669,7 @@
   }
 
-  ///Constant (read only) version of \ref YMap
-
-  ///\ingroup maps
-  ///Constant (read only) version of \ref YMap
+  ///Constant (read only) version of YMap
+
+  ///Constant (read only) version of YMap.
   ///
   template<class M>
@@ -696,9 +686,7 @@
   };
 
-  ///Returns a \ref ConstYMap class
-
-  ///This function just returns a \ref ConstYMap class.
-  ///
-  ///\ingroup maps
+  ///Returns a ConstYMap class
+
+  ///This function just returns a ConstYMap class.
   ///\relates ConstYMap
   template<class M>
@@ -709,10 +697,8 @@
 
 
-  ///\brief Map of the \ref Point::normSquare() "normSquare()"
-  ///of a \ref Point "Point"-map
+  ///\brief Map of the normSquare() of a <tt>Point</tt>-map
   ///
   ///Map of the \ref Point::normSquare() "normSquare()"
   ///of a \ref Point "Point"-map.
-  ///\ingroup maps
   template<class M>
   class NormSquareMap
@@ -728,9 +714,7 @@
   };
 
-  ///Returns a \ref NormSquareMap class
-
-  ///This function just returns a \ref NormSquareMap class.
-  ///
-  ///\ingroup maps
+  ///Returns a NormSquareMap class
+
+  ///This function just returns a NormSquareMap class.
   ///\relates NormSquareMap
   template<class M>
Index: lemon/error.h
===================================================================
--- lemon/error.h	(revision 212)
+++ lemon/error.h	(revision 291)
@@ -36,144 +36,15 @@
   /// @{
 
-  /// \brief Exception safe wrapper class.
-  ///
-  /// Exception safe wrapper class to implement the members of exceptions.
-  template <typename _Type>
-  class ExceptionMember {
-  public:
-    typedef _Type Type;
-
-    ExceptionMember() throw() {
-      try {
-        ptr.reset(new Type());
-      } catch (...) {}
-    }
-
-    ExceptionMember(const Type& type) throw() {
-      try {
-        ptr.reset(new Type());
-        if (ptr.get() == 0) return;
-        *ptr = type;
-      } catch (...) {}
-    }
-
-    ExceptionMember(const ExceptionMember& copy) throw() {
-      try {
-        if (!copy.valid()) return;
-        ptr.reset(new Type());
-        if (ptr.get() == 0) return;
-        *ptr = copy.get();
-      } catch (...) {}
-    }
-
-    ExceptionMember& operator=(const ExceptionMember& copy) throw() {
-      if (ptr.get() == 0) return;
-      try {
-        if (!copy.valid()) return;
-        *ptr = copy.get();
-      } catch (...) {}
-    }
-
-    void set(const Type& type) throw() {
-      if (ptr.get() == 0) return;
-      try {
-        *ptr = type;
-      } catch (...) {}
-    }
-
-    const Type& get() const {
-      return *ptr;
-    }
-
-    bool valid() const throw() {
-      return ptr.get() != 0;
-    }
-
-  private:
-    std::auto_ptr<_Type> ptr;
-  };
-
-  /// Exception-safe convenient error message builder class.
-
-  /// Helper class which provides a convenient ostream-like (operator <<
-  /// based) interface to create a string message. Mostly useful in
-  /// exception classes (therefore the name).
-  class ErrorMessage {
-  protected:
-    ///\e
-
-    ///\todo The good solution is boost::shared_ptr...
-    ///
-    mutable std::auto_ptr<std::ostringstream> buf;
-
-    ///\e
-    bool init() throw() {
-      try {
-        buf.reset(new std::ostringstream);
-      }
-      catch(...) {
-        buf.reset();
-      }
-      return buf.get();
-    }
-
-  public:
-
-    ///\e
-    ErrorMessage() throw() { init(); }
-
-    ErrorMessage(const ErrorMessage& em) throw() : buf(em.buf) { }
-
-    ///\e
-    ErrorMessage(const char *msg) throw() {
-      init();
-      *this << msg;
-    }
-
-    ///\e
-    ErrorMessage(const std::string &msg) throw() {
-      init();
-      *this << msg;
-    }
-
-    ///\e
-    template <typename T>
-    ErrorMessage& operator<<(const T &t) throw() {
-      if( ! buf.get() ) return *this;
-
-      try {
-        *buf << t;
-      }
-      catch(...) {
-        buf.reset();
-      }
-      return *this;
-    }
-
-    ///\e
-    const char* message() throw() {
-      if( ! buf.get() ) return 0;
-
-      const char* mes = 0;
-      try {
-        mes = buf->str().c_str();
-      }
-      catch(...) {}
-      return mes;
-    }
-
-  };
-
-  /// Generic exception class.
-
+  /// \brief Generic exception class.
+  ///
   /// Base class for exceptions used in LEMON.
   ///
   class Exception : public std::exception {
   public:
-    ///\e
-    Exception() {}
-    ///\e
+    ///Constructor
+    Exception() throw() {}
+    ///Virtual destructor
     virtual ~Exception() throw() {}
-    ///\e
+    ///A short description of the exception
     virtual const char* what() const throw() {
       return "lemon::Exception";
@@ -181,237 +52,222 @@
   };
 
-  /// One of the two main subclasses of \ref Exception.
-
-  /// Logic errors represent problems in the internal logic of a program;
-  /// in theory, these are preventable, and even detectable before the
-  /// program runs (e.g. violations of class invariants).
-  ///
-  /// A typical example for this is \ref UninitializedParameter.
-  class LogicError : public Exception {
+  /// \brief Input-Output error
+  ///
+  /// This exception is thrown when a file operation cannot be
+  /// succeeded.
+  class IoError : public Exception {
+  protected:
+    std::string _message;
+    std::string _file;
+
+    mutable std::string _what;
   public:
+
+    /// Copy constructor
+    IoError(const IoError &error) throw() : Exception() {
+      message(error._message);
+      file(error._file);
+    }
+
+    /// Constructor
+    explicit IoError(const char *message) throw() {
+      IoError::message(message);
+    }
+
+    /// Constructor
+    explicit IoError(const std::string &message) throw() {
+      IoError::message(message);
+    }
+
+    /// Constructor
+    explicit IoError(const char *message,
+                     const std::string &file) throw() {
+      IoError::message(message);
+      IoError::file(file);
+    }
+
+    /// Constructor
+    explicit IoError(const std::string &message,
+                     const std::string &file) throw() {
+      IoError::message(message);
+      IoError::file(file);
+    }
+
+    /// Virtual destructor
+    virtual ~IoError() throw() {}
+
+    /// Set the error message
+    void message(const char *message) throw() {
+      try {
+        _message = message;
+      } catch (...) {}
+    }
+
+    /// Set the error message
+    void message(const std::string& message) throw() {
+      try {
+        _message = message;
+      } catch (...) {}
+    }
+
+    /// Set the file name
+    void file(const std::string &file) throw() {
+      try {
+        _file = file;
+      } catch (...) {}
+    }
+
+    /// Returns the error message
+    const std::string& message() const throw() {
+      return _message;
+    }
+
+    /// \brief Returns the filename
+    ///
+    /// Returns the filename or an empty string if it was not specified.
+    const std::string& file() const throw() {
+      return _file;
+    }
+
+    /// \brief Returns a short error message
+    ///
+    /// Returns a short error message which contains the message and the
+    /// file name.
     virtual const char* what() const throw() {
-      return "lemon::LogicError";
-    }
-  };
-
-  /// \ref Exception for uninitialized parameters.
-
-  /// This error represents problems in the initialization
-  /// of the parameters of the algorithms.
-  class UninitializedParameter : public LogicError {
-  public:
-    virtual const char* what() const throw() {
-      return "lemon::UninitializedParameter";
-    }
-  };
-
-
-  /// One of the two main subclasses of \ref Exception.
-
-  /// Runtime errors represent problems outside the scope of a program;
-  /// they cannot be easily predicted and can generally only be caught
-  /// as the program executes.
-  class RuntimeError : public Exception {
-  public:
-    virtual const char* what() const throw() {
-      return "lemon::RuntimeError";
-    }
-  };
-
-  ///\e
-  class RangeError : public RuntimeError {
-  public:
-    virtual const char* what() const throw() {
-      return "lemon::RangeError";
-    }
-  };
-
-  ///\e
-  class IoError : public RuntimeError {
-  public:
-    virtual const char* what() const throw() {
-      return "lemon::IoError";
-    }
-  };
-
-  ///\e
-  class DataFormatError : public IoError {
-  protected:
-    ExceptionMember<std::string> _message;
-    ExceptionMember<std::string> _file;
-    int _line;
-
-    mutable ExceptionMember<std::string> _message_holder;
-  public:
-
-    DataFormatError(const DataFormatError &dfe) :
-      IoError(dfe), _message(dfe._message), _file(dfe._file),
-      _line(dfe._line) {}
-
-    ///\e
-    explicit DataFormatError(const char *the_message)
-      : _message(the_message), _line(0) {}
-
-    ///\e
-    DataFormatError(const std::string &file_name, int line_num,
-                    const char *the_message)
-      : _message(the_message), _line(line_num) { file(file_name); }
-
-    ///\e
-    void line(int ln) { _line = ln; }
-    ///\e
-    void message(const std::string& msg) { _message.set(msg); }
-    ///\e
-    void file(const std::string &fl) { _file.set(fl); }
-
-    ///\e
-    int line() const { return _line; }
-    ///\e
-    const char* message() const {
-      if (_message.valid() && !_message.get().empty()) {
-        return _message.get().c_str();
-      } else {
-        return 0;
-      }
-    }
-
-    /// \brief Returns the filename.
-    ///
-    /// Returns \e null if the filename was not specified.
-    const char* file() const {
-      if (_file.valid() && !_file.get().empty()) {
-        return _file.get().c_str();
-      } else {
-        return 0;
-      }
-    }
-
-    ///\e
-    virtual const char* what() const throw() {
-      try {
-        std::ostringstream ostr;
-        ostr << "lemon:DataFormatError" << ": ";
-        if (message()) ostr << message();
-        if( file() || line() != 0 ) {
-          ostr << " (";
-          if( file() ) ostr << "in file '" << file() << "'";
-          if( file() && line() != 0 ) ostr << " ";
-          if( line() != 0 ) ostr << "at line " << line();
-          ostr << ")";
+      try {
+        _what.clear();
+        std::ostringstream oss;
+        oss << "lemon:IoError" << ": ";
+        oss << _message;
+        if (!_file.empty()) {
+          oss << " ('" << _file << "')";
         }
-        _message_holder.set(ostr.str());
+        _what = oss.str();
       }
       catch (...) {}
-      if( _message_holder.valid()) return _message_holder.get().c_str();
-      return "lemon:DataFormatError";
-    }
-
-    virtual ~DataFormatError() throw() {}
+      if (!_what.empty()) return _what.c_str();
+      else return "lemon:IoError";
+    }
+
   };
 
-  ///\e
-  class FileOpenError : public IoError {
+  /// \brief Format error
+  ///
+  /// This exception is thrown when an input file has wrong
+  /// format or a data representation is not legal.
+  class FormatError : public Exception {
   protected:
-    ExceptionMember<std::string> _file;
-
-    mutable ExceptionMember<std::string> _message_holder;
+    std::string _message;
+    std::string _file;
+    int _line;
+
+    mutable std::string _what;
   public:
 
-    FileOpenError(const FileOpenError &foe) :
-      IoError(foe), _file(foe._file) {}
-
-    ///\e
-    explicit FileOpenError(const std::string& fl)
-      : _file(fl) {}
-
-
-    ///\e
-    void file(const std::string &fl) { _file.set(fl); }
-
-    /// \brief Returns the filename.
-    ///
-    /// Returns \e null if the filename was not specified.
-    const char* file() const {
-      if (_file.valid() && !_file.get().empty()) {
-        return _file.get().c_str();
-      } else {
-        return 0;
-      }
-    }
-
-    ///\e
+    /// Copy constructor
+    FormatError(const FormatError &error) throw() : Exception() {
+      message(error._message);
+      file(error._file);
+      line(error._line);
+    }
+
+    /// Constructor
+    explicit FormatError(const char *message) throw() {
+      FormatError::message(message);
+      _line = 0;
+    }
+
+    /// Constructor
+    explicit FormatError(const std::string &message) throw() {
+      FormatError::message(message);
+      _line = 0;
+    }
+
+    /// Constructor
+    explicit FormatError(const char *message,
+                         const std::string &file, int line = 0) throw() {
+      FormatError::message(message);
+      FormatError::file(file);
+      FormatError::line(line);
+    }
+
+    /// Constructor
+    explicit FormatError(const std::string &message,
+                         const std::string &file, int line = 0) throw() {
+      FormatError::message(message);
+      FormatError::file(file);
+      FormatError::line(line);
+    }
+
+    /// Virtual destructor
+    virtual ~FormatError() throw() {}
+
+    /// Set the line number
+    void line(int line) throw() { _line = line; }
+
+    /// Set the error message
+    void message(const char *message) throw() {
+      try {
+        _message = message;
+      } catch (...) {}
+    }
+
+    /// Set the error message
+    void message(const std::string& message) throw() {
+      try {
+        _message = message;
+      } catch (...) {}
+    }
+
+    /// Set the file name
+    void file(const std::string &file) throw() {
+      try {
+        _file = file;
+      } catch (...) {}
+    }
+
+    /// \brief Returns the line number
+    ///
+    /// Returns the line number or zero if it was not specified.
+    int line() const throw() { return _line; }
+
+    /// Returns the error message
+    const std::string& message() const throw() {
+      return _message;
+    }
+
+    /// \brief Returns the filename
+    ///
+    /// Returns the filename or an empty string if it was not specified.
+    const std::string& file() const throw() {
+      return _file;
+    }
+
+    /// \brief Returns a short error message
+    ///
+    /// Returns a short error message which contains the message, the
+    /// file name and the line number.
     virtual const char* what() const throw() {
       try {
-        std::ostringstream ostr;
-        ostr << "lemon::FileOpenError" << ": ";
-        ostr << "Cannot open file - " << file();
-        _message_holder.set(ostr.str());
+        _what.clear();
+        std::ostringstream oss;
+        oss << "lemon:FormatError" << ": ";
+        oss << _message;
+        if (!_file.empty() || _line != 0) {
+          oss << " (";
+          if (!_file.empty()) oss << "in file '" << _file << "'";
+          if (!_file.empty() && _line != 0) oss << " ";
+          if (_line != 0) oss << "at line " << _line;
+          oss << ")";
+        }
+        _what = oss.str();
       }
       catch (...) {}
-      if( _message_holder.valid()) return _message_holder.get().c_str();
-      return "lemon::FileOpenError";
-    }
-    virtual ~FileOpenError() throw() {}
+      if (!_what.empty()) return _what.c_str();
+      else return "lemon:FormatError";
+    }
+
   };
 
-  class IoParameterError : public IoError {
-  protected:
-    ExceptionMember<std::string> _message;
-    ExceptionMember<std::string> _file;
-
-    mutable ExceptionMember<std::string> _message_holder;
-  public:
-
-    IoParameterError(const IoParameterError &ile) :
-      IoError(ile), _message(ile._message), _file(ile._file) {}
-
-    ///\e
-    explicit IoParameterError(const char *the_message)
-      : _message(the_message) {}
-
-    ///\e
-    IoParameterError(const char *file_name, const char *the_message)
-      : _message(the_message), _file(file_name) {}
-
-     ///\e
-    void message(const std::string& msg) { _message.set(msg); }
-    ///\e
-    void file(const std::string &fl) { _file.set(fl); }
-
-     ///\e
-    const char* message() const {
-      if (_message.valid()) {
-        return _message.get().c_str();
-      } else {
-        return 0;
-      }
-    }
-
-    /// \brief Returns the filename.
-    ///
-    /// Returns \c 0 if the filename was not specified.
-    const char* file() const {
-      if (_file.valid()) {
-        return _file.get().c_str();
-      } else {
-        return 0;
-      }
-    }
-
-    ///\e
-    virtual const char* what() const throw() {
-      try {
-        std::ostringstream ostr;
-        if (message()) ostr << message();
-        if (file()) ostr << "(when reading file '" << file() << "')";
-        _message_holder.set(ostr.str());
-      }
-      catch (...) {}
-      if( _message_holder.valid() ) return _message_holder.get().c_str();
-      return "lemon:IoParameterError";
-    }
-    virtual ~IoParameterError() throw() {}
-  };
-
   /// @}
 
Index: lemon/graph_to_eps.h
===================================================================
--- lemon/graph_to_eps.h	(revision 253)
+++ lemon/graph_to_eps.h	(revision 313)
@@ -41,4 +41,5 @@
 #include<lemon/color.h>
 #include<lemon/bits/bezier.h>
+#include<lemon/error.h>
 
 
@@ -62,5 +63,5 @@
   }
 
-///Default traits class of \ref GraphToEps
+///Default traits class of GraphToEps
 
 ///Default traits class of \ref GraphToEps.
@@ -667,5 +668,4 @@
   ///it draws the graph.
   void run() {
-    //\todo better 'epsilon' would be nice here.
     const double EPSILON=1e-9;
     if(dontPrint) return;
@@ -708,5 +708,4 @@
       for(ArcIt e(g);e!=INVALID;++e)
         max_w=std::max(double(_arcWidths[e]),max_w);
-      //\todo better 'epsilon' would be nice here.
       if(max_w>EPSILON) {
         _arcWidthScale/=max_w;
@@ -718,5 +717,4 @@
       for(NodeIt n(g);n!=INVALID;++n)
         max_s=std::max(double(_nodeSizes[n]),max_s);
-      //\todo better 'epsilon' would be nice here.
       if(max_s>EPSILON) {
         _nodeScale/=max_s;
@@ -874,5 +872,4 @@
       }
       else {
-        //\todo Verify centering
         double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
                   (A4WIDTH-2*A4BORDER)/bb.height());
@@ -907,5 +904,4 @@
             dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
           double l=std::sqrt(dvec.normSquare());
-          //\todo better 'epsilon' would be nice here.
           dim2::Point<double> d(dvec/std::max(l,EPSILON));
           dim2::Point<double> m;
@@ -1172,6 +1168,11 @@
 graphToEps(G &g,const char *file_name)
 {
+  std::ostream* os = new std::ofstream(file_name);
+  if (!(*os)) {
+    delete os;
+    throw IoError("Cannot write file", file_name);
+  }
   return GraphToEps<DefaultGraphToEpsTraits<G> >
-    (DefaultGraphToEpsTraits<G>(g,*new std::ofstream(file_name),true));
+    (DefaultGraphToEpsTraits<G>(g,*os,true));
 }
 
@@ -1188,6 +1189,11 @@
 graphToEps(G &g,const std::string& file_name)
 {
+  std::ostream* os = new std::ofstream(file_name.c_str());
+  if (!(*os)) {
+    delete os;
+    throw IoError("Cannot write file", file_name);
+  }
   return GraphToEps<DefaultGraphToEpsTraits<G> >
-    (DefaultGraphToEpsTraits<G>(g,*new std::ofstream(file_name.c_str()),true));
+    (DefaultGraphToEpsTraits<G>(g,*os,true));
 }
 
Index: lemon/lemon.pc.in
===================================================================
--- lemon/lemon.pc.in	(revision 1)
+++ lemon/lemon.pc.in	(revision 259)
@@ -7,4 +7,4 @@
 Description: Library of Efficient Models and Optimization in Networks
 Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lemon @GLPK_LIBS@ @CPLEX_LIBS@
-Cflags: -I${includedir} @GLPK_CFLAGS@ @CPLEX_CFLAGS@
+Libs: -L${libdir} -lemon
+Cflags: -I${includedir}
Index: lemon/lgf_reader.h
===================================================================
--- lemon/lgf_reader.h	(revision 236)
+++ lemon/lgf_reader.h	(revision 319)
@@ -32,5 +32,4 @@
 #include <map>
 
-#include <lemon/assert.h>
 #include <lemon/core.h>
 
@@ -49,9 +48,11 @@
         std::istringstream is(str);
         Value value;
-        is >> value;
+        if (!(is >> value)) {
+          throw FormatError("Cannot read token");
+        }
 
         char c;
         if (is >> std::ws >> c) {
-          throw DataFormatError("Remaining characters in token");
+          throw FormatError("Remaining characters in token");
         }
         return value;
@@ -167,5 +168,5 @@
           std::ostringstream msg;
           msg << "Item not found: " << str;
-          throw DataFormatError(msg.str().c_str());
+          throw FormatError(msg.str());
         }
         return it->second;
@@ -185,10 +186,10 @@
       typename Graph::Arc operator()(const std::string& str) {
         if (str.empty() || (str[0] != '+' && str[0] != '-')) {
-          throw DataFormatError("Item must start with '+' or '-'");
+          throw FormatError("Item must start with '+' or '-'");
         }
         typename std::map<std::string, typename Graph::Edge>
           ::const_iterator it = _map.find(str.substr(1));
         if (it == _map.end()) {
-          throw DataFormatError("Item not found");
+          throw FormatError("Item not found");
         }
         return _graph.direct(it->second, str[0] == '+');
@@ -236,5 +237,5 @@
       char c;
       if (!is.get(c))
-        throw DataFormatError("Escape format error");
+        throw FormatError("Escape format error");
 
       switch (c) {
@@ -265,5 +266,5 @@
           int code;
           if (!is.get(c) || !isHex(c))
-            throw DataFormatError("Escape format error");
+            throw FormatError("Escape format error");
           else if (code = valueHex(c), !is.get(c) || !isHex(c)) is.putback(c);
           else code = code * 16 + valueHex(c);
@@ -274,5 +275,5 @@
           int code;
           if (!isOct(c))
-            throw DataFormatError("Escape format error");
+            throw FormatError("Escape format error");
           else if (code = valueOct(c), !is.get(c) || !isOct(c))
             is.putback(c);
@@ -301,5 +302,5 @@
         }
         if (!is)
-          throw DataFormatError("Quoted format error");
+          throw FormatError("Quoted format error");
       } else {
         is.putback(c);
@@ -390,12 +391,35 @@
   class DigraphReader;
 
+  /// \brief Return a \ref DigraphReader class
+  ///
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph);
-
+  DigraphReader<Digraph> digraphReader(Digraph& digraph,
+                                       std::istream& is = std::cin) {
+    DigraphReader<Digraph> tmp(digraph, is);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphReader class
+  ///
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(const std::string& fn, Digraph& digraph);
-
+  DigraphReader<Digraph> digraphReader(Digraph& digraph,
+                                       const std::string& fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphReader class
+  ///
+  /// This function just returns a \ref DigraphReader class.
+  /// \relates DigraphReader
   template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph);
+  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
+    DigraphReader<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
 
   /// \ingroup lemon_io
@@ -420,5 +444,5 @@
   ///
   ///\code
-  /// DigraphReader<Digraph>(std::cin, digraph).
+  /// DigraphReader<Digraph>(digraph, std::cin).
   ///   nodeMap("coordinates", coord_map).
   ///   arcMap("capacity", cap_map).
@@ -461,4 +485,5 @@
     std::istream* _is;
     bool local_is;
+    std::string _filename;
 
     Digraph& _digraph;
@@ -500,5 +525,5 @@
     /// Construct a directed graph reader, which reads from the given
     /// input stream.
-    DigraphReader(std::istream& is, Digraph& digraph)
+    DigraphReader(Digraph& digraph, std::istream& is = std::cin)
       : _is(&is), local_is(false), _digraph(digraph),
         _use_nodes(false), _use_arcs(false),
@@ -509,8 +534,14 @@
     /// Construct a directed graph reader, which reads from the given
     /// file.
-    DigraphReader(const std::string& fn, Digraph& digraph)
-      : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph),
+    DigraphReader(Digraph& digraph, const std::string& fn)
+      : _is(new std::ifstream(fn.c_str())), local_is(true),
+        _filename(fn), _digraph(digraph),
         _use_nodes(false), _use_arcs(false),
-        _skip_nodes(false), _skip_arcs(false) {}
+        _skip_nodes(false), _skip_arcs(false) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Constructor
@@ -518,8 +549,14 @@
     /// Construct a directed graph reader, which reads from the given
     /// file.
-    DigraphReader(const char* fn, Digraph& digraph)
-      : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph),
+    DigraphReader(Digraph& digraph, const char* fn)
+      : _is(new std::ifstream(fn)), local_is(true),
+        _filename(fn), _digraph(digraph),
         _use_nodes(false), _use_arcs(false),
-        _skip_nodes(false), _skip_arcs(false) {}
+        _skip_nodes(false), _skip_arcs(false) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Destructor
@@ -548,10 +585,10 @@
   private:
 
-    friend DigraphReader<Digraph> digraphReader<>(std::istream& is,
-                                                  Digraph& digraph);
-    friend DigraphReader<Digraph> digraphReader<>(const std::string& fn,
-                                                  Digraph& digraph);
-    friend DigraphReader<Digraph> digraphReader<>(const char *fn,
-                                                  Digraph& digraph);
+    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
+                                                  std::istream& is);
+    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
+                                                  const std::string& fn);
+    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
+                                                  const char *fn);
 
     DigraphReader(DigraphReader& other)
@@ -846,5 +883,5 @@
         if (readSuccess() && line) line.putback(c);
         if (!_node_maps.empty())
-          throw DataFormatError("Cannot find map names");
+          throw FormatError("Cannot find map names");
         return;
       }
@@ -860,5 +897,5 @@
             std::ostringstream msg;
             msg << "Multiple occurence of node map: " << map;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           maps.insert(std::make_pair(map, index));
@@ -871,6 +908,6 @@
           if (jt == maps.end()) {
             std::ostringstream msg;
-            msg << "Map not found in file: " << _node_maps[i].first;
-            throw DataFormatError(msg.str().c_str());
+            msg << "Map not found: " << _node_maps[i].first;
+            throw FormatError(msg.str());
           }
           map_index[i] = jt->second;
@@ -896,9 +933,9 @@
             std::ostringstream msg;
             msg << "Column not found (" << i + 1 << ")";
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
         }
         if (line >> std::ws >> c)
-          throw DataFormatError("Extra character on the end of line");
+          throw FormatError("Extra character at the end of line");
 
         Node n;
@@ -909,5 +946,5 @@
         } else {
           if (label_index == -1)
-            throw DataFormatError("Label map not found in file");
+            throw FormatError("Label map not found");
           typename std::map<std::string, Node>::iterator it =
             _node_index.find(tokens[label_index]);
@@ -915,5 +952,5 @@
             std::ostringstream msg;
             msg << "Node with label not found: " << tokens[label_index];
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           n = it->second;
@@ -939,5 +976,5 @@
         if (readSuccess() && line) line.putback(c);
         if (!_arc_maps.empty())
-          throw DataFormatError("Cannot find map names");
+          throw FormatError("Cannot find map names");
         return;
       }
@@ -953,5 +990,5 @@
             std::ostringstream msg;
             msg << "Multiple occurence of arc map: " << map;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           maps.insert(std::make_pair(map, index));
@@ -964,6 +1001,6 @@
           if (jt == maps.end()) {
             std::ostringstream msg;
-            msg << "Map not found in file: " << _arc_maps[i].first;
-            throw DataFormatError(msg.str().c_str());
+            msg << "Map not found: " << _arc_maps[i].first;
+            throw FormatError(msg.str());
           }
           map_index[i] = jt->second;
@@ -988,8 +1025,8 @@
 
         if (!_reader_bits::readToken(line, source_token))
-          throw DataFormatError("Source not found");
+          throw FormatError("Source not found");
 
         if (!_reader_bits::readToken(line, target_token))
-          throw DataFormatError("Target not found");
+          throw FormatError("Target not found");
 
         std::vector<std::string> tokens(map_num);
@@ -998,9 +1035,9 @@
             std::ostringstream msg;
             msg << "Column not found (" << i + 1 << ")";
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
         }
         if (line >> std::ws >> c)
-          throw DataFormatError("Extra character on the end of line");
+          throw FormatError("Extra character at the end of line");
 
         Arc a;
@@ -1013,5 +1050,5 @@
             std::ostringstream msg;
             msg << "Item not found: " << source_token;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           Node source = it->second;
@@ -1021,5 +1058,5 @@
             std::ostringstream msg;
             msg << "Item not found: " << target_token;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           Node target = it->second;
@@ -1030,5 +1067,5 @@
         } else {
           if (label_index == -1)
-            throw DataFormatError("Label map not found in file");
+            throw FormatError("Label map not found");
           typename std::map<std::string, Arc>::iterator it =
             _arc_index.find(tokens[label_index]);
@@ -1036,5 +1073,5 @@
             std::ostringstream msg;
             msg << "Arc with label not found: " << tokens[label_index];
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           a = it->second;
@@ -1061,9 +1098,9 @@
         std::string attr, token;
         if (!_reader_bits::readToken(line, attr))
-          throw DataFormatError("Attribute name not found");
+          throw FormatError("Attribute name not found");
         if (!_reader_bits::readToken(line, token))
-          throw DataFormatError("Attribute value not found");
+          throw FormatError("Attribute value not found");
         if (line >> c)
-          throw DataFormatError("Extra character on the end of line");
+          throw FormatError("Extra character at the end of line");
 
         {
@@ -1071,6 +1108,6 @@
           if (it != read_attr.end()) {
             std::ostringstream msg;
-            msg << "Multiple occurence of attribute " << attr;
-            throw DataFormatError(msg.str().c_str());
+            msg << "Multiple occurence of attribute: " << attr;
+            throw FormatError(msg.str());
           }
           read_attr.insert(attr);
@@ -1093,6 +1130,6 @@
         if (read_attr.find(it->first) == read_attr.end()) {
           std::ostringstream msg;
-          msg << "Attribute not found in file: " << it->first;
-          throw DataFormatError(msg.str().c_str());
+          msg << "Attribute not found: " << it->first;
+          throw FormatError(msg.str());
         }
       }
@@ -1109,7 +1146,4 @@
     void run() {
       LEMON_ASSERT(_is != 0, "This reader assigned to an other reader");
-      if (!*_is) {
-        throw DataFormatError("Cannot find file");
-      }
 
       bool nodes_done = _skip_nodes;
@@ -1130,5 +1164,5 @@
 
           if (line >> c)
-            throw DataFormatError("Extra character on the end of line");
+            throw FormatError("Extra character at the end of line");
 
           if (section == "nodes" && !nodes_done) {
@@ -1152,6 +1186,7 @@
             skipSection();
           }
-        } catch (DataFormatError& error) {
+        } catch (FormatError& error) {
           error.line(line_num);
+          error.file(_filename);
           throw;
         }
@@ -1159,13 +1194,13 @@
 
       if (!nodes_done) {
-        throw DataFormatError("Section @nodes not found");
+        throw FormatError("Section @nodes not found");
       }
 
       if (!arcs_done) {
-        throw DataFormatError("Section @arcs not found");
+        throw FormatError("Section @arcs not found");
       }
 
       if (!attributes_done && !_attributes.empty()) {
-        throw DataFormatError("Section @attributes not found");
+        throw FormatError("Section @attributes not found");
       }
 
@@ -1176,46 +1211,36 @@
   };
 
-  /// \brief Return a \ref DigraphReader class
+  template <typename Graph>
+  class GraphReader;
+
+  /// \brief Return a \ref GraphReader class
   ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
-  template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) {
-    DigraphReader<Digraph> tmp(is, digraph);
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
+    GraphReader<Graph> tmp(graph, is);
     return tmp;
   }
 
-  /// \brief Return a \ref DigraphReader class
+  /// \brief Return a \ref GraphReader class
   ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
-  template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(const std::string& fn,
-                                       Digraph& digraph) {
-    DigraphReader<Digraph> tmp(fn, digraph);
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
+    GraphReader<Graph> tmp(graph, fn);
     return tmp;
   }
 
-  /// \brief Return a \ref DigraphReader class
+  /// \brief Return a \ref GraphReader class
   ///
-  /// This function just returns a \ref DigraphReader class.
-  /// \relates DigraphReader
-  template <typename Digraph>
-  DigraphReader<Digraph> digraphReader(const char* fn, Digraph& digraph) {
-    DigraphReader<Digraph> tmp(fn, digraph);
+  /// This function just returns a \ref GraphReader class.
+  /// \relates GraphReader
+  template <typename Graph>
+  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
+    GraphReader<Graph> tmp(graph, fn);
     return tmp;
   }
-
-  template <typename Graph>
-  class GraphReader;
-
-  template <typename Graph>
-  GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
-
-  template <typename Graph>
-  GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
-
-  template <typename Graph>
-  GraphReader<Graph> graphReader(const char *fn, Graph& graph);
 
   /// \ingroup lemon_io
@@ -1245,4 +1270,5 @@
     std::istream* _is;
     bool local_is;
+    std::string _filename;
 
     Graph& _graph;
@@ -1284,5 +1310,5 @@
     /// Construct an undirected graph reader, which reads from the given
     /// input stream.
-    GraphReader(std::istream& is, Graph& graph)
+    GraphReader(Graph& graph, std::istream& is = std::cin)
       : _is(&is), local_is(false), _graph(graph),
         _use_nodes(false), _use_edges(false),
@@ -1293,8 +1319,14 @@
     /// Construct an undirected graph reader, which reads from the given
     /// file.
-    GraphReader(const std::string& fn, Graph& graph)
-      : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph),
+    GraphReader(Graph& graph, const std::string& fn)
+      : _is(new std::ifstream(fn.c_str())), local_is(true),
+        _filename(fn), _graph(graph),
         _use_nodes(false), _use_edges(false),
-        _skip_nodes(false), _skip_edges(false) {}
+        _skip_nodes(false), _skip_edges(false) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Constructor
@@ -1302,8 +1334,14 @@
     /// Construct an undirected graph reader, which reads from the given
     /// file.
-    GraphReader(const char* fn, Graph& graph)
-      : _is(new std::ifstream(fn)), local_is(true), _graph(graph),
+    GraphReader(Graph& graph, const char* fn)
+      : _is(new std::ifstream(fn)), local_is(true),
+        _filename(fn), _graph(graph),
         _use_nodes(false), _use_edges(false),
-        _skip_nodes(false), _skip_edges(false) {}
+        _skip_nodes(false), _skip_edges(false) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Destructor
@@ -1331,8 +1369,8 @@
 
   private:
-    friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph);
-    friend GraphReader<Graph> graphReader<>(const std::string& fn,
-                                            Graph& graph);
-    friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph);
+    friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
+    friend GraphReader<Graph> graphReader<>(Graph& graph,
+                                            const std::string& fn);
+    friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
 
     GraphReader(GraphReader& other)
@@ -1674,5 +1712,5 @@
         if (readSuccess() && line) line.putback(c);
         if (!_node_maps.empty())
-          throw DataFormatError("Cannot find map names");
+          throw FormatError("Cannot find map names");
         return;
       }
@@ -1688,5 +1726,5 @@
             std::ostringstream msg;
             msg << "Multiple occurence of node map: " << map;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           maps.insert(std::make_pair(map, index));
@@ -1699,6 +1737,6 @@
           if (jt == maps.end()) {
             std::ostringstream msg;
-            msg << "Map not found in file: " << _node_maps[i].first;
-            throw DataFormatError(msg.str().c_str());
+            msg << "Map not found: " << _node_maps[i].first;
+            throw FormatError(msg.str());
           }
           map_index[i] = jt->second;
@@ -1724,9 +1762,9 @@
             std::ostringstream msg;
             msg << "Column not found (" << i + 1 << ")";
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
         }
         if (line >> std::ws >> c)
-          throw DataFormatError("Extra character on the end of line");
+          throw FormatError("Extra character at the end of line");
 
         Node n;
@@ -1737,5 +1775,5 @@
         } else {
           if (label_index == -1)
-            throw DataFormatError("Label map not found in file");
+            throw FormatError("Label map not found");
           typename std::map<std::string, Node>::iterator it =
             _node_index.find(tokens[label_index]);
@@ -1743,5 +1781,5 @@
             std::ostringstream msg;
             msg << "Node with label not found: " << tokens[label_index];
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           n = it->second;
@@ -1767,5 +1805,5 @@
         if (readSuccess() && line) line.putback(c);
         if (!_edge_maps.empty())
-          throw DataFormatError("Cannot find map names");
+          throw FormatError("Cannot find map names");
         return;
       }
@@ -1781,5 +1819,5 @@
             std::ostringstream msg;
             msg << "Multiple occurence of edge map: " << map;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           maps.insert(std::make_pair(map, index));
@@ -1792,6 +1830,6 @@
           if (jt == maps.end()) {
             std::ostringstream msg;
-            msg << "Map not found in file: " << _edge_maps[i].first;
-            throw DataFormatError(msg.str().c_str());
+            msg << "Map not found: " << _edge_maps[i].first;
+            throw FormatError(msg.str());
           }
           map_index[i] = jt->second;
@@ -1816,8 +1854,8 @@
 
         if (!_reader_bits::readToken(line, source_token))
-          throw DataFormatError("Node u not found");
+          throw FormatError("Node u not found");
 
         if (!_reader_bits::readToken(line, target_token))
-          throw DataFormatError("Node v not found");
+          throw FormatError("Node v not found");
 
         std::vector<std::string> tokens(map_num);
@@ -1826,9 +1864,9 @@
             std::ostringstream msg;
             msg << "Column not found (" << i + 1 << ")";
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
         }
         if (line >> std::ws >> c)
-          throw DataFormatError("Extra character on the end of line");
+          throw FormatError("Extra character at the end of line");
 
         Edge e;
@@ -1841,5 +1879,5 @@
             std::ostringstream msg;
             msg << "Item not found: " << source_token;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           Node source = it->second;
@@ -1849,5 +1887,5 @@
             std::ostringstream msg;
             msg << "Item not found: " << target_token;
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           Node target = it->second;
@@ -1858,5 +1896,5 @@
         } else {
           if (label_index == -1)
-            throw DataFormatError("Label map not found in file");
+            throw FormatError("Label map not found");
           typename std::map<std::string, Edge>::iterator it =
             _edge_index.find(tokens[label_index]);
@@ -1864,5 +1902,5 @@
             std::ostringstream msg;
             msg << "Edge with label not found: " << tokens[label_index];
-            throw DataFormatError(msg.str().c_str());
+            throw FormatError(msg.str());
           }
           e = it->second;
@@ -1889,9 +1927,9 @@
         std::string attr, token;
         if (!_reader_bits::readToken(line, attr))
-          throw DataFormatError("Attribute name not found");
+          throw FormatError("Attribute name not found");
         if (!_reader_bits::readToken(line, token))
-          throw DataFormatError("Attribute value not found");
+          throw FormatError("Attribute value not found");
         if (line >> c)
-          throw DataFormatError("Extra character on the end of line");
+          throw FormatError("Extra character at the end of line");
 
         {
@@ -1899,6 +1937,6 @@
           if (it != read_attr.end()) {
             std::ostringstream msg;
-            msg << "Multiple occurence of attribute " << attr;
-            throw DataFormatError(msg.str().c_str());
+            msg << "Multiple occurence of attribute: " << attr;
+            throw FormatError(msg.str());
           }
           read_attr.insert(attr);
@@ -1921,6 +1959,6 @@
         if (read_attr.find(it->first) == read_attr.end()) {
           std::ostringstream msg;
-          msg << "Attribute not found in file: " << it->first;
-          throw DataFormatError(msg.str().c_str());
+          msg << "Attribute not found: " << it->first;
+          throw FormatError(msg.str());
         }
       }
@@ -1956,5 +1994,5 @@
 
           if (line >> c)
-            throw DataFormatError("Extra character on the end of line");
+            throw FormatError("Extra character at the end of line");
 
           if (section == "nodes" && !nodes_done) {
@@ -1978,6 +2016,7 @@
             skipSection();
           }
-        } catch (DataFormatError& error) {
+        } catch (FormatError& error) {
           error.line(line_num);
+          error.file(_filename);
           throw;
         }
@@ -1985,13 +2024,13 @@
 
       if (!nodes_done) {
-        throw DataFormatError("Section @nodes not found");
+        throw FormatError("Section @nodes not found");
       }
 
       if (!edges_done) {
-        throw DataFormatError("Section @edges not found");
+        throw FormatError("Section @edges not found");
       }
 
       if (!attributes_done && !_attributes.empty()) {
-        throw DataFormatError("Section @attributes not found");
+        throw FormatError("Section @attributes not found");
       }
 
@@ -2001,35 +2040,4 @@
 
   };
-
-  /// \brief Return a \ref GraphReader class
-  ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
-  template <typename Graph>
-  GraphReader<Graph> graphReader(std::istream& is, Graph& graph) {
-    GraphReader<Graph> tmp(is, graph);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphReader class
-  ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
-  template <typename Graph>
-  GraphReader<Graph> graphReader(const std::string& fn,
-                                       Graph& graph) {
-    GraphReader<Graph> tmp(fn, graph);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphReader class
-  ///
-  /// This function just returns a \ref GraphReader class.
-  /// \relates GraphReader
-  template <typename Graph>
-  GraphReader<Graph> graphReader(const char* fn, Graph& graph) {
-    GraphReader<Graph> tmp(fn, graph);
-    return tmp;
-  }
 
   class SectionReader;
@@ -2055,4 +2063,5 @@
     std::istream* _is;
     bool local_is;
+    std::string _filename;
 
     typedef std::map<std::string, _reader_bits::Section*> Sections;
@@ -2075,5 +2084,11 @@
     /// Construct a section reader, which reads from the given file.
     SectionReader(const std::string& fn)
-      : _is(new std::ifstream(fn.c_str())), local_is(true) {}
+      : _is(new std::ifstream(fn.c_str())), local_is(true),
+        _filename(fn) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Constructor
@@ -2081,5 +2096,11 @@
     /// Construct a section reader, which reads from the given file.
     SectionReader(const char* fn)
-      : _is(new std::ifstream(fn)), local_is(true) {}
+      : _is(new std::ifstream(fn)), local_is(true),
+        _filename(fn) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Destructor
@@ -2237,10 +2258,10 @@
 
           if (line >> c)
-            throw DataFormatError("Extra character on the end of line");
+            throw FormatError("Extra character at the end of line");
 
           if (extra_sections.find(section) != extra_sections.end()) {
             std::ostringstream msg;
-            msg << "Multiple occurence of section " << section;
-            throw DataFormatError(msg.str().c_str());
+            msg << "Multiple occurence of section: " << section;
+            throw FormatError(msg.str());
           }
           Sections::iterator it = _sections.find(section);
@@ -2251,6 +2272,7 @@
           readLine();
           skipSection();
-        } catch (DataFormatError& error) {
+        } catch (FormatError& error) {
           error.line(line_num);
+          error.file(_filename);
           throw;
         }
@@ -2261,5 +2283,5 @@
           std::ostringstream os;
           os << "Cannot find section: " << it->first;
-          throw DataFormatError(os.str().c_str());
+          throw FormatError(os.str());
         }
       }
@@ -2361,5 +2383,10 @@
     /// file.
     LgfContents(const std::string& fn)
-      : _is(new std::ifstream(fn.c_str())), local_is(true) {}
+      : _is(new std::ifstream(fn.c_str())), local_is(true) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Constructor
@@ -2368,5 +2395,10 @@
     /// file.
     LgfContents(const char* fn)
-      : _is(new std::ifstream(fn)), local_is(true) {}
+      : _is(new std::ifstream(fn)), local_is(true) {
+      if (!(*_is)) {
+        delete _is;
+        throw IoError("Cannot open file", fn);
+      }
+    }
 
     /// \brief Destructor
Index: lemon/lgf_writer.h
===================================================================
--- lemon/lgf_writer.h	(revision 248)
+++ lemon/lgf_writer.h	(revision 319)
@@ -34,5 +34,4 @@
 #include <functional>
 
-#include <lemon/assert.h>
 #include <lemon/core.h>
 #include <lemon/maps.h>
@@ -56,5 +55,5 @@
     template <typename T>
     bool operator<(const T&, const T&) {
-      throw DataFormatError("Label map is not comparable");
+      throw FormatError("Label map is not comparable");
     }
 
@@ -204,5 +203,5 @@
           _map.find(str);
         if (it == _map.end()) {
-          throw DataFormatError("Item not found");
+          throw FormatError("Item not found");
         }
         return it->second;
@@ -224,5 +223,5 @@
           ::const_iterator it = _map.find(val);
         if (it == _map.end()) {
-          throw DataFormatError("Item not found");
+          throw FormatError("Item not found");
         }
         return (_graph.direction(val) ? '+' : '-') + it->second;
@@ -352,15 +351,36 @@
   class DigraphWriter;
 
+  /// \brief Return a \ref DigraphWriter class
+  ///
+  /// This function just returns a \ref DigraphWriter class.
+  /// \relates DigraphWriter
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
-                                       const Digraph& digraph);
-
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       std::ostream& os = std::cout) {
+    DigraphWriter<Digraph> tmp(digraph, os);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphWriter class
+  ///
+  /// This function just returns a \ref DigraphWriter class.
+  /// \relates DigraphWriter
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
-                                       const Digraph& digraph);
-
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const std::string& fn) {
+    DigraphWriter<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
+
+  /// \brief Return a \ref DigraphWriter class
+  ///
+  /// This function just returns a \ref DigraphWriter class.
+  /// \relates DigraphWriter
   template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const char *fn,
-                                       const Digraph& digraph);
+  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
+                                       const char* fn) {
+    DigraphWriter<Digraph> tmp(digraph, fn);
+    return tmp;
+  }
 
   /// \ingroup lemon_io
@@ -383,5 +403,5 @@
   ///
   ///\code
-  /// DigraphWriter<Digraph>(std::cout, digraph).
+  /// DigraphWriter<Digraph>(digraph, std::cout).
   ///   nodeMap("coordinates", coord_map).
   ///   nodeMap("size", size).
@@ -453,6 +473,6 @@
     /// Construct a directed graph writer, which writes to the given
     /// output stream.
-    DigraphWriter(std::ostream& is, const Digraph& digraph)
-      : _os(&is), local_os(false), _digraph(digraph),
+    DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
+      : _os(&os), local_os(false), _digraph(digraph),
         _skip_nodes(false), _skip_arcs(false) {}
 
@@ -461,7 +481,12 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    DigraphWriter(const std::string& fn, const Digraph& digraph)
+    DigraphWriter(const Digraph& digraph, const std::string& fn)
       : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
-        _skip_nodes(false), _skip_arcs(false) {}
+        _skip_nodes(false), _skip_arcs(false) {
+      if (!(*_os)) {
+        delete _os;
+        throw IoError("Cannot write file", fn);
+      }
+    }
 
     /// \brief Constructor
@@ -469,7 +494,12 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    DigraphWriter(const char* fn, const Digraph& digraph)
+    DigraphWriter(const Digraph& digraph, const char* fn)
       : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
-        _skip_nodes(false), _skip_arcs(false) {}
+        _skip_nodes(false), _skip_arcs(false) {
+      if (!(*_os)) {
+        delete _os;
+        throw IoError("Cannot write file", fn);
+      }
+    }
 
     /// \brief Destructor
@@ -497,10 +527,10 @@
   private:
 
-    friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
-                                                  const Digraph& digraph);
-    friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
-                                                  const Digraph& digraph);
-    friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
-                                                  const Digraph& digraph);
+    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
+                                                  std::ostream& os);
+    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
+                                                  const std::string& fn);
+    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
+                                                  const char *fn);
 
     DigraphWriter(DigraphWriter& other)
@@ -904,48 +934,37 @@
   };
 
-  /// \brief Return a \ref DigraphWriter class
-  ///
-  /// This function just returns a \ref DigraphWriter class.
-  /// \relates DigraphWriter
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
-                                       const Digraph& digraph) {
-    DigraphWriter<Digraph> tmp(os, digraph);
+  template <typename Graph>
+  class GraphWriter;
+
+  /// \brief Return a \ref GraphWriter class
+  ///
+  /// This function just returns a \ref GraphWriter class.
+  /// \relates GraphWriter
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(const Graph& graph,
+                                 std::ostream& os = std::cout) {
+    GraphWriter<Graph> tmp(graph, os);
     return tmp;
   }
 
-  /// \brief Return a \ref DigraphWriter class
-  ///
-  /// This function just returns a \ref DigraphWriter class.
-  /// \relates DigraphWriter
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
-                                       const Digraph& digraph) {
-    DigraphWriter<Digraph> tmp(fn, digraph);
+  /// \brief Return a \ref GraphWriter class
+  ///
+  /// This function just returns a \ref GraphWriter class.
+  /// \relates GraphWriter
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
+    GraphWriter<Graph> tmp(graph, fn);
     return tmp;
   }
 
-  /// \brief Return a \ref DigraphWriter class
-  ///
-  /// This function just returns a \ref DigraphWriter class.
-  /// \relates DigraphWriter
-  template <typename Digraph>
-  DigraphWriter<Digraph> digraphWriter(const char* fn,
-                                       const Digraph& digraph) {
-    DigraphWriter<Digraph> tmp(fn, digraph);
+  /// \brief Return a \ref GraphWriter class
+  ///
+  /// This function just returns a \ref GraphWriter class.
+  /// \relates GraphWriter
+  template <typename Graph>
+  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
+    GraphWriter<Graph> tmp(graph, fn);
     return tmp;
   }
-
-  template <typename Graph>
-  class GraphWriter;
-
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
-
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
-
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
 
   /// \ingroup lemon_io
@@ -1009,6 +1028,6 @@
     /// Construct a directed graph writer, which writes to the given
     /// output stream.
-    GraphWriter(std::ostream& is, const Graph& graph)
-      : _os(&is), local_os(false), _graph(graph),
+    GraphWriter(const Graph& graph, std::ostream& os = std::cout)
+      : _os(&os), local_os(false), _graph(graph),
         _skip_nodes(false), _skip_edges(false) {}
 
@@ -1017,7 +1036,12 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    GraphWriter(const std::string& fn, const Graph& graph)
+    GraphWriter(const Graph& graph, const std::string& fn)
       : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
-        _skip_nodes(false), _skip_edges(false) {}
+        _skip_nodes(false), _skip_edges(false) {
+      if (!(*_os)) {
+        delete _os;
+        throw IoError("Cannot write file", fn);
+      }
+    }
 
     /// \brief Constructor
@@ -1025,7 +1049,12 @@
     /// Construct a directed graph writer, which writes to the given
     /// output file.
-    GraphWriter(const char* fn, const Graph& graph)
+    GraphWriter(const Graph& graph, const char* fn)
       : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
-        _skip_nodes(false), _skip_edges(false) {}
+        _skip_nodes(false), _skip_edges(false) {
+      if (!(*_os)) {
+        delete _os;
+        throw IoError("Cannot write file", fn);
+      }
+    }
 
     /// \brief Destructor
@@ -1053,10 +1082,10 @@
   private:
 
-    friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
-                                            const Graph& graph);
-    friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
-                                            const Graph& graph);
-    friend GraphWriter<Graph> graphWriter<>(const char *fn,
-                                            const Graph& graph);
+    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
+                                            std::ostream& os);
+    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
+                                            const std::string& fn);
+    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
+                                            const char *fn);
 
     GraphWriter(GraphWriter& other)
@@ -1506,34 +1535,4 @@
   };
 
-  /// \brief Return a \ref GraphWriter class
-  ///
-  /// This function just returns a \ref GraphWriter class.
-  /// \relates GraphWriter
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) {
-    GraphWriter<Graph> tmp(os, graph);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphWriter class
-  ///
-  /// This function just returns a \ref GraphWriter class.
-  /// \relates GraphWriter
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {
-    GraphWriter<Graph> tmp(fn, graph);
-    return tmp;
-  }
-
-  /// \brief Return a \ref GraphWriter class
-  ///
-  /// This function just returns a \ref GraphWriter class.
-  /// \relates GraphWriter
-  template <typename Graph>
-  GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {
-    GraphWriter<Graph> tmp(fn, graph);
-    return tmp;
-  }
-
   class SectionWriter;
 
@@ -1577,5 +1576,10 @@
     /// Construct a section writer, which writes into the given file.
     SectionWriter(const std::string& fn)
-      : _os(new std::ofstream(fn.c_str())), local_os(true) {}
+      : _os(new std::ofstream(fn.c_str())), local_os(true) {
+      if (!(*_os)) {
+        delete _os;
+        throw IoError("Cannot write file", fn);
+      }
+    }
 
     /// \brief Constructor
@@ -1583,5 +1587,10 @@
     /// Construct a section writer, which writes into the given file.
     SectionWriter(const char* fn)
-      : _os(new std::ofstream(fn)), local_os(true) {}
+      : _os(new std::ofstream(fn)), local_os(true) {
+      if (!(*_os)) {
+        delete _os;
+        throw IoError("Cannot write file", fn);
+      }
+    }
 
     /// \brief Destructor
Index: lemon/list_graph.h
===================================================================
--- lemon/list_graph.h	(revision 239)
+++ lemon/list_graph.h	(revision 341)
@@ -414,5 +414,5 @@
     ///
     ///\note The <tt>InArcIt</tt>s referencing the changed arc remain
-    ///valid. However the <tt>ArcIt<tt>s and <tt>OutArcIt</tt>s are
+    ///valid. However the <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s are
     ///invalidated.
     ///
@@ -502,8 +502,6 @@
     ///be invalidated.
     ///
-    ///\warning This functionality cannot be used together with the
+    ///\warning This functionality cannot be used in conjunction with the
     ///Snapshot feature.
-    ///
-    ///\todo It could be implemented in a bit faster way.
     Node split(Node n, bool connect = true) {
       Node b = addNode();
@@ -843,6 +841,6 @@
 
     public:
-      operator Edge() const { 
-        return id != -1 ? edgeFromId(id / 2) : INVALID; 
+      operator Edge() const {
+        return id != -1 ? edgeFromId(id / 2) : INVALID;
       }
 
Index: lemon/maps.h
===================================================================
--- lemon/maps.h	(revision 220)
+++ lemon/maps.h	(revision 314)
@@ -44,5 +44,5 @@
   class MapBase {
   public:
-    /// \biref The key type of the map.
+    /// \brief The key type of the map.
     typedef K Key;
     /// \brief The value type of the map.
@@ -74,7 +74,7 @@
   };
 
-  /// Returns a \ref NullMap class
-
-  /// This function just returns a \ref NullMap class.
+  /// Returns a \c NullMap class
+
+  /// This function just returns a \c NullMap class.
   /// \relates NullMap
   template <typename K, typename V>
@@ -89,5 +89,5 @@
   /// value to each key.
   ///
-  /// In other aspects it is equivalent to \ref NullMap.
+  /// In other aspects it is equivalent to \c NullMap.
   /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
   /// concept, but it absorbs the data written to it.
@@ -134,7 +134,7 @@
   };
 
-  /// Returns a \ref ConstMap class
-
-  /// This function just returns a \ref ConstMap class.
+  /// Returns a \c ConstMap class
+
+  /// This function just returns a \c ConstMap class.
   /// \relates ConstMap
   template<typename K, typename V>
@@ -157,5 +157,5 @@
   /// value to each key.
   ///
-  /// In other aspects it is equivalent to \ref NullMap.
+  /// In other aspects it is equivalent to \c NullMap.
   /// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap"
   /// concept, but it absorbs the data written to it.
@@ -183,7 +183,7 @@
   };
 
-  /// Returns a \ref ConstMap class with inlined constant value
-
-  /// This function just returns a \ref ConstMap class with inlined
+  /// Returns a \c ConstMap class with inlined constant value
+
+  /// This function just returns a \c ConstMap class with inlined
   /// constant value.
   /// \relates ConstMap
@@ -213,7 +213,7 @@
   };
 
-  /// Returns an \ref IdentityMap class
-
-  /// This function just returns an \ref IdentityMap class.
+  /// Returns an \c IdentityMap class
+
+  /// This function just returns an \c IdentityMap class.
   /// \relates IdentityMap
   template<typename T>
@@ -229,5 +229,5 @@
   /// values to integer keys from the range <tt>[0..size-1]</tt>.
   /// It can be used with some data structures, for example
-  /// \ref UnionFind, \ref BinHeap, when the used items are small
+  /// \c UnionFind, \c BinHeap, when the used items are small
   /// integers. This map conforms the \ref concepts::ReferenceMap
   /// "ReferenceMap" concept.
@@ -269,5 +269,5 @@
       : _vector(vector.begin(), vector.end()) {}
 
-    /// Constructs the map from another \ref RangeMap.
+    /// Constructs the map from another \c RangeMap.
     template <typename V1>
     RangeMap(const RangeMap<V1> &c)
@@ -312,7 +312,7 @@
   };
 
-  /// Returns a \ref RangeMap class
-
-  /// This function just returns a \ref RangeMap class.
+  /// Returns a \c RangeMap class
+
+  /// This function just returns a \c RangeMap class.
   /// \relates RangeMap
   template<typename V>
@@ -321,8 +321,8 @@
   }
 
-  /// \brief Returns a \ref RangeMap class created from an appropriate
+  /// \brief Returns a \c RangeMap class created from an appropriate
   /// \c std::vector
 
-  /// This function just returns a \ref RangeMap class created from an
+  /// This function just returns a \c RangeMap class created from an
   /// appropriate \c std::vector.
   /// \relates RangeMap
@@ -389,5 +389,5 @@
       : _map(map.begin(), map.end()), _value(value) {}
 
-    /// \brief Constructs the map from another \ref SparseMap.
+    /// \brief Constructs the map from another \c SparseMap.
     template<typename V1, typename Comp1>
     SparseMap(const SparseMap<Key, V1, Comp1> &c)
@@ -434,7 +434,7 @@
   };
 
-  /// Returns a \ref SparseMap class
-
-  /// This function just returns a \ref SparseMap class with specified
+  /// Returns a \c SparseMap class
+
+  /// This function just returns a \c SparseMap class with specified
   /// default value.
   /// \relates SparseMap
@@ -449,8 +449,8 @@
   }
 
-  /// \brief Returns a \ref SparseMap class created from an appropriate
+  /// \brief Returns a \c SparseMap class created from an appropriate
   /// \c std::map
 
-  /// This function just returns a \ref SparseMap class created from an
+  /// This function just returns a \c SparseMap class created from an
   /// appropriate \c std::map.
   /// \relates SparseMap
@@ -485,6 +485,4 @@
   ///
   /// \sa CombineMap
-  ///
-  /// \todo Check the requirements.
   template <typename M1, typename M2>
   class ComposeMap : public MapBase<typename M2::Key, typename M1::Value> {
@@ -504,7 +502,7 @@
   };
 
-  /// Returns a \ref ComposeMap class
-
-  /// This function just returns a \ref ComposeMap class.
+  /// Returns a \c ComposeMap class
+
+  /// This function just returns a \c ComposeMap class.
   ///
   /// If \c m1 and \c m2 are maps and the \c Value type of \c m2 is
@@ -541,6 +539,4 @@
   ///
   /// \sa ComposeMap
-  ///
-  /// \todo Check the requirements.
   template<typename M1, typename M2, typename F,
            typename V = typename F::result_type>
@@ -561,7 +557,7 @@
   };
 
-  /// Returns a \ref CombineMap class
-
-  /// This function just returns a \ref CombineMap class.
+  /// Returns a \c CombineMap class
+
+  /// This function just returns a \c CombineMap class.
   ///
   /// For example, if \c m1 and \c m2 are both maps with \c double
@@ -630,7 +626,7 @@
   };
 
-  /// Returns a \ref FunctorToMap class
-
-  /// This function just returns a \ref FunctorToMap class.
+  /// Returns a \c FunctorToMap class
+
+  /// This function just returns a \c FunctorToMap class.
   ///
   /// This function is specialized for adaptable binary function
@@ -689,7 +685,7 @@
   };
 
-  /// Returns a \ref MapToFunctor class
-
-  /// This function just returns a \ref MapToFunctor class.
+  /// Returns a \c MapToFunctor class
+
+  /// This function just returns a \c MapToFunctor class.
   /// \relates MapToFunctor
   template<typename M>
@@ -728,7 +724,7 @@
   };
 
-  /// Returns a \ref ConvertMap class
-
-  /// This function just returns a \ref ConvertMap class.
+  /// Returns a \c ConvertMap class
+
+  /// This function just returns a \c ConvertMap class.
   /// \relates ConvertMap
   template<typename V, typename M>
@@ -768,7 +764,7 @@
   };
 
-  /// Returns a \ref ForkMap class
-
-  /// This function just returns a \ref ForkMap class.
+  /// Returns a \c ForkMap class
+
+  /// This function just returns a \c ForkMap class.
   /// \relates ForkMap
   template <typename M1, typename M2>
@@ -812,7 +808,7 @@
   };
 
-  /// Returns an \ref AddMap class
-
-  /// This function just returns an \ref AddMap class.
+  /// Returns an \c AddMap class
+
+  /// This function just returns an \c AddMap class.
   ///
   /// For example, if \c m1 and \c m2 are both maps with \c double
@@ -860,7 +856,7 @@
   };
 
-  /// Returns a \ref SubMap class
-
-  /// This function just returns a \ref SubMap class.
+  /// Returns a \c SubMap class
+
+  /// This function just returns a \c SubMap class.
   ///
   /// For example, if \c m1 and \c m2 are both maps with \c double
@@ -909,7 +905,7 @@
   };
 
-  /// Returns a \ref MulMap class
-
-  /// This function just returns a \ref MulMap class.
+  /// Returns a \c MulMap class
+
+  /// This function just returns a \c MulMap class.
   ///
   /// For example, if \c m1 and \c m2 are both maps with \c double
@@ -957,7 +953,7 @@
   };
 
-  /// Returns a \ref DivMap class
-
-  /// This function just returns a \ref DivMap class.
+  /// Returns a \c DivMap class
+
+  /// This function just returns a \c DivMap class.
   ///
   /// For example, if \c m1 and \c m2 are both maps with \c double
@@ -1043,7 +1039,7 @@
   };
 
-  /// Returns a \ref ShiftMap class
-
-  /// This function just returns a \ref ShiftMap class.
+  /// Returns a \c ShiftMap class
+
+  /// This function just returns a \c ShiftMap class.
   ///
   /// For example, if \c m is a map with \c double values and \c v is
@@ -1057,7 +1053,7 @@
   }
 
-  /// Returns a \ref ShiftWriteMap class
-
-  /// This function just returns a \ref ShiftWriteMap class.
+  /// Returns a \c ShiftWriteMap class
+
+  /// This function just returns a \c ShiftWriteMap class.
   ///
   /// For example, if \c m is a map with \c double values and \c v is
@@ -1145,7 +1141,7 @@
   };
 
-  /// Returns a \ref ScaleMap class
-
-  /// This function just returns a \ref ScaleMap class.
+  /// Returns a \c ScaleMap class
+
+  /// This function just returns a \c ScaleMap class.
   ///
   /// For example, if \c m is a map with \c double values and \c v is
@@ -1159,7 +1155,7 @@
   }
 
-  /// Returns a \ref ScaleWriteMap class
-
-  /// This function just returns a \ref ScaleWriteMap class.
+  /// Returns a \c ScaleWriteMap class
+
+  /// This function just returns a \c ScaleWriteMap class.
   ///
   /// For example, if \c m is a map with \c double values and \c v is
@@ -1245,7 +1241,7 @@
   };
 
-  /// Returns a \ref NegMap class
-
-  /// This function just returns a \ref NegMap class.
+  /// Returns a \c NegMap class
+
+  /// This function just returns a \c NegMap class.
   ///
   /// For example, if \c m is a map with \c double values, then
@@ -1258,7 +1254,7 @@
   }
 
-  /// Returns a \ref NegWriteMap class
-
-  /// This function just returns a \ref NegWriteMap class.
+  /// Returns a \c NegWriteMap class
+
+  /// This function just returns a \c NegWriteMap class.
   ///
   /// For example, if \c m is a map with \c double values, then
@@ -1301,7 +1297,7 @@
   };
 
-  /// Returns an \ref AbsMap class
-
-  /// This function just returns an \ref AbsMap class.
+  /// Returns an \c AbsMap class
+
+  /// This function just returns an \c AbsMap class.
   ///
   /// For example, if \c m is a map with \c double values, then
@@ -1350,7 +1346,7 @@
   };
 
-  /// Returns a \ref TrueMap class
-
-  /// This function just returns a \ref TrueMap class.
+  /// Returns a \c TrueMap class
+
+  /// This function just returns a \c TrueMap class.
   /// \relates TrueMap
   template<typename K>
@@ -1387,7 +1383,7 @@
   };
 
-  /// Returns a \ref FalseMap class
-
-  /// This function just returns a \ref FalseMap class.
+  /// Returns a \c FalseMap class
+
+  /// This function just returns a \c FalseMap class.
   /// \relates FalseMap
   template<typename K>
@@ -1434,7 +1430,7 @@
   };
 
-  /// Returns an \ref AndMap class
-
-  /// This function just returns an \ref AndMap class.
+  /// Returns an \c AndMap class
+
+  /// This function just returns an \c AndMap class.
   ///
   /// For example, if \c m1 and \c m2 are both maps with \c bool values,
@@ -1482,7 +1478,7 @@
   };
 
-  /// Returns an \ref OrMap class
-
-  /// This function just returns an \ref OrMap class.
+  /// Returns an \c OrMap class
+
+  /// This function just returns an \c OrMap class.
   ///
   /// For example, if \c m1 and \c m2 are both maps with \c bool values,
@@ -1549,7 +1545,7 @@
   };
 
-  /// Returns a \ref NotMap class
-
-  /// This function just returns a \ref NotMap class.
+  /// Returns a \c NotMap class
+
+  /// This function just returns a \c NotMap class.
   ///
   /// For example, if \c m is a map with \c bool values, then
@@ -1562,7 +1558,7 @@
   }
 
-  /// Returns a \ref NotWriteMap class
-
-  /// This function just returns a \ref NotWriteMap class.
+  /// Returns a \c NotWriteMap class
+
+  /// This function just returns a \c NotWriteMap class.
   ///
   /// For example, if \c m is a map with \c bool values, then
@@ -1610,7 +1606,7 @@
   };
 
-  /// Returns an \ref EqualMap class
-
-  /// This function just returns an \ref EqualMap class.
+  /// Returns an \c EqualMap class
+
+  /// This function just returns an \c EqualMap class.
   ///
   /// For example, if \c m1 and \c m2 are maps with keys and values of
@@ -1658,7 +1654,7 @@
   };
 
-  /// Returns an \ref LessMap class
-
-  /// This function just returns an \ref LessMap class.
+  /// Returns an \c LessMap class
+
+  /// This function just returns an \c LessMap class.
   ///
   /// For example, if \c m1 and \c m2 are maps with keys and values of
@@ -1687,4 +1683,9 @@
 
   }
+
+  /// @}
+
+  /// \addtogroup maps
+  /// @{
 
   /// \brief Writable bool map for logging each \c true assigned element
@@ -1750,7 +1751,7 @@
   };
 
-  /// Returns a \ref LoggerBoolMap class
-
-  /// This function just returns a \ref LoggerBoolMap class.
+  /// Returns a \c LoggerBoolMap class
+
+  /// This function just returns a \c LoggerBoolMap class.
   ///
   /// The most important usage of it is storing certain nodes or arcs
@@ -1772,5 +1773,5 @@
   /// \note LoggerBoolMap is just \ref concepts::WriteMap "writable", so
   /// it cannot be used when a readable map is needed, for example as
-  /// \c ReachedMap for \ref Bfs, \ref Dfs and \ref Dijkstra algorithms.
+  /// \c ReachedMap for \c Bfs, \c Dfs and \c Dijkstra algorithms.
   ///
   /// \relates LoggerBoolMap
@@ -1779,4 +1780,9 @@
     return LoggerBoolMap<Iterator>(it);
   }
+
+  /// @}
+
+  /// \addtogroup graph_maps
+  /// @{
 
   /// Provides an immutable and unique id for each item in the graph.
@@ -1886,6 +1892,4 @@
     /// The value type of the InvertableMap.
     typedef typename Map::Value Value;
-
-
 
     /// \brief Constructor.
@@ -2054,6 +2058,4 @@
     }
 
-
-
   };
 
@@ -2271,5 +2273,5 @@
     ///
     /// Constructor
-    /// \param _digraph The digraph that the map belongs to.
+    /// \param digraph The digraph that the map belongs to.
     explicit SourceMap(const Digraph& digraph) : _digraph(digraph) {}
 
@@ -2287,7 +2289,7 @@
   };
 
-  /// \brief Returns a \ref SourceMap class.
-  ///
-  /// This function just returns an \ref SourceMap class.
+  /// \brief Returns a \c SourceMap class.
+  ///
+  /// This function just returns an \c SourceMap class.
   /// \relates SourceMap
   template <typename Digraph>
@@ -2310,5 +2312,5 @@
     ///
     /// Constructor
-    /// \param _digraph The digraph that the map belongs to.
+    /// \param digraph The digraph that the map belongs to.
     explicit TargetMap(const Digraph& digraph) : _digraph(digraph) {}
 
@@ -2326,7 +2328,7 @@
   };
 
-  /// \brief Returns a \ref TargetMap class.
-  ///
-  /// This function just returns a \ref TargetMap class.
+  /// \brief Returns a \c TargetMap class.
+  ///
+  /// This function just returns a \c TargetMap class.
   /// \relates TargetMap
   template <typename Digraph>
@@ -2349,5 +2351,5 @@
     ///
     /// Constructor
-    /// \param _graph The graph that the map belongs to.
+    /// \param graph The graph that the map belongs to.
     explicit ForwardMap(const Graph& graph) : _graph(graph) {}
 
@@ -2365,7 +2367,7 @@
   };
 
-  /// \brief Returns a \ref ForwardMap class.
-  ///
-  /// This function just returns an \ref ForwardMap class.
+  /// \brief Returns a \c ForwardMap class.
+  ///
+  /// This function just returns an \c ForwardMap class.
   /// \relates ForwardMap
   template <typename Graph>
@@ -2388,5 +2390,5 @@
     ///
     /// Constructor
-    /// \param _graph The graph that the map belongs to.
+    /// \param graph The graph that the map belongs to.
     explicit BackwardMap(const Graph& graph) : _graph(graph) {}
 
@@ -2404,7 +2406,7 @@
   };
 
-  /// \brief Returns a \ref BackwardMap class
-
-  /// This function just returns a \ref BackwardMap class.
+  /// \brief Returns a \c BackwardMap class
+
+  /// This function just returns a \c BackwardMap class.
   /// \relates BackwardMap
   template <typename Graph>
Index: lemon/max_matching.h
===================================================================
--- lemon/max_matching.h	(revision 342)
+++ lemon/max_matching.h	(revision 342)
@@ -0,0 +1,3104 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2008
+ * 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.
+ *
+ */
+
+#ifndef LEMON_MAX_MATCHING_H
+#define LEMON_MAX_MATCHING_H
+
+#include <vector>
+#include <queue>
+#include <set>
+#include <limits>
+
+#include <lemon/core.h>
+#include <lemon/unionfind.h>
+#include <lemon/bin_heap.h>
+#include <lemon/maps.h>
+
+///\ingroup matching
+///\file
+///\brief Maximum matching algorithms in general graphs.
+
+namespace lemon {
+
+  /// \ingroup matching
+  ///
+  /// \brief Edmonds' alternating forest maximum matching algorithm.
+  ///
+  /// This class implements Edmonds' alternating forest matching
+  /// algorithm. The algorithm can be started from an arbitrary initial
+  /// matching (the default is the empty one)
+  ///
+  /// The dual solution of the problem is a map of the nodes to
+  /// MaxMatching::Status, having values \c EVEN/D, \c ODD/A and \c
+  /// MATCHED/C showing the Gallai-Edmonds decomposition of the
+  /// graph. The nodes in \c EVEN/D induce a graph with
+  /// factor-critical components, the nodes in \c ODD/A form the
+  /// barrier, and the nodes in \c MATCHED/C induce a graph having a
+  /// perfect matching. The number of the factor-critical components
+  /// minus the number of barrier nodes is a lower bound on the
+  /// unmatched nodes, and the matching is optimal if and only if this bound is
+  /// tight. This decomposition can be attained by calling \c
+  /// decomposition() after running the algorithm.
+  ///
+  /// \param _Graph The graph type the algorithm runs on.
+  template <typename _Graph>
+  class MaxMatching {
+  public:
+
+    typedef _Graph Graph;
+    typedef typename Graph::template NodeMap<typename Graph::Arc>
+    MatchingMap;
+
+    ///\brief Indicates the Gallai-Edmonds decomposition of the graph.
+    ///
+    ///Indicates the Gallai-Edmonds decomposition of the graph. The
+    ///nodes with Status \c EVEN/D induce a graph with factor-critical
+    ///components, the nodes in \c ODD/A form the canonical barrier,
+    ///and the nodes in \c MATCHED/C induce a graph having a perfect
+    ///matching.
+    enum Status {
+      EVEN = 1, D = 1, MATCHED = 0, C = 0, ODD = -1, A = -1, UNMATCHED = -2
+    };
+
+    typedef typename Graph::template NodeMap<Status> StatusMap;
+
+  private:
+
+    TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+    typedef UnionFindEnum<IntNodeMap> BlossomSet;
+    typedef ExtendFindEnum<IntNodeMap> TreeSet;
+    typedef RangeMap<Node> NodeIntMap;
+    typedef MatchingMap EarMap;
+    typedef std::vector<Node> NodeQueue;
+
+    const Graph& _graph;
+    MatchingMap* _matching;
+    StatusMap* _status;
+
+    EarMap* _ear;
+
+    IntNodeMap* _blossom_set_index;
+    BlossomSet* _blossom_set;
+    NodeIntMap* _blossom_rep;
+
+    IntNodeMap* _tree_set_index;
+    TreeSet* _tree_set;
+
+    NodeQueue _node_queue;
+    int _process, _postpone, _last;
+
+    int _node_num;
+
+  private:
+
+    void createStructures() {
+      _node_num = countNodes(_graph);
+      if (!_matching) {
+        _matching = new MatchingMap(_graph);
+      }
+      if (!_status) {
+        _status = new StatusMap(_graph);
+      }
+      if (!_ear) {
+        _ear = new EarMap(_graph);
+      }
+      if (!_blossom_set) {
+        _blossom_set_index = new IntNodeMap(_graph);
+        _blossom_set = new BlossomSet(*_blossom_set_index);
+      }
+      if (!_blossom_rep) {
+        _blossom_rep = new NodeIntMap(_node_num);
+      }
+      if (!_tree_set) {
+        _tree_set_index = new IntNodeMap(_graph);
+        _tree_set = new TreeSet(*_tree_set_index);
+      }
+      _node_queue.resize(_node_num);
+    }
+
+    void destroyStructures() {
+      if (_matching) {
+        delete _matching;
+      }
+      if (_status) {
+        delete _status;
+      }
+      if (_ear) {
+        delete _ear;
+      }
+      if (_blossom_set) {
+        delete _blossom_set;
+        delete _blossom_set_index;
+      }
+      if (_blossom_rep) {
+        delete _blossom_rep;
+      }
+      if (_tree_set) {
+        delete _tree_set_index;
+        delete _tree_set;
+      }
+    }
+
+    void processDense(const Node& n) {
+      _process = _postpone = _last = 0;
+      _node_queue[_last++] = n;
+
+      while (_process != _last) {
+        Node u = _node_queue[_process++];
+        for (OutArcIt a(_graph, u); a != INVALID; ++a) {
+          Node v = _graph.target(a);
+          if ((*_status)[v] == MATCHED) {
+            extendOnArc(a);
+          } else if ((*_status)[v] == UNMATCHED) {
+            augmentOnArc(a);
+            return;
+          }
+        }
+      }
+
+      while (_postpone != _last) {
+        Node u = _node_queue[_postpone++];
+
+        for (OutArcIt a(_graph, u); a != INVALID ; ++a) {
+          Node v = _graph.target(a);
+
+          if ((*_status)[v] == EVEN) {
+            if (_blossom_set->find(u) != _blossom_set->find(v)) {
+              shrinkOnEdge(a);
+            }
+          }
+
+          while (_process != _last) {
+            Node w = _node_queue[_process++];
+            for (OutArcIt b(_graph, w); b != INVALID; ++b) {
+              Node x = _graph.target(b);
+              if ((*_status)[x] == MATCHED) {
+                extendOnArc(b);
+              } else if ((*_status)[x] == UNMATCHED) {
+                augmentOnArc(b);
+                return;
+              }
+            }
+          }
+        }
+      }
+    }
+
+    void processSparse(const Node& n) {
+      _process = _last = 0;
+      _node_queue[_last++] = n;
+      while (_process != _last) {
+        Node u = _node_queue[_process++];
+        for (OutArcIt a(_graph, u); a != INVALID; ++a) {
+          Node v = _graph.target(a);
+
+          if ((*_status)[v] == EVEN) {
+            if (_blossom_set->find(u) != _blossom_set->find(v)) {
+              shrinkOnEdge(a);
+            }
+          } else if ((*_status)[v] == MATCHED) {
+            extendOnArc(a);
+          } else if ((*_status)[v] == UNMATCHED) {
+            augmentOnArc(a);
+            return;
+          }
+        }
+      }
+    }
+
+    void shrinkOnEdge(const Edge& e) {
+      Node nca = INVALID;
+
+      {
+        std::set<Node> left_set, right_set;
+
+        Node left = (*_blossom_rep)[_blossom_set->find(_graph.u(e))];
+        left_set.insert(left);
+
+        Node right = (*_blossom_rep)[_blossom_set->find(_graph.v(e))];
+        right_set.insert(right);
+
+        while (true) {
+          if ((*_matching)[left] == INVALID) break;
+          left = _graph.target((*_matching)[left]);
+          left = (*_blossom_rep)[_blossom_set->
+                                 find(_graph.target((*_ear)[left]))];
+          if (right_set.find(left) != right_set.end()) {
+            nca = left;
+            break;
+          }
+          left_set.insert(left);
+
+          if ((*_matching)[right] == INVALID) break;
+          right = _graph.target((*_matching)[right]);
+          right = (*_blossom_rep)[_blossom_set->
+                                  find(_graph.target((*_ear)[right]))];
+          if (left_set.find(right) != left_set.end()) {
+            nca = right;
+            break;
+          }
+          right_set.insert(right);
+        }
+
+        if (nca == INVALID) {
+          if ((*_matching)[left] == INVALID) {
+            nca = right;
+            while (left_set.find(nca) == left_set.end()) {
+              nca = _graph.target((*_matching)[nca]);
+              nca =(*_blossom_rep)[_blossom_set->
+                                   find(_graph.target((*_ear)[nca]))];
+            }
+          } else {
+            nca = left;
+            while (right_set.find(nca) == right_set.end()) {
+              nca = _graph.target((*_matching)[nca]);
+              nca = (*_blossom_rep)[_blossom_set->
+                                   find(_graph.target((*_ear)[nca]))];
+            }
+          }
+        }
+      }
+
+      {
+
+        Node node = _graph.u(e);
+        Arc arc = _graph.direct(e, true);
+        Node base = (*_blossom_rep)[_blossom_set->find(node)];
+
+        while (base != nca) {
+          _ear->set(node, arc);
+
+          Node n = node;
+          while (n != base) {
+            n = _graph.target((*_matching)[n]);
+            Arc a = (*_ear)[n];
+            n = _graph.target(a);
+            _ear->set(n, _graph.oppositeArc(a));
+          }
+          node = _graph.target((*_matching)[base]);
+          _tree_set->erase(base);
+          _tree_set->erase(node);
+          _blossom_set->insert(node, _blossom_set->find(base));
+          _status->set(node, EVEN);
+          _node_queue[_last++] = node;
+          arc = _graph.oppositeArc((*_ear)[node]);
+          node = _graph.target((*_ear)[node]);
+          base = (*_blossom_rep)[_blossom_set->find(node)];
+          _blossom_set->join(_graph.target(arc), base);
+        }
+      }
+
+      _blossom_rep->set(_blossom_set->find(nca), nca);
+
+      {
+
+        Node node = _graph.v(e);
+        Arc arc = _graph.direct(e, false);
+        Node base = (*_blossom_rep)[_blossom_set->find(node)];
+
+        while (base != nca) {
+          _ear->set(node, arc);
+
+          Node n = node;
+          while (n != base) {
+            n = _graph.target((*_matching)[n]);
+            Arc a = (*_ear)[n];
+            n = _graph.target(a);
+            _ear->set(n, _graph.oppositeArc(a));
+          }
+          node = _graph.target((*_matching)[base]);
+          _tree_set->erase(base);
+          _tree_set->erase(node);
+          _blossom_set->insert(node, _blossom_set->find(base));
+          _status->set(node, EVEN);
+          _node_queue[_last++] = node;
+          arc = _graph.oppositeArc((*_ear)[node]);
+          node = _graph.target((*_ear)[node]);
+          base = (*_blossom_rep)[_blossom_set->find(node)];
+          _blossom_set->join(_graph.target(arc), base);
+        }
+      }
+
+      _blossom_rep->set(_blossom_set->find(nca), nca);
+    }
+
+
+
+    void extendOnArc(const Arc& a) {
+      Node base = _graph.source(a);
+      Node odd = _graph.target(a);
+
+      _ear->set(odd, _graph.oppositeArc(a));
+      Node even = _graph.target((*_matching)[odd]);
+      _blossom_rep->set(_blossom_set->insert(even), even);
+      _status->set(odd, ODD);
+      _status->set(even, EVEN);
+      int tree = _tree_set->find((*_blossom_rep)[_blossom_set->find(base)]);
+      _tree_set->insert(odd, tree);
+      _tree_set->insert(even, tree);
+      _node_queue[_last++] = even;
+
+    }
+
+    void augmentOnArc(const Arc& a) {
+      Node even = _graph.source(a);
+      Node odd = _graph.target(a);
+
+      int tree = _tree_set->find((*_blossom_rep)[_blossom_set->find(even)]);
+
+      _matching->set(odd, _graph.oppositeArc(a));
+      _status->set(odd, MATCHED);
+
+      Arc arc = (*_matching)[even];
+      _matching->set(even, a);
+
+      while (arc != INVALID) {
+        odd = _graph.target(arc);
+        arc = (*_ear)[odd];
+        even = _graph.target(arc);
+        _matching->set(odd, arc);
+        arc = (*_matching)[even];
+        _matching->set(even, _graph.oppositeArc((*_matching)[odd]));
+      }
+
+      for (typename TreeSet::ItemIt it(*_tree_set, tree);
+           it != INVALID; ++it) {
+        if ((*_status)[it] == ODD) {
+          _status->set(it, MATCHED);
+        } else {
+          int blossom = _blossom_set->find(it);
+          for (typename BlossomSet::ItemIt jt(*_blossom_set, blossom);
+               jt != INVALID; ++jt) {
+            _status->set(jt, MATCHED);
+          }
+          _blossom_set->eraseClass(blossom);
+        }
+      }
+      _tree_set->eraseClass(tree);
+
+    }
+
+  public:
+
+    /// \brief Constructor
+    ///
+    /// Constructor.
+    MaxMatching(const Graph& graph)
+      : _graph(graph), _matching(0), _status(0), _ear(0),
+        _blossom_set_index(0), _blossom_set(0), _blossom_rep(0),
+        _tree_set_index(0), _tree_set(0) {}
+
+    ~MaxMatching() {
+      destroyStructures();
+    }
+
+    /// \name Execution control
+    /// The simplest way to execute the algorithm is to use the
+    /// \c run() member function.
+    /// \n
+
+    /// If you need better control on the execution, you must call
+    /// \ref init(), \ref greedyInit() or \ref matchingInit()
+    /// functions first, then you can start the algorithm with the \ref
+    /// startParse() or startDense() functions.
+
+    ///@{
+
+    /// \brief Sets the actual matching to the empty matching.
+    ///
+    /// Sets the actual matching to the empty matching.
+    ///
+    void init() {
+      createStructures();
+      for(NodeIt n(_graph); n != INVALID; ++n) {
+        _matching->set(n, INVALID);
+        _status->set(n, UNMATCHED);
+      }
+    }
+
+    ///\brief Finds an initial matching in a greedy way
+    ///
+    ///It finds an initial matching in a greedy way.
+    void greedyInit() {
+      createStructures();
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        _matching->set(n, INVALID);
+        _status->set(n, UNMATCHED);
+      }
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        if ((*_matching)[n] == INVALID) {
+          for (OutArcIt a(_graph, n); a != INVALID ; ++a) {
+            Node v = _graph.target(a);
+            if ((*_matching)[v] == INVALID && v != n) {
+              _matching->set(n, a);
+              _status->set(n, MATCHED);
+              _matching->set(v, _graph.oppositeArc(a));
+              _status->set(v, MATCHED);
+              break;
+            }
+          }
+        }
+      }
+    }
+
+
+    /// \brief Initialize the matching from a map containing.
+    ///
+    /// Initialize the matching from a \c bool valued \c Edge map. This
+    /// map must have the property that there are no two incident edges
+    /// with true value, ie. it contains a matching.
+    /// \return %True if the map contains a matching.
+    template <typename MatchingMap>
+    bool matchingInit(const MatchingMap& matching) {
+      createStructures();
+
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        _matching->set(n, INVALID);
+        _status->set(n, UNMATCHED);
+      }
+      for(EdgeIt e(_graph); e!=INVALID; ++e) {
+        if (matching[e]) {
+
+          Node u = _graph.u(e);
+          if ((*_matching)[u] != INVALID) return false;
+          _matching->set(u, _graph.direct(e, true));
+          _status->set(u, MATCHED);
+
+          Node v = _graph.v(e);
+          if ((*_matching)[v] != INVALID) return false;
+          _matching->set(v, _graph.direct(e, false));
+          _status->set(v, MATCHED);
+        }
+      }
+      return true;
+    }
+
+    /// \brief Starts Edmonds' algorithm
+    ///
+    /// If runs the original Edmonds' algorithm.
+    void startSparse() {
+      for(NodeIt n(_graph); n != INVALID; ++n) {
+        if ((*_status)[n] == UNMATCHED) {
+          (*_blossom_rep)[_blossom_set->insert(n)] = n;
+          _tree_set->insert(n);
+          _status->set(n, EVEN);
+          processSparse(n);
+        }
+      }
+    }
+
+    /// \brief Starts Edmonds' algorithm.
+    ///
+    /// It runs Edmonds' algorithm with a heuristic of postponing
+    /// shrinks, therefore resulting in a faster algorithm for dense graphs.
+    void startDense() {
+      for(NodeIt n(_graph); n != INVALID; ++n) {
+        if ((*_status)[n] == UNMATCHED) {
+          (*_blossom_rep)[_blossom_set->insert(n)] = n;
+          _tree_set->insert(n);
+          _status->set(n, EVEN);
+          processDense(n);
+        }
+      }
+    }
+
+
+    /// \brief Runs Edmonds' algorithm
+    ///
+    /// Runs Edmonds' algorithm for sparse graphs (<tt>m<2*n</tt>)
+    /// or Edmonds' algorithm with a heuristic of
+    /// postponing shrinks for dense graphs.
+    void run() {
+      if (countEdges(_graph) < 2 * countNodes(_graph)) {
+        greedyInit();
+        startSparse();
+      } else {
+        init();
+        startDense();
+      }
+    }
+
+    /// @}
+
+    /// \name Primal solution
+    /// Functions to get the primal solution, ie. the matching.
+
+    /// @{
+
+    ///\brief Returns the size of the current matching.
+    ///
+    ///Returns the size of the current matching. After \ref
+    ///run() it returns the size of the maximum matching in the graph.
+    int matchingSize() const {
+      int size = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        if ((*_matching)[n] != INVALID) {
+          ++size;
+        }
+      }
+      return size / 2;
+    }
+
+    /// \brief Returns true when the edge is in the matching.
+    ///
+    /// Returns true when the edge is in the matching.
+    bool matching(const Edge& edge) const {
+      return edge == (*_matching)[_graph.u(edge)];
+    }
+
+    /// \brief Returns the matching edge incident to the given node.
+    ///
+    /// Returns the matching edge of a \c node in the actual matching or
+    /// INVALID if the \c node is not covered by the actual matching.
+    Arc matching(const Node& n) const {
+      return (*_matching)[n];
+    }
+
+    ///\brief Returns the mate of a node in the actual matching.
+    ///
+    ///Returns the mate of a \c node in the actual matching or
+    ///INVALID if the \c node is not covered by the actual matching.
+    Node mate(const Node& n) const {
+      return (*_matching)[n] != INVALID ?
+        _graph.target((*_matching)[n]) : INVALID;
+    }
+
+    /// @}
+
+    /// \name Dual solution
+    /// Functions to get the dual solution, ie. the decomposition.
+
+    /// @{
+
+    /// \brief Returns the class of the node in the Edmonds-Gallai
+    /// decomposition.
+    ///
+    /// Returns the class of the node in the Edmonds-Gallai
+    /// decomposition.
+    Status decomposition(const Node& n) const {
+      return (*_status)[n];
+    }
+
+    /// \brief Returns true when the node is in the barrier.
+    ///
+    /// Returns true when the node is in the barrier.
+    bool barrier(const Node& n) const {
+      return (*_status)[n] == ODD;
+    }
+
+    /// @}
+
+  };
+
+  /// \ingroup matching
+  ///
+  /// \brief Weighted matching in general graphs
+  ///
+  /// This class provides an efficient implementation of Edmond's
+  /// maximum weighted matching algorithm. The implementation is based
+  /// on extensive use of priority queues and provides
+  /// \f$O(nm\log(n))\f$ time complexity.
+  ///
+  /// The maximum weighted matching problem is to find undirected
+  /// edges in the graph with maximum overall weight and no two of
+  /// them shares their ends. The problem can be formulated with the
+  /// following linear program.
+  /// \f[ \sum_{e \in \delta(u)}x_e \le 1 \quad \forall u\in V\f]
+  /** \f[ \sum_{e \in \gamma(B)}x_e \le \frac{\vert B \vert - 1}{2}
+      \quad \forall B\in\mathcal{O}\f] */
+  /// \f[x_e \ge 0\quad \forall e\in E\f]
+  /// \f[\max \sum_{e\in E}x_ew_e\f]
+  /// where \f$\delta(X)\f$ is the set of edges incident to a node in
+  /// \f$X\f$, \f$\gamma(X)\f$ is the set of edges with both ends in
+  /// \f$X\f$ and \f$\mathcal{O}\f$ is the set of odd cardinality
+  /// subsets of the nodes.
+  ///
+  /// The algorithm calculates an optimal matching and a proof of the
+  /// optimality. The solution of the dual problem can be used to check
+  /// the result of the algorithm. The dual linear problem is the
+  /** \f[ y_u + y_v + \sum_{B \in \mathcal{O}, uv \in \gamma(B)}
+      z_B \ge w_{uv} \quad \forall uv\in E\f] */
+  /// \f[y_u \ge 0 \quad \forall u \in V\f]
+  /// \f[z_B \ge 0 \quad \forall B \in \mathcal{O}\f]
+  /** \f[\min \sum_{u \in V}y_u + \sum_{B \in \mathcal{O}}
+      \frac{\vert B \vert - 1}{2}z_B\f] */
+  ///
+  /// The algorithm can be executed with \c run() or the \c init() and
+  /// then the \c start() member functions. After it the matching can
+  /// be asked with \c matching() or mate() functions. The dual
+  /// solution can be get with \c nodeValue(), \c blossomNum() and \c
+  /// blossomValue() members and \ref MaxWeightedMatching::BlossomIt
+  /// "BlossomIt" nested class, which is able to iterate on the nodes
+  /// of a blossom. If the value type is integral then the dual
+  /// solution is multiplied by \ref MaxWeightedMatching::dualScale "4".
+  template <typename _Graph,
+            typename _WeightMap = typename _Graph::template EdgeMap<int> >
+  class MaxWeightedMatching {
+  public:
+
+    typedef _Graph Graph;
+    typedef _WeightMap WeightMap;
+    typedef typename WeightMap::Value Value;
+
+    /// \brief Scaling factor for dual solution
+    ///
+    /// Scaling factor for dual solution, it is equal to 4 or 1
+    /// according to the value type.
+    static const int dualScale =
+      std::numeric_limits<Value>::is_integer ? 4 : 1;
+
+    typedef typename Graph::template NodeMap<typename Graph::Arc>
+    MatchingMap;
+
+  private:
+
+    TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+    typedef typename Graph::template NodeMap<Value> NodePotential;
+    typedef std::vector<Node> BlossomNodeList;
+
+    struct BlossomVariable {
+      int begin, end;
+      Value value;
+
+      BlossomVariable(int _begin, int _end, Value _value)
+        : begin(_begin), end(_end), value(_value) {}
+
+    };
+
+    typedef std::vector<BlossomVariable> BlossomPotential;
+
+    const Graph& _graph;
+    const WeightMap& _weight;
+
+    MatchingMap* _matching;
+
+    NodePotential* _node_potential;
+
+    BlossomPotential _blossom_potential;
+    BlossomNodeList _blossom_node_list;
+
+    int _node_num;
+    int _blossom_num;
+
+    typedef RangeMap<int> IntIntMap;
+
+    enum Status {
+      EVEN = -1, MATCHED = 0, ODD = 1, UNMATCHED = -2
+    };
+
+    typedef HeapUnionFind<Value, IntNodeMap> BlossomSet;
+    struct BlossomData {
+      int tree;
+      Status status;
+      Arc pred, next;
+      Value pot, offset;
+      Node base;
+    };
+
+    IntNodeMap *_blossom_index;
+    BlossomSet *_blossom_set;
+    RangeMap<BlossomData>* _blossom_data;
+
+    IntNodeMap *_node_index;
+    IntArcMap *_node_heap_index;
+
+    struct NodeData {
+
+      NodeData(IntArcMap& node_heap_index)
+        : heap(node_heap_index) {}
+
+      int blossom;
+      Value pot;
+      BinHeap<Value, IntArcMap> heap;
+      std::map<int, Arc> heap_index;
+
+      int tree;
+    };
+
+    RangeMap<NodeData>* _node_data;
+
+    typedef ExtendFindEnum<IntIntMap> TreeSet;
+
+    IntIntMap *_tree_set_index;
+    TreeSet *_tree_set;
+
+    IntNodeMap *_delta1_index;
+    BinHeap<Value, IntNodeMap> *_delta1;
+
+    IntIntMap *_delta2_index;
+    BinHeap<Value, IntIntMap> *_delta2;
+
+    IntEdgeMap *_delta3_index;
+    BinHeap<Value, IntEdgeMap> *_delta3;
+
+    IntIntMap *_delta4_index;
+    BinHeap<Value, IntIntMap> *_delta4;
+
+    Value _delta_sum;
+
+    void createStructures() {
+      _node_num = countNodes(_graph);
+      _blossom_num = _node_num * 3 / 2;
+
+      if (!_matching) {
+        _matching = new MatchingMap(_graph);
+      }
+      if (!_node_potential) {
+        _node_potential = new NodePotential(_graph);
+      }
+      if (!_blossom_set) {
+        _blossom_index = new IntNodeMap(_graph);
+        _blossom_set = new BlossomSet(*_blossom_index);
+        _blossom_data = new RangeMap<BlossomData>(_blossom_num);
+      }
+
+      if (!_node_index) {
+        _node_index = new IntNodeMap(_graph);
+        _node_heap_index = new IntArcMap(_graph);
+        _node_data = new RangeMap<NodeData>(_node_num,
+                                              NodeData(*_node_heap_index));
+      }
+
+      if (!_tree_set) {
+        _tree_set_index = new IntIntMap(_blossom_num);
+        _tree_set = new TreeSet(*_tree_set_index);
+      }
+      if (!_delta1) {
+        _delta1_index = new IntNodeMap(_graph);
+        _delta1 = new BinHeap<Value, IntNodeMap>(*_delta1_index);
+      }
+      if (!_delta2) {
+        _delta2_index = new IntIntMap(_blossom_num);
+        _delta2 = new BinHeap<Value, IntIntMap>(*_delta2_index);
+      }
+      if (!_delta3) {
+        _delta3_index = new IntEdgeMap(_graph);
+        _delta3 = new BinHeap<Value, IntEdgeMap>(*_delta3_index);
+      }
+      if (!_delta4) {
+        _delta4_index = new IntIntMap(_blossom_num);
+        _delta4 = new BinHeap<Value, IntIntMap>(*_delta4_index);
+      }
+    }
+
+    void destroyStructures() {
+      _node_num = countNodes(_graph);
+      _blossom_num = _node_num * 3 / 2;
+
+      if (_matching) {
+        delete _matching;
+      }
+      if (_node_potential) {
+        delete _node_potential;
+      }
+      if (_blossom_set) {
+        delete _blossom_index;
+        delete _blossom_set;
+        delete _blossom_data;
+      }
+
+      if (_node_index) {
+        delete _node_index;
+        delete _node_heap_index;
+        delete _node_data;
+      }
+
+      if (_tree_set) {
+        delete _tree_set_index;
+        delete _tree_set;
+      }
+      if (_delta1) {
+        delete _delta1_index;
+        delete _delta1;
+      }
+      if (_delta2) {
+        delete _delta2_index;
+        delete _delta2;
+      }
+      if (_delta3) {
+        delete _delta3_index;
+        delete _delta3;
+      }
+      if (_delta4) {
+        delete _delta4_index;
+        delete _delta4;
+      }
+    }
+
+    void matchedToEven(int blossom, int tree) {
+      if (_delta2->state(blossom) == _delta2->IN_HEAP) {
+        _delta2->erase(blossom);
+      }
+
+      if (!_blossom_set->trivial(blossom)) {
+        (*_blossom_data)[blossom].pot -=
+          2 * (_delta_sum - (*_blossom_data)[blossom].offset);
+      }
+
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+
+        _blossom_set->increase(n, std::numeric_limits<Value>::max());
+        int ni = (*_node_index)[n];
+
+        (*_node_data)[ni].heap.clear();
+        (*_node_data)[ni].heap_index.clear();
+
+        (*_node_data)[ni].pot += _delta_sum - (*_blossom_data)[blossom].offset;
+
+        _delta1->push(n, (*_node_data)[ni].pot);
+
+        for (InArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.source(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if ((*_blossom_data)[vb].status == EVEN) {
+            if (_delta3->state(e) != _delta3->IN_HEAP && blossom != vb) {
+              _delta3->push(e, rw / 2);
+            }
+          } else if ((*_blossom_data)[vb].status == UNMATCHED) {
+            if (_delta3->state(e) != _delta3->IN_HEAP) {
+              _delta3->push(e, rw);
+            }
+          } else {
+            typename std::map<int, Arc>::iterator it =
+              (*_node_data)[vi].heap_index.find(tree);
+
+            if (it != (*_node_data)[vi].heap_index.end()) {
+              if ((*_node_data)[vi].heap[it->second] > rw) {
+                (*_node_data)[vi].heap.replace(it->second, e);
+                (*_node_data)[vi].heap.decrease(e, rw);
+                it->second = e;
+              }
+            } else {
+              (*_node_data)[vi].heap.push(e, rw);
+              (*_node_data)[vi].heap_index.insert(std::make_pair(tree, e));
+            }
+
+            if ((*_blossom_set)[v] > (*_node_data)[vi].heap.prio()) {
+              _blossom_set->decrease(v, (*_node_data)[vi].heap.prio());
+
+              if ((*_blossom_data)[vb].status == MATCHED) {
+                if (_delta2->state(vb) != _delta2->IN_HEAP) {
+                  _delta2->push(vb, _blossom_set->classPrio(vb) -
+                               (*_blossom_data)[vb].offset);
+                } else if ((*_delta2)[vb] > _blossom_set->classPrio(vb) -
+                           (*_blossom_data)[vb].offset){
+                  _delta2->decrease(vb, _blossom_set->classPrio(vb) -
+                                   (*_blossom_data)[vb].offset);
+                }
+              }
+            }
+          }
+        }
+      }
+      (*_blossom_data)[blossom].offset = 0;
+    }
+
+    void matchedToOdd(int blossom) {
+      if (_delta2->state(blossom) == _delta2->IN_HEAP) {
+        _delta2->erase(blossom);
+      }
+      (*_blossom_data)[blossom].offset += _delta_sum;
+      if (!_blossom_set->trivial(blossom)) {
+        _delta4->push(blossom, (*_blossom_data)[blossom].pot / 2 +
+                     (*_blossom_data)[blossom].offset);
+      }
+    }
+
+    void evenToMatched(int blossom, int tree) {
+      if (!_blossom_set->trivial(blossom)) {
+        (*_blossom_data)[blossom].pot += 2 * _delta_sum;
+      }
+
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+        int ni = (*_node_index)[n];
+        (*_node_data)[ni].pot -= _delta_sum;
+
+        _delta1->erase(n);
+
+        for (InArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.source(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if (vb == blossom) {
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+          } else if ((*_blossom_data)[vb].status == EVEN) {
+
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+
+            int vt = _tree_set->find(vb);
+
+            if (vt != tree) {
+
+              Arc r = _graph.oppositeArc(e);
+
+              typename std::map<int, Arc>::iterator it =
+                (*_node_data)[ni].heap_index.find(vt);
+
+              if (it != (*_node_data)[ni].heap_index.end()) {
+                if ((*_node_data)[ni].heap[it->second] > rw) {
+                  (*_node_data)[ni].heap.replace(it->second, r);
+                  (*_node_data)[ni].heap.decrease(r, rw);
+                  it->second = r;
+                }
+              } else {
+                (*_node_data)[ni].heap.push(r, rw);
+                (*_node_data)[ni].heap_index.insert(std::make_pair(vt, r));
+              }
+
+              if ((*_blossom_set)[n] > (*_node_data)[ni].heap.prio()) {
+                _blossom_set->decrease(n, (*_node_data)[ni].heap.prio());
+
+                if (_delta2->state(blossom) != _delta2->IN_HEAP) {
+                  _delta2->push(blossom, _blossom_set->classPrio(blossom) -
+                               (*_blossom_data)[blossom].offset);
+                } else if ((*_delta2)[blossom] >
+                           _blossom_set->classPrio(blossom) -
+                           (*_blossom_data)[blossom].offset){
+                  _delta2->decrease(blossom, _blossom_set->classPrio(blossom) -
+                                   (*_blossom_data)[blossom].offset);
+                }
+              }
+            }
+
+          } else if ((*_blossom_data)[vb].status == UNMATCHED) {
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+          } else {
+
+            typename std::map<int, Arc>::iterator it =
+              (*_node_data)[vi].heap_index.find(tree);
+
+            if (it != (*_node_data)[vi].heap_index.end()) {
+              (*_node_data)[vi].heap.erase(it->second);
+              (*_node_data)[vi].heap_index.erase(it);
+              if ((*_node_data)[vi].heap.empty()) {
+                _blossom_set->increase(v, std::numeric_limits<Value>::max());
+              } else if ((*_blossom_set)[v] < (*_node_data)[vi].heap.prio()) {
+                _blossom_set->increase(v, (*_node_data)[vi].heap.prio());
+              }
+
+              if ((*_blossom_data)[vb].status == MATCHED) {
+                if (_blossom_set->classPrio(vb) ==
+                    std::numeric_limits<Value>::max()) {
+                  _delta2->erase(vb);
+                } else if ((*_delta2)[vb] < _blossom_set->classPrio(vb) -
+                           (*_blossom_data)[vb].offset) {
+                  _delta2->increase(vb, _blossom_set->classPrio(vb) -
+                                   (*_blossom_data)[vb].offset);
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+
+    void oddToMatched(int blossom) {
+      (*_blossom_data)[blossom].offset -= _delta_sum;
+
+      if (_blossom_set->classPrio(blossom) !=
+          std::numeric_limits<Value>::max()) {
+        _delta2->push(blossom, _blossom_set->classPrio(blossom) -
+                       (*_blossom_data)[blossom].offset);
+      }
+
+      if (!_blossom_set->trivial(blossom)) {
+        _delta4->erase(blossom);
+      }
+    }
+
+    void oddToEven(int blossom, int tree) {
+      if (!_blossom_set->trivial(blossom)) {
+        _delta4->erase(blossom);
+        (*_blossom_data)[blossom].pot -=
+          2 * (2 * _delta_sum - (*_blossom_data)[blossom].offset);
+      }
+
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+        int ni = (*_node_index)[n];
+
+        _blossom_set->increase(n, std::numeric_limits<Value>::max());
+
+        (*_node_data)[ni].heap.clear();
+        (*_node_data)[ni].heap_index.clear();
+        (*_node_data)[ni].pot +=
+          2 * _delta_sum - (*_blossom_data)[blossom].offset;
+
+        _delta1->push(n, (*_node_data)[ni].pot);
+
+        for (InArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.source(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if ((*_blossom_data)[vb].status == EVEN) {
+            if (_delta3->state(e) != _delta3->IN_HEAP && blossom != vb) {
+              _delta3->push(e, rw / 2);
+            }
+          } else if ((*_blossom_data)[vb].status == UNMATCHED) {
+            if (_delta3->state(e) != _delta3->IN_HEAP) {
+              _delta3->push(e, rw);
+            }
+          } else {
+
+            typename std::map<int, Arc>::iterator it =
+              (*_node_data)[vi].heap_index.find(tree);
+
+            if (it != (*_node_data)[vi].heap_index.end()) {
+              if ((*_node_data)[vi].heap[it->second] > rw) {
+                (*_node_data)[vi].heap.replace(it->second, e);
+                (*_node_data)[vi].heap.decrease(e, rw);
+                it->second = e;
+              }
+            } else {
+              (*_node_data)[vi].heap.push(e, rw);
+              (*_node_data)[vi].heap_index.insert(std::make_pair(tree, e));
+            }
+
+            if ((*_blossom_set)[v] > (*_node_data)[vi].heap.prio()) {
+              _blossom_set->decrease(v, (*_node_data)[vi].heap.prio());
+
+              if ((*_blossom_data)[vb].status == MATCHED) {
+                if (_delta2->state(vb) != _delta2->IN_HEAP) {
+                  _delta2->push(vb, _blossom_set->classPrio(vb) -
+                               (*_blossom_data)[vb].offset);
+                } else if ((*_delta2)[vb] > _blossom_set->classPrio(vb) -
+                           (*_blossom_data)[vb].offset) {
+                  _delta2->decrease(vb, _blossom_set->classPrio(vb) -
+                                   (*_blossom_data)[vb].offset);
+                }
+              }
+            }
+          }
+        }
+      }
+      (*_blossom_data)[blossom].offset = 0;
+    }
+
+
+    void matchedToUnmatched(int blossom) {
+      if (_delta2->state(blossom) == _delta2->IN_HEAP) {
+        _delta2->erase(blossom);
+      }
+
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+        int ni = (*_node_index)[n];
+
+        _blossom_set->increase(n, std::numeric_limits<Value>::max());
+
+        (*_node_data)[ni].heap.clear();
+        (*_node_data)[ni].heap_index.clear();
+
+        for (OutArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.target(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if ((*_blossom_data)[vb].status == EVEN) {
+            if (_delta3->state(e) != _delta3->IN_HEAP) {
+              _delta3->push(e, rw);
+            }
+          }
+        }
+      }
+    }
+
+    void unmatchedToMatched(int blossom) {
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+        int ni = (*_node_index)[n];
+
+        for (InArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.source(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if (vb == blossom) {
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+          } else if ((*_blossom_data)[vb].status == EVEN) {
+
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+
+            int vt = _tree_set->find(vb);
+
+            Arc r = _graph.oppositeArc(e);
+
+            typename std::map<int, Arc>::iterator it =
+              (*_node_data)[ni].heap_index.find(vt);
+
+            if (it != (*_node_data)[ni].heap_index.end()) {
+              if ((*_node_data)[ni].heap[it->second] > rw) {
+                (*_node_data)[ni].heap.replace(it->second, r);
+                (*_node_data)[ni].heap.decrease(r, rw);
+                it->second = r;
+              }
+            } else {
+              (*_node_data)[ni].heap.push(r, rw);
+              (*_node_data)[ni].heap_index.insert(std::make_pair(vt, r));
+            }
+
+            if ((*_blossom_set)[n] > (*_node_data)[ni].heap.prio()) {
+              _blossom_set->decrease(n, (*_node_data)[ni].heap.prio());
+
+              if (_delta2->state(blossom) != _delta2->IN_HEAP) {
+                _delta2->push(blossom, _blossom_set->classPrio(blossom) -
+                             (*_blossom_data)[blossom].offset);
+              } else if ((*_delta2)[blossom] > _blossom_set->classPrio(blossom)-
+                         (*_blossom_data)[blossom].offset){
+                _delta2->decrease(blossom, _blossom_set->classPrio(blossom) -
+                                 (*_blossom_data)[blossom].offset);
+              }
+            }
+
+          } else if ((*_blossom_data)[vb].status == UNMATCHED) {
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+          }
+        }
+      }
+    }
+
+    void alternatePath(int even, int tree) {
+      int odd;
+
+      evenToMatched(even, tree);
+      (*_blossom_data)[even].status = MATCHED;
+
+      while ((*_blossom_data)[even].pred != INVALID) {
+        odd = _blossom_set->find(_graph.target((*_blossom_data)[even].pred));
+        (*_blossom_data)[odd].status = MATCHED;
+        oddToMatched(odd);
+        (*_blossom_data)[odd].next = (*_blossom_data)[odd].pred;
+
+        even = _blossom_set->find(_graph.target((*_blossom_data)[odd].pred));
+        (*_blossom_data)[even].status = MATCHED;
+        evenToMatched(even, tree);
+        (*_blossom_data)[even].next =
+          _graph.oppositeArc((*_blossom_data)[odd].pred);
+      }
+
+    }
+
+    void destroyTree(int tree) {
+      for (TreeSet::ItemIt b(*_tree_set, tree); b != INVALID; ++b) {
+        if ((*_blossom_data)[b].status == EVEN) {
+          (*_blossom_data)[b].status = MATCHED;
+          evenToMatched(b, tree);
+        } else if ((*_blossom_data)[b].status == ODD) {
+          (*_blossom_data)[b].status = MATCHED;
+          oddToMatched(b);
+        }
+      }
+      _tree_set->eraseClass(tree);
+    }
+
+
+    void unmatchNode(const Node& node) {
+      int blossom = _blossom_set->find(node);
+      int tree = _tree_set->find(blossom);
+
+      alternatePath(blossom, tree);
+      destroyTree(tree);
+
+      (*_blossom_data)[blossom].status = UNMATCHED;
+      (*_blossom_data)[blossom].base = node;
+      matchedToUnmatched(blossom);
+    }
+
+
+    void augmentOnEdge(const Edge& edge) {
+
+      int left = _blossom_set->find(_graph.u(edge));
+      int right = _blossom_set->find(_graph.v(edge));
+
+      if ((*_blossom_data)[left].status == EVEN) {
+        int left_tree = _tree_set->find(left);
+        alternatePath(left, left_tree);
+        destroyTree(left_tree);
+      } else {
+        (*_blossom_data)[left].status = MATCHED;
+        unmatchedToMatched(left);
+      }
+
+      if ((*_blossom_data)[right].status == EVEN) {
+        int right_tree = _tree_set->find(right);
+        alternatePath(right, right_tree);
+        destroyTree(right_tree);
+      } else {
+        (*_blossom_data)[right].status = MATCHED;
+        unmatchedToMatched(right);
+      }
+
+      (*_blossom_data)[left].next = _graph.direct(edge, true);
+      (*_blossom_data)[right].next = _graph.direct(edge, false);
+    }
+
+    void extendOnArc(const Arc& arc) {
+      int base = _blossom_set->find(_graph.target(arc));
+      int tree = _tree_set->find(base);
+
+      int odd = _blossom_set->find(_graph.source(arc));
+      _tree_set->insert(odd, tree);
+      (*_blossom_data)[odd].status = ODD;
+      matchedToOdd(odd);
+      (*_blossom_data)[odd].pred = arc;
+
+      int even = _blossom_set->find(_graph.target((*_blossom_data)[odd].next));
+      (*_blossom_data)[even].pred = (*_blossom_data)[even].next;
+      _tree_set->insert(even, tree);
+      (*_blossom_data)[even].status = EVEN;
+      matchedToEven(even, tree);
+    }
+
+    void shrinkOnEdge(const Edge& edge, int tree) {
+      int nca = -1;
+      std::vector<int> left_path, right_path;
+
+      {
+        std::set<int> left_set, right_set;
+        int left = _blossom_set->find(_graph.u(edge));
+        left_path.push_back(left);
+        left_set.insert(left);
+
+        int right = _blossom_set->find(_graph.v(edge));
+        right_path.push_back(right);
+        right_set.insert(right);
+
+        while (true) {
+
+          if ((*_blossom_data)[left].pred == INVALID) break;
+
+          left =
+            _blossom_set->find(_graph.target((*_blossom_data)[left].pred));
+          left_path.push_back(left);
+          left =
+            _blossom_set->find(_graph.target((*_blossom_data)[left].pred));
+          left_path.push_back(left);
+
+          left_set.insert(left);
+
+          if (right_set.find(left) != right_set.end()) {
+            nca = left;
+            break;
+          }
+
+          if ((*_blossom_data)[right].pred == INVALID) break;
+
+          right =
+            _blossom_set->find(_graph.target((*_blossom_data)[right].pred));
+          right_path.push_back(right);
+          right =
+            _blossom_set->find(_graph.target((*_blossom_data)[right].pred));
+          right_path.push_back(right);
+
+          right_set.insert(right);
+
+          if (left_set.find(right) != left_set.end()) {
+            nca = right;
+            break;
+          }
+
+        }
+
+        if (nca == -1) {
+          if ((*_blossom_data)[left].pred == INVALID) {
+            nca = right;
+            while (left_set.find(nca) == left_set.end()) {
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              right_path.push_back(nca);
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              right_path.push_back(nca);
+            }
+          } else {
+            nca = left;
+            while (right_set.find(nca) == right_set.end()) {
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              left_path.push_back(nca);
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              left_path.push_back(nca);
+            }
+          }
+        }
+      }
+
+      std::vector<int> subblossoms;
+      Arc prev;
+
+      prev = _graph.direct(edge, true);
+      for (int i = 0; left_path[i] != nca; i += 2) {
+        subblossoms.push_back(left_path[i]);
+        (*_blossom_data)[left_path[i]].next = prev;
+        _tree_set->erase(left_path[i]);
+
+        subblossoms.push_back(left_path[i + 1]);
+        (*_blossom_data)[left_path[i + 1]].status = EVEN;
+        oddToEven(left_path[i + 1], tree);
+        _tree_set->erase(left_path[i + 1]);
+        prev = _graph.oppositeArc((*_blossom_data)[left_path[i + 1]].pred);
+      }
+
+      int k = 0;
+      while (right_path[k] != nca) ++k;
+
+      subblossoms.push_back(nca);
+      (*_blossom_data)[nca].next = prev;
+
+      for (int i = k - 2; i >= 0; i -= 2) {
+        subblossoms.push_back(right_path[i + 1]);
+        (*_blossom_data)[right_path[i + 1]].status = EVEN;
+        oddToEven(right_path[i + 1], tree);
+        _tree_set->erase(right_path[i + 1]);
+
+        (*_blossom_data)[right_path[i + 1]].next =
+          (*_blossom_data)[right_path[i + 1]].pred;
+
+        subblossoms.push_back(right_path[i]);
+        _tree_set->erase(right_path[i]);
+      }
+
+      int surface =
+        _blossom_set->join(subblossoms.begin(), subblossoms.end());
+
+      for (int i = 0; i < int(subblossoms.size()); ++i) {
+        if (!_blossom_set->trivial(subblossoms[i])) {
+          (*_blossom_data)[subblossoms[i]].pot += 2 * _delta_sum;
+        }
+        (*_blossom_data)[subblossoms[i]].status = MATCHED;
+      }
+
+      (*_blossom_data)[surface].pot = -2 * _delta_sum;
+      (*_blossom_data)[surface].offset = 0;
+      (*_blossom_data)[surface].status = EVEN;
+      (*_blossom_data)[surface].pred = (*_blossom_data)[nca].pred;
+      (*_blossom_data)[surface].next = (*_blossom_data)[nca].pred;
+
+      _tree_set->insert(surface, tree);
+      _tree_set->erase(nca);
+    }
+
+    void splitBlossom(int blossom) {
+      Arc next = (*_blossom_data)[blossom].next;
+      Arc pred = (*_blossom_data)[blossom].pred;
+
+      int tree = _tree_set->find(blossom);
+
+      (*_blossom_data)[blossom].status = MATCHED;
+      oddToMatched(blossom);
+      if (_delta2->state(blossom) == _delta2->IN_HEAP) {
+        _delta2->erase(blossom);
+      }
+
+      std::vector<int> subblossoms;
+      _blossom_set->split(blossom, std::back_inserter(subblossoms));
+
+      Value offset = (*_blossom_data)[blossom].offset;
+      int b = _blossom_set->find(_graph.source(pred));
+      int d = _blossom_set->find(_graph.source(next));
+
+      int ib = -1, id = -1;
+      for (int i = 0; i < int(subblossoms.size()); ++i) {
+        if (subblossoms[i] == b) ib = i;
+        if (subblossoms[i] == d) id = i;
+
+        (*_blossom_data)[subblossoms[i]].offset = offset;
+        if (!_blossom_set->trivial(subblossoms[i])) {
+          (*_blossom_data)[subblossoms[i]].pot -= 2 * offset;
+        }
+        if (_blossom_set->classPrio(subblossoms[i]) !=
+            std::numeric_limits<Value>::max()) {
+          _delta2->push(subblossoms[i],
+                        _blossom_set->classPrio(subblossoms[i]) -
+                        (*_blossom_data)[subblossoms[i]].offset);
+        }
+      }
+
+      if (id > ib ? ((id - ib) % 2 == 0) : ((ib - id) % 2 == 1)) {
+        for (int i = (id + 1) % subblossoms.size();
+             i != ib; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          (*_blossom_data)[sb].next =
+            _graph.oppositeArc((*_blossom_data)[tb].next);
+        }
+
+        for (int i = ib; i != id; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          int ub = subblossoms[(i + 2) % subblossoms.size()];
+
+          (*_blossom_data)[sb].status = ODD;
+          matchedToOdd(sb);
+          _tree_set->insert(sb, tree);
+          (*_blossom_data)[sb].pred = pred;
+          (*_blossom_data)[sb].next =
+                           _graph.oppositeArc((*_blossom_data)[tb].next);
+
+          pred = (*_blossom_data)[ub].next;
+
+          (*_blossom_data)[tb].status = EVEN;
+          matchedToEven(tb, tree);
+          _tree_set->insert(tb, tree);
+          (*_blossom_data)[tb].pred = (*_blossom_data)[tb].next;
+        }
+
+        (*_blossom_data)[subblossoms[id]].status = ODD;
+        matchedToOdd(subblossoms[id]);
+        _tree_set->insert(subblossoms[id], tree);
+        (*_blossom_data)[subblossoms[id]].next = next;
+        (*_blossom_data)[subblossoms[id]].pred = pred;
+
+      } else {
+
+        for (int i = (ib + 1) % subblossoms.size();
+             i != id; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          (*_blossom_data)[sb].next =
+            _graph.oppositeArc((*_blossom_data)[tb].next);
+        }
+
+        for (int i = id; i != ib; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          int ub = subblossoms[(i + 2) % subblossoms.size()];
+
+          (*_blossom_data)[sb].status = ODD;
+          matchedToOdd(sb);
+          _tree_set->insert(sb, tree);
+          (*_blossom_data)[sb].next = next;
+          (*_blossom_data)[sb].pred =
+            _graph.oppositeArc((*_blossom_data)[tb].next);
+
+          (*_blossom_data)[tb].status = EVEN;
+          matchedToEven(tb, tree);
+          _tree_set->insert(tb, tree);
+          (*_blossom_data)[tb].pred =
+            (*_blossom_data)[tb].next =
+            _graph.oppositeArc((*_blossom_data)[ub].next);
+          next = (*_blossom_data)[ub].next;
+        }
+
+        (*_blossom_data)[subblossoms[ib]].status = ODD;
+        matchedToOdd(subblossoms[ib]);
+        _tree_set->insert(subblossoms[ib], tree);
+        (*_blossom_data)[subblossoms[ib]].next = next;
+        (*_blossom_data)[subblossoms[ib]].pred = pred;
+      }
+      _tree_set->erase(blossom);
+    }
+
+    void extractBlossom(int blossom, const Node& base, const Arc& matching) {
+      if (_blossom_set->trivial(blossom)) {
+        int bi = (*_node_index)[base];
+        Value pot = (*_node_data)[bi].pot;
+
+        _matching->set(base, matching);
+        _blossom_node_list.push_back(base);
+        _node_potential->set(base, pot);
+      } else {
+
+        Value pot = (*_blossom_data)[blossom].pot;
+        int bn = _blossom_node_list.size();
+
+        std::vector<int> subblossoms;
+        _blossom_set->split(blossom, std::back_inserter(subblossoms));
+        int b = _blossom_set->find(base);
+        int ib = -1;
+        for (int i = 0; i < int(subblossoms.size()); ++i) {
+          if (subblossoms[i] == b) { ib = i; break; }
+        }
+
+        for (int i = 1; i < int(subblossoms.size()); i += 2) {
+          int sb = subblossoms[(ib + i) % subblossoms.size()];
+          int tb = subblossoms[(ib + i + 1) % subblossoms.size()];
+
+          Arc m = (*_blossom_data)[tb].next;
+          extractBlossom(sb, _graph.target(m), _graph.oppositeArc(m));
+          extractBlossom(tb, _graph.source(m), m);
+        }
+        extractBlossom(subblossoms[ib], base, matching);
+
+        int en = _blossom_node_list.size();
+
+        _blossom_potential.push_back(BlossomVariable(bn, en, pot));
+      }
+    }
+
+    void extractMatching() {
+      std::vector<int> blossoms;
+      for (typename BlossomSet::ClassIt c(*_blossom_set); c != INVALID; ++c) {
+        blossoms.push_back(c);
+      }
+
+      for (int i = 0; i < int(blossoms.size()); ++i) {
+        if ((*_blossom_data)[blossoms[i]].status == MATCHED) {
+
+          Value offset = (*_blossom_data)[blossoms[i]].offset;
+          (*_blossom_data)[blossoms[i]].pot += 2 * offset;
+          for (typename BlossomSet::ItemIt n(*_blossom_set, blossoms[i]);
+               n != INVALID; ++n) {
+            (*_node_data)[(*_node_index)[n]].pot -= offset;
+          }
+
+          Arc matching = (*_blossom_data)[blossoms[i]].next;
+          Node base = _graph.source(matching);
+          extractBlossom(blossoms[i], base, matching);
+        } else {
+          Node base = (*_blossom_data)[blossoms[i]].base;
+          extractBlossom(blossoms[i], base, INVALID);
+        }
+      }
+    }
+
+  public:
+
+    /// \brief Constructor
+    ///
+    /// Constructor.
+    MaxWeightedMatching(const Graph& graph, const WeightMap& weight)
+      : _graph(graph), _weight(weight), _matching(0),
+        _node_potential(0), _blossom_potential(), _blossom_node_list(),
+        _node_num(0), _blossom_num(0),
+
+        _blossom_index(0), _blossom_set(0), _blossom_data(0),
+        _node_index(0), _node_heap_index(0), _node_data(0),
+        _tree_set_index(0), _tree_set(0),
+
+        _delta1_index(0), _delta1(0),
+        _delta2_index(0), _delta2(0),
+        _delta3_index(0), _delta3(0),
+        _delta4_index(0), _delta4(0),
+
+        _delta_sum() {}
+
+    ~MaxWeightedMatching() {
+      destroyStructures();
+    }
+
+    /// \name Execution control
+    /// The simplest way to execute the algorithm is to use the
+    /// \c run() member function.
+
+    ///@{
+
+    /// \brief Initialize the algorithm
+    ///
+    /// Initialize the algorithm
+    void init() {
+      createStructures();
+
+      for (ArcIt e(_graph); e != INVALID; ++e) {
+        _node_heap_index->set(e, BinHeap<Value, IntArcMap>::PRE_HEAP);
+      }
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        _delta1_index->set(n, _delta1->PRE_HEAP);
+      }
+      for (EdgeIt e(_graph); e != INVALID; ++e) {
+        _delta3_index->set(e, _delta3->PRE_HEAP);
+      }
+      for (int i = 0; i < _blossom_num; ++i) {
+        _delta2_index->set(i, _delta2->PRE_HEAP);
+        _delta4_index->set(i, _delta4->PRE_HEAP);
+      }
+
+      int index = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        Value max = 0;
+        for (OutArcIt e(_graph, n); e != INVALID; ++e) {
+          if (_graph.target(e) == n) continue;
+          if ((dualScale * _weight[e]) / 2 > max) {
+            max = (dualScale * _weight[e]) / 2;
+          }
+        }
+        _node_index->set(n, index);
+        (*_node_data)[index].pot = max;
+        _delta1->push(n, max);
+        int blossom =
+          _blossom_set->insert(n, std::numeric_limits<Value>::max());
+
+        _tree_set->insert(blossom);
+
+        (*_blossom_data)[blossom].status = EVEN;
+        (*_blossom_data)[blossom].pred = INVALID;
+        (*_blossom_data)[blossom].next = INVALID;
+        (*_blossom_data)[blossom].pot = 0;
+        (*_blossom_data)[blossom].offset = 0;
+        ++index;
+      }
+      for (EdgeIt e(_graph); e != INVALID; ++e) {
+        int si = (*_node_index)[_graph.u(e)];
+        int ti = (*_node_index)[_graph.v(e)];
+        if (_graph.u(e) != _graph.v(e)) {
+          _delta3->push(e, ((*_node_data)[si].pot + (*_node_data)[ti].pot -
+                            dualScale * _weight[e]) / 2);
+        }
+      }
+    }
+
+    /// \brief Starts the algorithm
+    ///
+    /// Starts the algorithm
+    void start() {
+      enum OpType {
+        D1, D2, D3, D4
+      };
+
+      int unmatched = _node_num;
+      while (unmatched > 0) {
+        Value d1 = !_delta1->empty() ?
+          _delta1->prio() : std::numeric_limits<Value>::max();
+
+        Value d2 = !_delta2->empty() ?
+          _delta2->prio() : std::numeric_limits<Value>::max();
+
+        Value d3 = !_delta3->empty() ?
+          _delta3->prio() : std::numeric_limits<Value>::max();
+
+        Value d4 = !_delta4->empty() ?
+          _delta4->prio() : std::numeric_limits<Value>::max();
+
+        _delta_sum = d1; OpType ot = D1;
+        if (d2 < _delta_sum) { _delta_sum = d2; ot = D2; }
+        if (d3 < _delta_sum) { _delta_sum = d3; ot = D3; }
+        if (d4 < _delta_sum) { _delta_sum = d4; ot = D4; }
+
+
+        switch (ot) {
+        case D1:
+          {
+            Node n = _delta1->top();
+            unmatchNode(n);
+            --unmatched;
+          }
+          break;
+        case D2:
+          {
+            int blossom = _delta2->top();
+            Node n = _blossom_set->classTop(blossom);
+            Arc e = (*_node_data)[(*_node_index)[n]].heap.top();
+            extendOnArc(e);
+          }
+          break;
+        case D3:
+          {
+            Edge e = _delta3->top();
+
+            int left_blossom = _blossom_set->find(_graph.u(e));
+            int right_blossom = _blossom_set->find(_graph.v(e));
+
+            if (left_blossom == right_blossom) {
+              _delta3->pop();
+            } else {
+              int left_tree;
+              if ((*_blossom_data)[left_blossom].status == EVEN) {
+                left_tree = _tree_set->find(left_blossom);
+              } else {
+                left_tree = -1;
+                ++unmatched;
+              }
+              int right_tree;
+              if ((*_blossom_data)[right_blossom].status == EVEN) {
+                right_tree = _tree_set->find(right_blossom);
+              } else {
+                right_tree = -1;
+                ++unmatched;
+              }
+
+              if (left_tree == right_tree) {
+                shrinkOnEdge(e, left_tree);
+              } else {
+                augmentOnEdge(e);
+                unmatched -= 2;
+              }
+            }
+          } break;
+        case D4:
+          splitBlossom(_delta4->top());
+          break;
+        }
+      }
+      extractMatching();
+    }
+
+    /// \brief Runs %MaxWeightedMatching algorithm.
+    ///
+    /// This method runs the %MaxWeightedMatching algorithm.
+    ///
+    /// \note mwm.run() is just a shortcut of the following code.
+    /// \code
+    ///   mwm.init();
+    ///   mwm.start();
+    /// \endcode
+    void run() {
+      init();
+      start();
+    }
+
+    /// @}
+
+    /// \name Primal solution
+    /// Functions to get the primal solution, ie. the matching.
+
+    /// @{
+
+    /// \brief Returns the weight of the matching.
+    ///
+    /// Returns the weight of the matching.
+    Value matchingValue() const {
+      Value sum = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        if ((*_matching)[n] != INVALID) {
+          sum += _weight[(*_matching)[n]];
+        }
+      }
+      return sum /= 2;
+    }
+
+    /// \brief Returns the cardinality of the matching.
+    ///
+    /// Returns the cardinality of the matching.
+    int matchingSize() const {
+      int num = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        if ((*_matching)[n] != INVALID) {
+          ++num;
+        }
+      }
+      return num /= 2;
+    }
+
+    /// \brief Returns true when the edge is in the matching.
+    ///
+    /// Returns true when the edge is in the matching.
+    bool matching(const Edge& edge) const {
+      return edge == (*_matching)[_graph.u(edge)];
+    }
+
+    /// \brief Returns the incident matching arc.
+    ///
+    /// Returns the incident matching arc from given node. If the
+    /// node is not matched then it gives back \c INVALID.
+    Arc matching(const Node& node) const {
+      return (*_matching)[node];
+    }
+
+    /// \brief Returns the mate of the node.
+    ///
+    /// Returns the adjancent node in a mathcing arc. If the node is
+    /// not matched then it gives back \c INVALID.
+    Node mate(const Node& node) const {
+      return (*_matching)[node] != INVALID ?
+        _graph.target((*_matching)[node]) : INVALID;
+    }
+
+    /// @}
+
+    /// \name Dual solution
+    /// Functions to get the dual solution.
+
+    /// @{
+
+    /// \brief Returns the value of the dual solution.
+    ///
+    /// Returns the value of the dual solution. It should be equal to
+    /// the primal value scaled by \ref dualScale "dual scale".
+    Value dualValue() const {
+      Value sum = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        sum += nodeValue(n);
+      }
+      for (int i = 0; i < blossomNum(); ++i) {
+        sum += blossomValue(i) * (blossomSize(i) / 2);
+      }
+      return sum;
+    }
+
+    /// \brief Returns the value of the node.
+    ///
+    /// Returns the the value of the node.
+    Value nodeValue(const Node& n) const {
+      return (*_node_potential)[n];
+    }
+
+    /// \brief Returns the number of the blossoms in the basis.
+    ///
+    /// Returns the number of the blossoms in the basis.
+    /// \see BlossomIt
+    int blossomNum() const {
+      return _blossom_potential.size();
+    }
+
+
+    /// \brief Returns the number of the nodes in the blossom.
+    ///
+    /// Returns the number of the nodes in the blossom.
+    int blossomSize(int k) const {
+      return _blossom_potential[k].end - _blossom_potential[k].begin;
+    }
+
+    /// \brief Returns the value of the blossom.
+    ///
+    /// Returns the the value of the blossom.
+    /// \see BlossomIt
+    Value blossomValue(int k) const {
+      return _blossom_potential[k].value;
+    }
+
+    /// \brief Iterator for obtaining the nodes of the blossom.
+    ///
+    /// Iterator for obtaining the nodes of the blossom. This class
+    /// provides a common lemon style iterator for listing a
+    /// subset of the nodes.
+    class BlossomIt {
+    public:
+
+      /// \brief Constructor.
+      ///
+      /// Constructor to get the nodes of the variable.
+      BlossomIt(const MaxWeightedMatching& algorithm, int variable)
+        : _algorithm(&algorithm)
+      {
+        _index = _algorithm->_blossom_potential[variable].begin;
+        _last = _algorithm->_blossom_potential[variable].end;
+      }
+
+      /// \brief Conversion to node.
+      ///
+      /// Conversion to node.
+      operator Node() const {
+        return _algorithm->_blossom_node_list[_index];
+      }
+
+      /// \brief Increment operator.
+      ///
+      /// Increment operator.
+      BlossomIt& operator++() {
+        ++_index;
+        return *this;
+      }
+
+      /// \brief Validity checking
+      ///
+      /// Checks whether the iterator is invalid.
+      bool operator==(Invalid) const { return _index == _last; }
+
+      /// \brief Validity checking
+      ///
+      /// Checks whether the iterator is valid.
+      bool operator!=(Invalid) const { return _index != _last; }
+
+    private:
+      const MaxWeightedMatching* _algorithm;
+      int _last;
+      int _index;
+    };
+
+    /// @}
+
+  };
+
+  /// \ingroup matching
+  ///
+  /// \brief Weighted perfect matching in general graphs
+  ///
+  /// This class provides an efficient implementation of Edmond's
+  /// maximum weighted perfect matching algorithm. The implementation
+  /// is based on extensive use of priority queues and provides
+  /// \f$O(nm\log(n))\f$ time complexity.
+  ///
+  /// The maximum weighted matching problem is to find undirected
+  /// edges in the graph with maximum overall weight and no two of
+  /// them shares their ends and covers all nodes. The problem can be
+  /// formulated with the following linear program.
+  /// \f[ \sum_{e \in \delta(u)}x_e = 1 \quad \forall u\in V\f]
+  /** \f[ \sum_{e \in \gamma(B)}x_e \le \frac{\vert B \vert - 1}{2}
+      \quad \forall B\in\mathcal{O}\f] */
+  /// \f[x_e \ge 0\quad \forall e\in E\f]
+  /// \f[\max \sum_{e\in E}x_ew_e\f]
+  /// where \f$\delta(X)\f$ is the set of edges incident to a node in
+  /// \f$X\f$, \f$\gamma(X)\f$ is the set of edges with both ends in
+  /// \f$X\f$ and \f$\mathcal{O}\f$ is the set of odd cardinality
+  /// subsets of the nodes.
+  ///
+  /// The algorithm calculates an optimal matching and a proof of the
+  /// optimality. The solution of the dual problem can be used to check
+  /// the result of the algorithm. The dual linear problem is the
+  /** \f[ y_u + y_v + \sum_{B \in \mathcal{O}, uv \in \gamma(B)}z_B \ge
+      w_{uv} \quad \forall uv\in E\f] */
+  /// \f[z_B \ge 0 \quad \forall B \in \mathcal{O}\f]
+  /** \f[\min \sum_{u \in V}y_u + \sum_{B \in \mathcal{O}}
+      \frac{\vert B \vert - 1}{2}z_B\f] */
+  ///
+  /// The algorithm can be executed with \c run() or the \c init() and
+  /// then the \c start() member functions. After it the matching can
+  /// be asked with \c matching() or mate() functions. The dual
+  /// solution can be get with \c nodeValue(), \c blossomNum() and \c
+  /// blossomValue() members and \ref MaxWeightedMatching::BlossomIt
+  /// "BlossomIt" nested class which is able to iterate on the nodes
+  /// of a blossom. If the value type is integral then the dual
+  /// solution is multiplied by \ref MaxWeightedMatching::dualScale "4".
+  template <typename _Graph,
+            typename _WeightMap = typename _Graph::template EdgeMap<int> >
+  class MaxWeightedPerfectMatching {
+  public:
+
+    typedef _Graph Graph;
+    typedef _WeightMap WeightMap;
+    typedef typename WeightMap::Value Value;
+
+    /// \brief Scaling factor for dual solution
+    ///
+    /// Scaling factor for dual solution, it is equal to 4 or 1
+    /// according to the value type.
+    static const int dualScale =
+      std::numeric_limits<Value>::is_integer ? 4 : 1;
+
+    typedef typename Graph::template NodeMap<typename Graph::Arc>
+    MatchingMap;
+
+  private:
+
+    TEMPLATE_GRAPH_TYPEDEFS(Graph);
+
+    typedef typename Graph::template NodeMap<Value> NodePotential;
+    typedef std::vector<Node> BlossomNodeList;
+
+    struct BlossomVariable {
+      int begin, end;
+      Value value;
+
+      BlossomVariable(int _begin, int _end, Value _value)
+        : begin(_begin), end(_end), value(_value) {}
+
+    };
+
+    typedef std::vector<BlossomVariable> BlossomPotential;
+
+    const Graph& _graph;
+    const WeightMap& _weight;
+
+    MatchingMap* _matching;
+
+    NodePotential* _node_potential;
+
+    BlossomPotential _blossom_potential;
+    BlossomNodeList _blossom_node_list;
+
+    int _node_num;
+    int _blossom_num;
+
+    typedef RangeMap<int> IntIntMap;
+
+    enum Status {
+      EVEN = -1, MATCHED = 0, ODD = 1
+    };
+
+    typedef HeapUnionFind<Value, IntNodeMap> BlossomSet;
+    struct BlossomData {
+      int tree;
+      Status status;
+      Arc pred, next;
+      Value pot, offset;
+    };
+
+    IntNodeMap *_blossom_index;
+    BlossomSet *_blossom_set;
+    RangeMap<BlossomData>* _blossom_data;
+
+    IntNodeMap *_node_index;
+    IntArcMap *_node_heap_index;
+
+    struct NodeData {
+
+      NodeData(IntArcMap& node_heap_index)
+        : heap(node_heap_index) {}
+
+      int blossom;
+      Value pot;
+      BinHeap<Value, IntArcMap> heap;
+      std::map<int, Arc> heap_index;
+
+      int tree;
+    };
+
+    RangeMap<NodeData>* _node_data;
+
+    typedef ExtendFindEnum<IntIntMap> TreeSet;
+
+    IntIntMap *_tree_set_index;
+    TreeSet *_tree_set;
+
+    IntIntMap *_delta2_index;
+    BinHeap<Value, IntIntMap> *_delta2;
+
+    IntEdgeMap *_delta3_index;
+    BinHeap<Value, IntEdgeMap> *_delta3;
+
+    IntIntMap *_delta4_index;
+    BinHeap<Value, IntIntMap> *_delta4;
+
+    Value _delta_sum;
+
+    void createStructures() {
+      _node_num = countNodes(_graph);
+      _blossom_num = _node_num * 3 / 2;
+
+      if (!_matching) {
+        _matching = new MatchingMap(_graph);
+      }
+      if (!_node_potential) {
+        _node_potential = new NodePotential(_graph);
+      }
+      if (!_blossom_set) {
+        _blossom_index = new IntNodeMap(_graph);
+        _blossom_set = new BlossomSet(*_blossom_index);
+        _blossom_data = new RangeMap<BlossomData>(_blossom_num);
+      }
+
+      if (!_node_index) {
+        _node_index = new IntNodeMap(_graph);
+        _node_heap_index = new IntArcMap(_graph);
+        _node_data = new RangeMap<NodeData>(_node_num,
+                                            NodeData(*_node_heap_index));
+      }
+
+      if (!_tree_set) {
+        _tree_set_index = new IntIntMap(_blossom_num);
+        _tree_set = new TreeSet(*_tree_set_index);
+      }
+      if (!_delta2) {
+        _delta2_index = new IntIntMap(_blossom_num);
+        _delta2 = new BinHeap<Value, IntIntMap>(*_delta2_index);
+      }
+      if (!_delta3) {
+        _delta3_index = new IntEdgeMap(_graph);
+        _delta3 = new BinHeap<Value, IntEdgeMap>(*_delta3_index);
+      }
+      if (!_delta4) {
+        _delta4_index = new IntIntMap(_blossom_num);
+        _delta4 = new BinHeap<Value, IntIntMap>(*_delta4_index);
+      }
+    }
+
+    void destroyStructures() {
+      _node_num = countNodes(_graph);
+      _blossom_num = _node_num * 3 / 2;
+
+      if (_matching) {
+        delete _matching;
+      }
+      if (_node_potential) {
+        delete _node_potential;
+      }
+      if (_blossom_set) {
+        delete _blossom_index;
+        delete _blossom_set;
+        delete _blossom_data;
+      }
+
+      if (_node_index) {
+        delete _node_index;
+        delete _node_heap_index;
+        delete _node_data;
+      }
+
+      if (_tree_set) {
+        delete _tree_set_index;
+        delete _tree_set;
+      }
+      if (_delta2) {
+        delete _delta2_index;
+        delete _delta2;
+      }
+      if (_delta3) {
+        delete _delta3_index;
+        delete _delta3;
+      }
+      if (_delta4) {
+        delete _delta4_index;
+        delete _delta4;
+      }
+    }
+
+    void matchedToEven(int blossom, int tree) {
+      if (_delta2->state(blossom) == _delta2->IN_HEAP) {
+        _delta2->erase(blossom);
+      }
+
+      if (!_blossom_set->trivial(blossom)) {
+        (*_blossom_data)[blossom].pot -=
+          2 * (_delta_sum - (*_blossom_data)[blossom].offset);
+      }
+
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+
+        _blossom_set->increase(n, std::numeric_limits<Value>::max());
+        int ni = (*_node_index)[n];
+
+        (*_node_data)[ni].heap.clear();
+        (*_node_data)[ni].heap_index.clear();
+
+        (*_node_data)[ni].pot += _delta_sum - (*_blossom_data)[blossom].offset;
+
+        for (InArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.source(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if ((*_blossom_data)[vb].status == EVEN) {
+            if (_delta3->state(e) != _delta3->IN_HEAP && blossom != vb) {
+              _delta3->push(e, rw / 2);
+            }
+          } else {
+            typename std::map<int, Arc>::iterator it =
+              (*_node_data)[vi].heap_index.find(tree);
+
+            if (it != (*_node_data)[vi].heap_index.end()) {
+              if ((*_node_data)[vi].heap[it->second] > rw) {
+                (*_node_data)[vi].heap.replace(it->second, e);
+                (*_node_data)[vi].heap.decrease(e, rw);
+                it->second = e;
+              }
+            } else {
+              (*_node_data)[vi].heap.push(e, rw);
+              (*_node_data)[vi].heap_index.insert(std::make_pair(tree, e));
+            }
+
+            if ((*_blossom_set)[v] > (*_node_data)[vi].heap.prio()) {
+              _blossom_set->decrease(v, (*_node_data)[vi].heap.prio());
+
+              if ((*_blossom_data)[vb].status == MATCHED) {
+                if (_delta2->state(vb) != _delta2->IN_HEAP) {
+                  _delta2->push(vb, _blossom_set->classPrio(vb) -
+                               (*_blossom_data)[vb].offset);
+                } else if ((*_delta2)[vb] > _blossom_set->classPrio(vb) -
+                           (*_blossom_data)[vb].offset){
+                  _delta2->decrease(vb, _blossom_set->classPrio(vb) -
+                                   (*_blossom_data)[vb].offset);
+                }
+              }
+            }
+          }
+        }
+      }
+      (*_blossom_data)[blossom].offset = 0;
+    }
+
+    void matchedToOdd(int blossom) {
+      if (_delta2->state(blossom) == _delta2->IN_HEAP) {
+        _delta2->erase(blossom);
+      }
+      (*_blossom_data)[blossom].offset += _delta_sum;
+      if (!_blossom_set->trivial(blossom)) {
+        _delta4->push(blossom, (*_blossom_data)[blossom].pot / 2 +
+                     (*_blossom_data)[blossom].offset);
+      }
+    }
+
+    void evenToMatched(int blossom, int tree) {
+      if (!_blossom_set->trivial(blossom)) {
+        (*_blossom_data)[blossom].pot += 2 * _delta_sum;
+      }
+
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+        int ni = (*_node_index)[n];
+        (*_node_data)[ni].pot -= _delta_sum;
+
+        for (InArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.source(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if (vb == blossom) {
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+          } else if ((*_blossom_data)[vb].status == EVEN) {
+
+            if (_delta3->state(e) == _delta3->IN_HEAP) {
+              _delta3->erase(e);
+            }
+
+            int vt = _tree_set->find(vb);
+
+            if (vt != tree) {
+
+              Arc r = _graph.oppositeArc(e);
+
+              typename std::map<int, Arc>::iterator it =
+                (*_node_data)[ni].heap_index.find(vt);
+
+              if (it != (*_node_data)[ni].heap_index.end()) {
+                if ((*_node_data)[ni].heap[it->second] > rw) {
+                  (*_node_data)[ni].heap.replace(it->second, r);
+                  (*_node_data)[ni].heap.decrease(r, rw);
+                  it->second = r;
+                }
+              } else {
+                (*_node_data)[ni].heap.push(r, rw);
+                (*_node_data)[ni].heap_index.insert(std::make_pair(vt, r));
+              }
+
+              if ((*_blossom_set)[n] > (*_node_data)[ni].heap.prio()) {
+                _blossom_set->decrease(n, (*_node_data)[ni].heap.prio());
+
+                if (_delta2->state(blossom) != _delta2->IN_HEAP) {
+                  _delta2->push(blossom, _blossom_set->classPrio(blossom) -
+                               (*_blossom_data)[blossom].offset);
+                } else if ((*_delta2)[blossom] >
+                           _blossom_set->classPrio(blossom) -
+                           (*_blossom_data)[blossom].offset){
+                  _delta2->decrease(blossom, _blossom_set->classPrio(blossom) -
+                                   (*_blossom_data)[blossom].offset);
+                }
+              }
+            }
+          } else {
+
+            typename std::map<int, Arc>::iterator it =
+              (*_node_data)[vi].heap_index.find(tree);
+
+            if (it != (*_node_data)[vi].heap_index.end()) {
+              (*_node_data)[vi].heap.erase(it->second);
+              (*_node_data)[vi].heap_index.erase(it);
+              if ((*_node_data)[vi].heap.empty()) {
+                _blossom_set->increase(v, std::numeric_limits<Value>::max());
+              } else if ((*_blossom_set)[v] < (*_node_data)[vi].heap.prio()) {
+                _blossom_set->increase(v, (*_node_data)[vi].heap.prio());
+              }
+
+              if ((*_blossom_data)[vb].status == MATCHED) {
+                if (_blossom_set->classPrio(vb) ==
+                    std::numeric_limits<Value>::max()) {
+                  _delta2->erase(vb);
+                } else if ((*_delta2)[vb] < _blossom_set->classPrio(vb) -
+                           (*_blossom_data)[vb].offset) {
+                  _delta2->increase(vb, _blossom_set->classPrio(vb) -
+                                   (*_blossom_data)[vb].offset);
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+
+    void oddToMatched(int blossom) {
+      (*_blossom_data)[blossom].offset -= _delta_sum;
+
+      if (_blossom_set->classPrio(blossom) !=
+          std::numeric_limits<Value>::max()) {
+        _delta2->push(blossom, _blossom_set->classPrio(blossom) -
+                       (*_blossom_data)[blossom].offset);
+      }
+
+      if (!_blossom_set->trivial(blossom)) {
+        _delta4->erase(blossom);
+      }
+    }
+
+    void oddToEven(int blossom, int tree) {
+      if (!_blossom_set->trivial(blossom)) {
+        _delta4->erase(blossom);
+        (*_blossom_data)[blossom].pot -=
+          2 * (2 * _delta_sum - (*_blossom_data)[blossom].offset);
+      }
+
+      for (typename BlossomSet::ItemIt n(*_blossom_set, blossom);
+           n != INVALID; ++n) {
+        int ni = (*_node_index)[n];
+
+        _blossom_set->increase(n, std::numeric_limits<Value>::max());
+
+        (*_node_data)[ni].heap.clear();
+        (*_node_data)[ni].heap_index.clear();
+        (*_node_data)[ni].pot +=
+          2 * _delta_sum - (*_blossom_data)[blossom].offset;
+
+        for (InArcIt e(_graph, n); e != INVALID; ++e) {
+          Node v = _graph.source(e);
+          int vb = _blossom_set->find(v);
+          int vi = (*_node_index)[v];
+
+          Value rw = (*_node_data)[ni].pot + (*_node_data)[vi].pot -
+            dualScale * _weight[e];
+
+          if ((*_blossom_data)[vb].status == EVEN) {
+            if (_delta3->state(e) != _delta3->IN_HEAP && blossom != vb) {
+              _delta3->push(e, rw / 2);
+            }
+          } else {
+
+            typename std::map<int, Arc>::iterator it =
+              (*_node_data)[vi].heap_index.find(tree);
+
+            if (it != (*_node_data)[vi].heap_index.end()) {
+              if ((*_node_data)[vi].heap[it->second] > rw) {
+                (*_node_data)[vi].heap.replace(it->second, e);
+                (*_node_data)[vi].heap.decrease(e, rw);
+                it->second = e;
+              }
+            } else {
+              (*_node_data)[vi].heap.push(e, rw);
+              (*_node_data)[vi].heap_index.insert(std::make_pair(tree, e));
+            }
+
+            if ((*_blossom_set)[v] > (*_node_data)[vi].heap.prio()) {
+              _blossom_set->decrease(v, (*_node_data)[vi].heap.prio());
+
+              if ((*_blossom_data)[vb].status == MATCHED) {
+                if (_delta2->state(vb) != _delta2->IN_HEAP) {
+                  _delta2->push(vb, _blossom_set->classPrio(vb) -
+                               (*_blossom_data)[vb].offset);
+                } else if ((*_delta2)[vb] > _blossom_set->classPrio(vb) -
+                           (*_blossom_data)[vb].offset) {
+                  _delta2->decrease(vb, _blossom_set->classPrio(vb) -
+                                   (*_blossom_data)[vb].offset);
+                }
+              }
+            }
+          }
+        }
+      }
+      (*_blossom_data)[blossom].offset = 0;
+    }
+
+    void alternatePath(int even, int tree) {
+      int odd;
+
+      evenToMatched(even, tree);
+      (*_blossom_data)[even].status = MATCHED;
+
+      while ((*_blossom_data)[even].pred != INVALID) {
+        odd = _blossom_set->find(_graph.target((*_blossom_data)[even].pred));
+        (*_blossom_data)[odd].status = MATCHED;
+        oddToMatched(odd);
+        (*_blossom_data)[odd].next = (*_blossom_data)[odd].pred;
+
+        even = _blossom_set->find(_graph.target((*_blossom_data)[odd].pred));
+        (*_blossom_data)[even].status = MATCHED;
+        evenToMatched(even, tree);
+        (*_blossom_data)[even].next =
+          _graph.oppositeArc((*_blossom_data)[odd].pred);
+      }
+
+    }
+
+    void destroyTree(int tree) {
+      for (TreeSet::ItemIt b(*_tree_set, tree); b != INVALID; ++b) {
+        if ((*_blossom_data)[b].status == EVEN) {
+          (*_blossom_data)[b].status = MATCHED;
+          evenToMatched(b, tree);
+        } else if ((*_blossom_data)[b].status == ODD) {
+          (*_blossom_data)[b].status = MATCHED;
+          oddToMatched(b);
+        }
+      }
+      _tree_set->eraseClass(tree);
+    }
+
+    void augmentOnEdge(const Edge& edge) {
+
+      int left = _blossom_set->find(_graph.u(edge));
+      int right = _blossom_set->find(_graph.v(edge));
+
+      int left_tree = _tree_set->find(left);
+      alternatePath(left, left_tree);
+      destroyTree(left_tree);
+
+      int right_tree = _tree_set->find(right);
+      alternatePath(right, right_tree);
+      destroyTree(right_tree);
+
+      (*_blossom_data)[left].next = _graph.direct(edge, true);
+      (*_blossom_data)[right].next = _graph.direct(edge, false);
+    }
+
+    void extendOnArc(const Arc& arc) {
+      int base = _blossom_set->find(_graph.target(arc));
+      int tree = _tree_set->find(base);
+
+      int odd = _blossom_set->find(_graph.source(arc));
+      _tree_set->insert(odd, tree);
+      (*_blossom_data)[odd].status = ODD;
+      matchedToOdd(odd);
+      (*_blossom_data)[odd].pred = arc;
+
+      int even = _blossom_set->find(_graph.target((*_blossom_data)[odd].next));
+      (*_blossom_data)[even].pred = (*_blossom_data)[even].next;
+      _tree_set->insert(even, tree);
+      (*_blossom_data)[even].status = EVEN;
+      matchedToEven(even, tree);
+    }
+
+    void shrinkOnEdge(const Edge& edge, int tree) {
+      int nca = -1;
+      std::vector<int> left_path, right_path;
+
+      {
+        std::set<int> left_set, right_set;
+        int left = _blossom_set->find(_graph.u(edge));
+        left_path.push_back(left);
+        left_set.insert(left);
+
+        int right = _blossom_set->find(_graph.v(edge));
+        right_path.push_back(right);
+        right_set.insert(right);
+
+        while (true) {
+
+          if ((*_blossom_data)[left].pred == INVALID) break;
+
+          left =
+            _blossom_set->find(_graph.target((*_blossom_data)[left].pred));
+          left_path.push_back(left);
+          left =
+            _blossom_set->find(_graph.target((*_blossom_data)[left].pred));
+          left_path.push_back(left);
+
+          left_set.insert(left);
+
+          if (right_set.find(left) != right_set.end()) {
+            nca = left;
+            break;
+          }
+
+          if ((*_blossom_data)[right].pred == INVALID) break;
+
+          right =
+            _blossom_set->find(_graph.target((*_blossom_data)[right].pred));
+          right_path.push_back(right);
+          right =
+            _blossom_set->find(_graph.target((*_blossom_data)[right].pred));
+          right_path.push_back(right);
+
+          right_set.insert(right);
+
+          if (left_set.find(right) != left_set.end()) {
+            nca = right;
+            break;
+          }
+
+        }
+
+        if (nca == -1) {
+          if ((*_blossom_data)[left].pred == INVALID) {
+            nca = right;
+            while (left_set.find(nca) == left_set.end()) {
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              right_path.push_back(nca);
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              right_path.push_back(nca);
+            }
+          } else {
+            nca = left;
+            while (right_set.find(nca) == right_set.end()) {
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              left_path.push_back(nca);
+              nca =
+                _blossom_set->find(_graph.target((*_blossom_data)[nca].pred));
+              left_path.push_back(nca);
+            }
+          }
+        }
+      }
+
+      std::vector<int> subblossoms;
+      Arc prev;
+
+      prev = _graph.direct(edge, true);
+      for (int i = 0; left_path[i] != nca; i += 2) {
+        subblossoms.push_back(left_path[i]);
+        (*_blossom_data)[left_path[i]].next = prev;
+        _tree_set->erase(left_path[i]);
+
+        subblossoms.push_back(left_path[i + 1]);
+        (*_blossom_data)[left_path[i + 1]].status = EVEN;
+        oddToEven(left_path[i + 1], tree);
+        _tree_set->erase(left_path[i + 1]);
+        prev = _graph.oppositeArc((*_blossom_data)[left_path[i + 1]].pred);
+      }
+
+      int k = 0;
+      while (right_path[k] != nca) ++k;
+
+      subblossoms.push_back(nca);
+      (*_blossom_data)[nca].next = prev;
+
+      for (int i = k - 2; i >= 0; i -= 2) {
+        subblossoms.push_back(right_path[i + 1]);
+        (*_blossom_data)[right_path[i + 1]].status = EVEN;
+        oddToEven(right_path[i + 1], tree);
+        _tree_set->erase(right_path[i + 1]);
+
+        (*_blossom_data)[right_path[i + 1]].next =
+          (*_blossom_data)[right_path[i + 1]].pred;
+
+        subblossoms.push_back(right_path[i]);
+        _tree_set->erase(right_path[i]);
+      }
+
+      int surface =
+        _blossom_set->join(subblossoms.begin(), subblossoms.end());
+
+      for (int i = 0; i < int(subblossoms.size()); ++i) {
+        if (!_blossom_set->trivial(subblossoms[i])) {
+          (*_blossom_data)[subblossoms[i]].pot += 2 * _delta_sum;
+        }
+        (*_blossom_data)[subblossoms[i]].status = MATCHED;
+      }
+
+      (*_blossom_data)[surface].pot = -2 * _delta_sum;
+      (*_blossom_data)[surface].offset = 0;
+      (*_blossom_data)[surface].status = EVEN;
+      (*_blossom_data)[surface].pred = (*_blossom_data)[nca].pred;
+      (*_blossom_data)[surface].next = (*_blossom_data)[nca].pred;
+
+      _tree_set->insert(surface, tree);
+      _tree_set->erase(nca);
+    }
+
+    void splitBlossom(int blossom) {
+      Arc next = (*_blossom_data)[blossom].next;
+      Arc pred = (*_blossom_data)[blossom].pred;
+
+      int tree = _tree_set->find(blossom);
+
+      (*_blossom_data)[blossom].status = MATCHED;
+      oddToMatched(blossom);
+      if (_delta2->state(blossom) == _delta2->IN_HEAP) {
+        _delta2->erase(blossom);
+      }
+
+      std::vector<int> subblossoms;
+      _blossom_set->split(blossom, std::back_inserter(subblossoms));
+
+      Value offset = (*_blossom_data)[blossom].offset;
+      int b = _blossom_set->find(_graph.source(pred));
+      int d = _blossom_set->find(_graph.source(next));
+
+      int ib = -1, id = -1;
+      for (int i = 0; i < int(subblossoms.size()); ++i) {
+        if (subblossoms[i] == b) ib = i;
+        if (subblossoms[i] == d) id = i;
+
+        (*_blossom_data)[subblossoms[i]].offset = offset;
+        if (!_blossom_set->trivial(subblossoms[i])) {
+          (*_blossom_data)[subblossoms[i]].pot -= 2 * offset;
+        }
+        if (_blossom_set->classPrio(subblossoms[i]) !=
+            std::numeric_limits<Value>::max()) {
+          _delta2->push(subblossoms[i],
+                        _blossom_set->classPrio(subblossoms[i]) -
+                        (*_blossom_data)[subblossoms[i]].offset);
+        }
+      }
+
+      if (id > ib ? ((id - ib) % 2 == 0) : ((ib - id) % 2 == 1)) {
+        for (int i = (id + 1) % subblossoms.size();
+             i != ib; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          (*_blossom_data)[sb].next =
+            _graph.oppositeArc((*_blossom_data)[tb].next);
+        }
+
+        for (int i = ib; i != id; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          int ub = subblossoms[(i + 2) % subblossoms.size()];
+
+          (*_blossom_data)[sb].status = ODD;
+          matchedToOdd(sb);
+          _tree_set->insert(sb, tree);
+          (*_blossom_data)[sb].pred = pred;
+          (*_blossom_data)[sb].next =
+                           _graph.oppositeArc((*_blossom_data)[tb].next);
+
+          pred = (*_blossom_data)[ub].next;
+
+          (*_blossom_data)[tb].status = EVEN;
+          matchedToEven(tb, tree);
+          _tree_set->insert(tb, tree);
+          (*_blossom_data)[tb].pred = (*_blossom_data)[tb].next;
+        }
+
+        (*_blossom_data)[subblossoms[id]].status = ODD;
+        matchedToOdd(subblossoms[id]);
+        _tree_set->insert(subblossoms[id], tree);
+        (*_blossom_data)[subblossoms[id]].next = next;
+        (*_blossom_data)[subblossoms[id]].pred = pred;
+
+      } else {
+
+        for (int i = (ib + 1) % subblossoms.size();
+             i != id; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          (*_blossom_data)[sb].next =
+            _graph.oppositeArc((*_blossom_data)[tb].next);
+        }
+
+        for (int i = id; i != ib; i = (i + 2) % subblossoms.size()) {
+          int sb = subblossoms[i];
+          int tb = subblossoms[(i + 1) % subblossoms.size()];
+          int ub = subblossoms[(i + 2) % subblossoms.size()];
+
+          (*_blossom_data)[sb].status = ODD;
+          matchedToOdd(sb);
+          _tree_set->insert(sb, tree);
+          (*_blossom_data)[sb].next = next;
+          (*_blossom_data)[sb].pred =
+            _graph.oppositeArc((*_blossom_data)[tb].next);
+
+          (*_blossom_data)[tb].status = EVEN;
+          matchedToEven(tb, tree);
+          _tree_set->insert(tb, tree);
+          (*_blossom_data)[tb].pred =
+            (*_blossom_data)[tb].next =
+            _graph.oppositeArc((*_blossom_data)[ub].next);
+          next = (*_blossom_data)[ub].next;
+        }
+
+        (*_blossom_data)[subblossoms[ib]].status = ODD;
+        matchedToOdd(subblossoms[ib]);
+        _tree_set->insert(subblossoms[ib], tree);
+        (*_blossom_data)[subblossoms[ib]].next = next;
+        (*_blossom_data)[subblossoms[ib]].pred = pred;
+      }
+      _tree_set->erase(blossom);
+    }
+
+    void extractBlossom(int blossom, const Node& base, const Arc& matching) {
+      if (_blossom_set->trivial(blossom)) {
+        int bi = (*_node_index)[base];
+        Value pot = (*_node_data)[bi].pot;
+
+        _matching->set(base, matching);
+        _blossom_node_list.push_back(base);
+        _node_potential->set(base, pot);
+      } else {
+
+        Value pot = (*_blossom_data)[blossom].pot;
+        int bn = _blossom_node_list.size();
+
+        std::vector<int> subblossoms;
+        _blossom_set->split(blossom, std::back_inserter(subblossoms));
+        int b = _blossom_set->find(base);
+        int ib = -1;
+        for (int i = 0; i < int(subblossoms.size()); ++i) {
+          if (subblossoms[i] == b) { ib = i; break; }
+        }
+
+        for (int i = 1; i < int(subblossoms.size()); i += 2) {
+          int sb = subblossoms[(ib + i) % subblossoms.size()];
+          int tb = subblossoms[(ib + i + 1) % subblossoms.size()];
+
+          Arc m = (*_blossom_data)[tb].next;
+          extractBlossom(sb, _graph.target(m), _graph.oppositeArc(m));
+          extractBlossom(tb, _graph.source(m), m);
+        }
+        extractBlossom(subblossoms[ib], base, matching);
+
+        int en = _blossom_node_list.size();
+
+        _blossom_potential.push_back(BlossomVariable(bn, en, pot));
+      }
+    }
+
+    void extractMatching() {
+      std::vector<int> blossoms;
+      for (typename BlossomSet::ClassIt c(*_blossom_set); c != INVALID; ++c) {
+        blossoms.push_back(c);
+      }
+
+      for (int i = 0; i < int(blossoms.size()); ++i) {
+
+        Value offset = (*_blossom_data)[blossoms[i]].offset;
+        (*_blossom_data)[blossoms[i]].pot += 2 * offset;
+        for (typename BlossomSet::ItemIt n(*_blossom_set, blossoms[i]);
+             n != INVALID; ++n) {
+          (*_node_data)[(*_node_index)[n]].pot -= offset;
+        }
+
+        Arc matching = (*_blossom_data)[blossoms[i]].next;
+        Node base = _graph.source(matching);
+        extractBlossom(blossoms[i], base, matching);
+      }
+    }
+
+  public:
+
+    /// \brief Constructor
+    ///
+    /// Constructor.
+    MaxWeightedPerfectMatching(const Graph& graph, const WeightMap& weight)
+      : _graph(graph), _weight(weight), _matching(0),
+        _node_potential(0), _blossom_potential(), _blossom_node_list(),
+        _node_num(0), _blossom_num(0),
+
+        _blossom_index(0), _blossom_set(0), _blossom_data(0),
+        _node_index(0), _node_heap_index(0), _node_data(0),
+        _tree_set_index(0), _tree_set(0),
+
+        _delta2_index(0), _delta2(0),
+        _delta3_index(0), _delta3(0),
+        _delta4_index(0), _delta4(0),
+
+        _delta_sum() {}
+
+    ~MaxWeightedPerfectMatching() {
+      destroyStructures();
+    }
+
+    /// \name Execution control
+    /// The simplest way to execute the algorithm is to use the
+    /// \c run() member function.
+
+    ///@{
+
+    /// \brief Initialize the algorithm
+    ///
+    /// Initialize the algorithm
+    void init() {
+      createStructures();
+
+      for (ArcIt e(_graph); e != INVALID; ++e) {
+        _node_heap_index->set(e, BinHeap<Value, IntArcMap>::PRE_HEAP);
+      }
+      for (EdgeIt e(_graph); e != INVALID; ++e) {
+        _delta3_index->set(e, _delta3->PRE_HEAP);
+      }
+      for (int i = 0; i < _blossom_num; ++i) {
+        _delta2_index->set(i, _delta2->PRE_HEAP);
+        _delta4_index->set(i, _delta4->PRE_HEAP);
+      }
+
+      int index = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        Value max = - std::numeric_limits<Value>::max();
+        for (OutArcIt e(_graph, n); e != INVALID; ++e) {
+          if (_graph.target(e) == n) continue;
+          if ((dualScale * _weight[e]) / 2 > max) {
+            max = (dualScale * _weight[e]) / 2;
+          }
+        }
+        _node_index->set(n, index);
+        (*_node_data)[index].pot = max;
+        int blossom =
+          _blossom_set->insert(n, std::numeric_limits<Value>::max());
+
+        _tree_set->insert(blossom);
+
+        (*_blossom_data)[blossom].status = EVEN;
+        (*_blossom_data)[blossom].pred = INVALID;
+        (*_blossom_data)[blossom].next = INVALID;
+        (*_blossom_data)[blossom].pot = 0;
+        (*_blossom_data)[blossom].offset = 0;
+        ++index;
+      }
+      for (EdgeIt e(_graph); e != INVALID; ++e) {
+        int si = (*_node_index)[_graph.u(e)];
+        int ti = (*_node_index)[_graph.v(e)];
+        if (_graph.u(e) != _graph.v(e)) {
+          _delta3->push(e, ((*_node_data)[si].pot + (*_node_data)[ti].pot -
+                            dualScale * _weight[e]) / 2);
+        }
+      }
+    }
+
+    /// \brief Starts the algorithm
+    ///
+    /// Starts the algorithm
+    bool start() {
+      enum OpType {
+        D2, D3, D4
+      };
+
+      int unmatched = _node_num;
+      while (unmatched > 0) {
+        Value d2 = !_delta2->empty() ?
+          _delta2->prio() : std::numeric_limits<Value>::max();
+
+        Value d3 = !_delta3->empty() ?
+          _delta3->prio() : std::numeric_limits<Value>::max();
+
+        Value d4 = !_delta4->empty() ?
+          _delta4->prio() : std::numeric_limits<Value>::max();
+
+        _delta_sum = d2; OpType ot = D2;
+        if (d3 < _delta_sum) { _delta_sum = d3; ot = D3; }
+        if (d4 < _delta_sum) { _delta_sum = d4; ot = D4; }
+
+        if (_delta_sum == std::numeric_limits<Value>::max()) {
+          return false;
+        }
+
+        switch (ot) {
+        case D2:
+          {
+            int blossom = _delta2->top();
+            Node n = _blossom_set->classTop(blossom);
+            Arc e = (*_node_data)[(*_node_index)[n]].heap.top();
+            extendOnArc(e);
+          }
+          break;
+        case D3:
+          {
+            Edge e = _delta3->top();
+
+            int left_blossom = _blossom_set->find(_graph.u(e));
+            int right_blossom = _blossom_set->find(_graph.v(e));
+
+            if (left_blossom == right_blossom) {
+              _delta3->pop();
+            } else {
+              int left_tree = _tree_set->find(left_blossom);
+              int right_tree = _tree_set->find(right_blossom);
+
+              if (left_tree == right_tree) {
+                shrinkOnEdge(e, left_tree);
+              } else {
+                augmentOnEdge(e);
+                unmatched -= 2;
+              }
+            }
+          } break;
+        case D4:
+          splitBlossom(_delta4->top());
+          break;
+        }
+      }
+      extractMatching();
+      return true;
+    }
+
+    /// \brief Runs %MaxWeightedPerfectMatching algorithm.
+    ///
+    /// This method runs the %MaxWeightedPerfectMatching algorithm.
+    ///
+    /// \note mwm.run() is just a shortcut of the following code.
+    /// \code
+    ///   mwm.init();
+    ///   mwm.start();
+    /// \endcode
+    bool run() {
+      init();
+      return start();
+    }
+
+    /// @}
+
+    /// \name Primal solution
+    /// Functions to get the primal solution, ie. the matching.
+
+    /// @{
+
+    /// \brief Returns the matching value.
+    ///
+    /// Returns the matching value.
+    Value matchingValue() const {
+      Value sum = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        if ((*_matching)[n] != INVALID) {
+          sum += _weight[(*_matching)[n]];
+        }
+      }
+      return sum /= 2;
+    }
+
+    /// \brief Returns true when the edge is in the matching.
+    ///
+    /// Returns true when the edge is in the matching.
+    bool matching(const Edge& edge) const {
+      return static_cast<const Edge&>((*_matching)[_graph.u(edge)]) == edge;
+    }
+
+    /// \brief Returns the incident matching edge.
+    ///
+    /// Returns the incident matching arc from given edge.
+    Arc matching(const Node& node) const {
+      return (*_matching)[node];
+    }
+
+    /// \brief Returns the mate of the node.
+    ///
+    /// Returns the adjancent node in a mathcing arc.
+    Node mate(const Node& node) const {
+      return _graph.target((*_matching)[node]);
+    }
+
+    /// @}
+
+    /// \name Dual solution
+    /// Functions to get the dual solution.
+
+    /// @{
+
+    /// \brief Returns the value of the dual solution.
+    ///
+    /// Returns the value of the dual solution. It should be equal to
+    /// the primal value scaled by \ref dualScale "dual scale".
+    Value dualValue() const {
+      Value sum = 0;
+      for (NodeIt n(_graph); n != INVALID; ++n) {
+        sum += nodeValue(n);
+      }
+      for (int i = 0; i < blossomNum(); ++i) {
+        sum += blossomValue(i) * (blossomSize(i) / 2);
+      }
+      return sum;
+    }
+
+    /// \brief Returns the value of the node.
+    ///
+    /// Returns the the value of the node.
+    Value nodeValue(const Node& n) const {
+      return (*_node_potential)[n];
+    }
+
+    /// \brief Returns the number of the blossoms in the basis.
+    ///
+    /// Returns the number of the blossoms in the basis.
+    /// \see BlossomIt
+    int blossomNum() const {
+      return _blossom_potential.size();
+    }
+
+
+    /// \brief Returns the number of the nodes in the blossom.
+    ///
+    /// Returns the number of the nodes in the blossom.
+    int blossomSize(int k) const {
+      return _blossom_potential[k].end - _blossom_potential[k].begin;
+    }
+
+    /// \brief Returns the value of the blossom.
+    ///
+    /// Returns the the value of the blossom.
+    /// \see BlossomIt
+    Value blossomValue(int k) const {
+      return _blossom_potential[k].value;
+    }
+
+    /// \brief Iterator for obtaining the nodes of the blossom.
+    ///
+    /// Iterator for obtaining the nodes of the blossom. This class
+    /// provides a common lemon style iterator for listing a
+    /// subset of the nodes.
+    class BlossomIt {
+    public:
+
+      /// \brief Constructor.
+      ///
+      /// Constructor to get the nodes of the variable.
+      BlossomIt(const MaxWeightedPerfectMatching& algorithm, int variable)
+        : _algorithm(&algorithm)
+      {
+        _index = _algorithm->_blossom_potential[variable].begin;
+        _last = _algorithm->_blossom_potential[variable].end;
+      }
+
+      /// \brief Conversion to node.
+      ///
+      /// Conversion to node.
+      operator Node() const {
+        return _algorithm->_blossom_node_list[_index];
+      }
+
+      /// \brief Increment operator.
+      ///
+      /// Increment operator.
+      BlossomIt& operator++() {
+        ++_index;
+        return *this;
+      }
+
+      /// \brief Validity checking
+      ///
+      /// Checks whether the iterator is invalid.
+      bool operator==(Invalid) const { return _index == _last; }
+
+      /// \brief Validity checking
+      ///
+      /// Checks whether the iterator is valid.
+      bool operator!=(Invalid) const { return _index != _last; }
+
+    private:
+      const MaxWeightedPerfectMatching* _algorithm;
+      int _last;
+      int _index;
+    };
+
+    /// @}
+
+  };
+
+
+} //END OF NAMESPACE LEMON
+
+#endif //LEMON_MAX_MATCHING_H
Index: lemon/path.h
===================================================================
--- lemon/path.h	(revision 236)
+++ lemon/path.h	(revision 313)
@@ -850,5 +850,5 @@
     int empty() const { return len == 0; }
 
-    /// \break Erase all arcs in the digraph.
+    /// \brief Erase all arcs in the digraph.
     void clear() {
       len = 0;
Index: lemon/random.h
===================================================================
--- lemon/random.h	(revision 209)
+++ lemon/random.h	(revision 280)
@@ -822,5 +822,4 @@
     /// \note The Cartesian form of the Box-Muller
     /// transformation is used to generate a random normal distribution.
-    /// \todo Consider using the "ziggurat" method instead.
     double gauss()
     {
Index: lemon/smart_graph.h
===================================================================
--- lemon/smart_graph.h	(revision 238)
+++ lemon/smart_graph.h	(revision 341)
@@ -301,5 +301,4 @@
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
-    ///\todo It could be implemented in a bit faster way.
     Node split(Node n, bool connect = true)
     {
@@ -367,5 +366,5 @@
 
       ///This constructor immediately makes a snapshot of the digraph.
-      ///\param _g The digraph we make a snapshot of.
+      ///\param graph The digraph we make a snapshot of.
       Snapshot(SmartDigraph &graph) : _graph(&graph) {
         node_num=_graph->nodes.size();
@@ -379,5 +378,5 @@
       ///This function can be called more than once. In case of a repeated
       ///call, the previous snapshot gets lost.
-      ///\param _g The digraph we make the snapshot of.
+      ///\param graph The digraph we make the snapshot of.
       void save(SmartDigraph &graph)
       {
@@ -466,6 +465,6 @@
 
     public:
-      operator Edge() const { 
-        return _id != -1 ? edgeFromId(_id / 2) : INVALID; 
+      operator Edge() const {
+        return _id != -1 ? edgeFromId(_id / 2) : INVALID;
       }
 
@@ -777,5 +776,5 @@
 
       ///This constructor immediately makes a snapshot of the digraph.
-      ///\param g The digraph we make a snapshot of.
+      ///\param graph The digraph we make a snapshot of.
       Snapshot(SmartGraph &graph) {
         graph.saveSnapshot(*this);
@@ -788,5 +787,5 @@
       ///This function can be called more than once. In case of a repeated
       ///call, the previous snapshot gets lost.
-      ///\param g The digraph we make the snapshot of.
+      ///\param graph The digraph we make the snapshot of.
       void save(SmartGraph &graph)
       {
Index: lemon/time_measure.h
===================================================================
--- lemon/time_measure.h	(revision 210)
+++ lemon/time_measure.h	(revision 314)
@@ -293,5 +293,4 @@
   ///function, consider the usage of \ref TimeReport instead.
   ///
-  ///\todo This shouldn't be Unix (Linux) specific.
   ///\sa TimeReport
   class Timer
@@ -313,10 +312,9 @@
     ///Basically a Timer can be either running or stopped,
     ///but it provides a bit finer control on the execution.
-    ///The \ref Timer also counts the number of \ref start()
-    ///executions, and is stops only after the same amount (or more)
-    ///\ref stop() "stop()"s. This can be useful e.g. to compute
-    ///the running time
+    ///The \ref lemon::Timer "Timer" also counts the number of
+    ///\ref lemon::Timer::start() "start()" executions, and it stops
+    ///only after the same amount (or more) \ref lemon::Timer::stop()
+    ///"stop()"s. This can be useful e.g. to compute the running time
     ///of recursive functions.
-    ///
 
     ///@{
@@ -474,5 +472,5 @@
   };
 
-  ///Same as \ref Timer but prints a report on destruction.
+  ///Same as Timer but prints a report on destruction.
 
   ///Same as \ref Timer but prints a report on destruction.
@@ -488,5 +486,4 @@
   ///\sa Timer
   ///\sa NoTimeReport
-  ///\todo There is no test case for this
   class TimeReport : public Timer
   {
@@ -494,13 +491,13 @@
     std::ostream &_os;
   public:
-    ///\e
-
+    ///Constructor
+
+    ///Constructor.
     ///\param title This text will be printed before the ellapsed time.
     ///\param os The stream to print the report to.
     ///\param run Sets whether the timer should start immediately.
-
     TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true)
       : Timer(run), _title(title), _os(os){}
-    ///\e Prints the ellapsed time on destruction.
+    ///Destructor that prints the ellapsed time
     ~TimeReport()
     {
@@ -509,5 +506,5 @@
   };
 
-  ///'Do nothing' version of \ref TimeReport
+  ///'Do nothing' version of TimeReport
 
   ///\sa TimeReport
Index: lemon/tolerance.h
===================================================================
--- lemon/tolerance.h	(revision 209)
+++ lemon/tolerance.h	(revision 280)
@@ -25,6 +25,4 @@
 ///floating point numbers.
 ///
-///\todo It should be in a module like "Basic tools"
-
 
 namespace lemon {
Index: scripts/chg-len.py
===================================================================
--- scripts/chg-len.py	(revision 284)
+++ scripts/chg-len.py	(revision 284)
@@ -0,0 +1,40 @@
+#! /usr/bin/env python
+
+import sys
+import os
+
+if len(sys.argv)>1 and sys.argv[1] in ["-h","--help"]:
+    print """
+This utility just prints the length of the longest path
+in the revision graph from revison 0 to the current one.
+"""
+    exit(0)
+plist = os.popen("HGRCPATH='' hg parents --template='{rev}\n'").readlines()
+if len(plist)>1:
+    print "You are in the process of merging"
+    exit(1)
+PAR = int(plist[0])
+
+f = os.popen("HGRCPATH='' hg log -r 0:tip --template='{rev} {parents}\n'").\
+    readlines()
+REV = -1
+lengths=[]
+for l in f:
+    REV+=1
+    s = l.split()
+    rev = int(s[0])
+    if REV != rev:
+        print "Something is seriously wrong"
+        exit(1)
+    if len(s) == 1:
+        par1 = par2 = rev - 1
+    elif len(s) == 2:
+        par1 = par2 = int(s[1].split(":")[0])
+    else:
+        par1 = int(s[1].split(":")[0])
+        par2 = int(s[2].split(":")[0])
+    if rev == 0:
+        lengths.append(0)
+    else:
+        lengths.append(max(lengths[par1],lengths[par2])+1)
+print lengths[PAR]
Index: scripts/unify-sources.sh
===================================================================
--- scripts/unify-sources.sh	(revision 208)
+++ scripts/unify-sources.sh	(revision 343)
@@ -4,7 +4,175 @@
 HGROOT=`hg root`
 
-function update_header() {
+# file enumaration modes
+
+function all_files() {
+    hg status -a -m -c |
+    cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' |
+    while read file; do echo $HGROOT/$file; done
+}
+
+function modified_files() {
+    hg status -a -m |
+    cut -d ' ' -f 2 | grep -E  '(\.(cc|h|dox)$|Makefile\.am$)' |
+    while read file; do echo $HGROOT/$file; done
+}
+
+function changed_files() {
+    {
+        if [ -n "$HG_PARENT1" ]
+        then
+            hg status --rev $HG_PARENT1:$HG_NODE -a -m
+        fi
+        if [ -n "$HG_PARENT2" ]
+        then
+            hg status --rev $HG_PARENT2:$HG_NODE -a -m
+        fi
+    } | cut -d ' ' -f 2 | grep -E '(\.(cc|h|dox)$|Makefile\.am$)' | 
+    sort | uniq |
+    while read file; do echo $HGROOT/$file; done
+}
+
+function given_files() {
+    for file in $GIVEN_FILES
+    do
+	echo $file
+    done
+}
+
+# actions
+
+function update_action() {
+    if ! diff -q $1 $2 >/dev/null
+    then
+	echo -n " [$3 updated]"
+	rm $2
+	mv $1 $2
+	CHANGED=YES
+    fi
+}
+
+function update_warning() {
+    echo -n " [$2 warning]"
+    WARNED=YES
+}
+
+function update_init() {
+    echo Update source files...
+    TOTAL_FILES=0
+    CHANGED_FILES=0
+    WARNED_FILES=0
+}
+
+function update_done() {
+    echo $CHANGED_FILES out of $TOTAL_FILES files has been changed.
+    echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings.
+}
+
+function update_begin() {
+    ((TOTAL_FILES++))
+    CHANGED=NO
+    WARNED=NO
+}
+
+function update_end() {
+    if [ $CHANGED == YES ]
+    then
+	((++CHANGED_FILES))
+    fi
+    if [ $WARNED == YES ]
+    then
+	((++WARNED_FILES))
+    fi
+}
+
+function check_action() {
+    if ! diff -q $1 $2 >/dev/null
+    then
+	echo
+	echo -n "      $3 failed at line(s): "
+	echo -n $(diff $1 $2 | grep '^[0-9]' | sed "s/^\(.*\)c.*$/ \1/g" | 
+	          sed "s/,/-/g" | paste -s -d',')
+	FAILED=YES
+    fi
+}
+
+function check_warning() {
+    echo
+    if [ "$2" == 'long lines' ]
+    then
+        echo -n "      $2 warning at line(s): "
+        echo -n $(grep -n -E '.{81,}' $1 | sed "s/^\([0-9]*\)/ \1\t/g" | 
+                  cut -f 1 | paste -s -d',')
+    else
+        echo -n "      $2 warning"
+    fi
+    WARNED=YES
+}
+
+function check_init() {
+    echo Check source files...
+    FAILED_FILES=0
+    WARNED_FILES=0
+    TOTAL_FILES=0
+}
+
+function check_done() {
+    echo $FAILED_FILES out of $TOTAL_FILES files has been failed.
+    echo $WARNED_FILES out of $TOTAL_FILES files triggered warnings.
+
+    if [ $FAILED_FILES -gt 0 ]
+    then
+	return 1
+    elif [ $WARNED_FILES -gt 0 ]
+    then
+	if [ "$WARNING" == 'INTERACTIVE' ]
+	then
+	    echo -n "Are the files with warnings acceptable? (yes/no) "
+	    while read answer
+	    do
+		if [ "$answer" == 'yes' ]
+		then
+		    return 0
+		elif [ "$answer" == 'no' ]
+		then
+		    return 1
+		fi
+		echo -n "Are the files with warnings acceptable? (yes/no) "
+	    done
+	elif [ "$WARNING" == 'WERROR' ]
+	then
+	    return 1
+	fi
+    fi
+}
+
+function check_begin() {
+    ((TOTAL_FILES++))
+    FAILED=NO
+    WARNED=NO
+}
+
+function check_end() {
+    if [ $FAILED == YES ]
+    then
+	((++FAILED_FILES))
+    fi
+    if [ $WARNED == YES ]
+    then
+	((++WARNED_FILES))
+    fi
+}
+
+
+
+# checks
+
+function header_check() {
+    if echo $1 | grep -q -E 'Makefile\.am$'
+    then
+	return
+    fi
+
     TMP_FILE=`mktemp`
-    FILE_NAME=$1
 
     (echo "/* -*- mode: C++; indent-tabs-mode: nil; -*-
@@ -26,5 +194,5 @@
  */
 "
-	awk 'BEGIN { pm=0; }
+    awk 'BEGIN { pm=0; }
      pm==3 { print }
      /\/\* / && pm==0 { pm=1;}
@@ -32,103 +200,148 @@
      /\*\// && pm==1 { pm=2;}
     ' $1
-	) >$TMP_FILE
-
-    HEADER_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES`
-
-    rm $FILE_NAME
-    mv $TMP_FILE $FILE_NAME
-}
-
-function update_tabs() {
+    ) >$TMP_FILE
+
+    "$ACTION"_action "$TMP_FILE" "$1" header
+}
+
+function tabs_check() {
+    if echo $1 | grep -q -v -E 'Makefile\.am$'
+    then
+        OLD_PATTERN=$(echo -e '\t')
+        NEW_PATTERN='        '
+    else
+        OLD_PATTERN='        '
+        NEW_PATTERN=$(echo -e '\t')
+    fi
     TMP_FILE=`mktemp`
-    FILE_NAME=$1
-
-    cat $1 |
-    sed -e 's/\t/        /g' >$TMP_FILE
-
-    TABS_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES`
-
-    rm $FILE_NAME
-    mv $TMP_FILE $FILE_NAME
-}
-
-function remove_trailing_space() {
+    cat $1 | sed -e "s/$OLD_PATTERN/$NEW_PATTERN/g" >$TMP_FILE
+
+    "$ACTION"_action "$TMP_FILE" "$1" 'tabs'
+}
+
+function spaces_check() {
     TMP_FILE=`mktemp`
-    FILE_NAME=$1
-
-    cat $1 |
-    sed -e 's/ \+$//g' >$TMP_FILE
-
-    SPACES_CH=`diff -q $TMP_FILE $FILE_NAME >/dev/null&&echo NO||echo YES`
-
-    rm $FILE_NAME
-    mv $TMP_FILE $FILE_NAME
-}
-
-function long_line_test() {
-    cat $1 |grep -q -E '.{81,}'
-}
-
-function update_file() {
-    echo -n '    update' $i ...
-
-    update_header $1
-    update_tabs $1
-    remove_trailing_space $1
-
-    CHANGED=NO;
-    if [[ $HEADER_CH = YES ]];
-    then
-	echo -n '  [header updated]'
-	CHANGED=YES;
-    fi
-    if [[ $TABS_CH = YES ]];
-    then
-	echo -n ' [tabs removed]'
-	CHANGED=YES;
-    fi
-    if [[ $SPACES_CH = YES ]];
-    then
-	echo -n ' [trailing spaces removed]'
-	CHANGED=YES;
-    fi
-    if long_line_test $1 ;
-    then
-	echo -n ' [LONG LINES]'
-	((LONG_LINE_FILES++))
-    fi
+    cat $1 | sed -e 's/ \+$//g' >$TMP_FILE
+
+    "$ACTION"_action "$TMP_FILE" "$1" 'trailing spaces'
+}
+
+function long_lines_check() {
+    if cat $1 | grep -q -E '.{81,}'
+    then
+	"$ACTION"_warning $1 'long lines'
+    fi
+}
+
+# process the file
+
+function process_file() {
+    echo -n "    $ACTION $1..."
+
+    CHECKING="header tabs spaces long_lines"
+
+    "$ACTION"_begin $1
+    for check in $CHECKING
+    do
+	"$check"_check $1
+    done
+    "$ACTION"_end $1
     echo
-    if [[ $CHANGED = YES ]];
-    then
-	((CHANGED_FILES++))
-    fi
-}
-
-CHANGED_FILES=0
-TOTAL_FILES=0
-LONG_LINE_FILES=0
-if [ $# == 0 ]; then
-    echo Update all source files...
-    for i in `hg manifest|grep -E  '\.(cc|h|dox)$'`
+}
+
+function process_all {
+    "$ACTION"_init
+    while read file
     do
-	update_file $HGROOT/$i
-	((TOTAL_FILES++))
-    done
-    echo '  done.'
-else
-    for i in $*
-    do
-	update_file $i
-	((TOTAL_FILES++))
-    done
+	process_file $file
+    done < <($FILES)
+    "$ACTION"_done
+}
+
+while [ $# -gt 0 ]
+do
+    
+    if [ "$1" == '--help' ] || [ "$1" == '-h' ]
+    then
+	echo -n \
+"Usage:
+  $0 [OPTIONS] [files]
+Options:
+  --dry-run|-n
+     Check the files, but do not modify them.
+  --interactive|-i
+     If --dry-run is specified and the checker emits warnings,
+     then the user is asked if the warnings should be considered
+     errors.
+  --werror|-w
+     Make all warnings into errors.
+  --all|-a
+     Check all source files in the repository.
+  --modified|-m
+     Check only the modified (and new) source files. This option is
+     useful to check the modification before making a commit.
+  --changed|-c
+     Check only the changed source files compared to the parent(s) of
+     the current hg node.  This option is useful as hg hook script.
+     To automatically check all your changes before making a commit,
+     add the following section to the appropriate .hg/hgrc file.
+
+       [hooks]
+       pretxncommit.checksources = scripts/unify-sources.sh -c -n -i
+
+  --help|-h
+     Print this help message.
+  files
+     The files to check/unify. If no file names are given, the modified
+     source files will be checked/unified (just like using the
+     --modified|-m option).
+"
+        exit 0
+    elif [ "$1" == '--dry-run' ] || [ "$1" == '-n' ]
+    then
+	[ -n "$ACTION" ] && echo "Conflicting action options" >&2 && exit 1
+	ACTION=check
+    elif [ "$1" == "--all" ] || [ "$1" == '-a' ]
+    then
+	[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1
+	FILES=all_files
+    elif [ "$1" == "--changed" ] || [ "$1" == '-c' ]
+    then
+	[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1
+	FILES=changed_files
+    elif [ "$1" == "--modified" ] || [ "$1" == '-m' ]
+    then
+	[ -n "$FILES" ] && echo "Conflicting target options" >&2 && exit 1
+	FILES=modified_files
+    elif [ "$1" == "--interactive" ] || [ "$1" == "-i" ]
+    then
+	[ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1
+	WARNING='INTERACTIVE'
+    elif [ "$1" == "--werror" ] || [ "$1" == "-w" ]
+    then
+	[ -n "$WARNING" ] && echo "Conflicting warning options" >&2 && exit 1
+	WARNING='WERROR'
+    elif [ $(echo x$1 | cut -c 2) == '-' ]
+    then
+	echo "Invalid option $1" >&2 && exit 1
+    else
+	[ -n "$FILES" ] && echo "Invalid option $1" >&2 && exit 1
+	GIVEN_FILES=$@
+	FILES=given_files
+	break
+    fi
+    
+    shift
+done
+
+if [ -z $FILES ]
+then
+    FILES=modified_files
 fi
-echo $CHANGED_FILES out of $TOTAL_FILES files has been changed.
-if [[ $LONG_LINE_FILES -gt 1 ]]; then
-    echo
-    echo WARNING: $LONG_LINE_FILES files contains long lines!    
-    echo
-elif [[ $LONG_LINE_FILES -gt 0 ]]; then
-    echo
-    echo WARNING: a file contains long lines!
-    echo
+
+if [ -z $ACTION ]
+then
+    ACTION=update
 fi
+
+process_all
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt	(revision 225)
+++ test/CMakeLists.txt	(revision 339)
@@ -17,4 +17,5 @@
   kruskal_test
   maps_test
+  max_matching_test
   random_test
   path_test
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 228)
+++ test/Makefile.am	(revision 339)
@@ -20,4 +20,5 @@
 	test/kruskal_test \
         test/maps_test \
+	test/max_matching_test \
         test/random_test \
         test/path_test \
@@ -43,4 +44,5 @@
 test_kruskal_test_SOURCES = test/kruskal_test.cc
 test_maps_test_SOURCES = test/maps_test.cc
+test_max_matching_test_SOURCES = test/max_matching_test.cc
 test_path_test_SOURCES = test/path_test.cc
 test_random_test_SOURCES = test/random_test.cc
Index: test/bfs_test.cc
===================================================================
--- test/bfs_test.cc	(revision 228)
+++ test/bfs_test.cc	(revision 293)
@@ -55,28 +55,50 @@
   typedef concepts::Digraph Digraph;
   typedef Bfs<Digraph> BType;
+  typedef Digraph::Node Node;
+  typedef Digraph::Arc Arc;
 
   Digraph G;
-  Digraph::Node n;
-  Digraph::Arc e;
+  Node s, t;
+  Arc e;
   int l;
   bool b;
   BType::DistMap d(G);
   BType::PredMap p(G);
-  //  BType::PredNodeMap pn(G);
+  Path<Digraph> pp;
 
-  BType bfs_test(G);
+  {
+    BType bfs_test(G);
 
-  bfs_test.run(n);
+    bfs_test.run(s);
+    bfs_test.run(s,t);
+    bfs_test.run();
 
-  l  = bfs_test.dist(n);
-  e  = bfs_test.predArc(n);
-  n  = bfs_test.predNode(n);
-  d  = bfs_test.distMap();
+    l  = bfs_test.dist(t);
+    e  = bfs_test.predArc(t);
+    s  = bfs_test.predNode(t);
+    b  = bfs_test.reached(t);
+    d  = bfs_test.distMap();
+    p  = bfs_test.predMap();
+    pp = bfs_test.path(t);
+  }
+  {
+    BType
+      ::SetPredMap<concepts::ReadWriteMap<Node,Arc> >
+      ::SetDistMap<concepts::ReadWriteMap<Node,int> >
+      ::SetReachedMap<concepts::ReadWriteMap<Node,bool> >
+      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
+      ::SetStandardProcessedMap
+      ::Create bfs_test(G);
 
-  p  = bfs_test.predMap();
-  //  pn = bfs_test.predNodeMap();
-  b  = bfs_test.reached(n);
+    bfs_test.run(s);
+    bfs_test.run(s,t);
+    bfs_test.run();
 
-  Path<Digraph> pp = bfs_test.path(n);
+    l  = bfs_test.dist(t);
+    e  = bfs_test.predArc(t);
+    s  = bfs_test.predNode(t);
+    b  = bfs_test.reached(t);
+    pp = bfs_test.path(t);
+  }
 }
 
@@ -89,12 +111,28 @@
 
   Digraph g;
-  bfs(g,Node()).run();
-  bfs(g).source(Node()).run();
+  bool b;
+  bfs(g).run(Node());
+  b=bfs(g).run(Node(),Node());
+  bfs(g).run();
   bfs(g)
-    .predMap(concepts::WriteMap<Node,Arc>())
-    .distMap(concepts::WriteMap<Node,VType>())
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
     .reachedMap(concepts::ReadWriteMap<Node,bool>())
     .processedMap(concepts::WriteMap<Node,bool>())
     .run(Node());
+  b=bfs(g)
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
+    .reachedMap(concepts::ReadWriteMap<Node,bool>())
+    .processedMap(concepts::WriteMap<Node,bool>())
+    .path(concepts::Path<Digraph>())
+    .dist(VType())
+    .run(Node(),Node());
+  bfs(g)
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
+    .reachedMap(concepts::ReadWriteMap<Node,bool>())
+    .processedMap(concepts::WriteMap<Node,bool>())
+    .run();
 }
 
@@ -107,5 +145,5 @@
 
   std::istringstream input(test_lgf);
-  digraphReader(input, G).
+  digraphReader(G, input).
     node("source", s).
     node("target", t).
@@ -115,5 +153,5 @@
   bfs_test.run(s);
 
-  check(bfs_test.dist(t)==2,"Bfs found a wrong path." << bfs_test.dist(t));
+  check(bfs_test.dist(t)==2,"Bfs found a wrong path.");
 
   Path<Digraph> p = bfs_test.path(t);
@@ -129,5 +167,5 @@
     check( !bfs_test.reached(u) ||
            (bfs_test.dist(v) <= bfs_test.dist(u)+1),
-           "Wrong output." << G.id(v) << ' ' << G.id(u));
+           "Wrong output. " << G.id(u) << "->" << G.id(v));
   }
 
@@ -141,8 +179,12 @@
         check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
               "Wrong distance. Difference: "
-              << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
-                          - 1));
+              << std::abs(bfs_test.dist(v) - bfs_test.dist(u) - 1));
       }
     }
+  }
+
+  {
+    NullMap<Node,Arc> myPredMap;
+    bfs(G).predMap(myPredMap).run(s);
   }
 }
Index: test/dfs_test.cc
===================================================================
--- test/dfs_test.cc	(revision 228)
+++ test/dfs_test.cc	(revision 293)
@@ -21,5 +21,4 @@
 #include <lemon/list_graph.h>
 #include <lemon/lgf_reader.h>
-
 #include <lemon/dfs.h>
 #include <lemon/path.h>
@@ -58,25 +57,50 @@
   typedef concepts::Digraph Digraph;
   typedef Dfs<Digraph> DType;
+  typedef Digraph::Node Node;
+  typedef Digraph::Arc Arc;
 
   Digraph G;
-  Digraph::Node n;
-  Digraph::Arc e;
+  Node s, t;
+  Arc e;
   int l;
   bool b;
   DType::DistMap d(G);
   DType::PredMap p(G);
+  Path<Digraph> pp;
 
-  DType dfs_test(G);
+  {
+    DType dfs_test(G);
 
-  dfs_test.run(n);
+    dfs_test.run(s);
+    dfs_test.run(s,t);
+    dfs_test.run();
 
-  l  = dfs_test.dist(n);
-  e  = dfs_test.predArc(n);
-  n  = dfs_test.predNode(n);
-  d  = dfs_test.distMap();
-  p  = dfs_test.predMap();
-  b  = dfs_test.reached(n);
+    l  = dfs_test.dist(t);
+    e  = dfs_test.predArc(t);
+    s  = dfs_test.predNode(t);
+    b  = dfs_test.reached(t);
+    d  = dfs_test.distMap();
+    p  = dfs_test.predMap();
+    pp = dfs_test.path(t);
+  }
+  {
+    DType
+      ::SetPredMap<concepts::ReadWriteMap<Node,Arc> >
+      ::SetDistMap<concepts::ReadWriteMap<Node,int> >
+      ::SetReachedMap<concepts::ReadWriteMap<Node,bool> >
+      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
+      ::SetStandardProcessedMap
+      ::Create dfs_test(G);
 
-  Path<Digraph> pp = dfs_test.path(n);
+    dfs_test.run(s);
+    dfs_test.run(s,t);
+    dfs_test.run();
+
+    l  = dfs_test.dist(t);
+    e  = dfs_test.predArc(t);
+    s  = dfs_test.predNode(t);
+    b  = dfs_test.reached(t);
+    pp = dfs_test.path(t);
+  }
 }
 
@@ -89,12 +113,28 @@
 
   Digraph g;
-  dfs(g,Node()).run();
-  dfs(g).source(Node()).run();
+  bool b;
+  dfs(g).run(Node());
+  b=dfs(g).run(Node(),Node());
+  dfs(g).run();
   dfs(g)
-    .predMap(concepts::WriteMap<Node,Arc>())
-    .distMap(concepts::WriteMap<Node,VType>())
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
     .reachedMap(concepts::ReadWriteMap<Node,bool>())
     .processedMap(concepts::WriteMap<Node,bool>())
     .run(Node());
+  b=dfs(g)
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
+    .reachedMap(concepts::ReadWriteMap<Node,bool>())
+    .processedMap(concepts::WriteMap<Node,bool>())
+    .path(concepts::Path<Digraph>())
+    .dist(VType())
+    .run(Node(),Node());
+  dfs(g)
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
+    .reachedMap(concepts::ReadWriteMap<Node,bool>())
+    .processedMap(concepts::WriteMap<Node,bool>())
+    .run();
 }
 
@@ -107,5 +147,5 @@
 
   std::istringstream input(test_lgf);
-  digraphReader(input, G).
+  digraphReader(G, input).
     node("source", s).
     node("target", t).
@@ -130,7 +170,12 @@
         check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
               "Wrong distance. (" << dfs_test.dist(u) << "->"
-              <<dfs_test.dist(v) << ')');
+              << dfs_test.dist(v) << ")");
       }
     }
+  }
+
+  {
+    NullMap<Node,Arc> myPredMap;
+    dfs(G).predMap(myPredMap).run(s);
   }
 }
Index: test/dijkstra_test.cc
===================================================================
--- test/dijkstra_test.cc	(revision 228)
+++ test/dijkstra_test.cc	(revision 293)
@@ -21,7 +21,7 @@
 #include <lemon/list_graph.h>
 #include <lemon/lgf_reader.h>
-
 #include <lemon/dijkstra.h>
 #include <lemon/path.h>
+#include <lemon/bin_heap.h>
 
 #include "graph_test.h"
@@ -57,28 +57,52 @@
   typedef concepts::ReadMap<Digraph::Arc,VType> LengthMap;
   typedef Dijkstra<Digraph, LengthMap> DType;
+  typedef Digraph::Node Node;
+  typedef Digraph::Arc Arc;
 
   Digraph G;
-  Digraph::Node n;
-  Digraph::Arc e;
+  Node s, t;
+  Arc e;
   VType l;
   bool b;
   DType::DistMap d(G);
   DType::PredMap p(G);
-  //  DType::PredNodeMap pn(G);
   LengthMap length;
+  Path<Digraph> pp;
 
-  DType dijkstra_test(G,length);
+  {
+    DType dijkstra_test(G,length);
 
-  dijkstra_test.run(n);
+    dijkstra_test.run(s);
+    dijkstra_test.run(s,t);
 
-  l  = dijkstra_test.dist(n);
-  e  = dijkstra_test.predArc(n);
-  n  = dijkstra_test.predNode(n);
-  d  = dijkstra_test.distMap();
-  p  = dijkstra_test.predMap();
-  //  pn = dijkstra_test.predNodeMap();
-  b  = dijkstra_test.reached(n);
+    l  = dijkstra_test.dist(t);
+    e  = dijkstra_test.predArc(t);
+    s  = dijkstra_test.predNode(t);
+    b  = dijkstra_test.reached(t);
+    d  = dijkstra_test.distMap();
+    p  = dijkstra_test.predMap();
+    pp = dijkstra_test.path(t);
+  }
+  {
+    DType
+      ::SetPredMap<concepts::ReadWriteMap<Node,Arc> >
+      ::SetDistMap<concepts::ReadWriteMap<Node,VType> >
+      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
+      ::SetStandardProcessedMap
+      ::SetOperationTraits<DijkstraWidestPathOperationTraits<VType> >
+      ::SetHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > >
+      ::SetStandardHeap<BinHeap<VType, concepts::ReadWriteMap<Node,int> > >
+      ::Create dijkstra_test(G,length);
 
-  Path<Digraph> pp = dijkstra_test.path(n);
+    dijkstra_test.run(s);
+    dijkstra_test.run(s,t);
+
+    l  = dijkstra_test.dist(t);
+    e  = dijkstra_test.predArc(t);
+    s  = dijkstra_test.predNode(t);
+    b  = dijkstra_test.reached(t);
+    pp = dijkstra_test.path(t);
+  }
+
 }
 
@@ -92,10 +116,19 @@
 
   Digraph g;
-  dijkstra(g,LengthMap(),Node()).run();
-  dijkstra(g,LengthMap()).source(Node()).run();
+  bool b;
+  dijkstra(g,LengthMap()).run(Node());
+  b=dijkstra(g,LengthMap()).run(Node(),Node());
   dijkstra(g,LengthMap())
-    .predMap(concepts::WriteMap<Node,Arc>())
-    .distMap(concepts::WriteMap<Node,VType>())
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
+    .processedMap(concepts::WriteMap<Node,bool>())
     .run(Node());
+  b=dijkstra(g,LengthMap())
+    .predMap(concepts::ReadWriteMap<Node,Arc>())
+    .distMap(concepts::ReadWriteMap<Node,VType>())
+    .processedMap(concepts::WriteMap<Node,bool>())
+    .path(concepts::Path<Digraph>())
+    .dist(VType())
+    .run(Node(),Node());
 }
 
@@ -110,5 +143,5 @@
 
   std::istringstream input(test_lgf);
-  digraphReader(input, G).
+  digraphReader(G, input).
     arcMap("length", length).
     node("source", s).
@@ -123,5 +156,5 @@
 
   Path<Digraph> p = dijkstra_test.path(t);
-  check(p.length()==3,"getPath() found a wrong path.");
+  check(p.length()==3,"path() found a wrong path.");
   check(checkPath(G, p),"path() found a wrong path.");
   check(pathSource(G, p) == s,"path() found a wrong path.");
@@ -133,5 +166,5 @@
     check( !dijkstra_test.reached(u) ||
            (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= length[e]),
-           "dist(target)-dist(source)-arc_length= " <<
+           "Wrong output. dist(target)-dist(source)-arc_length=" <<
            dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]);
   }
Index: test/error_test.cc
===================================================================
--- test/error_test.cc	(revision 223)
+++ test/error_test.cc	(revision 277)
@@ -48,12 +48,7 @@
 }
 
-void fixme_disable() {
-  LEMON_FIXME("fixme_disable() is fixme!");
-}
-
 void check_assertion_disable() {
   no_assertion_text_disable();
   assertion_text_disable();
-  fixme_disable();
 }
 #undef LEMON_DISABLE_ASSERTS
@@ -79,13 +74,8 @@
 }
 
-void fixme_custom() {
-  LEMON_FIXME("fixme_custom() is fixme!");
-}
-
 void check_assertion_custom() {
   no_assertion_text_custom();
   assertion_text_custom();
-  fixme_custom();
-  check(cnt == 2, "The custom assert handler does not work");
+  check(cnt == 1, "The custom assert handler does not work");
 }
 
Index: test/graph_copy_test.cc
===================================================================
--- test/graph_copy_test.cc	(revision 220)
+++ test/graph_copy_test.cc	(revision 282)
@@ -64,9 +64,9 @@
   ListDigraph::ArcMap<SmartDigraph::Arc> ecr(to);
 
-  DigraphCopy<ListDigraph, SmartDigraph>(to, from).
-    nodeMap(tnm, fnm).arcMap(tam, fam).
+  digraphCopy(from, to).
+    nodeMap(fnm, tnm).arcMap(fam, tam).
     nodeRef(nr).arcRef(er).
     nodeCrossRef(ncr).arcCrossRef(ecr).
-    node(tn, fn).arc(ta, fa).run();
+    node(fn, tn).arc(fa, ta).run();
 
   for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) {
@@ -139,9 +139,9 @@
   ListGraph::EdgeMap<SmartGraph::Edge> ecr(to);
 
-  GraphCopy<ListGraph, SmartGraph>(to, from).
-    nodeMap(tnm, fnm).arcMap(tam, fam).edgeMap(tem, fem).
+  graphCopy(from, to).
+    nodeMap(fnm, tnm).arcMap(fam, tam).edgeMap(fem, tem).
     nodeRef(nr).arcRef(ar).edgeRef(er).
     nodeCrossRef(ncr).arcCrossRef(acr).edgeCrossRef(ecr).
-    node(tn, fn).arc(ta, fa).edge(te, fe).run();
+    node(fn, tn).arc(fa, ta).edge(fe, te).run();
 
   for (SmartGraph::NodeIt it(from); it != INVALID; ++it) {
Index: test/graph_test.h
===================================================================
--- test/graph_test.h	(revision 228)
+++ test/graph_test.h	(revision 263)
@@ -213,8 +213,8 @@
     check(s == 0, "Wrong sum.");
 
-    map = constMap<Node>(12);
-    for (NodeIt it(G); it != INVALID; ++it) {
-      check(map[it] == 12, "Wrong operator[].");
-    }
+    // map = constMap<Node>(12);
+    // for (NodeIt it(G); it != INVALID; ++it) {
+    //   check(map[it] == 12, "Wrong operator[].");
+    // }
   }
 
@@ -243,8 +243,8 @@
     check(s == 0, "Wrong sum.");
 
-    map = constMap<Arc>(12);
-    for (ArcIt it(G); it != INVALID; ++it) {
-      check(map[it] == 12, "Wrong operator[].");
-    }
+    // map = constMap<Arc>(12);
+    // for (ArcIt it(G); it != INVALID; ++it) {
+    //   check(map[it] == 12, "Wrong operator[].");
+    // }
   }
 
@@ -273,8 +273,8 @@
     check(s == 0, "Wrong sum.");
 
-    map = constMap<Edge>(12);
-    for (EdgeIt it(G); it != INVALID; ++it) {
-      check(map[it] == 12, "Wrong operator[].");
-    }
+    // map = constMap<Edge>(12);
+    // for (EdgeIt it(G); it != INVALID; ++it) {
+    //   check(map[it] == 12, "Wrong operator[].");
+    // }
   }
 
Index: test/heap_test.cc
===================================================================
--- test/heap_test.cc	(revision 212)
+++ test/heap_test.cc	(revision 293)
@@ -132,5 +132,5 @@
                       Node source) {
 
-  typename Dijkstra<Digraph, IntArcMap>::template DefStandardHeap<Heap>::
+  typename Dijkstra<Digraph, IntArcMap>::template SetStandardHeap<Heap>::
     Create dijkstra(digraph, length);
 
@@ -168,5 +168,5 @@
 
   std::istringstream input(test_lgf);
-  digraphReader(input, digraph).
+  digraphReader(digraph, input).
     arcMap("capacity", length).
     node("source", source).
Index: test/max_matching_test.cc
===================================================================
--- test/max_matching_test.cc	(revision 339)
+++ test/max_matching_test.cc	(revision 339)
@@ -0,0 +1,310 @@
+/* -*- mode: C++; indent-tabs-mode: nil; -*-
+ *
+ * This file is a part of LEMON, a generic C++ optimization library.
+ *
+ * Copyright (C) 2003-2008
+ * 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 <lemon/math.h>
+#include <cstdlib>
+
+#include <lemon/max_matching.h>
+#include <lemon/smart_graph.h>
+#include <lemon/lgf_reader.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 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.decomposition(n) == MaxMatching<SmartGraph>::EVEN ||
+          mm.matching(n) != INVALID, "Wrong Gallai-Edmonds decomposition");
+    if (mm.decomposition(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.decomposition(graph.u(e)) != MaxMatching<SmartGraph>::EVEN ||
+          mm.decomposition(graph.v(e)) != MaxMatching<SmartGraph>::MATCHED,
+          "Wrong Gallai-Edmonds decomposition");
+
+    check(mm.decomposition(graph.v(e)) != MaxMatching<SmartGraph>::EVEN ||
+          mm.decomposition(graph.u(e)) != MaxMatching<SmartGraph>::MATCHED,
+          "Wrong Gallai-Edmonds decomposition");
+
+    if (mm.decomposition(graph.u(e)) != MaxMatching<SmartGraph>::ODD &&
+        mm.decomposition(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.decomposition(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: tools/Makefile.am
===================================================================
--- tools/Makefile.am	(revision 146)
+++ tools/Makefile.am	(revision 310)
@@ -2,4 +2,5 @@
 
 bin_PROGRAMS +=
+dist_bin_SCRIPTS += tools/lemon-0.x-to-1.x.sh
 
 endif WANT_TOOLS
Index: tools/lemon-0.x-to-1.x.sh
===================================================================
--- tools/lemon-0.x-to-1.x.sh	(revision 335)
+++ tools/lemon-0.x-to-1.x.sh	(revision 335)
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+set -e
+
+if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then
+    echo "Usage:"
+    echo "  $0 source-file(s)"
+    exit
+fi
+
+for i in $@
+do
+    echo Update $i...
+    TMP=`mktemp`
+    sed -e "s/undirected graph/_gr_aph_label_/g"\
+        -e "s/undirected edge/_ed_ge_label_/g"\
+        -e "s/graph_/_gr_aph_label__/g"\
+        -e "s/_graph/__gr_aph_label_/g"\
+        -e "s/UGraph/_Gr_aph_label_/g"\
+        -e "s/uGraph/_gr_aph_label_/g"\
+        -e "s/ugraph/_gr_aph_label_/g"\
+        -e "s/Graph/_Digr_aph_label_/g"\
+        -e "s/graph/_digr_aph_label_/g"\
+        -e "s/UEdge/_Ed_ge_label_/g"\
+        -e "s/uEdge/_ed_ge_label_/g"\
+        -e "s/uedge/_ed_ge_label_/g"\
+        -e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\
+        -e "s/Edge/_Ar_c_label_/g"\
+        -e "s/edge/_ar_c_label_/g"\
+        -e "s/ANode/_Re_d_label_/g"\
+        -e "s/BNode/_Blu_e_label_/g"\
+        -e "s/A-Node/_Re_d_label_/g"\
+        -e "s/B-Node/_Blu_e_label_/g"\
+        -e "s/anode/_re_d_label_/g"\
+        -e "s/bnode/_blu_e_label_/g"\
+        -e "s/aNode/_re_d_label_/g"\
+        -e "s/bNode/_blu_e_label_/g"\
+        -e "s/_Digr_aph_label_/Digraph/g"\
+        -e "s/_digr_aph_label_/digraph/g"\
+        -e "s/_Gr_aph_label_/Graph/g"\
+        -e "s/_gr_aph_label_/graph/g"\
+        -e "s/_Ar_c_label_/Arc/g"\
+        -e "s/_ar_c_label_/arc/g"\
+        -e "s/_Ed_ge_label_/Edge/g"\
+        -e "s/_ed_ge_label_/edge/g"\
+        -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\
+        -e "s/_Re_d_label_/Red/g"\
+        -e "s/_Blu_e_label_/Blue/g"\
+        -e "s/_re_d_label_/red/g"\
+        -e "s/_blu_e_label_/blue/g"\
+        -e "s/\<DefPredMap\>/SetPredMap/g"\
+        -e "s/\<DefDistMap\>/SetDistMap/g"\
+        -e "s/\<DefReachedMap\>/SetReachedMap/g"\
+        -e "s/\<DefProcessedMap\>/SetProcessedMap/g"\
+        -e "s/\<DefHeap\>/SetHeap/g"\
+        -e "s/\<DefStandardHeap\>/SetStandradHeap/g"\
+        -e "s/\<DefOperationTraits\>/SetOperationTraits/g"\
+        -e "s/\<DefProcessedMapToBeDefaultMap\>/SetStandardProcessedMap/g"\
+        -e "s/\<copyGraph\>/graphCopy/g"\
+        -e "s/\<copyDigraph\>/digraphCopy/g"\
+        -e "s/\<IntegerMap\>/RangeMap/g"\
+        -e "s/\<integerMap\>/rangeMap/g"\
+        -e "s/\<\([sS]\)tdMap\>/\1parseMap/g"\
+        -e "s/\<\([Ff]\)unctorMap\>/\1unctorToMap/g"\
+        -e "s/\<\([Mm]\)apFunctor\>/\1apToFunctor/g"\
+        -e "s/\<\([Ff]\)orkWriteMap\>/\1orkMap/g"\
+        -e "s/\<StoreBoolMap\>/LoggerBoolMap/g"\
+        -e "s/\<storeBoolMap\>/loggerBoolMap/g"\
+        -e "s/\<BoundingBox\>/Box/g"\
+    <$i > $TMP
+    mv $TMP $i
+done
