Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 236)
+++ CMakeLists.txt	(revision 141)
@@ -1,101 +1,5 @@
-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}")
-
-PROJECT(${PROJECT_NAME})
-
-SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
-
-INCLUDE(FindDoxygen)
-INCLUDE(FindGhostscript)
-
-ENABLE_TESTING()
-
-ADD_SUBDIRECTORY(lemon)
-ADD_SUBDIRECTORY(demo)
-ADD_SUBDIRECTORY(doc)
-ADD_SUBDIRECTORY(test)
-
-IF(WIN32)
-  INSTALL(FILES ${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico
-    DESTINATION bin)
-ENDIF(WIN32)
-
-IF(WIN32)
-  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
-  SET(CPACK_PACKAGE_VENDOR
-    "EGRES - Egervary Research Group on Combinatorial Optimization")
-  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
-    "LEMON - Library of Efficient Models and Optimization in Networks")
-  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}")
-  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
-    "${PROJECT_NAME} ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
-
-  # Variables to generate a component-based installer.
-  #SET(CPACK_COMPONENTS_ALL headers library html_documentation)
-
-  #SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
-  #SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Static library")
-  #SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
-
-  #SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
-  #  "C++ header files for use with the LEMON library")
-  #SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
-  #  "Static library used to build programs with LEMON")
-  #SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
-  #  "Doxygen generated documentation")
-
-  #SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
-
-  #SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
-  #SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
-  #SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
-
-  #SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
-  #  "Components needed to develop software using LEMON")
-  #SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
-  #  "Documentation of LEMON")
-
-  #SET(CPACK_ALL_INSTALL_TYPES Full Developer)
-
-  #SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
-  #SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
-  #SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
-
-  SET(CPACK_GENERATOR "NSIS")
-  SET(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis/lemon.ico")
-  SET(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/cmake/nsis/uninstall.ico")
-  #SET(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
-  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
-  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
-  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
-  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
-  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
-  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
-    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\doc\\\\index.html\\\"
-    ")
-  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
-    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
-    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
-    ")
-
-  INCLUDE(CPack)
-ENDIF(WIN32)
+project (LEMON)
+enable_testing ()
+add_subdirectory (lemon)
+add_subdirectory (demo)
+add_subdirectory (test)
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 227)
+++ Makefile.am	(revision 146)
@@ -9,6 +9,5 @@
 	m4/lx_check_glpk.m4 \
 	m4/lx_check_soplex.m4 \
-	CMakeLists.txt \
-	cmake
+	CMakeLists.txt
 
 pkgconfigdir = $(libdir)/pkgconfig
Index: ake/FindGhostscript.cmake
===================================================================
--- cmake/FindGhostscript.cmake	(revision 225)
+++ 	(revision )
@@ -1,10 +1,0 @@
-INCLUDE(FindPackageHandleStandardArgs)
-
-FIND_PROGRAM(GHOSTSCRIPT_EXECUTABLE
-  NAMES gs gswin32c
-  PATHS "$ENV{ProgramFiles}/gs"
-  PATH_SUFFIXES gs8.61/bin gs8.62/bin
-  DOC "Ghostscript: PostScript and PDF language interpreter and previewer."
-)
-
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ghostscript DEFAULT_MSG GHOSTSCRIPT_EXECUTABLE)
Index: configure.ac
===================================================================
--- configure.ac	(revision 236)
+++ configure.ac	(revision 175)
@@ -7,5 +7,5 @@
 
 AC_PREREQ([2.59])
-AC_INIT([LEMON], [lemon_version()], [lemon-user@lemon.cs.elte.hu], [lemon])
+AC_INIT([LEMON], [lemon_version()], [lemon-devel@lemon.cs.elte.hu], [lemon])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
@@ -26,5 +26,4 @@
 AC_CHECK_PROG([gs_found],[gs],[yes],[no])
 
-dnl Set custom compiler flags when using g++.
 if test x"$lx_cmdline_cxxflags_set" != x"set" -a "$GXX" = yes; 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"
@@ -36,5 +35,5 @@
 LX_CHECK_SOPLEX
 
-dnl Disable/enable building the demo programs.
+dnl Disable/enable building the demo programs
 AC_ARG_ENABLE([demo],
 AS_HELP_STRING([--enable-demo], [build the demo programs])
@@ -49,5 +48,5 @@
 AM_CONDITIONAL([WANT_DEMO], [test x"$enable_demo" != x"no"])
 
-dnl Disable/enable building the binary tools.
+dnl Disable/enable building the binary tools
 AC_ARG_ENABLE([tools],
 AS_HELP_STRING([--enable-tools], [build additional tools @<:@default@:>@])
@@ -62,5 +61,5 @@
 AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"])
 
-dnl Disable/enable building the benchmarks.
+dnl Disable/enable building the benchmarks
 AC_ARG_ENABLE([benchmark],
 AS_HELP_STRING([--enable-benchmark], [build the benchmarks])
@@ -88,8 +87,4 @@
 AC_HEADER_STDC
 AC_CHECK_FUNCS(gettimeofday times ctime_r)
-
-dnl Add dependencies on files generated by configure.
-AC_SUBST([CONFIG_STATUS_DEPENDENCIES],
-  ['$(top_srcdir)/doc/Doxyfile.in $(top_srcdir)/lemon/lemon.pc.in'])
 
 AC_CONFIG_FILES([
Index: demo/CMakeLists.txt
===================================================================
--- demo/CMakeLists.txt	(revision 225)
+++ demo/CMakeLists.txt	(revision 141)
@@ -1,13 +1,13 @@
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+include_directories (${LEMON_SOURCE_DIR})
 
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
+link_directories (${LEMON_BINARY_DIR}/lemon)
 
-SET(DEMOS
+set (DEMOS
   arg_parser_demo
   graph_to_eps_demo
   lgf_demo)
 
-FOREACH(DEMO_NAME ${DEMOS})
-  ADD_EXECUTABLE(${DEMO_NAME} ${DEMO_NAME}.cc)
-  TARGET_LINK_LIBRARIES(${DEMO_NAME} lemon)
-ENDFOREACH(DEMO_NAME)
+foreach (DEMO_NAME ${DEMOS})
+  add_executable (${DEMO_NAME} ${DEMO_NAME}.cc)
+  target_link_libraries (${DEMO_NAME} lemon)
+  endforeach (DEMO_NAME)
Index: demo/graph_to_eps_demo.cc
===================================================================
--- demo/graph_to_eps_demo.cc	(revision 220)
+++ demo/graph_to_eps_demo.cc	(revision 211)
@@ -32,4 +32,5 @@
 
 #include<lemon/list_graph.h>
+#include<lemon/graph_utils.h>
 #include<lemon/graph_to_eps.h>
 #include<lemon/math.h>
Index: c/CMakeLists.txt
===================================================================
--- doc/CMakeLists.txt	(revision 225)
+++ 	(revision )
@@ -1,42 +1,0 @@
-SET(PACKAGE_NAME ${PROJECT_NAME})
-SET(PACKAGE_VERSION ${PROJECT_VERSION})
-SET(abs_top_srcdir ${CMAKE_SOURCE_DIR})
-SET(abs_top_builddir ${CMAKE_BINARY_DIR})
-
-CONFIGURE_FILE(
-  ${CMAKE_SOURCE_DIR}/doc/Doxyfile.in
-  ${CMAKE_BINARY_DIR}/doc/Doxyfile
-  @ONLY)
-
-IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
-  IF(UNIX)
-    ADD_CUSTOM_TARGET(html
-      COMMAND rm -rf gen-images
-      COMMAND mkdir gen-images
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
-      COMMAND rm -rf html
-      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
-      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-  ELSEIF(WIN32)
-    ADD_CUSTOM_TARGET(html
-      COMMAND if exist gen-images rmdir /s /q gen-images
-      COMMAND mkdir gen-images
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
-      COMMAND ${GHOSTSCRIPT_EXECUTABLE} -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
-      COMMAND if exist html rmdir /s /q html
-      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
-      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-  ENDIF(UNIX)
-ENDIF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
-
-INSTALL(
-  DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
-  DESTINATION doc
-  COMPONENT html_documentation)
Index: doc/Doxyfile.in
===================================================================
--- doc/Doxyfile.in	(revision 226)
+++ doc/Doxyfile.in	(revision 212)
@@ -16,6 +16,6 @@
 INLINE_INHERITED_MEMB  = NO
 FULL_PATH_NAMES        = YES
-STRIP_FROM_PATH        = "@abs_top_srcdir@"
-STRIP_FROM_INC_PATH    = "@abs_top_srcdir@"
+STRIP_FROM_PATH        = @abs_top_srcdir@
+STRIP_FROM_INC_PATH    = @abs_top_srcdir@
 SHORT_NAMES            = YES
 JAVADOC_AUTOBRIEF      = NO
@@ -81,11 +81,11 @@
 # configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = "@abs_top_srcdir@/doc" \
-                         "@abs_top_srcdir@/lemon" \
-                         "@abs_top_srcdir@/lemon/bits" \
-                         "@abs_top_srcdir@/lemon/concepts" \
-                         "@abs_top_srcdir@/demo" \
-                         "@abs_top_srcdir@/tools" \
-                         "@abs_top_srcdir@/test/test_tools.h"
+INPUT                  = @abs_top_srcdir@/doc \
+                         @abs_top_srcdir@/lemon \
+                         @abs_top_srcdir@/lemon/bits \
+                         @abs_top_srcdir@/lemon/concepts \
+                         @abs_top_srcdir@/demo \
+                         @abs_top_srcdir@/tools \
+                         @abs_top_srcdir@/test/test_tools.h
 INPUT_ENCODING         = UTF-8
 FILE_PATTERNS          = *.h \
@@ -97,11 +97,11 @@
 EXCLUDE_PATTERNS       = 
 EXCLUDE_SYMBOLS        = 
-EXAMPLE_PATH           = "@abs_top_srcdir@/demo" \
-                         "@abs_top_srcdir@/LICENSE" \
-                         "@abs_top_srcdir@/doc"
+EXAMPLE_PATH           = @abs_top_srcdir@/demo \
+                         @abs_top_srcdir@/LICENSE \
+                         @abs_top_srcdir@/doc
 EXAMPLE_PATTERNS       = 
 EXAMPLE_RECURSIVE      = NO
-IMAGE_PATH             = "@abs_top_srcdir@/doc/images" \
-                         "@abs_top_builddir@/doc/gen-images"
+IMAGE_PATH             = @abs_top_srcdir@/doc/images \
+                         @abs_top_builddir@/doc/gen-images
 INPUT_FILTER           = 
 FILTER_PATTERNS        = 
@@ -146,5 +146,5 @@
 DISABLE_INDEX          = NO
 ENUM_VALUES_PER_LINE   = 4
-GENERATE_TREEVIEW      = NO
+GENERATE_TREEVIEW      = YES
 TREEVIEW_WIDTH         = 250
 #---------------------------------------------------------------------------
Index: doc/Makefile.am
===================================================================
--- doc/Makefile.am	(revision 227)
+++ doc/Makefile.am	(revision 156)
@@ -8,6 +8,5 @@
 	doc/mainpage.dox \
 	doc/namespaces.dox \
-	doc/html \
-	doc/CMakeLists.txt
+	doc/html
 
 DOC_EPS_IMAGES18 = \
Index: doc/groups.dox
===================================================================
--- doc/groups.dox	(revision 236)
+++ doc/groups.dox	(revision 210)
@@ -326,5 +326,5 @@
 maximum cardinality matching.
 
-LEMON contains the next algorithms:
+Lemon contains the next algorithms:
 - \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp
   augmenting path algorithm for calculate maximum cardinality matching in
@@ -477,10 +477,10 @@
 
 /**
-@defgroup lemon_io LEMON Input-Output
+@defgroup lemon_io Lemon Input-Output
 @ingroup io_group
-\brief Reading and writing \ref lgf-format "LEMON Graph Format".
+\brief Reading and writing \ref lgf-format "Lemon Graph Format".
 
 This group describes methods for reading and writing
-\ref lgf-format "LEMON Graph Format".
+\ref lgf-format "Lemon Graph Format".
 */
 
Index: doc/lgf.dox
===================================================================
--- doc/lgf.dox	(revision 236)
+++ doc/lgf.dox	(revision 212)
@@ -22,5 +22,5 @@
 
 
-\page lgf-format LEMON Graph Format (LGF)
+\page lgf-format Lemon Graph Format (LGF)
 
 The \e LGF is a <em>column oriented</em>
Index: lemon/CMakeLists.txt
===================================================================
--- lemon/CMakeLists.txt	(revision 225)
+++ lemon/CMakeLists.txt	(revision 141)
@@ -1,18 +1,2 @@
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
-
-ADD_LIBRARY(lemon
-  arg_parser.cc
-  base.cc
-  color.cc
-  random.cc)
-
-INSTALL(
-  TARGETS lemon
-  ARCHIVE DESTINATION lib
-  COMPONENT library)
-
-INSTALL(
-  DIRECTORY . bits concepts
-  DESTINATION include/lemon
-  COMPONENT headers
-  FILES_MATCHING PATTERN "*.h")
+include_directories (${LEMON_SOURCE_DIR})
+add_library (lemon arg_parser.cc base.cc color.cc random.cc)
Index: lemon/Makefile.am
===================================================================
--- lemon/Makefile.am	(revision 220)
+++ lemon/Makefile.am	(revision 195)
@@ -25,5 +25,4 @@
 	lemon/concept_check.h \
         lemon/counter.h \
-	lemon/core.h \
         lemon/dfs.h \
         lemon/dijkstra.h \
@@ -31,4 +30,5 @@
 	lemon/error.h \
         lemon/graph_to_eps.h \
+	lemon/graph_utils.h \
 	lemon/kruskal.h \
 	lemon/lgf_reader.h \
@@ -50,9 +50,10 @@
         lemon/bits/bezier.h \
 	lemon/bits/default_map.h \
-        lemon/bits/enable_if.h \
 	lemon/bits/graph_extender.h \
+        lemon/bits/invalid.h \
 	lemon/bits/map_extender.h \
 	lemon/bits/path_dump.h \
 	lemon/bits/traits.h \
+        lemon/bits/utility.h \
 	lemon/bits/vector_map.h
 
Index: lemon/assert.h
===================================================================
--- lemon/assert.h	(revision 218)
+++ lemon/assert.h	(revision 212)
@@ -238,5 +238,5 @@
 
 #    if LEMON_ENABLE_DEBUG
-#      define LEMON_DEBUG(exp, msg)                                     \
+#      define LEMON_DEBUG(exp, msg)
          (static_cast<void> (!!(exp) ? 0 : (                            \
            LEMON_ASSERT_HANDLER(__FILE__, __LINE__,                     \
Index: lemon/base.cc
===================================================================
--- lemon/base.cc	(revision 220)
+++ lemon/base.cc	(revision 209)
@@ -21,5 +21,5 @@
 
 #include<lemon/tolerance.h>
-#include<lemon/core.h>
+#include<lemon/bits/invalid.h>
 namespace lemon {
 
Index: lemon/bfs.h
===================================================================
--- lemon/bfs.h	(revision 220)
+++ lemon/bfs.h	(revision 244)
@@ -22,15 +22,14 @@
 ///\ingroup search
 ///\file
-///\brief Bfs algorithm.
+///\brief BFS algorithm.
 
 #include <lemon/list_graph.h>
+#include <lemon/graph_utils.h>
 #include <lemon/bits/path_dump.h>
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 #include <lemon/error.h>
 #include <lemon/maps.h>
 
 namespace lemon {
-
-
 
   ///Default traits class of Bfs class.
@@ -41,30 +40,32 @@
   struct BfsDefaultTraits
   {
-    ///The digraph type the algorithm runs on.
+    ///The type of the digraph the algorithm runs on.
     typedef GR Digraph;
-    ///\brief The type of the map that stores the last
+
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///
-    ///The type of the map that stores the last
+    ///The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef typename Digraph::template NodeMap<typename GR::Arc> PredMap;
-    ///Instantiates a PredMap.
+    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+    ///Instantiates a \ref PredMap.
 
     ///This function instantiates a \ref PredMap.
-    ///\param G is the digraph, to which we would like to define the 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
-    static PredMap *createPredMap(const GR &G)
-    {
-      return new PredMap(G);
-    }
+    static PredMap *createPredMap(const Digraph &g)
+    {
+      return new PredMap(g);
+    }
+
     ///The type of the map that indicates which nodes are processed.
 
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
+    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a ProcessedMap.
+    ///Instantiates a \ref ProcessedMap.
 
     ///This function instantiates a \ref ProcessedMap.
@@ -72,40 +73,40 @@
     ///we would like to define the \ref ProcessedMap
 #ifdef DOXYGEN
-    static ProcessedMap *createProcessedMap(const GR &g)
+    static ProcessedMap *createProcessedMap(const Digraph &g)
 #else
-    static ProcessedMap *createProcessedMap(const GR &)
+    static ProcessedMap *createProcessedMap(const Digraph &)
 #endif
     {
       return new ProcessedMap();
     }
+
     ///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.
+    typedef typename Digraph::template NodeMap<bool> ReachedMap;
+    ///Instantiates a \ref ReachedMap.
+
+    ///This function instantiates a \ref ReachedMap.
+    ///\param g is the digraph, to which
+    ///we would like to define the \ref ReachedMap.
+    static ReachedMap *createReachedMap(const Digraph &g)
+    {
+      return new ReachedMap(g);
+    }
+
+    ///The type of the map that stores the distances of the nodes.
+
+    ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
-    typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
-    ///\param G is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
-    static ReachedMap *createReachedMap(const GR &G)
-    {
-      return new ReachedMap(G);
-    }
-    ///The type of the map that stores the dists of the nodes.
-
-    ///The type of the map that stores the dists of the nodes.
-    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
     typedef typename Digraph::template NodeMap<int> DistMap;
-    ///Instantiates a DistMap.
+    ///Instantiates a \ref DistMap.
 
     ///This function instantiates a \ref DistMap.
-    ///\param G is the digraph, to which we would like to define
-    ///the \ref DistMap
-    static DistMap *createDistMap(const GR &G)
-    {
-      return new DistMap(G);
+    ///\param g is the digraph, to which we would like to define the
+    ///\ref DistMap.
+    static DistMap *createDistMap(const Digraph &g)
+    {
+      return new DistMap(g);
     }
   };
@@ -116,7 +117,11 @@
   ///This class provides an efficient implementation of the %BFS algorithm.
   ///
-  ///\tparam GR The digraph type the algorithm runs on. The default value is
-  ///\ref ListDigraph. The value of GR is not used directly by Bfs, it
-  ///is only passed to \ref BfsDefaultTraits.
+  ///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.
+  ///
+  ///\tparam GR The type of the digraph the algorithm runs on.
+  ///The default value is \ref ListDigraph. The value of GR is not used
+  ///directly by \ref Bfs, it is only passed to \ref BfsDefaultTraits.
   ///\tparam TR Traits class to set various data types used by the algorithm.
   ///The default traits class is
@@ -124,5 +129,4 @@
   ///See \ref BfsDefaultTraits for the documentation of
   ///a Bfs traits class.
-
 #ifdef DOXYGEN
   template <typename GR,
@@ -134,10 +138,8 @@
   class Bfs {
   public:
-    /**
-     * \brief \ref Exception for uninitialized parameters.
-     *
-     * This error represents problems in the initialization
-     * of the parameters of the algorithms.
-     */
+    ///\ref Exception for uninitialized parameters.
+
+    ///This error represents problems in the initialization of the
+    ///parameters of the algorithm.
     class UninitializedParameter : public lemon::UninitializedParameter {
     public:
@@ -147,17 +149,22 @@
     };
 
+    ///The type of the digraph the algorithm runs on.
+    typedef typename TR::Digraph Digraph;
+
+    ///\brief The type of the map that stores the predecessor arcs of the
+    ///shortest paths.
+    typedef typename TR::PredMap PredMap;
+    ///The type of the map that stores the distances of the nodes.
+    typedef typename TR::DistMap DistMap;
+    ///The type of the map that indicates which nodes are reached.
+    typedef typename TR::ReachedMap ReachedMap;
+    ///The type of the map that indicates which nodes are processed.
+    typedef typename TR::ProcessedMap ProcessedMap;
+    ///The type of the paths.
+    typedef PredMapPath<Digraph, PredMap> Path;
+
+    ///The traits class.
     typedef TR Traits;
-    ///The type of the underlying digraph.
-    typedef typename TR::Digraph Digraph;
-
-    ///\brief The type of the map that stores the last
-    ///arcs of the shortest paths.
-    typedef typename TR::PredMap PredMap;
-    ///The type of the map indicating which nodes are reached.
-    typedef typename TR::ReachedMap ReachedMap;
-    ///The type of the map indicating which nodes are processed.
-    typedef typename TR::ProcessedMap ProcessedMap;
-    ///The type of the map that stores the dists of the nodes.
-    typedef typename TR::DistMap DistMap;
+
   private:
 
@@ -167,21 +174,21 @@
     typedef typename Digraph::OutArcIt OutArcIt;
 
-    /// Pointer to the underlying digraph.
+    //Pointer to the underlying digraph.
     const Digraph *G;
-    ///Pointer to the map of predecessors arcs.
+    //Pointer to the map of predecessor arcs.
     PredMap *_pred;
-    ///Indicates if \ref _pred is locally allocated (\c true) or not.
+    //Indicates if _pred is locally allocated (true) or not.
     bool local_pred;
-    ///Pointer to the map of distances.
+    //Pointer to the map of distances.
     DistMap *_dist;
-    ///Indicates if \ref _dist is locally allocated (\c true) or not.
+    //Indicates if _dist is locally allocated (true) or not.
     bool local_dist;
-    ///Pointer to the map of reached status of the nodes.
+    //Pointer to the map of reached status of the nodes.
     ReachedMap *_reached;
-    ///Indicates if \ref _reached is locally allocated (\c true) or not.
+    //Indicates if _reached is locally allocated (true) or not.
     bool local_reached;
-    ///Pointer to the map of processed status of the nodes.
+    //Pointer to the map of processed status of the nodes.
     ProcessedMap *_processed;
-    ///Indicates if \ref _processed is locally allocated (\c true) or not.
+    //Indicates if _processed is locally allocated (true) or not.
     bool local_processed;
 
@@ -191,5 +198,4 @@
 
     ///Creates the maps if necessary.
-
     ///\todo Better memory allocation (instead of new).
     void create_maps()
@@ -234,8 +240,8 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///PredMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting PredMap type
-    ///
+    ///\ref PredMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref PredMap type.
     template <class T>
     struct DefPredMap : public Bfs< Digraph, DefPredMapTraits<T> > {
@@ -252,8 +258,8 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///DistMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting DistMap type
-    ///
+    ///\ref DistMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref DistMap type.
     template <class T>
     struct DefDistMap : public Bfs< Digraph, DefDistMapTraits<T> > {
@@ -270,8 +276,8 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///ReachedMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting ReachedMap type
-    ///
+    ///\ref ReachedMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref ReachedMap type.
     template <class T>
     struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits<T> > {
@@ -288,8 +294,8 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///ProcessedMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
-    ///
+    ///\ref ProcessedMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref ProcessedMap type.
     template <class T>
     struct DefProcessedMap : public Bfs< Digraph, DefProcessedMapTraits<T> > {
@@ -299,14 +305,14 @@
     struct DefDigraphProcessedMapTraits : public Traits {
       typedef typename Digraph::template NodeMap<bool> ProcessedMap;
-      static ProcessedMap *createProcessedMap(const Digraph &G)
+      static ProcessedMap *createProcessedMap(const Digraph &g)
       {
-        return new ProcessedMap(G);
-      }
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting the ProcessedMap type to be Digraph::NodeMap<bool>.
-    ///
-    ///\ref named-templ-param "Named parameter"
-    ///for setting the ProcessedMap type to be Digraph::NodeMap<bool>.
+        return new ProcessedMap(g);
+      }
+    };
+    ///\brief \ref named-templ-param "Named parameter" for setting
+    ///\ref 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>.
     ///If you don't set it explicitly, it will be automatically allocated.
     template <class T>
@@ -322,8 +328,8 @@
     ///Constructor.
 
-    ///\param _G the digraph the algorithm will run on.
-    ///
-    Bfs(const Digraph& _G) :
-      G(&_G),
+    ///Constructor.
+    ///\param g The digraph the algorithm runs on.
+    Bfs(const Digraph &g) :
+      G(&g),
       _pred(NULL), local_pred(false),
       _dist(NULL), local_dist(false),
@@ -341,7 +347,7 @@
     }
 
-    ///Sets the map storing the predecessor arcs.
-
-    ///Sets the map storing the predecessor arcs.
+    ///Sets the map that stores the predecessor arcs.
+
+    ///Sets the map that stores the predecessor arcs.
     ///If you don't use this function before calling \ref run(),
     ///it will allocate one. The destructor deallocates this
@@ -358,7 +364,7 @@
     }
 
-    ///Sets the map indicating the reached nodes.
-
-    ///Sets the map indicating the reached nodes.
+    ///Sets the map that indicates which nodes are reached.
+
+    ///Sets the map that indicates which nodes are reached.
     ///If you don't use this function before calling \ref run(),
     ///it will allocate one. The destructor deallocates this
@@ -375,7 +381,7 @@
     }
 
-    ///Sets the map indicating the processed nodes.
-
-    ///Sets the map indicating the processed nodes.
+    ///Sets the map that indicates which nodes are processed.
+
+    ///Sets the map that indicates which nodes are processed.
     ///If you don't use this function before calling \ref run(),
     ///it will allocate one. The destructor deallocates this
@@ -392,7 +398,8 @@
     }
 
-    ///Sets the map storing the distances calculated by the algorithm.
-
-    ///Sets the map storing the distances calculated by the algorithm.
+    ///Sets the map that stores the distances of the nodes.
+
+    ///Sets the map that stores the distances of the nodes calculated by
+    ///the algorithm.
     ///If you don't use this function before calling \ref run(),
     ///it will allocate one. The destructor deallocates this
@@ -410,18 +417,19 @@
 
   public:
+
     ///\name Execution control
     ///The simplest way to execute the algorithm is to use
-    ///one of the member functions called \c run(...).
+    ///one of the member functions called \ref lemon::Bfs::run() "run()".
     ///\n
-    ///If you need more control on the execution,
-    ///first you must call \ref init(), then you can add several source nodes
-    ///with \ref addSource().
-    ///Finally \ref start() will perform the actual path
-    ///computation.
+    ///If you need more control on the execution, first you must call
+    ///\ref lemon::Bfs::init() "init()", then you can add several source
+    ///nodes with \ref lemon::Bfs::addSource() "addSource()".
+    ///Finally \ref lemon::Bfs::start() "start()" will perform the
+    ///actual path computation.
 
     ///@{
 
-    ///\brief Initializes the internal data structures.
-    ///
+    ///Initializes the internal data structures.
+
     ///Initializes the internal data structures.
     ///
@@ -461,5 +469,5 @@
     ///\return The processed node.
     ///
-    ///\warning The queue must not be empty!
+    ///\pre The queue must not be empty.
     Node processNextNode()
     {
@@ -483,14 +491,15 @@
     ///Processes the next node.
 
-    ///Processes the next node. And checks that the given target node
+    ///Processes the next node and checks if the given target node
     ///is reached. If the target node is reachable from the processed
-    ///node then the reached parameter will be set true. The reached
-    ///parameter should be initially false.
+    ///node, then the \c reach parameter will be set to \c true.
     ///
     ///\param target The target node.
-    ///\retval reach Indicates that the target node is reached.
+    ///\retval reach Indicates if the target node is reached.
+    ///It should be initially \c false.
+    ///
     ///\return The processed node.
     ///
-    ///\warning The queue must not be empty!
+    ///\pre The queue must not be empty.
     Node processNextNode(Node target, bool& reach)
     {
@@ -515,14 +524,17 @@
     ///Processes the next node.
 
-    ///Processes the next node. And checks that at least one of
-    ///reached node has true value in the \c nm node map. If one node
-    ///with true value is reachable from the processed node then the
-    ///rnode parameter will be set to the first of such nodes.
-    ///
-    ///\param nm The node map of possible targets.
+    ///Processes the next node and checks if at least one of reached
+    ///nodes has \c true value in the \c nm node map. If one node
+    ///with \c true value is reachable from the processed node, then the
+    ///\c rnode parameter will be set to the first of such nodes.
+    ///
+    ///\param nm A \c bool (or convertible) node map that indicates the
+    ///possible targets.
     ///\retval rnode The reached target node.
+    ///It should be initially \c INVALID.
+    ///
     ///\return The processed node.
     ///
-    ///\warning The queue must not be empty!
+    ///\pre The queue must not be empty.
     template<class NM>
     Node processNextNode(const NM& nm, Node& rnode)
@@ -546,11 +558,9 @@
     }
 
-    ///Next node to be processed.
-
-    ///Next node to be processed.
-    ///
-    ///\return The next node to be processed or INVALID if the queue is
-    /// empty.
-    Node nextNode()
+    ///The next node to be processed.
+
+    ///Returns the next node to be processed or \c INVALID if the queue
+    ///is empty.
+    Node nextNode() const
     {
       return _queue_tail<_queue_head?_queue[_queue_tail]:INVALID;
@@ -558,13 +568,14 @@
 
     ///\brief Returns \c false if there are nodes
-    ///to be processed in the queue
+    ///to be processed.
     ///
     ///Returns \c false if there are nodes
-    ///to be processed in the queue
-    bool emptyQueue() { return _queue_tail==_queue_head; }
+    ///to be processed in the queue.
+    bool emptyQueue() const { return _queue_tail==_queue_head; }
+
     ///Returns the number of the nodes to be processed.
 
     ///Returns the number of the nodes to be processed in the queue.
-    int queueSize() { return _queue_head-_queue_tail; }
+    int queueSize() const { return _queue_head-_queue_tail; }
 
     ///Executes the algorithm.
@@ -572,13 +583,20 @@
     ///Executes the algorithm.
     ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
-    ///
     ///This method runs the %BFS algorithm from the root node(s)
-    ///in order to
-    ///compute the
-    ///shortest path to each node. The algorithm computes
-    ///- The shortest path tree.
-    ///- The distance of each node from the root(s).
+    ///in order to compute the shortest path to each node.
+    ///
+    ///The algorithm computes
+    ///- the shortest path tree (forest),
+    ///- the distance of each node from the root(s).
+    ///
+    ///\pre init() must be called and at least one root node should be
+    ///added with addSource() before using this function.
+    ///
+    ///\note <tt>b.start()</tt> is just a shortcut of the following code.
+    ///\code
+    ///  while ( !b.emptyQueue() ) {
+    ///    b.processNextNode();
+    ///  }
+    ///\endcode
     void start()
     {
@@ -586,16 +604,25 @@
     }
 
-    ///Executes the algorithm until \c dest is reached.
-
-    ///Executes the algorithm until \c dest is reached.
-    ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
+    ///Executes the algorithm until the given target node is reached.
+
+    ///Executes the algorithm until the given target node is reached.
     ///
     ///This method runs the %BFS algorithm from the root node(s)
     ///in order to compute the shortest path to \c dest.
+    ///
     ///The algorithm computes
-    ///- The shortest path to \c  dest.
-    ///- The distance of \c dest from the root(s).
+    ///- the shortest path to \c dest,
+    ///- the distance of \c dest from the root(s).
+    ///
+    ///\pre init() must be called and at least one root node should be
+    ///added with addSource() before using this function.
+    ///
+    ///\note <tt>b.start(t)</tt> is just a shortcut of the following code.
+    ///\code
+    ///  bool reach = false;
+    ///  while ( !b.emptyQueue() && !reach ) {
+    ///    b.processNextNode(t, reach);
+    ///  }
+    ///\endcode
     void start(Node dest)
     {
@@ -608,15 +635,27 @@
     ///Executes the algorithm until a condition is met.
     ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
-    ///
-    ///\param nm must be a bool (or convertible) node map. The
-    ///algorithm will stop when it reaches a node \c v with
-    /// <tt>nm[v]</tt> true.
+    ///This method runs the %BFS algorithm from the root node(s) in
+    ///order to compute the shortest path to a node \c v with
+    /// <tt>nm[v]</tt> true, if such a node can be found.
+    ///
+    ///\param nm A \c bool (or convertible) node map. The algorithm
+    ///will stop when it reaches a node \c v with <tt>nm[v]</tt> true.
     ///
     ///\return The reached node \c v with <tt>nm[v]</tt> true or
     ///\c INVALID if no such node was found.
-    template<class NM>
-    Node start(const NM &nm)
+    ///
+    ///\pre init() must be called and at least one root node should be
+    ///added with addSource() before using this function.
+    ///
+    ///\note <tt>b.start(nm)</tt> is just a shortcut of the following code.
+    ///\code
+    ///  Node rnode = INVALID;
+    ///  while ( !b.emptyQueue() && rnode == INVALID ) {
+    ///    b.processNextNode(nm, rnode);
+    ///  }
+    ///  return rnode;
+    ///\endcode
+    template<class NodeBoolMap>
+    Node start(const NodeBoolMap &nm)
     {
       Node rnode = INVALID;
@@ -627,14 +666,14 @@
     }
 
-    ///Runs %BFS algorithm from node \c s.
-
-    ///This method runs the %BFS algorithm from a root node \c s
-    ///in order to
-    ///compute the
-    ///shortest path to each node. The algorithm computes
-    ///- The shortest path tree.
-    ///- The distance of each node from the root.
-    ///
-    ///\note b.run(s) is just a shortcut of the following code.
+    ///Runs the algorithm from the given node.
+
+    ///This method runs the %BFS algorithm from node \c s
+    ///in order to compute the shortest path to each node.
+    ///
+    ///The algorithm computes
+    ///- the shortest path tree,
+    ///- the distance of each node from the root.
+    ///
+    ///\note <tt>b.run(s)</tt> is just a shortcut of the following code.
     ///\code
     ///  b.init();
@@ -650,10 +689,12 @@
     ///Finds the shortest path between \c s and \c t.
 
-    ///Finds the shortest path between \c s and \c t.
-    ///
-    ///\return The length of the shortest s---t path if there exists one,
-    ///0 otherwise.
-    ///\note Apart from the return value, b.run(s) is
-    ///just a shortcut of the following code.
+    ///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.
+    ///
+    ///\note Apart from the return value, <tt>b.run(s,t)</tt> is just a
+    ///shortcut of the following code.
     ///\code
     ///  b.init();
@@ -668,4 +709,33 @@
     }
 
+    ///Runs the algorithm to visit all nodes in the digraph.
+
+    ///This method runs the %BFS algorithm in order to
+    ///compute the shortest path to each node.
+    ///
+    ///The algorithm computes
+    ///- the shortest path tree (forest),
+    ///- the distance of each node from the root(s).
+    ///
+    ///\note <tt>b.run(s)</tt> is just a shortcut of the following code.
+    ///\code
+    ///  b.init();
+    ///  for (NodeIt n(gr); n != INVALID; ++n) {
+    ///    if (!b.reached(n)) {
+    ///      b.addSource(n);
+    ///      b.start();
+    ///    }
+    ///  }
+    ///\endcode
+    void run() {
+      init();
+      for (NodeIt n(*G); n != INVALID; ++n) {
+        if (!reached(n)) {
+          addSource(n);
+          start();
+        }
+      }
+    }
+
     ///@}
 
@@ -673,51 +743,54 @@
     ///The result of the %BFS algorithm can be obtained using these
     ///functions.\n
-    ///Before the use of these functions,
-    ///either run() or start() must be calleb.
+    ///Either \ref lemon::Bfs::run() "run()" or \ref lemon::Bfs::start()
+    ///"start()" must be called before using them.
 
     ///@{
 
-    typedef PredMapPath<Digraph, PredMap> Path;
-
-    ///Gives back the shortest path.
-
-    ///Gives back the shortest path.
-    ///\pre The \c t should be reachable from the source.
-    Path path(Node t)
-    {
-      return Path(*G, *_pred, t);
-    }
+    ///The shortest path to a node.
+
+    ///Returns the shortest path to a node.
+    ///
+    ///\warning \c t should be reachable from the root(s).
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
+    Path path(Node t) const { return Path(*G, *_pred, t); }
 
     ///The distance of a node from the root(s).
 
     ///Returns the distance of a node from the root(s).
-    ///\pre \ref run() must be called before using this function.
-    ///\warning If node \c v in unreachable from the root(s) the return value
-    ///of this function is undefined.
+    ///
+    ///\warning If node \c v is not reachable from the root(s), then
+    ///the return value of this function is undefined.
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
     int dist(Node v) const { return (*_dist)[v]; }
 
-    ///Returns the 'previous arc' of the shortest path tree.
-
-    ///For a node \c v it returns the 'previous arc'
-    ///of the shortest path tree,
-    ///i.e. it returns the last arc of a shortest path from the root(s) to \c
-    ///v. It is \ref INVALID
-    ///if \c v is unreachable from the root(s) or \c v is a root. The
-    ///shortest path tree used here is equal to the shortest path tree used in
-    ///\ref predNode().
-    ///\pre Either \ref run() or \ref start() must be called before using
-    ///this function.
+    ///Returns the 'previous arc' of the shortest path tree for a node.
+
+    ///This function returns the 'previous arc' of the shortest path
+    ///tree for the node \c v, i.e. it returns the last arc of a
+    ///shortest path from the root(s) to \c v. It is \c INVALID if \c v
+    ///is not reachable from the root(s) or if \c v is a root.
+    ///
+    ///The shortest path tree used here is equal to the shortest path
+    ///tree used in \ref predNode().
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
     Arc predArc(Node v) const { return (*_pred)[v];}
 
-    ///Returns the 'previous node' of the shortest path tree.
-
-    ///For a node \c v it returns the 'previous node'
-    ///of the shortest path tree,
-    ///i.e. it returns the last but one node from a shortest path from the
-    ///root(a) to \c /v.
-    ///It is INVALID if \c v is unreachable from the root(s) or
-    ///if \c v itself a root.
+    ///Returns the 'previous node' of the shortest path tree for a node.
+
+    ///This function returns the 'previous node' of the shortest path
+    ///tree for the node \c v, i.e. it returns the last but one node
+    ///from a shortest path from the root(s) to \c v. It is \c INVALID
+    ///if \c v is not reachable from the root(s) or if \c v is a root.
+    ///
     ///The shortest path tree used here is equal to the shortest path
     ///tree used in \ref predArc().
+    ///
     ///\pre Either \ref run() or \ref start() must be called before
     ///using this function.
@@ -725,57 +798,61 @@
                                   G->source((*_pred)[v]); }
 
-    ///Returns a reference to the NodeMap of distances.
-
-    ///Returns a reference to the NodeMap of distances.
-    ///\pre Either \ref run() or \ref init() must
-    ///be called before using this function.
+    ///\brief Returns a const reference to the node map that stores the
+    /// distances of the nodes.
+    ///
+    ///Returns a const reference to the node map that stores the distances
+    ///of the nodes calculated by the algorithm.
+    ///
+    ///\pre Either \ref run() or \ref init()
+    ///must be called before using this function.
     const DistMap &distMap() const { return *_dist;}
 
-    ///Returns a reference to the shortest path tree map.
-
-    ///Returns a reference to the NodeMap of the arcs of the
-    ///shortest path tree.
+    ///\brief Returns a const reference to the node map that stores the
+    ///predecessor arcs.
+    ///
+    ///Returns a const reference to the node map that stores the predecessor
+    ///arcs, which form the shortest path tree.
+    ///
     ///\pre Either \ref run() or \ref init()
     ///must be called before using this function.
     const PredMap &predMap() const { return *_pred;}
 
-    ///Checks if a node is reachable from the root.
-
-    ///Returns \c true if \c v is reachable from the root.
-    ///\warning The source nodes are indicated as unreached.
+    ///Checks if a node is reachable from the root(s).
+
+    ///Returns \c true if \c v is reachable from the root(s).
     ///\pre Either \ref run() or \ref start()
     ///must be called before using this function.
-    ///
-    bool reached(Node v) { return (*_reached)[v]; }
+    bool reached(Node v) const { return (*_reached)[v]; }
 
     ///@}
   };
 
-  ///Default traits class of Bfs function.
-
-  ///Default traits class of Bfs function.
+  ///Default traits class of bfs() function.
+
+  ///Default traits class of bfs() function.
   ///\tparam GR Digraph type.
   template<class GR>
   struct BfsWizardDefaultTraits
   {
-    ///The digraph type the algorithm runs on.
+    ///The type of the digraph the algorithm runs on.
     typedef GR Digraph;
-    ///\brief The type of the map that stores the last
+
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///
-    ///The type of the map that stores the last
+    ///The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef NullMap<typename Digraph::Node,typename GR::Arc> PredMap;
-    ///Instantiates a PredMap.
+    typedef NullMap<typename Digraph::Node,typename Digraph::Arc> PredMap;
+    ///Instantiates a \ref PredMap.
 
     ///This function instantiates a \ref PredMap.
-    ///\param g is the digraph, to which we would like to define the 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
-    static PredMap *createPredMap(const GR &g)
+    static PredMap *createPredMap(const Digraph &g)
 #else
-    static PredMap *createPredMap(const GR &)
+    static PredMap *createPredMap(const Digraph &)
 #endif
     {
@@ -787,41 +864,41 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a ProcessedMap.
+    ///Instantiates a \ref ProcessedMap.
 
     ///This function instantiates a \ref ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap
+    ///we would like to define the \ref ProcessedMap.
 #ifdef DOXYGEN
-    static ProcessedMap *createProcessedMap(const GR &g)
+    static ProcessedMap *createProcessedMap(const Digraph &g)
 #else
-    static ProcessedMap *createProcessedMap(const GR &)
+    static ProcessedMap *createProcessedMap(const Digraph &)
 #endif
     {
       return new ProcessedMap();
     }
+
     ///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.
+    typedef typename Digraph::template NodeMap<bool> ReachedMap;
+    ///Instantiates a \ref ReachedMap.
+
+    ///This function instantiates a \ref ReachedMap.
+    ///\param g is the digraph, to which
+    ///we would like to define the \ref ReachedMap.
+    static ReachedMap *createReachedMap(const Digraph &g)
+    {
+      return new ReachedMap(g);
+    }
+
+    ///The type of the map that stores the distances of the nodes.
+
+    ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
-    typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
-    ///\param G is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
-    static ReachedMap *createReachedMap(const GR &G)
-    {
-      return new ReachedMap(G);
-    }
-    ///The type of the map that stores the dists of the nodes.
-
-    ///The type of the map that stores the dists of the nodes.
-    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     ///
     typedef NullMap<typename Digraph::Node,int> DistMap;
-    ///Instantiates a DistMap.
+    ///Instantiates a \ref DistMap.
 
     ///This function instantiates a \ref DistMap.
@@ -829,7 +906,7 @@
     ///the \ref DistMap
 #ifdef DOXYGEN
-    static DistMap *createDistMap(const GR &g)
+    static DistMap *createDistMap(const Digraph &g)
 #else
-    static DistMap *createDistMap(const GR &)
+    static DistMap *createDistMap(const Digraph &)
 #endif
     {
@@ -838,10 +915,10 @@
   };
 
-  /// Default traits used by \ref BfsWizard
+  /// Default traits class used by \ref BfsWizard
 
   /// To make it easier to use Bfs algorithm
-  ///we have created a wizard class.
+  /// we have created a wizard class.
   /// This \ref BfsWizard class needs default traits,
-  ///as well as the \ref Bfs class.
+  /// as well as the \ref Bfs class.
   /// The \ref BfsWizardBase is a class to be the default traits of the
   /// \ref BfsWizard class.
@@ -852,18 +929,18 @@
     typedef BfsWizardDefaultTraits<GR> Base;
   protected:
-    /// Type of the nodes in the digraph.
+    //The type of the nodes in the digraph.
     typedef typename Base::Digraph::Node Node;
 
-    /// Pointer to the underlying digraph.
+    //Pointer to the digraph the algorithm runs on.
     void *_g;
-    ///Pointer to the map of reached nodes.
+    //Pointer to the map of reached nodes.
     void *_reached;
-    ///Pointer to the map of processed nodes.
+    //Pointer to the map of processed nodes.
     void *_processed;
-    ///Pointer to the map of predecessors arcs.
+    //Pointer to the map of predecessors arcs.
     void *_pred;
-    ///Pointer to the map of distances.
+    //Pointer to the map of distances.
     void *_dist;
-    ///Pointer to the source node.
+    //Pointer to the source node.
     Node _source;
 
@@ -874,5 +951,5 @@
     /// all of the attributes to default values (0, INVALID).
     BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
-                           _dist(0), _source(INVALID) {}
+                      _dist(0), _source(INVALID) {}
 
     /// Constructor.
@@ -881,6 +958,6 @@
     /// listed in the parameters list.
     /// Others are initiated to 0.
-    /// \param g is the initial value of  \ref _g
-    /// \param s is the initial value of  \ref _source
+    /// \param g The digraph the algorithm runs on.
+    /// \param s The source node.
     BfsWizardBase(const GR &g, Node s=INVALID) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
@@ -889,9 +966,11 @@
   };
 
-  /// A class to make the usage of Bfs algorithm easier
-
-  /// This class is created to make it easier to use Bfs algorithm.
-  /// It uses the functions and features of the plain \ref Bfs,
-  /// but it is much simpler to use it.
+  /// 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.
   ///
   /// Simplicity means that the way to change the types defined
@@ -902,10 +981,10 @@
   /// the original class by using the ::
   /// operator. In the case of \ref BfsWizard only
-  /// a function have to be called and it will
+  /// 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 class, and calls the \ref Bfs::run
-  /// method of it.
+  /// 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.
   template<class TR>
   class BfsWizard : public TR
@@ -913,28 +992,24 @@
     typedef TR Base;
 
-    ///The type of the underlying digraph.
+    ///The type of the digraph the algorithm runs on.
     typedef typename TR::Digraph Digraph;
-    //\e
+
     typedef typename Digraph::Node Node;
-    //\e
     typedef typename Digraph::NodeIt NodeIt;
-    //\e
     typedef typename Digraph::Arc Arc;
-    //\e
     typedef typename Digraph::OutArcIt OutArcIt;
 
-    ///\brief The type of the map that stores
-    ///the reached nodes
-    typedef typename TR::ReachedMap ReachedMap;
-    ///\brief The type of the map that stores
-    ///the processed nodes
-    typedef typename TR::ProcessedMap ProcessedMap;
-    ///\brief The type of the map that stores the last
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     typedef typename TR::PredMap PredMap;
-    ///The type of the map that stores the dists of the nodes.
+    ///\brief The type of the map that stores the distances of the nodes.
     typedef typename TR::DistMap DistMap;
+    ///\brief The type of the map that indicates which nodes are reached.
+    typedef typename TR::ReachedMap ReachedMap;
+    ///\brief The type of the map that indicates which nodes are processed.
+    typedef typename TR::ProcessedMap ProcessedMap;
 
   public:
+
     /// Constructor.
     BfsWizard() : TR() {}
@@ -952,8 +1027,8 @@
     ~BfsWizard() {}
 
-    ///Runs Bfs algorithm from a given node.
-
-    ///Runs Bfs algorithm from a given node.
-    ///The node can be given by the \ref source function.
+    ///Runs BFS algorithm from a source node.
+
+    ///Runs BFS algorithm from a source node.
+    ///The node can be given with the \ref source() function.
     void run()
     {
@@ -971,7 +1046,7 @@
     }
 
-    ///Runs Bfs algorithm from the given node.
-
-    ///Runs Bfs algorithm from the given node.
+    ///Runs BFS algorithm from the given node.
+
+    ///Runs BFS algorithm from the given node.
     ///\param s is the given source.
     void run(Node s)
@@ -979,4 +1054,14 @@
       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;
     }
 
@@ -987,11 +1072,9 @@
       DefPredMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting PredMap
+    ///for setting \ref PredMap object.
     ///
     /// \ref named-templ-param "Named parameter"
-    ///function for setting PredMap
-    ///
+    ///for setting \ref PredMap object.
     template<class T>
     BfsWizard<DefPredMapBase<T> > predMap(const T &t)
@@ -1000,5 +1083,4 @@
       return BfsWizard<DefPredMapBase<T> >(*this);
     }
-
 
     template<class T>
@@ -1008,11 +1090,9 @@
       DefReachedMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting ReachedMap
+    ///for setting \ref ReachedMap object.
     ///
     /// \ref named-templ-param "Named parameter"
-    ///function for setting ReachedMap
-    ///
+    ///for setting \ref ReachedMap object.
     template<class T>
     BfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
@@ -1021,5 +1101,4 @@
       return BfsWizard<DefReachedMapBase<T> >(*this);
     }
-
 
     template<class T>
@@ -1029,11 +1108,9 @@
       DefProcessedMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting ProcessedMap
+    ///for setting \ref ProcessedMap object.
     ///
     /// \ref named-templ-param "Named parameter"
-    ///function for setting ProcessedMap
-    ///
+    ///for setting \ref ProcessedMap object.
     template<class T>
     BfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
@@ -1042,5 +1119,4 @@
       return BfsWizard<DefProcessedMapBase<T> >(*this);
     }
-
 
     template<class T>
@@ -1050,11 +1126,9 @@
       DefDistMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting DistMap type
+    ///for setting \ref DistMap object.
     ///
     /// \ref named-templ-param "Named parameter"
-    ///function for setting DistMap type
-    ///
+    ///for setting \ref DistMap object.
     template<class T>
     BfsWizard<DefDistMapBase<T> > distMap(const T &t)
@@ -1062,14 +1136,4 @@
       Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
       return BfsWizard<DefDistMapBase<T> >(*this);
-    }
-
-    /// 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;
     }
 
@@ -1101,8 +1165,8 @@
 
 #ifdef DOXYGEN
-  /// \brief Visitor class for bfs.
+  /// \brief Visitor class for BFS.
   ///
   /// This class defines the interface of the BfsVisit events, and
-  /// it could be the base of a real Visitor class.
+  /// it could be the base of a real visitor class.
   template <typename _Digraph>
   struct BfsVisitor {
@@ -1110,27 +1174,27 @@
     typedef typename Digraph::Arc Arc;
     typedef typename Digraph::Node Node;
-    /// \brief Called when the arc reach a node.
-    ///
-    /// It is called when the bfs find an arc which target is not
-    /// reached yet.
+    /// \brief Called for the source node(s) of the BFS.
+    ///
+    /// This function is called for the source node(s) of the BFS.
+    void start(const Node& node) {}
+    /// \brief Called when a node is reached first time.
+    ///
+    /// This function is called when a node is reached first time.
+    void reach(const Node& node) {}
+    /// \brief Called when a node is processed.
+    ///
+    /// This function is called when a node is processed.
+    void process(const Node& node) {}
+    /// \brief Called when an arc reaches a new node.
+    ///
+    /// This function is called when the BFS finds an arc whose target node
+    /// is not reached yet.
     void discover(const Arc& arc) {}
-    /// \brief Called when the node reached first time.
-    ///
-    /// It is Called when the node reached first time.
-    void reach(const Node& node) {}
-    /// \brief Called when the arc examined but target of the arc
+    /// \brief Called when an arc is examined but its target node is
     /// already discovered.
     ///
-    /// It called when the arc examined but the target of the arc
+    /// This function is called when an arc is examined but its target node is
     /// already discovered.
     void examine(const Arc& arc) {}
-    /// \brief Called for the source node of the bfs.
-    ///
-    /// It is called for the source node of the bfs.
-    void start(const Node& node) {}
-    /// \brief Called when the node processed.
-    ///
-    /// It is Called when the node processed.
-    void process(const Node& node) {}
   };
 #else
@@ -1140,9 +1204,9 @@
     typedef typename Digraph::Arc Arc;
     typedef typename Digraph::Node Node;
+    void start(const Node&) {}
+    void reach(const Node&) {}
+    void process(const Node&) {}
     void discover(const Arc&) {}
-    void reach(const Node&) {}
     void examine(const Arc&) {}
-    void start(const Node&) {}
-    void process(const Node&) {}
 
     template <typename _Visitor>
@@ -1151,9 +1215,9 @@
         Arc arc;
         Node node;
+        visitor.start(node);
+        visitor.reach(node);
+        visitor.process(node);
         visitor.discover(arc);
-        visitor.reach(node);
         visitor.examine(arc);
-        visitor.start(node);
-        visitor.process(node);
       }
       _Visitor& visitor;
@@ -1165,9 +1229,9 @@
   ///
   /// Default traits class of BfsVisit class.
-  /// \tparam _Digraph Digraph type.
+  /// \tparam _Digraph The type of the digraph the algorithm runs on.
   template<class _Digraph>
   struct BfsVisitDefaultTraits {
 
-    /// \brief The digraph type the algorithm runs on.
+    /// \brief The type of the digraph the algorithm runs on.
     typedef _Digraph Digraph;
 
@@ -1175,9 +1239,8 @@
     ///
     /// The type of the map that indicates which nodes are reached.
-    /// It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    /// \todo named parameter to set this type, function to read and write.
+    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
 
-    /// \brief Instantiates a ReachedMap.
+    /// \brief Instantiates a \ref ReachedMap.
     ///
     /// This function instantiates a \ref ReachedMap.
@@ -1192,5 +1255,5 @@
   /// \ingroup search
   ///
-  /// \brief %BFS Visit algorithm class.
+  /// \brief %BFS algorithm class with visitor interface.
   ///
   /// This class provides an efficient implementation of the %BFS algorithm
@@ -1199,19 +1262,19 @@
   /// The %BfsVisit class provides an alternative interface to the Bfs
   /// class. It works with callback mechanism, the BfsVisit object calls
-  /// on every bfs event the \c Visitor class member functions.
+  /// the member functions of the \c Visitor class on every BFS event.
   ///
-  /// \tparam _Digraph The digraph type the algorithm runs on.
+  /// \tparam _Digraph The type of the digraph the algorithm runs on.
   /// The default value is
-  /// \ref ListDigraph. The value of _Digraph is not used directly by Bfs, it
-  /// is only passed to \ref BfsDefaultTraits.
-  /// \tparam _Visitor The Visitor object for the algorithm. The
-  /// \ref BfsVisitor "BfsVisitor<_Digraph>" is an empty Visitor which
-  /// does not observe the Bfs events. If you want to observe the bfs
-  /// events you should implement your own Visitor class.
+  /// \ref ListDigraph. The value of _Digraph is not used directly by
+  /// \ref BfsVisit, it is only passed to \ref BfsVisitDefaultTraits.
+  /// \tparam _Visitor The Visitor type that is used by the algorithm.
+  /// \ref BfsVisitor "BfsVisitor<_Digraph>" is an empty visitor, which
+  /// does not observe the BFS events. If you want to observe the BFS
+  /// events, you should implement your own visitor class.
   /// \tparam _Traits Traits class to set various data types used by the
   /// algorithm. The default traits class is
   /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<_Digraph>".
   /// See \ref BfsVisitDefaultTraits for the documentation of
-  /// a Bfs visit traits class.
+  /// a BFS visit traits class.
 #ifdef DOXYGEN
   template <typename _Digraph, typename _Visitor, typename _Traits>
@@ -1227,5 +1290,5 @@
     ///
     /// This error represents problems in the initialization
-    /// of the parameters of the algorithms.
+    /// of the parameters of the algorithm.
     class UninitializedParameter : public lemon::UninitializedParameter {
     public:
@@ -1236,11 +1299,14 @@
     };
 
+    ///The traits class.
     typedef _Traits Traits;
 
+    ///The type of the digraph the algorithm runs on.
     typedef typename Traits::Digraph Digraph;
 
+    ///The visitor type used by the algorithm.
     typedef _Visitor Visitor;
 
-    ///The type of the map indicating which nodes are reached.
+    ///The type of the map that indicates which nodes are reached.
     typedef typename Traits::ReachedMap ReachedMap;
 
@@ -1252,11 +1318,11 @@
     typedef typename Digraph::OutArcIt OutArcIt;
 
-    /// Pointer to the underlying digraph.
+    //Pointer to the underlying digraph.
     const Digraph *_digraph;
-    /// Pointer to the visitor object.
+    //Pointer to the visitor object.
     Visitor *_visitor;
-    ///Pointer to the map of reached status of the nodes.
+    //Pointer to the map of reached status of the nodes.
     ReachedMap *_reached;
-    ///Indicates if \ref _reached is locally allocated (\c true) or not.
+    //Indicates if _reached is locally allocated (true) or not.
     bool local_reached;
 
@@ -1264,7 +1330,6 @@
     int _list_front, _list_back;
 
-    /// \brief Creates the maps if necessary.
-    ///
-    /// Creates the maps if necessary.
+    ///Creates the maps if necessary.
+    ///\todo Better memory allocation (instead of new).
     void create_maps() {
       if(!_reached) {
@@ -1293,7 +1358,7 @@
     };
     /// \brief \ref named-templ-param "Named parameter" for setting
-    /// ReachedMap type
-    ///
-    /// \ref named-templ-param "Named parameter" for setting ReachedMap type
+    /// ReachedMap type.
+    ///
+    /// \ref named-templ-param "Named parameter" for setting ReachedMap type.
     template <class T>
     struct DefReachedMap : public BfsVisit< Digraph, Visitor,
@@ -1309,7 +1374,6 @@
     /// Constructor.
     ///
-    /// \param digraph the digraph the algorithm will run on.
-    /// \param visitor The visitor of the algorithm.
-    ///
+    /// \param digraph The digraph the algorithm runs on.
+    /// \param visitor The visitor object of the algorithm.
     BfsVisit(const Digraph& digraph, Visitor& visitor)
       : _digraph(&digraph), _visitor(&visitor),
@@ -1317,15 +1381,13 @@
 
     /// \brief Destructor.
-    ///
-    /// Destructor.
     ~BfsVisit() {
       if(local_reached) delete _reached;
     }
 
-    /// \brief Sets the map indicating if a node is reached.
-    ///
-    /// Sets the map indicating if a node is reached.
+    /// \brief Sets the map that indicates which nodes are reached.
+    ///
+    /// Sets the map that indicates which nodes are reached.
     /// If you don't use this function before calling \ref run(),
-    /// it will allocate one. The destuctor deallocates this
+    /// it will allocate one. The destructor deallocates this
     /// automatically allocated map, of course.
     /// \return <tt> (*this) </tt>
@@ -1340,19 +1402,21 @@
 
   public:
+
     /// \name Execution control
     /// The simplest way to execute the algorithm is to use
-    /// one of the member functions called \c run(...).
+    /// one of the member functions called \ref lemon::BfsVisit::run()
+    /// "run()".
     /// \n
-    /// If you need more control on the execution,
-    /// first you must call \ref init(), then you can adda source node
-    /// with \ref addSource().
-    /// Finally \ref start() will perform the actual path
-    /// computation.
+    /// If you need more control on the execution, first you must call
+    /// \ref lemon::BfsVisit::init() "init()", then you can add several
+    /// source nodes with \ref lemon::BfsVisit::addSource() "addSource()".
+    /// Finally \ref lemon::BfsVisit::start() "start()" will perform the
+    /// actual path computation.
 
     /// @{
+
     /// \brief Initializes the internal data structures.
     ///
     /// Initializes the internal data structures.
-    ///
     void init() {
       create_maps();
@@ -1382,5 +1446,5 @@
     /// \return The processed node.
     ///
-    /// \pre The queue must not be empty!
+    /// \pre The queue must not be empty.
     Node processNextNode() {
       Node n = _list[++_list_front];
@@ -1403,14 +1467,15 @@
     /// \brief Processes the next node.
     ///
-    /// Processes the next node. And checks that the given target node
+    /// Processes the next node and checks if the given target node
     /// is reached. If the target node is reachable from the processed
-    /// node then the reached parameter will be set true. The reached
-    /// parameter should be initially false.
+    /// node, then the \c reach parameter will be set to \c true.
     ///
     /// \param target The target node.
-    /// \retval reach Indicates that the target node is reached.
+    /// \retval reach Indicates if the target node is reached.
+    /// It should be initially \c false.
+    ///
     /// \return The processed node.
     ///
-    /// \warning The queue must not be empty!
+    /// \pre The queue must not be empty.
     Node processNextNode(Node target, bool& reach) {
       Node n = _list[++_list_front];
@@ -1434,14 +1499,17 @@
     /// \brief Processes the next node.
     ///
-    /// Processes the next node. And checks that at least one of
-    /// reached node has true value in the \c nm node map. If one node
-    /// with true value is reachable from the processed node then the
-    /// rnode parameter will be set to the first of such nodes.
-    ///
-    /// \param nm The node map of possible targets.
+    /// Processes the next node and checks if at least one of reached
+    /// nodes has \c true value in the \c nm node map. If one node
+    /// with \c true value is reachable from the processed node, then the
+    /// \c rnode parameter will be set to the first of such nodes.
+    ///
+    /// \param nm A \c bool (or convertible) node map that indicates the
+    /// possible targets.
     /// \retval rnode The reached target node.
+    /// It should be initially \c INVALID.
+    ///
     /// \return The processed node.
     ///
-    /// \warning The queue must not be empty!
+    /// \pre The queue must not be empty.
     template <typename NM>
     Node processNextNode(const NM& nm, Node& rnode) {
@@ -1464,25 +1532,23 @@
     }
 
-    /// \brief Next node to be processed.
-    ///
-    /// Next node to be processed.
-    ///
-    /// \return The next node to be processed or INVALID if the stack is
-    /// empty.
-    Node nextNode() {
+    /// \brief The next node to be processed.
+    ///
+    /// Returns the next node to be processed or \c INVALID if the queue
+    /// is empty.
+    Node nextNode() const {
       return _list_front != _list_back ? _list[_list_front + 1] : INVALID;
     }
 
     /// \brief Returns \c false if there are nodes
-    /// to be processed in the queue
+    /// to be processed.
     ///
     /// Returns \c false if there are nodes
-    /// to be processed in the queue
-    bool emptyQueue() { return _list_front == _list_back; }
+    /// to be processed in the queue.
+    bool emptyQueue() const { return _list_front == _list_back; }
 
     /// \brief Returns the number of the nodes to be processed.
     ///
     /// Returns the number of the nodes to be processed in the queue.
-    int queueSize() { return _list_back - _list_front; }
+    int queueSize() const { return _list_back - _list_front; }
 
     /// \brief Executes the algorithm.
@@ -1490,16 +1556,45 @@
     /// Executes the algorithm.
     ///
-    /// \pre init() must be called and at least one node should be added
+    /// This method runs the %BFS algorithm from the root node(s)
+    /// in order to compute the shortest path to each node.
+    ///
+    /// The algorithm computes
+    /// - the shortest path tree (forest),
+    /// - the distance of each node from the root(s).
+    ///
+    /// \pre init() must be called and at least one root node should be added
     /// with addSource() before using this function.
+    ///
+    /// \note <tt>b.start()</tt> is just a shortcut of the following code.
+    /// \code
+    ///   while ( !b.emptyQueue() ) {
+    ///     b.processNextNode();
+    ///   }
+    /// \endcode
     void start() {
       while ( !emptyQueue() ) processNextNode();
     }
 
-    /// \brief Executes the algorithm until \c dest is reached.
-    ///
-    /// Executes the algorithm until \c dest is reached.
-    ///
-    /// \pre init() must be called and at least one node should be added
-    /// with addSource() before using this function.
+    /// \brief Executes the algorithm until the given target node is reached.
+    ///
+    /// Executes the algorithm until the given target node is reached.
+    ///
+    /// This method runs the %BFS algorithm from the root node(s)
+    /// in order to compute the shortest path to \c dest.
+    ///
+    /// The algorithm computes
+    /// - the shortest path to \c dest,
+    /// - the distance of \c dest from the root(s).
+    ///
+    /// \pre init() must be called and at least one root node should be
+    /// added with addSource() before using this function.
+    ///
+    /// \note <tt>b.start(t)</tt> is just a shortcut of the following code.
+    /// \code
+    ///   bool reach = false;
+    ///   while ( !b.emptyQueue() && !reach ) {
+    ///     b.processNextNode(t, reach);
+    ///   }
+    /// \endcode
     void start(Node dest) {
       bool reach = false;
@@ -1511,13 +1606,26 @@
     /// Executes the algorithm until a condition is met.
     ///
-    /// \pre init() must be called and at least one node should be added
-    /// with addSource() before using this function.
-    ///
-    ///\param nm must be a bool (or convertible) node map. The
-    ///algorithm will stop when it reaches a node \c v with
+    /// This method runs the %BFS algorithm from the root node(s) in
+    /// order to compute the shortest path to a node \c v with
+    /// <tt>nm[v]</tt> true, if such a node can be found.
+    ///
+    /// \param nm must be a bool (or convertible) node map. The
+    /// algorithm will stop when it reaches a node \c v with
     /// <tt>nm[v]</tt> true.
     ///
-    ///\return The reached node \c v with <tt>nm[v]</tt> true or
-    ///\c INVALID if no such node was found.
+    /// \return The reached node \c v with <tt>nm[v]</tt> true or
+    /// \c INVALID if no such node was found.
+    ///
+    /// \pre init() must be called and at least one root node should be
+    /// added with addSource() before using this function.
+    ///
+    /// \note <tt>b.start(nm)</tt> is just a shortcut of the following code.
+    /// \code
+    ///   Node rnode = INVALID;
+    ///   while ( !b.emptyQueue() && rnode == INVALID ) {
+    ///     b.processNextNode(nm, rnode);
+    ///   }
+    ///   return rnode;
+    /// \endcode
     template <typename NM>
     Node start(const NM &nm) {
@@ -1529,8 +1637,14 @@
     }
 
-    /// \brief Runs %BFSVisit algorithm from node \c s.
-    ///
-    /// This method runs the %BFS algorithm from a root node \c s.
-    /// \note b.run(s) is just a shortcut of the following code.
+    /// \brief Runs the algorithm from the given node.
+    ///
+    /// This method runs the %BFS algorithm from node \c s
+    /// in order to compute the shortest path to each node.
+    ///
+    /// The algorithm computes
+    /// - the shortest path tree,
+    /// - the distance of each node from the root.
+    ///
+    /// \note <tt>b.run(s)</tt> is just a shortcut of the following code.
     ///\code
     ///   b.init();
@@ -1544,17 +1658,19 @@
     }
 
-    /// \brief Runs %BFSVisit algorithm to visit all nodes in the digraph.
+    /// \brief Runs the algorithm to visit all nodes in the digraph.
     ///
     /// This method runs the %BFS algorithm in order to
-    /// compute the %BFS path to each node. The algorithm computes
-    /// - The %BFS tree.
-    /// - The distance of each node from the root in the %BFS tree.
-    ///
-    ///\note b.run() is just a shortcut of the following code.
+    /// compute the shortest path to each node.
+    ///
+    /// The algorithm computes
+    /// - the shortest path tree (forest),
+    /// - the distance of each node from the root(s).
+    ///
+    /// \note <tt>b.run(s)</tt> is just a shortcut of the following code.
     ///\code
     ///  b.init();
-    ///  for (NodeIt it(digraph); it != INVALID; ++it) {
-    ///    if (!b.reached(it)) {
-    ///      b.addSource(it);
+    ///  for (NodeIt n(gr); n != INVALID; ++n) {
+    ///    if (!b.reached(n)) {
+    ///      b.addSource(n);
     ///      b.start();
     ///    }
@@ -1570,4 +1686,5 @@
       }
     }
+
     ///@}
 
@@ -1575,17 +1692,18 @@
     /// The result of the %BFS algorithm can be obtained using these
     /// functions.\n
-    /// Before the use of these functions,
-    /// either run() or start() must be called.
+    /// Either \ref lemon::BfsVisit::run() "run()" or
+    /// \ref lemon::BfsVisit::start() "start()" must be called before
+    /// using them.
     ///@{
 
-    /// \brief Checks if a node is reachable from the root.
+    /// \brief Checks if a node is reachable from the root(s).
     ///
     /// Returns \c true if \c v is reachable from the root(s).
-    /// \warning The source nodes are inditated as unreachable.
     /// \pre Either \ref run() or \ref start()
     /// must be called before using this function.
-    ///
     bool reached(Node v) { return (*_reached)[v]; }
+
     ///@}
+
   };
 
@@ -1593,3 +1711,2 @@
 
 #endif
-
Index: lemon/bits/alteration_notifier.h
===================================================================
--- lemon/bits/alteration_notifier.h	(revision 236)
+++ lemon/bits/alteration_notifier.h	(revision 209)
@@ -23,5 +23,5 @@
 #include <list>
 
-#include <lemon/core.h>
+#include <lemon/bits/utility.h>
 
 ///\ingroup graphbits
@@ -42,5 +42,5 @@
   ///
   /// 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
+  /// 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
@@ -410,7 +410,7 @@
           ++it;
         } catch (const ImmediateDetach&) {
+          it = _observers.erase(it);
           (*it)->_index = _observers.end();
           (*it)->_notifier = 0;
-          it = _observers.erase(it);
         }
       }
@@ -430,7 +430,7 @@
           ++it;
         } catch (const ImmediateDetach&) {
+          it = _observers.erase(it);
           (*it)->_index = _observers.end();
           (*it)->_notifier = 0;
-          it = _observers.erase(it);
         }
       }
@@ -469,7 +469,7 @@
           ++it;
         } catch (const ImmediateDetach&) {
+          it = _observers.erase(it);
           (*it)->_index = _observers.end();
           (*it)->_notifier = 0;
-          it = _observers.erase(it);
         }
       }
Index: lemon/bits/base_extender.h
===================================================================
--- lemon/bits/base_extender.h	(revision 220)
+++ lemon/bits/base_extender.h	(revision 209)
@@ -20,5 +20,5 @@
 #define LEMON_BITS_BASE_EXTENDER_H
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 #include <lemon/error.h>
 
Index: mon/bits/enable_if.h
===================================================================
--- lemon/bits/enable_if.h	(revision 220)
+++ 	(revision )
@@ -1,131 +1,0 @@
-/* -*- 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.
- *
- */
-
-// This file contains a modified version of the enable_if library from BOOST.
-// See the appropriate copyright notice below.
-
-// Boost enable_if library
-
-// Copyright 2003 (c) The Trustees of Indiana University.
-
-// Use, modification, and distribution is subject to 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)
-
-//    Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
-//             Jeremiah Willcock (jewillco at osl.iu.edu)
-//             Andrew Lumsdaine (lums at osl.iu.edu)
-
-
-#ifndef LEMON_BITS_ENABLE_IF_H
-#define LEMON_BITS_ENABLE_IF_H
-
-///\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.
-  ///
-  ///\sa False
-  struct True {
-    ///\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.
-  ///
-  ///\sa True
-  struct False {
-    ///\e
-    static const bool value = false;
-  };
-
-
-
-  template <typename T>
-  struct Wrap {
-    const T &value;
-    Wrap(const T &t) : value(t) {}
-  };
-
-  /**************** dummy class to avoid ambiguity ****************/
-
-  template<int T> struct dummy { dummy(int) {} };
-
-  /**************** enable_if from BOOST ****************/
-
-  template <typename Type, typename T = void>
-  struct exists {
-    typedef T type;
-  };
-
-
-  template <bool B, class T = void>
-  struct enable_if_c {
-    typedef T type;
-  };
-
-  template <class T>
-  struct enable_if_c<false, T> {};
-
-  template <class Cond, class T = void>
-  struct enable_if : public enable_if_c<Cond::value, T> {};
-
-  template <bool B, class T>
-  struct lazy_enable_if_c {
-    typedef typename T::type type;
-  };
-
-  template <class T>
-  struct lazy_enable_if_c<false, T> {};
-
-  template <class Cond, class T>
-  struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
-
-
-  template <bool B, class T = void>
-  struct disable_if_c {
-    typedef T type;
-  };
-
-  template <class T>
-  struct disable_if_c<true, T> {};
-
-  template <class Cond, class T = void>
-  struct disable_if : public disable_if_c<Cond::value, T> {};
-
-  template <bool B, class T>
-  struct lazy_disable_if_c {
-    typedef typename T::type type;
-  };
-
-  template <class T>
-  struct lazy_disable_if_c<true, T> {};
-
-  template <class Cond, class T>
-  struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
-
-} // namespace lemon
-
-#endif
Index: lemon/bits/graph_extender.h
===================================================================
--- lemon/bits/graph_extender.h	(revision 220)
+++ lemon/bits/graph_extender.h	(revision 209)
@@ -20,5 +20,6 @@
 #define LEMON_BITS_GRAPH_EXTENDER_H
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
+#include <lemon/bits/utility.h>
 
 #include <lemon/bits/map_extender.h>
Index: lemon/bits/invalid.h
===================================================================
--- lemon/bits/invalid.h	(revision 209)
+++ lemon/bits/invalid.h	(revision 209)
@@ -0,0 +1,55 @@
+/* -*- 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_BITS_INVALID_H
+#define LEMON_BITS_INVALID_H
+
+///\file
+///\brief Definition of INVALID.
+
+namespace lemon {
+
+  /// \brief Dummy type to make it easier to create invalid iterators.
+  ///
+  /// Dummy type to make it easier to create invalid iterators.
+  /// See \ref INVALID for the usage.
+  struct Invalid {
+  public:
+    bool operator==(Invalid) { return true;  }
+    bool operator!=(Invalid) { return false; }
+    bool operator< (Invalid) { return false; }
+  };
+
+  /// \brief Invalid iterators.
+  ///
+  /// \ref Invalid is a global type that converts to each iterator
+  /// in such a way that the value of the target iterator will be invalid.
+
+  //Some people didn't like this:
+  //const Invalid &INVALID = *(Invalid *)0;
+
+#ifdef LEMON_ONLY_TEMPLATES
+  const Invalid INVALID = Invalid();
+#else
+  extern const Invalid INVALID;
+#endif
+
+} //namespace lemon
+
+#endif
+
Index: lemon/bits/traits.h
===================================================================
--- lemon/bits/traits.h	(revision 220)
+++ lemon/bits/traits.h	(revision 209)
@@ -20,14 +20,11 @@
 #define LEMON_BITS_TRAITS_H
 
+#include <lemon/bits/utility.h>
+
 ///\file
 ///\brief Traits for graphs and maps
 ///
 
-#include <lemon/bits/enable_if.h>
-
 namespace lemon {
-
-  struct InvalidType {};
-
   template <typename _Graph, typename _Item>
   class ItemSetTraits {};
Index: lemon/bits/utility.h
===================================================================
--- lemon/bits/utility.h	(revision 209)
+++ lemon/bits/utility.h	(revision 209)
@@ -0,0 +1,140 @@
+/* -*- 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.
+ *
+ */
+
+// This file contains a modified version of the enable_if library from BOOST.
+// See the appropriate copyright notice below.
+
+// Boost enable_if library
+
+// Copyright 2003 (c) The Trustees of Indiana University.
+
+// Use, modification, and distribution is subject to 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)
+
+//    Authors: Jaakko Jarvi (jajarvi at osl.iu.edu)
+//             Jeremiah Willcock (jewillco at osl.iu.edu)
+//             Andrew Lumsdaine (lums at osl.iu.edu)
+
+
+#ifndef LEMON_BITS_UTILITY_H
+#define LEMON_BITS_UTILITY_H
+
+///\file
+///\brief Miscellaneous basic utilities
+///
+///\todo Please rethink the organisation of the basic files like this.
+///E.g. this file might be merged with invalid.h.
+
+
+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.
+  ///
+  ///\sa False
+  ///
+  /// \todo This should go to a separate "basic_types.h" (or something)
+  /// file.
+  struct True {
+    ///\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.
+  ///
+  ///\sa True
+  struct False {
+    ///\e
+    static const bool value = false;
+  };
+
+
+  struct InvalidType {
+  };
+
+  template <typename T>
+  struct Wrap {
+    const T &value;
+    Wrap(const T &t) : value(t) {}
+  };
+
+  /**************** dummy class to avoid ambiguity ****************/
+
+  template<int T> struct dummy { dummy(int) {} };
+
+  /**************** enable_if from BOOST ****************/
+
+  template <typename Type, typename T = void>
+  struct exists {
+    typedef T type;
+  };
+
+
+  template <bool B, class T = void>
+  struct enable_if_c {
+    typedef T type;
+  };
+
+  template <class T>
+  struct enable_if_c<false, T> {};
+
+  template <class Cond, class T = void>
+  struct enable_if : public enable_if_c<Cond::value, T> {};
+
+  template <bool B, class T>
+  struct lazy_enable_if_c {
+    typedef typename T::type type;
+  };
+
+  template <class T>
+  struct lazy_enable_if_c<false, T> {};
+
+  template <class Cond, class T>
+  struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
+
+
+  template <bool B, class T = void>
+  struct disable_if_c {
+    typedef T type;
+  };
+
+  template <class T>
+  struct disable_if_c<true, T> {};
+
+  template <class Cond, class T = void>
+  struct disable_if : public disable_if_c<Cond::value, T> {};
+
+  template <bool B, class T>
+  struct lazy_disable_if_c {
+    typedef typename T::type type;
+  };
+
+  template <class T>
+  struct lazy_disable_if_c<true, T> {};
+
+  template <class Cond, class T>
+  struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
+
+} // namespace lemon
+
+#endif
Index: lemon/bits/vector_map.h
===================================================================
--- lemon/bits/vector_map.h	(revision 220)
+++ lemon/bits/vector_map.h	(revision 209)
@@ -23,5 +23,7 @@
 #include <algorithm>
 
-#include <lemon/core.h>
+#include <lemon/bits/traits.h>
+#include <lemon/bits/utility.h>
+
 #include <lemon/bits/alteration_notifier.h>
 
Index: lemon/concepts/digraph.h
===================================================================
--- lemon/concepts/digraph.h	(revision 220)
+++ lemon/concepts/digraph.h	(revision 209)
@@ -24,5 +24,6 @@
 ///\brief The concept of directed graphs.
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
+#include <lemon/bits/utility.h>
 #include <lemon/concepts/maps.h>
 #include <lemon/concept_check.h>
Index: lemon/concepts/graph.h
===================================================================
--- lemon/concepts/graph.h	(revision 220)
+++ lemon/concepts/graph.h	(revision 209)
@@ -26,5 +26,5 @@
 #include <lemon/concepts/graph_components.h>
 #include <lemon/concepts/graph.h>
-#include <lemon/core.h>
+#include <lemon/bits/utility.h>
 
 namespace lemon {
Index: lemon/concepts/graph_components.h
===================================================================
--- lemon/concepts/graph_components.h	(revision 220)
+++ lemon/concepts/graph_components.h	(revision 209)
@@ -25,5 +25,5 @@
 #define LEMON_CONCEPT_GRAPH_COMPONENTS_H
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 #include <lemon/concepts/maps.h>
 
Index: lemon/concepts/heap.h
===================================================================
--- lemon/concepts/heap.h	(revision 220)
+++ lemon/concepts/heap.h	(revision 209)
@@ -24,5 +24,5 @@
 #define LEMON_CONCEPT_HEAP_H
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 
 namespace lemon {
Index: lemon/concepts/maps.h
===================================================================
--- lemon/concepts/maps.h	(revision 220)
+++ lemon/concepts/maps.h	(revision 210)
@@ -20,5 +20,5 @@
 #define LEMON_CONCEPT_MAPS_H
 
-#include <lemon/core.h>
+#include <lemon/bits/utility.h>
 #include <lemon/concept_check.h>
 
Index: lemon/concepts/path.h
===================================================================
--- lemon/concepts/path.h	(revision 236)
+++ lemon/concepts/path.h	(revision 212)
@@ -26,5 +26,6 @@
 #define LEMON_CONCEPT_PATH_H
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
+#include <lemon/bits/utility.h>
 #include <lemon/concept_check.h>
 
@@ -78,5 +79,5 @@
       void clear() {}
 
-      /// \brief LEMON style iterator for path arcs
+      /// \brief Lemon style iterator for path arcs
       ///
       /// This class is used to iterate on the arcs of the paths.
@@ -201,5 +202,5 @@
     /// If we would like to give back a real path from these
     /// algorithms then we should create a temporarly path object. In
-    /// LEMON such algorithms gives back a path dumper what can
+    /// Lemon such algorithms gives back a path dumper what can
     /// assigned to a real path and the dumpers can be implemented as
     /// an adaptor class to the predecessor map.
@@ -233,5 +234,5 @@
       typedef False RevPathTag;
 
-      /// \brief LEMON style iterator for path arcs
+      /// \brief Lemon style iterator for path arcs
       ///
       /// This class is used to iterate on the arcs of the paths.
@@ -260,5 +261,5 @@
       };
 
-      /// \brief LEMON style iterator for path arcs
+      /// \brief Lemon style iterator for path arcs
       ///
       /// This class is used to iterate on the arcs of the paths in
Index: mon/core.h
===================================================================
--- lemon/core.h	(revision 233)
+++ 	(revision )
@@ -1,1828 +1,0 @@
-/* -*- 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_CORE_H
-#define LEMON_CORE_H
-
-#include <vector>
-#include <algorithm>
-
-#include <lemon/bits/enable_if.h>
-#include <lemon/bits/traits.h>
-
-///\file
-///\brief LEMON core utilities.
-///
-///This header file contains core utilities for LEMON.
-///It is automatically included by all graph types, therefore it usually
-///do not have to be included directly.
-
-namespace lemon {
-
-  /// \brief Dummy type to make it easier to create invalid iterators.
-  ///
-  /// Dummy type to make it easier to create invalid iterators.
-  /// See \ref INVALID for the usage.
-  struct Invalid {
-  public:
-    bool operator==(Invalid) { return true;  }
-    bool operator!=(Invalid) { return false; }
-    bool operator< (Invalid) { return false; }
-  };
-
-  /// \brief Invalid iterators.
-  ///
-  /// \ref Invalid is a global type that converts to each iterator
-  /// in such a way that the value of the target iterator will be invalid.
-#ifdef LEMON_ONLY_TEMPLATES
-  const Invalid INVALID = Invalid();
-#else
-  extern const Invalid INVALID;
-#endif
-
-  /// \addtogroup gutils
-  /// @{
-
-  ///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,
-  ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
-  ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap.
-  ///
-  ///\note If the graph type is a dependent type, ie. the graph type depend
-  ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
-  ///macro.
-#define DIGRAPH_TYPEDEFS(Digraph)                                       \
-  typedef Digraph::Node Node;                                           \
-  typedef Digraph::NodeIt NodeIt;                                       \
-  typedef Digraph::Arc Arc;                                             \
-  typedef Digraph::ArcIt ArcIt;                                         \
-  typedef Digraph::InArcIt InArcIt;                                     \
-  typedef Digraph::OutArcIt OutArcIt;                                   \
-  typedef Digraph::NodeMap<bool> BoolNodeMap;                           \
-  typedef Digraph::NodeMap<int> IntNodeMap;                             \
-  typedef Digraph::NodeMap<double> DoubleNodeMap;                       \
-  typedef Digraph::ArcMap<bool> BoolArcMap;                             \
-  typedef Digraph::ArcMap<int> IntArcMap;                               \
-  typedef Digraph::ArcMap<double> DoubleArcMap
-
-  ///Creates convenience typedefs for the digraph types and iterators
-
-  ///\see DIGRAPH_TYPEDEFS
-  ///
-  ///\note Use this macro, if the graph type is a dependent type,
-  ///ie. the graph type depend on a template parameter.
-#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph)                              \
-  typedef typename Digraph::Node Node;                                  \
-  typedef typename Digraph::NodeIt NodeIt;                              \
-  typedef typename Digraph::Arc Arc;                                    \
-  typedef typename Digraph::ArcIt ArcIt;                                \
-  typedef typename Digraph::InArcIt InArcIt;                            \
-  typedef typename Digraph::OutArcIt OutArcIt;                          \
-  typedef typename Digraph::template NodeMap<bool> BoolNodeMap;         \
-  typedef typename Digraph::template NodeMap<int> IntNodeMap;           \
-  typedef typename Digraph::template NodeMap<double> DoubleNodeMap;     \
-  typedef typename Digraph::template ArcMap<bool> BoolArcMap;           \
-  typedef typename Digraph::template ArcMap<int> IntArcMap;             \
-  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
-  ///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates
-  ///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap,
-  ///\c DoubleEdgeMap.
-  ///
-  ///\note If the graph type is a dependent type, ie. the graph type depend
-  ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
-  ///macro.
-#define GRAPH_TYPEDEFS(Graph)                                           \
-  DIGRAPH_TYPEDEFS(Graph);                                              \
-  typedef Graph::Edge Edge;                                             \
-  typedef Graph::EdgeIt EdgeIt;                                         \
-  typedef Graph::IncEdgeIt IncEdgeIt;                                   \
-  typedef Graph::EdgeMap<bool> BoolEdgeMap;                             \
-  typedef Graph::EdgeMap<int> IntEdgeMap;                               \
-  typedef Graph::EdgeMap<double> DoubleEdgeMap
-
-  ///Creates convenience typedefs for the graph types and iterators
-
-  ///\see GRAPH_TYPEDEFS
-  ///
-  ///\note Use this macro, if the graph type is a dependent type,
-  ///ie. the graph type depend on a template parameter.
-#define TEMPLATE_GRAPH_TYPEDEFS(Graph)                                  \
-  TEMPLATE_DIGRAPH_TYPEDEFS(Graph);                                     \
-  typedef typename Graph::Edge Edge;                                    \
-  typedef typename Graph::EdgeIt EdgeIt;                                \
-  typedef typename Graph::IncEdgeIt IncEdgeIt;                          \
-  typedef typename Graph::template EdgeMap<bool> BoolEdgeMap;           \
-  typedef typename Graph::template EdgeMap<int> IntEdgeMap;             \
-  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
-  /// it iterates on all of the items.
-  template <typename Graph, typename Item>
-  inline int countItems(const Graph& g) {
-    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
-    int num = 0;
-    for (ItemIt it(g); it != INVALID; ++it) {
-      ++num;
-    }
-    return num;
-  }
-
-  // Node counting:
-
-  namespace _core_bits {
-
-    template <typename Graph, typename Enable = void>
-    struct CountNodesSelector {
-      static int count(const Graph &g) {
-        return countItems<Graph, typename Graph::Node>(g);
-      }
-    };
-
-    template <typename Graph>
-    struct CountNodesSelector<
-      Graph, typename
-      enable_if<typename Graph::NodeNumTag, void>::type>
-    {
-      static int count(const Graph &g) {
-        return g.nodeNum();
-      }
-    };
-  }
-
-  /// \brief Function to count the nodes in the graph.
-  ///
-  /// 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
-  /// function to query the cardinality of the node set.
-  template <typename Graph>
-  inline int countNodes(const Graph& g) {
-    return _core_bits::CountNodesSelector<Graph>::count(g);
-  }
-
-  // Arc counting:
-
-  namespace _core_bits {
-
-    template <typename Graph, typename Enable = void>
-    struct CountArcsSelector {
-      static int count(const Graph &g) {
-        return countItems<Graph, typename Graph::Arc>(g);
-      }
-    };
-
-    template <typename Graph>
-    struct CountArcsSelector<
-      Graph,
-      typename enable_if<typename Graph::ArcNumTag, void>::type>
-    {
-      static int count(const Graph &g) {
-        return g.arcNum();
-      }
-    };
-  }
-
-  /// \brief Function to count the arcs in the graph.
-  ///
-  /// 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
-  /// function to query the cardinality of the arc set.
-  template <typename Graph>
-  inline int countArcs(const Graph& g) {
-    return _core_bits::CountArcsSelector<Graph>::count(g);
-  }
-
-  // Edge counting:
-  namespace _core_bits {
-
-    template <typename Graph, typename Enable = void>
-    struct CountEdgesSelector {
-      static int count(const Graph &g) {
-        return countItems<Graph, typename Graph::Edge>(g);
-      }
-    };
-
-    template <typename Graph>
-    struct CountEdgesSelector<
-      Graph,
-      typename enable_if<typename Graph::EdgeNumTag, void>::type>
-    {
-      static int count(const Graph &g) {
-        return g.edgeNum();
-      }
-    };
-  }
-
-  /// \brief Function to count the edges in the graph.
-  ///
-  /// 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
-  /// function to query the cardinality of the edge set.
-  template <typename Graph>
-  inline int countEdges(const Graph& g) {
-    return _core_bits::CountEdgesSelector<Graph>::count(g);
-
-  }
-
-
-  template <typename Graph, typename DegIt>
-  inline int countNodeDegree(const Graph& _g, const typename Graph::Node& _n) {
-    int num = 0;
-    for (DegIt it(_g, _n); it != INVALID; ++it) {
-      ++num;
-    }
-    return num;
-  }
-
-  /// \brief Function to count the number of the out-arcs from node \c n.
-  ///
-  /// This function counts the number of the out-arcs from node \c n
-  /// in the graph.
-  template <typename Graph>
-  inline int countOutArcs(const Graph& _g,  const typename Graph::Node& _n) {
-    return countNodeDegree<Graph, typename Graph::OutArcIt>(_g, _n);
-  }
-
-  /// \brief Function to count the number of the in-arcs to node \c n.
-  ///
-  /// This function counts the number of the in-arcs to node \c n
-  /// in the graph.
-  template <typename Graph>
-  inline int countInArcs(const Graph& _g,  const typename Graph::Node& _n) {
-    return countNodeDegree<Graph, typename Graph::InArcIt>(_g, _n);
-  }
-
-  /// \brief Function to count the number of the inc-edges to node \c n.
-  ///
-  /// This function counts the number of the inc-edges to node \c n
-  /// in the graph.
-  template <typename Graph>
-  inline int countIncEdges(const Graph& _g,  const typename Graph::Node& _n) {
-    return countNodeDegree<Graph, typename Graph::IncEdgeIt>(_g, _n);
-  }
-
-  namespace _core_bits {
-
-    template <typename Digraph, typename Item, typename RefMap>
-    class MapCopyBase {
-    public:
-      virtual void copy(const Digraph& from, const RefMap& refMap) = 0;
-
-      virtual ~MapCopyBase() {}
-    };
-
-    template <typename Digraph, typename Item, typename RefMap,
-              typename ToMap, typename FromMap>
-    class MapCopy : public MapCopyBase<Digraph, Item, RefMap> {
-    public:
-
-      MapCopy(ToMap& tmap, const FromMap& map)
-        : _tmap(tmap), _map(map) {}
-
-      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
-        typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
-        for (ItemIt it(digraph); it != INVALID; ++it) {
-          _tmap.set(refMap[it], _map[it]);
-        }
-      }
-
-    private:
-      ToMap& _tmap;
-      const FromMap& _map;
-    };
-
-    template <typename Digraph, typename Item, typename RefMap, typename It>
-    class ItemCopy : public MapCopyBase<Digraph, Item, RefMap> {
-    public:
-
-      ItemCopy(It& it, const Item& item) : _it(it), _item(item) {}
-
-      virtual void copy(const Digraph&, const RefMap& refMap) {
-        _it = refMap[_item];
-      }
-
-    private:
-      It& _it;
-      Item _item;
-    };
-
-    template <typename Digraph, typename Item, typename RefMap, typename Ref>
-    class RefCopy : public MapCopyBase<Digraph, Item, RefMap> {
-    public:
-
-      RefCopy(Ref& map) : _map(map) {}
-
-      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
-        typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
-        for (ItemIt it(digraph); it != INVALID; ++it) {
-          _map.set(it, refMap[it]);
-        }
-      }
-
-    private:
-      Ref& _map;
-    };
-
-    template <typename Digraph, typename Item, typename RefMap,
-              typename CrossRef>
-    class CrossRefCopy : public MapCopyBase<Digraph, Item, RefMap> {
-    public:
-
-      CrossRefCopy(CrossRef& cmap) : _cmap(cmap) {}
-
-      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
-        typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
-        for (ItemIt it(digraph); it != INVALID; ++it) {
-          _cmap.set(refMap[it], it);
-        }
-      }
-
-    private:
-      CrossRef& _cmap;
-    };
-
-    template <typename Digraph, typename Enable = void>
-    struct DigraphCopySelector {
-      template <typename From, typename NodeRefMap, typename ArcRefMap>
-      static void copy(Digraph &to, const From& from,
-                       NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
-        for (typename From::NodeIt it(from); it != INVALID; ++it) {
-          nodeRefMap[it] = to.addNode();
-        }
-        for (typename From::ArcIt it(from); it != INVALID; ++it) {
-          arcRefMap[it] = to.addArc(nodeRefMap[from.source(it)],
-                                    nodeRefMap[from.target(it)]);
-        }
-      }
-    };
-
-    template <typename Digraph>
-    struct DigraphCopySelector<
-      Digraph,
-      typename enable_if<typename Digraph::BuildTag, void>::type>
-    {
-      template <typename From, typename NodeRefMap, typename ArcRefMap>
-      static void copy(Digraph &to, const From& from,
-                       NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
-        to.build(from, nodeRefMap, arcRefMap);
-      }
-    };
-
-    template <typename Graph, typename Enable = void>
-    struct GraphCopySelector {
-      template <typename From, typename NodeRefMap, typename EdgeRefMap>
-      static void copy(Graph &to, const From& from,
-                       NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
-        for (typename From::NodeIt it(from); it != INVALID; ++it) {
-          nodeRefMap[it] = to.addNode();
-        }
-        for (typename From::EdgeIt it(from); it != INVALID; ++it) {
-          edgeRefMap[it] = to.addEdge(nodeRefMap[from.u(it)],
-                                      nodeRefMap[from.v(it)]);
-        }
-      }
-    };
-
-    template <typename Graph>
-    struct GraphCopySelector<
-      Graph,
-      typename enable_if<typename Graph::BuildTag, void>::type>
-    {
-      template <typename From, typename NodeRefMap, typename EdgeRefMap>
-      static void copy(Graph &to, const From& from,
-                       NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
-        to.build(from, nodeRefMap, edgeRefMap);
-      }
-    };
-
-  }
-
-  /// \brief Class to copy a digraph.
-  ///
-  /// 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
-  /// 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
-  /// assigned to copy. In the end, the \c run() member should be
-  /// called.
-  ///
-  /// The next code copies a graph with several data:
-  ///\code
-  ///  DigraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
-  ///  // create a reference for the nodes
-  ///  OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
-  ///  dc.nodeRef(nr);
-  ///  // create a cross reference (inverse) for the arcs
-  ///  NewGraph::ArcMap<OrigGraph::Arc> acr(new_graph);
-  ///  dc.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
-  ///  OrigGraph::Node on;
-  ///  NewGraph::Node nn;
-  ///  dc.node(nn, on);
-  ///  // Executions of copy
-  ///  dc.run();
-  ///\endcode
-  template <typename To, typename From>
-  class DigraphCopy {
-  private:
-
-    typedef typename From::Node Node;
-    typedef typename From::NodeIt NodeIt;
-    typedef typename From::Arc Arc;
-    typedef typename From::ArcIt ArcIt;
-
-    typedef typename To::Node TNode;
-    typedef typename To::Arc TArc;
-
-    typedef typename From::template NodeMap<TNode> NodeRefMap;
-    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)
-      : _from(from), _to(to) {}
-
-    /// \brief Destructor of the DigraphCopy
-    ///
-    /// Destructor of the DigraphCopy
-    ~DigraphCopy() {
-      for (int i = 0; i < int(_node_maps.size()); ++i) {
-        delete _node_maps[i];
-      }
-      for (int i = 0; i < int(_arc_maps.size()); ++i) {
-        delete _arc_maps[i];
-      }
-
-    }
-
-    /// \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.
-    template <typename NodeRef>
-    DigraphCopy& nodeRef(NodeRef& map) {
-      _node_maps.push_back(new _core_bits::RefCopy<From, Node,
-                           NodeRefMap, NodeRef>(map));
-      return *this;
-    }
-
-    /// \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.
-    template <typename NodeCrossRef>
-    DigraphCopy& nodeCrossRef(NodeCrossRef& map) {
-      _node_maps.push_back(new _core_bits::CrossRefCopy<From, Node,
-                           NodeRefMap, NodeCrossRef>(map));
-      return *this;
-    }
-
-    /// \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) {
-      _node_maps.push_back(new _core_bits::MapCopy<From, Node,
-                           NodeRefMap, ToMap, FromMap>(tmap, map));
-      return *this;
-    }
-
-    /// \brief Make a copy of the given node.
-    ///
-    /// Make a copy of the given node.
-    DigraphCopy& node(TNode& tnode, const Node& snode) {
-      _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.
-    template <typename ArcRef>
-    DigraphCopy& arcRef(ArcRef& map) {
-      _arc_maps.push_back(new _core_bits::RefCopy<From, Arc,
-                          ArcRefMap, ArcRef>(map));
-      return *this;
-    }
-
-    /// \brief Copies the arc cross references into the given map.
-    ///
-    ///  Copies the arc cross references (reverse references) into
-    ///  the given map.
-    template <typename ArcCrossRef>
-    DigraphCopy& arcCrossRef(ArcCrossRef& map) {
-      _arc_maps.push_back(new _core_bits::CrossRefCopy<From, Arc,
-                          ArcRefMap, ArcCrossRef>(map));
-      return *this;
-    }
-
-    /// \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) {
-      _arc_maps.push_back(new _core_bits::MapCopy<From, Arc,
-                          ArcRefMap, ToMap, FromMap>(tmap, map));
-      return *this;
-    }
-
-    /// \brief Make a copy of the given arc.
-    ///
-    /// Make a copy of the given arc.
-    DigraphCopy& arc(TArc& tarc, const Arc& sarc) {
-      _arc_maps.push_back(new _core_bits::ItemCopy<From, Arc,
-                          ArcRefMap, TArc>(tarc, sarc));
-      return *this;
-    }
-
-    /// \brief Executes the copies.
-    ///
-    /// Executes the copies.
-    void run() {
-      NodeRefMap nodeRefMap(_from);
-      ArcRefMap arcRefMap(_from);
-      _core_bits::DigraphCopySelector<To>::
-        copy(_to, _from, nodeRefMap, arcRefMap);
-      for (int i = 0; i < int(_node_maps.size()); ++i) {
-        _node_maps[i]->copy(_from, nodeRefMap);
-      }
-      for (int i = 0; i < int(_arc_maps.size()); ++i) {
-        _arc_maps[i]->copy(_from, arcRefMap);
-      }
-    }
-
-  protected:
-
-
-    const From& _from;
-    To& _to;
-
-    std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* >
-    _node_maps;
-
-    std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* >
-    _arc_maps;
-
-  };
-
-  /// \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:
-  ///\code
-  /// copyDigraph(trg, src).nodeRef(nr).arcCrossRef(ecr).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
-  /// 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);
-  }
-
-  /// \brief Class to copy a graph.
-  ///
-  /// 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
-  /// 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.
-  ///
-  /// To make a copy from a graph, first an instance of GraphCopy
-  /// should be created, then the data belongs to the graph should
-  /// assigned to copy. In the end, the \c run() member should be
-  /// called.
-  ///
-  /// The next code copies a graph with several data:
-  ///\code
-  ///  GraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
-  ///  // create a reference 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
-  ///  OrigGraph::Node on;
-  ///  NewGraph::Node nn;
-  ///  dc.node(nn, on);
-  ///  // Executions of copy
-  ///  dc.run();
-  ///\endcode
-  template <typename To, typename From>
-  class GraphCopy {
-  private:
-
-    typedef typename From::Node Node;
-    typedef typename From::NodeIt NodeIt;
-    typedef typename From::Arc Arc;
-    typedef typename From::ArcIt ArcIt;
-    typedef typename From::Edge Edge;
-    typedef typename From::EdgeIt EdgeIt;
-
-    typedef typename To::Node TNode;
-    typedef typename To::Arc TArc;
-    typedef typename To::Edge TEdge;
-
-    typedef typename From::template NodeMap<TNode> NodeRefMap;
-    typedef typename From::template EdgeMap<TEdge> EdgeRefMap;
-
-    struct ArcRefMap {
-      ArcRefMap(const To& to, const From& from,
-                const EdgeRefMap& edge_ref, const NodeRefMap& node_ref)
-        : _to(to), _from(from),
-          _edge_ref(edge_ref), _node_ref(node_ref) {}
-
-      typedef typename From::Arc Key;
-      typedef typename To::Arc Value;
-
-      Value operator[](const Key& key) const {
-        bool forward = _from.u(key) != _from.v(key) ?
-          _node_ref[_from.source(key)] ==
-          _to.source(_to.direct(_edge_ref[key], true)) :
-          _from.direction(key);
-        return _to.direct(_edge_ref[key], forward);
-      }
-
-      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)
-      : _from(from), _to(to) {}
-
-    /// \brief Destructor of the GraphCopy
-    ///
-    /// Destructor of the GraphCopy
-    ~GraphCopy() {
-      for (int i = 0; i < int(_node_maps.size()); ++i) {
-        delete _node_maps[i];
-      }
-      for (int i = 0; i < int(_arc_maps.size()); ++i) {
-        delete _arc_maps[i];
-      }
-      for (int i = 0; i < int(_edge_maps.size()); ++i) {
-        delete _edge_maps[i];
-      }
-
-    }
-
-    /// \brief Copies the node references into the given map.
-    ///
-    /// Copies the node references into the given map.
-    template <typename NodeRef>
-    GraphCopy& nodeRef(NodeRef& map) {
-      _node_maps.push_back(new _core_bits::RefCopy<From, Node,
-                           NodeRefMap, NodeRef>(map));
-      return *this;
-    }
-
-    /// \brief Copies the node cross references into the given map.
-    ///
-    ///  Copies the node cross references (reverse references) into
-    ///  the given map.
-    template <typename NodeCrossRef>
-    GraphCopy& nodeCrossRef(NodeCrossRef& map) {
-      _node_maps.push_back(new _core_bits::CrossRefCopy<From, Node,
-                           NodeRefMap, NodeCrossRef>(map));
-      return *this;
-    }
-
-    /// \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) {
-      _node_maps.push_back(new _core_bits::MapCopy<From, Node,
-                           NodeRefMap, ToMap, FromMap>(tmap, map));
-      return *this;
-    }
-
-    /// \brief Make a copy of the given node.
-    ///
-    /// Make a copy of the given node.
-    GraphCopy& node(TNode& tnode, const Node& snode) {
-      _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.
-    template <typename ArcRef>
-    GraphCopy& arcRef(ArcRef& map) {
-      _arc_maps.push_back(new _core_bits::RefCopy<From, Arc,
-                          ArcRefMap, ArcRef>(map));
-      return *this;
-    }
-
-    /// \brief Copies the arc cross references into the given map.
-    ///
-    ///  Copies the arc cross references (reverse references) into
-    ///  the given map.
-    template <typename ArcCrossRef>
-    GraphCopy& arcCrossRef(ArcCrossRef& map) {
-      _arc_maps.push_back(new _core_bits::CrossRefCopy<From, Arc,
-                          ArcRefMap, ArcCrossRef>(map));
-      return *this;
-    }
-
-    /// \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) {
-      _arc_maps.push_back(new _core_bits::MapCopy<From, Arc,
-                          ArcRefMap, ToMap, FromMap>(tmap, map));
-      return *this;
-    }
-
-    /// \brief Make a copy of the given arc.
-    ///
-    /// Make a copy of the given arc.
-    GraphCopy& arc(TArc& tarc, const Arc& sarc) {
-      _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.
-    template <typename EdgeRef>
-    GraphCopy& edgeRef(EdgeRef& map) {
-      _edge_maps.push_back(new _core_bits::RefCopy<From, Edge,
-                           EdgeRefMap, EdgeRef>(map));
-      return *this;
-    }
-
-    /// \brief Copies the edge cross references into the given map.
-    ///
-    /// Copies the edge cross references (reverse
-    /// references) into the given map.
-    template <typename EdgeCrossRef>
-    GraphCopy& edgeCrossRef(EdgeCrossRef& map) {
-      _edge_maps.push_back(new _core_bits::CrossRefCopy<From,
-                           Edge, EdgeRefMap, EdgeCrossRef>(map));
-      return *this;
-    }
-
-    /// \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) {
-      _edge_maps.push_back(new _core_bits::MapCopy<From, Edge,
-                           EdgeRefMap, ToMap, FromMap>(tmap, map));
-      return *this;
-    }
-
-    /// \brief Make a copy of the given edge.
-    ///
-    /// Make a copy of the given edge.
-    GraphCopy& edge(TEdge& tedge, const Edge& sedge) {
-      _edge_maps.push_back(new _core_bits::ItemCopy<From, Edge,
-                           EdgeRefMap, TEdge>(tedge, sedge));
-      return *this;
-    }
-
-    /// \brief Executes the copies.
-    ///
-    /// Executes the copies.
-    void run() {
-      NodeRefMap nodeRefMap(_from);
-      EdgeRefMap edgeRefMap(_from);
-      ArcRefMap arcRefMap(_to, _from, edgeRefMap, nodeRefMap);
-      _core_bits::GraphCopySelector<To>::
-        copy(_to, _from, nodeRefMap, edgeRefMap);
-      for (int i = 0; i < int(_node_maps.size()); ++i) {
-        _node_maps[i]->copy(_from, nodeRefMap);
-      }
-      for (int i = 0; i < int(_edge_maps.size()); ++i) {
-        _edge_maps[i]->copy(_from, edgeRefMap);
-      }
-      for (int i = 0; i < int(_arc_maps.size()); ++i) {
-        _arc_maps[i]->copy(_from, arcRefMap);
-      }
-    }
-
-  private:
-
-    const From& _from;
-    To& _to;
-
-    std::vector<_core_bits::MapCopyBase<From, Node, NodeRefMap>* >
-    _node_maps;
-
-    std::vector<_core_bits::MapCopyBase<From, Arc, ArcRefMap>* >
-    _arc_maps;
-
-    std::vector<_core_bits::MapCopyBase<From, Edge, EdgeRefMap>* >
-    _edge_maps;
-
-  };
-
-  /// \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:
-  ///\code
-  /// copyGraph(trg, src).nodeRef(nr).arcCrossRef(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.
-  ///
-  /// \see GraphCopy
-  template <typename To, typename From>
-  GraphCopy<To, From>
-  copyGraph(To& to, const From& from) {
-    return GraphCopy<To, From>(to, from);
-  }
-
-  namespace _core_bits {
-
-    template <typename Graph, typename Enable = void>
-    struct FindArcSelector {
-      typedef typename Graph::Node Node;
-      typedef typename Graph::Arc Arc;
-      static Arc find(const Graph &g, Node u, Node v, Arc e) {
-        if (e == INVALID) {
-          g.firstOut(e, u);
-        } else {
-          g.nextOut(e);
-        }
-        while (e != INVALID && g.target(e) != v) {
-          g.nextOut(e);
-        }
-        return e;
-      }
-    };
-
-    template <typename Graph>
-    struct FindArcSelector<
-      Graph,
-      typename enable_if<typename Graph::FindEdgeTag, void>::type>
-    {
-      typedef typename Graph::Node Node;
-      typedef typename Graph::Arc Arc;
-      static Arc find(const Graph &g, Node u, Node v, Arc prev) {
-        return g.findArc(u, v, prev);
-      }
-    };
-  }
-
-  /// \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.
-  ///
-  /// 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.
-  ///\code
-  /// for(Arc e=findArc(g,u,v);e!=INVALID;e=findArc(g,u,v,e)) {
-  ///   ...
-  /// }
-  ///\endcode
-  ///
-  ///\sa ArcLookUp
-  ///\sa AllArcLookUp
-  ///\sa DynArcLookUp
-  ///\sa ConArcIt
-  template <typename Graph>
-  inline typename Graph::Arc
-  findArc(const Graph &g, typename Graph::Node u, typename Graph::Node v,
-          typename Graph::Arc prev = INVALID) {
-    return _core_bits::FindArcSelector<Graph>::find(g, u, v, prev);
-  }
-
-  /// \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
-  /// use it the following way:
-  ///\code
-  /// for (ConArcIt<Graph> it(g, src, trg); it != INVALID; ++it) {
-  ///   ...
-  /// }
-  ///\endcode
-  ///
-  ///\sa findArc()
-  ///\sa ArcLookUp
-  ///\sa AllArcLookUp
-  ///\sa DynArcLookUp
-  template <typename _Graph>
-  class ConArcIt : public _Graph::Arc {
-  public:
-
-    typedef _Graph Graph;
-    typedef typename Graph::Arc Parent;
-
-    typedef typename Graph::Arc Arc;
-    typedef typename Graph::Node Node;
-
-    /// \brief Constructor.
-    ///
-    /// Construct a new ConArcIt iterating on the arcs which
-    /// connects the \c u and \c v node.
-    ConArcIt(const Graph& g, Node u, Node v) : _graph(g) {
-      Parent::operator=(findArc(_graph, u, v));
-    }
-
-    /// \brief Constructor.
-    ///
-    /// Construct a new ConArcIt which continues the iterating from
-    /// the \c e arc.
-    ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
-
-    /// \brief Increment operator.
-    ///
-    /// It increments the iterator and gives back the next arc.
-    ConArcIt& operator++() {
-      Parent::operator=(findArc(_graph, _graph.source(*this),
-                                _graph.target(*this), *this));
-      return *this;
-    }
-  private:
-    const Graph& _graph;
-  };
-
-  namespace _core_bits {
-
-    template <typename Graph, typename Enable = void>
-    struct FindEdgeSelector {
-      typedef typename Graph::Node Node;
-      typedef typename Graph::Edge Edge;
-      static Edge find(const Graph &g, Node u, Node v, Edge e) {
-        bool b;
-        if (u != v) {
-          if (e == INVALID) {
-            g.firstInc(e, b, u);
-          } else {
-            b = g.u(e) == u;
-            g.nextInc(e, b);
-          }
-          while (e != INVALID && (b ? g.v(e) : g.u(e)) != v) {
-            g.nextInc(e, b);
-          }
-        } else {
-          if (e == INVALID) {
-            g.firstInc(e, b, u);
-          } else {
-            b = true;
-            g.nextInc(e, b);
-          }
-          while (e != INVALID && (!b || g.v(e) != v)) {
-            g.nextInc(e, b);
-          }
-        }
-        return e;
-      }
-    };
-
-    template <typename Graph>
-    struct FindEdgeSelector<
-      Graph,
-      typename enable_if<typename Graph::FindEdgeTag, void>::type>
-    {
-      typedef typename Graph::Node Node;
-      typedef typename Graph::Edge Edge;
-      static Edge find(const Graph &g, Node u, Node v, Edge prev) {
-        return g.findEdge(u, v, prev);
-      }
-    };
-  }
-
-  /// \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
-  /// 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.
-  ///\code
-  /// for(Edge e = findEdge(g,u,v); e != INVALID;
-  ///     e = findEdge(g,u,v,e)) {
-  ///   ...
-  /// }
-  ///\endcode
-  ///
-  ///\sa ConEdgeIt
-
-  template <typename Graph>
-  inline typename Graph::Edge
-  findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
-            typename Graph::Edge p = INVALID) {
-    return _core_bits::FindEdgeSelector<Graph>::find(g, u, v, p);
-  }
-
-  /// \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
-  /// use it the following way:
-  ///\code
-  /// for (ConEdgeIt<Graph> it(g, src, trg); it != INVALID; ++it) {
-  ///   ...
-  /// }
-  ///\endcode
-  ///
-  ///\sa findEdge()
-  template <typename _Graph>
-  class ConEdgeIt : public _Graph::Edge {
-  public:
-
-    typedef _Graph Graph;
-    typedef typename Graph::Edge Parent;
-
-    typedef typename Graph::Edge Edge;
-    typedef typename Graph::Node Node;
-
-    /// \brief Constructor.
-    ///
-    /// Construct a new ConEdgeIt iterating on the edges which
-    /// connects the \c u and \c v node.
-    ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) {
-      Parent::operator=(findEdge(_graph, u, v));
-    }
-
-    /// \brief Constructor.
-    ///
-    /// Construct a new ConEdgeIt which continues the iterating from
-    /// the \c e edge.
-    ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
-
-    /// \brief Increment operator.
-    ///
-    /// It increments the iterator and gives back the next edge.
-    ConEdgeIt& operator++() {
-      Parent::operator=(findEdge(_graph, _graph.u(*this),
-                                 _graph.v(*this), *this));
-      return *this;
-    }
-  private:
-    const Graph& _graph;
-  };
-
-
-  ///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>,
-  ///where <em>d</em> is the out-degree of the source node.
-  ///
-  ///It is possible to find \e all parallel arcs between two nodes with
-  ///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
-  ///optimal time bound in a constant factor for any distribution of
-  ///queries.
-  ///
-  ///\tparam G The type of the underlying digraph.
-  ///
-  ///\sa ArcLookUp
-  ///\sa AllArcLookUp
-  template<class G>
-  class DynArcLookUp
-    : protected ItemSetTraits<G, typename G::Arc>::ItemNotifier::ObserverBase
-  {
-  public:
-    typedef typename ItemSetTraits<G, typename G::Arc>
-    ::ItemNotifier::ObserverBase Parent;
-
-    TEMPLATE_DIGRAPH_TYPEDEFS(G);
-    typedef G Digraph;
-
-  protected:
-
-    class AutoNodeMap : public ItemSetTraits<G, Node>::template Map<Arc>::Type {
-    public:
-
-      typedef typename ItemSetTraits<G, Node>::template Map<Arc>::Type Parent;
-
-      AutoNodeMap(const G& digraph) : Parent(digraph, INVALID) {}
-
-      virtual void add(const Node& node) {
-        Parent::add(node);
-        Parent::set(node, INVALID);
-      }
-
-      virtual void add(const std::vector<Node>& nodes) {
-        Parent::add(nodes);
-        for (int i = 0; i < int(nodes.size()); ++i) {
-          Parent::set(nodes[i], INVALID);
-        }
-      }
-
-      virtual void build() {
-        Parent::build();
-        Node it;
-        typename Parent::Notifier* nf = Parent::notifier();
-        for (nf->first(it); it != INVALID; nf->next(it)) {
-          Parent::set(it, INVALID);
-        }
-      }
-    };
-
-    const Digraph &_g;
-    AutoNodeMap _head;
-    typename Digraph::template ArcMap<Arc> _parent;
-    typename Digraph::template ArcMap<Arc> _left;
-    typename Digraph::template ArcMap<Arc> _right;
-
-    class ArcLess {
-      const Digraph &g;
-    public:
-      ArcLess(const Digraph &_g) : g(_g) {}
-      bool operator()(Arc a,Arc b) const
-      {
-        return g.target(a)<g.target(b);
-      }
-    };
-
-  public:
-
-    ///Constructor
-
-    ///Constructor.
-    ///
-    ///It builds up the search database.
-    DynArcLookUp(const Digraph &g)
-      : _g(g),_head(g),_parent(g),_left(g),_right(g)
-    {
-      Parent::attach(_g.notifier(typename Digraph::Arc()));
-      refresh();
-    }
-
-  protected:
-
-    virtual void add(const Arc& arc) {
-      insert(arc);
-    }
-
-    virtual void add(const std::vector<Arc>& arcs) {
-      for (int i = 0; i < int(arcs.size()); ++i) {
-        insert(arcs[i]);
-      }
-    }
-
-    virtual void erase(const Arc& arc) {
-      remove(arc);
-    }
-
-    virtual void erase(const std::vector<Arc>& arcs) {
-      for (int i = 0; i < int(arcs.size()); ++i) {
-        remove(arcs[i]);
-      }
-    }
-
-    virtual void build() {
-      refresh();
-    }
-
-    virtual void clear() {
-      for(NodeIt n(_g);n!=INVALID;++n) {
-        _head.set(n, INVALID);
-      }
-    }
-
-    void insert(Arc arc) {
-      Node s = _g.source(arc);
-      Node t = _g.target(arc);
-      _left.set(arc, INVALID);
-      _right.set(arc, INVALID);
-
-      Arc e = _head[s];
-      if (e == INVALID) {
-        _head.set(s, arc);
-        _parent.set(arc, INVALID);
-        return;
-      }
-      while (true) {
-        if (t < _g.target(e)) {
-          if (_left[e] == INVALID) {
-            _left.set(e, arc);
-            _parent.set(arc, e);
-            splay(arc);
-            return;
-          } else {
-            e = _left[e];
-          }
-        } else {
-          if (_right[e] == INVALID) {
-            _right.set(e, arc);
-            _parent.set(arc, e);
-            splay(arc);
-            return;
-          } else {
-            e = _right[e];
-          }
-        }
-      }
-    }
-
-    void remove(Arc arc) {
-      if (_left[arc] == INVALID) {
-        if (_right[arc] != INVALID) {
-          _parent.set(_right[arc], _parent[arc]);
-        }
-        if (_parent[arc] != INVALID) {
-          if (_left[_parent[arc]] == arc) {
-            _left.set(_parent[arc], _right[arc]);
-          } else {
-            _right.set(_parent[arc], _right[arc]);
-          }
-        } else {
-          _head.set(_g.source(arc), _right[arc]);
-        }
-      } else if (_right[arc] == INVALID) {
-        _parent.set(_left[arc], _parent[arc]);
-        if (_parent[arc] != INVALID) {
-          if (_left[_parent[arc]] == arc) {
-            _left.set(_parent[arc], _left[arc]);
-          } else {
-            _right.set(_parent[arc], _left[arc]);
-          }
-        } else {
-          _head.set(_g.source(arc), _left[arc]);
-        }
-      } else {
-        Arc e = _left[arc];
-        if (_right[e] != INVALID) {
-          e = _right[e];
-          while (_right[e] != INVALID) {
-            e = _right[e];
-          }
-          Arc s = _parent[e];
-          _right.set(_parent[e], _left[e]);
-          if (_left[e] != INVALID) {
-            _parent.set(_left[e], _parent[e]);
-          }
-
-          _left.set(e, _left[arc]);
-          _parent.set(_left[arc], e);
-          _right.set(e, _right[arc]);
-          _parent.set(_right[arc], e);
-
-          _parent.set(e, _parent[arc]);
-          if (_parent[arc] != INVALID) {
-            if (_left[_parent[arc]] == arc) {
-              _left.set(_parent[arc], e);
-            } else {
-              _right.set(_parent[arc], e);
-            }
-          }
-          splay(s);
-        } else {
-          _right.set(e, _right[arc]);
-          _parent.set(_right[arc], e);
-          _parent.set(e, _parent[arc]);
-
-          if (_parent[arc] != INVALID) {
-            if (_left[_parent[arc]] == arc) {
-              _left.set(_parent[arc], e);
-            } else {
-              _right.set(_parent[arc], e);
-            }
-          } else {
-            _head.set(_g.source(arc), e);
-          }
-        }
-      }
-    }
-
-    Arc refreshRec(std::vector<Arc> &v,int a,int b)
-    {
-      int m=(a+b)/2;
-      Arc me=v[m];
-      if (a < m) {
-        Arc left = refreshRec(v,a,m-1);
-        _left.set(me, left);
-        _parent.set(left, me);
-      } else {
-        _left.set(me, INVALID);
-      }
-      if (m < b) {
-        Arc right = refreshRec(v,m+1,b);
-        _right.set(me, right);
-        _parent.set(right, me);
-      } else {
-        _right.set(me, INVALID);
-      }
-      return me;
-    }
-
-    void refresh() {
-      for(NodeIt n(_g);n!=INVALID;++n) {
-        std::vector<Arc> v;
-        for(OutArcIt a(_g,n);a!=INVALID;++a) v.push_back(a);
-        if (!v.empty()) {
-          std::sort(v.begin(),v.end(),ArcLess(_g));
-          Arc head = refreshRec(v,0,v.size()-1);
-          _head.set(n, head);
-          _parent.set(head, INVALID);
-        }
-        else _head.set(n, INVALID);
-      }
-    }
-
-    void zig(Arc v) {
-      Arc w = _parent[v];
-      _parent.set(v, _parent[w]);
-      _parent.set(w, v);
-      _left.set(w, _right[v]);
-      _right.set(v, w);
-      if (_parent[v] != INVALID) {
-        if (_right[_parent[v]] == w) {
-          _right.set(_parent[v], v);
-        } else {
-          _left.set(_parent[v], v);
-        }
-      }
-      if (_left[w] != INVALID){
-        _parent.set(_left[w], w);
-      }
-    }
-
-    void zag(Arc v) {
-      Arc w = _parent[v];
-      _parent.set(v, _parent[w]);
-      _parent.set(w, v);
-      _right.set(w, _left[v]);
-      _left.set(v, w);
-      if (_parent[v] != INVALID){
-        if (_left[_parent[v]] == w) {
-          _left.set(_parent[v], v);
-        } else {
-          _right.set(_parent[v], v);
-        }
-      }
-      if (_right[w] != INVALID){
-        _parent.set(_right[w], w);
-      }
-    }
-
-    void splay(Arc v) {
-      while (_parent[v] != INVALID) {
-        if (v == _left[_parent[v]]) {
-          if (_parent[_parent[v]] == INVALID) {
-            zig(v);
-          } else {
-            if (_parent[v] == _left[_parent[_parent[v]]]) {
-              zig(_parent[v]);
-              zig(v);
-            } else {
-              zig(v);
-              zag(v);
-            }
-          }
-        } else {
-          if (_parent[_parent[v]] == INVALID) {
-            zag(v);
-          } else {
-            if (_parent[v] == _left[_parent[_parent[v]]]) {
-              zag(v);
-              zig(v);
-            } else {
-              zag(_parent[v]);
-              zag(v);
-            }
-          }
-        }
-      }
-      _head[_g.source(v)] = v;
-    }
-
-
-  public:
-
-    ///Find an arc between two nodes.
-
-    ///Find an arc between two nodes.
-    ///\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.
-    ///\return An arc from \c s to \c t after \c p or
-    ///\ref INVALID if there is no more.
-    ///
-    ///For example, you can count the number of arcs from \c u to \c v in the
-    ///following way.
-    ///\code
-    ///DynArcLookUp<ListDigraph> ae(g);
-    ///...
-    ///int n=0;
-    ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) n++;
-    ///\endcode
-    ///
-    ///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
-    ///current query distribution in a constant factor.
-    ///
-    ///\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
-    ///them.
-    ///
-    Arc operator()(Node s, Node t, Arc p = INVALID) const  {
-      if (p == INVALID) {
-        Arc a = _head[s];
-        if (a == INVALID) return INVALID;
-        Arc r = INVALID;
-        while (true) {
-          if (_g.target(a) < t) {
-            if (_right[a] == INVALID) {
-              const_cast<DynArcLookUp&>(*this).splay(a);
-              return r;
-            } else {
-              a = _right[a];
-            }
-          } else {
-            if (_g.target(a) == t) {
-              r = a;
-            }
-            if (_left[a] == INVALID) {
-              const_cast<DynArcLookUp&>(*this).splay(a);
-              return r;
-            } else {
-              a = _left[a];
-            }
-          }
-        }
-      } else {
-        Arc a = p;
-        if (_right[a] != INVALID) {
-          a = _right[a];
-          while (_left[a] != INVALID) {
-            a = _left[a];
-          }
-          const_cast<DynArcLookUp&>(*this).splay(a);
-        } else {
-          while (_parent[a] != INVALID && _right[_parent[a]] ==  a) {
-            a = _parent[a];
-          }
-          if (_parent[a] == INVALID) {
-            return INVALID;
-          } else {
-            a = _parent[a];
-            const_cast<DynArcLookUp&>(*this).splay(a);
-          }
-        }
-        if (_g.target(a) == t) return a;
-        else return INVALID;
-      }
-    }
-
-  };
-
-  ///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>,
-  ///where <em>d</em> is the out-degree of the source node.
-  ///
-  ///It is not possible to find \e all parallel arcs between two nodes.
-  ///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).
-  ///
-  ///\tparam G The type of the underlying digraph.
-  ///
-  ///\sa DynArcLookUp
-  ///\sa AllArcLookUp
-  template<class G>
-  class ArcLookUp
-  {
-  public:
-    TEMPLATE_DIGRAPH_TYPEDEFS(G);
-    typedef G Digraph;
-
-  protected:
-    const Digraph &_g;
-    typename Digraph::template NodeMap<Arc> _head;
-    typename Digraph::template ArcMap<Arc> _left;
-    typename Digraph::template ArcMap<Arc> _right;
-
-    class ArcLess {
-      const Digraph &g;
-    public:
-      ArcLess(const Digraph &_g) : g(_g) {}
-      bool operator()(Arc a,Arc b) const
-      {
-        return g.target(a)<g.target(b);
-      }
-    };
-
-  public:
-
-    ///Constructor
-
-    ///Constructor.
-    ///
-    ///It builds up the search database, which remains valid until the digraph
-    ///changes.
-    ArcLookUp(const Digraph &g) :_g(g),_head(g),_left(g),_right(g) {refresh();}
-
-  private:
-    Arc refreshRec(std::vector<Arc> &v,int a,int b)
-    {
-      int m=(a+b)/2;
-      Arc me=v[m];
-      _left[me] = a<m?refreshRec(v,a,m-1):INVALID;
-      _right[me] = m<b?refreshRec(v,m+1,b):INVALID;
-      return me;
-    }
-  public:
-    ///Refresh the 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.
-    void refresh(Node n)
-    {
-      std::vector<Arc> v;
-      for(OutArcIt e(_g,n);e!=INVALID;++e) v.push_back(e);
-      if(v.size()) {
-        std::sort(v.begin(),v.end(),ArcLess(_g));
-        _head[n]=refreshRec(v,0,v.size()-1);
-      }
-      else _head[n]=INVALID;
-    }
-    ///Refresh the full data structure.
-
-    ///Build up the full search database. In fact, it simply calls
-    ///\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
-    ///out-degree of the digraph.
-
-    void refresh()
-    {
-      for(NodeIt n(_g);n!=INVALID;++n) refresh(n);
-    }
-
-    ///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
-    ///\return An arc from \c s to \c t if there exists,
-    ///\ref INVALID otherwise.
-    ///
-    ///\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.
-    ///
-    Arc operator()(Node s, Node t) const
-    {
-      Arc e;
-      for(e=_head[s];
-          e!=INVALID&&_g.target(e)!=t;
-          e = t < _g.target(e)?_left[e]:_right[e]) ;
-      return e;
-    }
-
-  };
-
-  ///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).
-  ///
-  ///\tparam G The type of the underlying digraph.
-  ///
-  ///\sa DynArcLookUp
-  ///\sa ArcLookUp
-  template<class G>
-  class AllArcLookUp : public ArcLookUp<G>
-  {
-    using ArcLookUp<G>::_g;
-    using ArcLookUp<G>::_right;
-    using ArcLookUp<G>::_left;
-    using ArcLookUp<G>::_head;
-
-    TEMPLATE_DIGRAPH_TYPEDEFS(G);
-    typedef G Digraph;
-
-    typename Digraph::template ArcMap<Arc> _next;
-
-    Arc refreshNext(Arc head,Arc next=INVALID)
-    {
-      if(head==INVALID) return next;
-      else {
-        next=refreshNext(_right[head],next);
-//         _next[head]=next;
-        _next[head]=( next!=INVALID && _g.target(next)==_g.target(head))
-          ? next : INVALID;
-        return refreshNext(_left[head],head);
-      }
-    }
-
-    void refreshNext()
-    {
-      for(NodeIt n(_g);n!=INVALID;++n) refreshNext(_head[n]);
-    }
-
-  public:
-    ///Constructor
-
-    ///Constructor.
-    ///
-    ///It builds up the search database, which remains valid until the digraph
-    ///changes.
-    AllArcLookUp(const Digraph &g) : ArcLookUp<G>(g), _next(g) {refreshNext();}
-
-    ///Refresh the 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.
-
-    void refresh(Node n)
-    {
-      ArcLookUp<G>::refresh(n);
-      refreshNext(_head[n]);
-    }
-
-    ///Refresh the full data structure.
-
-    ///Build up the full search database. In fact, it simply calls
-    ///\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
-    ///out-degree of the digraph.
-
-    void refresh()
-    {
-      for(NodeIt n(_g);n!=INVALID;++n) refresh(_head[n]);
-    }
-
-    ///Find an arc between two nodes.
-
-    ///Find an arc between two nodes.
-    ///\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.
-    ///\return An arc from \c s to \c t after \c prev or
-    ///\ref INVALID if there is no more.
-    ///
-    ///For example, you can count the number of arcs from \c u to \c v in the
-    ///following way.
-    ///\code
-    ///AllArcLookUp<ListDigraph> ae(g);
-    ///...
-    ///int n=0;
-    ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) 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
-    ///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.
-    ///
-#ifdef DOXYGEN
-    Arc operator()(Node s, Node t, Arc prev=INVALID) const {}
-#else
-    using ArcLookUp<G>::operator() ;
-    Arc operator()(Node s, Node t, Arc prev) const
-    {
-      return prev==INVALID?(*this)(s,t):_next[prev];
-    }
-#endif
-
-  };
-
-  /// @}
-
-} //namespace lemon
-
-#endif
Index: lemon/dfs.h
===================================================================
--- lemon/dfs.h	(revision 220)
+++ lemon/dfs.h	(revision 244)
@@ -22,16 +22,15 @@
 ///\ingroup search
 ///\file
-///\brief Dfs algorithm.
+///\brief DFS algorithm.
 
 #include <lemon/list_graph.h>
+#include <lemon/graph_utils.h>
 #include <lemon/bits/path_dump.h>
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 #include <lemon/error.h>
+#include <lemon/assert.h>
 #include <lemon/maps.h>
 
-#include <lemon/concept_check.h>
-
 namespace lemon {
-
 
   ///Default traits class of Dfs class.
@@ -42,22 +41,23 @@
   struct DfsDefaultTraits
   {
-    ///The digraph type the algorithm runs on.
+    ///The type of the digraph the algorithm runs on.
     typedef GR Digraph;
-    ///\brief The type of the map that stores the last
+
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the %DFS paths.
     ///
-    ///The type of the map that stores the last
+    ///The type of the map that stores the predecessor
     ///arcs of the %DFS paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef typename Digraph::template NodeMap<typename GR::Arc> PredMap;
-    ///Instantiates a PredMap.
+    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+    ///Instantiates a \ref PredMap.
 
     ///This function instantiates a \ref PredMap.
-    ///\param G is the digraph, to which we would like to define the 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
-    static PredMap *createPredMap(const GR &G)
-    {
-      return new PredMap(G);
+    static PredMap *createPredMap(const Digraph &g)
+    {
+      return new PredMap(g);
     }
 
@@ -66,7 +66,7 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
+    ///By default it is a NullMap.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a ProcessedMap.
+    ///Instantiates a \ref ProcessedMap.
 
     ///This function instantiates a \ref ProcessedMap.
@@ -74,40 +74,40 @@
     ///we would like to define the \ref ProcessedMap
 #ifdef DOXYGEN
-    static ProcessedMap *createProcessedMap(const GR &g)
+    static ProcessedMap *createProcessedMap(const Digraph &g)
 #else
-    static ProcessedMap *createProcessedMap(const GR &)
+    static ProcessedMap *createProcessedMap(const Digraph &)
 #endif
     {
       return new ProcessedMap();
     }
+
     ///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.
+    typedef typename Digraph::template NodeMap<bool> ReachedMap;
+    ///Instantiates a \ref ReachedMap.
+
+    ///This function instantiates a \ref ReachedMap.
+    ///\param g is the digraph, to which
+    ///we would like to define the \ref ReachedMap.
+    static ReachedMap *createReachedMap(const Digraph &g)
+    {
+      return new ReachedMap(g);
+    }
+
+    ///The type of the map that stores the distances of the nodes.
+
+    ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
-    typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
-    ///\param G is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
-    static ReachedMap *createReachedMap(const GR &G)
-    {
-      return new ReachedMap(G);
-    }
-    ///The type of the map that stores the dists of the nodes.
-
-    ///The type of the map that stores the dists of the nodes.
-    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
     typedef typename Digraph::template NodeMap<int> DistMap;
-    ///Instantiates a DistMap.
+    ///Instantiates a \ref DistMap.
 
     ///This function instantiates a \ref DistMap.
-    ///\param G is the digraph, to which we would like to define
-    ///the \ref DistMap
-    static DistMap *createDistMap(const GR &G)
-    {
-      return new DistMap(G);
+    ///\param g is the digraph, to which we would like to define the
+    ///\ref DistMap.
+    static DistMap *createDistMap(const Digraph &g)
+    {
+      return new DistMap(g);
     }
   };
@@ -118,7 +118,11 @@
   ///This class provides an efficient implementation of the %DFS algorithm.
   ///
-  ///\tparam GR The digraph type the algorithm runs on. The default value is
-  ///\ref ListDigraph. The value of GR is not used directly by Dfs, it
-  ///is only passed to \ref DfsDefaultTraits.
+  ///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.
+  ///
+  ///\tparam GR The type of the digraph the algorithm runs on.
+  ///The default value is \ref ListDigraph. The value of GR is not used
+  ///directly by \ref Dfs, it is only passed to \ref DfsDefaultTraits.
   ///\tparam TR Traits class to set various data types used by the algorithm.
   ///The default traits class is
@@ -135,10 +139,8 @@
   class Dfs {
   public:
-    /**
-     * \brief \ref Exception for uninitialized parameters.
-     *
-     * This error represents problems in the initialization
-     * of the parameters of the algorithms.
-     */
+    ///\ref Exception for uninitialized parameters.
+
+    ///This error represents problems in the initialization of the
+    ///parameters of the algorithm.
     class UninitializedParameter : public lemon::UninitializedParameter {
     public:
@@ -148,43 +150,46 @@
     };
 
+    ///The type of the digraph the algorithm runs on.
+    typedef typename TR::Digraph Digraph;
+
+    ///\brief The type of the map that stores the predecessor arcs of the
+    ///DFS paths.
+    typedef typename TR::PredMap PredMap;
+    ///The type of the map that stores the distances of the nodes.
+    typedef typename TR::DistMap DistMap;
+    ///The type of the map that indicates which nodes are reached.
+    typedef typename TR::ReachedMap ReachedMap;
+    ///The type of the map that indicates which nodes are processed.
+    typedef typename TR::ProcessedMap ProcessedMap;
+    ///The type of the paths.
+    typedef PredMapPath<Digraph, PredMap> Path;
+
+    ///The traits class.
     typedef TR Traits;
-    ///The type of the underlying digraph.
-    typedef typename TR::Digraph Digraph;
-    ///\e
+
+  private:
+
     typedef typename Digraph::Node Node;
-    ///\e
     typedef typename Digraph::NodeIt NodeIt;
-    ///\e
     typedef typename Digraph::Arc Arc;
-    ///\e
     typedef typename Digraph::OutArcIt OutArcIt;
 
-    ///\brief The type of the map that stores the last
-    ///arcs of the %DFS paths.
-    typedef typename TR::PredMap PredMap;
-    ///The type of the map indicating which nodes are reached.
-    typedef typename TR::ReachedMap ReachedMap;
-    ///The type of the map indicating which nodes are processed.
-    typedef typename TR::ProcessedMap ProcessedMap;
-    ///The type of the map that stores the dists of the nodes.
-    typedef typename TR::DistMap DistMap;
-  private:
-    /// Pointer to the underlying digraph.
+    //Pointer to the underlying digraph.
     const Digraph *G;
-    ///Pointer to the map of predecessors arcs.
+    //Pointer to the map of predecessor arcs.
     PredMap *_pred;
-    ///Indicates if \ref _pred is locally allocated (\c true) or not.
+    //Indicates if _pred is locally allocated (true) or not.
     bool local_pred;
-    ///Pointer to the map of distances.
+    //Pointer to the map of distances.
     DistMap *_dist;
-    ///Indicates if \ref _dist is locally allocated (\c true) or not.
+    //Indicates if _dist is locally allocated (true) or not.
     bool local_dist;
-    ///Pointer to the map of reached status of the nodes.
+    //Pointer to the map of reached status of the nodes.
     ReachedMap *_reached;
-    ///Indicates if \ref _reached is locally allocated (\c true) or not.
+    //Indicates if _reached is locally allocated (true) or not.
     bool local_reached;
-    ///Pointer to the map of processed status of the nodes.
+    //Pointer to the map of processed status of the nodes.
     ProcessedMap *_processed;
-    ///Indicates if \ref _processed is locally allocated (\c true) or not.
+    //Indicates if _processed is locally allocated (true) or not.
     bool local_processed;
 
@@ -193,5 +198,4 @@
 
     ///Creates the maps if necessary.
-
     ///\todo Better memory allocation (instead of new).
     void create_maps()
@@ -230,5 +234,5 @@
     struct DefPredMapTraits : public Traits {
       typedef T PredMap;
-      static PredMap *createPredMap(const Digraph &G)
+      static PredMap *createPredMap(const Digraph &)
       {
         throw UninitializedParameter();
@@ -236,13 +240,12 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///PredMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting PredMap type
-    ///
+    ///\ref PredMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref PredMap type.
     template <class T>
     struct DefPredMap : public Dfs<Digraph, DefPredMapTraits<T> > {
       typedef Dfs<Digraph, DefPredMapTraits<T> > Create;
     };
-
 
     template <class T>
@@ -255,10 +258,10 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///DistMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting DistMap
-    ///type
+    ///\ref DistMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref DistMap type.
     template <class T>
-    struct DefDistMap {
+    struct DefDistMap : public Dfs< Digraph, DefDistMapTraits<T> > {
       typedef Dfs<Digraph, DefDistMapTraits<T> > Create;
     };
@@ -273,8 +276,8 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///ReachedMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting ReachedMap type
-    ///
+    ///\ref ReachedMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref ReachedMap type.
     template <class T>
     struct DefReachedMap : public Dfs< Digraph, DefReachedMapTraits<T> > {
@@ -291,8 +294,8 @@
     };
     ///\brief \ref named-templ-param "Named parameter" for setting
-    ///ProcessedMap type
-    ///
-    ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
-    ///
+    ///\ref ProcessedMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref ProcessedMap type.
     template <class T>
     struct DefProcessedMap : public Dfs< Digraph, DefProcessedMapTraits<T> > {
@@ -302,17 +305,17 @@
     struct DefDigraphProcessedMapTraits : public Traits {
       typedef typename Digraph::template NodeMap<bool> ProcessedMap;
-      static ProcessedMap *createProcessedMap(const Digraph &G)
+      static ProcessedMap *createProcessedMap(const Digraph &g)
       {
-        return new ProcessedMap(G);
-      }
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting the ProcessedMap type to be Digraph::NodeMap<bool>.
-    ///
-    ///\ref named-templ-param "Named parameter"
-    ///for setting the ProcessedMap type to be Digraph::NodeMap<bool>.
-    ///If you don't set it explicitely, it will be automatically allocated.
+        return new ProcessedMap(g);
+      }
+    };
+    ///\brief \ref named-templ-param "Named parameter" for setting
+    ///\ref 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>.
+    ///If you don't set it explicitly, it will be automatically allocated.
     template <class T>
-    class DefProcessedMapToBeDefaultMap :
+    struct DefProcessedMapToBeDefaultMap :
       public Dfs< Digraph, DefDigraphProcessedMapTraits> {
       typedef Dfs< Digraph, DefDigraphProcessedMapTraits> Create;
@@ -325,8 +328,8 @@
     ///Constructor.
 
-    ///\param _G the digraph the algorithm will run on.
-    ///
-    Dfs(const Digraph& _G) :
-      G(&_G),
+    ///Constructor.
+    ///\param g The digraph the algorithm runs on.
+    Dfs(const Digraph &g) :
+      G(&g),
       _pred(NULL), local_pred(false),
       _dist(NULL), local_dist(false),
@@ -344,9 +347,9 @@
     }
 
-    ///Sets the map storing the predecessor arcs.
-
-    ///Sets the map storing the predecessor arcs.
+    ///Sets the map that stores the predecessor arcs.
+
+    ///Sets the map that stores the predecessor arcs.
     ///If you don't use this function before calling \ref run(),
-    ///it will allocate one. The destuctor deallocates this
+    ///it will allocate one. The destructor deallocates this
     ///automatically allocated map, of course.
     ///\return <tt> (*this) </tt>
@@ -361,9 +364,44 @@
     }
 
-    ///Sets the map storing the distances calculated by the algorithm.
-
-    ///Sets the map storing the distances calculated by the algorithm.
+    ///Sets the map that indicates which nodes are reached.
+
+    ///Sets the map that indicates which nodes are reached.
     ///If you don't use this function before calling \ref run(),
-    ///it will allocate one. The destuctor deallocates this
+    ///it will allocate one. The destructor deallocates this
+    ///automatically allocated map, of course.
+    ///\return <tt> (*this) </tt>
+    Dfs &reachedMap(ReachedMap &m)
+    {
+      if(local_reached) {
+        delete _reached;
+        local_reached=false;
+      }
+      _reached = &m;
+      return *this;
+    }
+
+    ///Sets the map that indicates which nodes are processed.
+
+    ///Sets the map that indicates which nodes are processed.
+    ///If you don't use this function before calling \ref run(),
+    ///it will allocate one. The destructor deallocates this
+    ///automatically allocated map, of course.
+    ///\return <tt> (*this) </tt>
+    Dfs &processedMap(ProcessedMap &m)
+    {
+      if(local_processed) {
+        delete _processed;
+        local_processed=false;
+      }
+      _processed = &m;
+      return *this;
+    }
+
+    ///Sets the map that stores the distances of the nodes.
+
+    ///Sets the map that stores the distances of the nodes calculated by
+    ///the algorithm.
+    ///If you don't use this function before calling \ref run(),
+    ///it will allocate one. The destructor deallocates this
     ///automatically allocated map, of course.
     ///\return <tt> (*this) </tt>
@@ -378,48 +416,15 @@
     }
 
-    ///Sets the map indicating if a node is reached.
-
-    ///Sets the map indicating if a node is reached.
-    ///If you don't use this function before calling \ref run(),
-    ///it will allocate one. The destuctor deallocates this
-    ///automatically allocated map, of course.
-    ///\return <tt> (*this) </tt>
-    Dfs &reachedMap(ReachedMap &m)
-    {
-      if(local_reached) {
-        delete _reached;
-        local_reached=false;
-      }
-      _reached = &m;
-      return *this;
-    }
-
-    ///Sets the map indicating if a node is processed.
-
-    ///Sets the map indicating if a node is processed.
-    ///If you don't use this function before calling \ref run(),
-    ///it will allocate one. The destuctor deallocates this
-    ///automatically allocated map, of course.
-    ///\return <tt> (*this) </tt>
-    Dfs &processedMap(ProcessedMap &m)
-    {
-      if(local_processed) {
-        delete _processed;
-        local_processed=false;
-      }
-      _processed = &m;
-      return *this;
-    }
-
   public:
+
     ///\name Execution control
     ///The simplest way to execute the algorithm is to use
-    ///one of the member functions called \c run(...).
+    ///one of the member functions called \ref lemon::Dfs::run() "run()".
     ///\n
-    ///If you need more control on the execution,
-    ///first you must call \ref init(), then you can add a source node
-    ///with \ref addSource().
-    ///Finally \ref start() will perform the actual path
-    ///computation.
+    ///If you need more control on the execution, first you must call
+    ///\ref lemon::Dfs::init() "init()", then you can add a source node
+    ///with \ref lemon::Dfs::addSource() "addSource()".
+    ///Finally \ref lemon::Dfs::start() "start()" will perform the
+    ///actual path computation.
 
     ///@{
@@ -436,5 +441,4 @@
       for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
         _pred->set(u,INVALID);
-        // _predNode->set(u,INVALID);
         _reached->set(u,false);
         _processed->set(u,false);
@@ -446,8 +450,12 @@
     ///Adds a new source node to the set of nodes to be processed.
     ///
-    ///\warning dists are wrong (or at least strange)
-    ///in case of multiple sources.
+    ///\pre The stack must be empty. (Otherwise the algorithm gives
+    ///false results.)
+    ///
+    ///\warning Distances will be wrong (or at least strange) in case of
+    ///multiple sources.
     void addSource(Node s)
     {
+      LEMON_DEBUG(emptyQueue(), "The stack is not empty.");
       if(!(*_reached)[s])
         {
@@ -472,5 +480,5 @@
     ///\return The processed arc.
     ///
-    ///\pre The stack must not be empty!
+    ///\pre The stack must not be empty.
     Arc processNextArc()
     {
@@ -498,11 +506,12 @@
       return e;
     }
+
     ///Next arc to be processed.
 
     ///Next arc to be processed.
     ///
-    ///\return The next arc to be processed or INVALID if the stack is
-    /// empty.
-    OutArcIt nextArc()
+    ///\return The next arc to be processed or \c INVALID if the stack
+    ///is empty.
+    OutArcIt nextArc() const
     {
       return _stack_head>=0?_stack[_stack_head]:INVALID;
@@ -510,13 +519,14 @@
 
     ///\brief Returns \c false if there are nodes
-    ///to be processed in the queue
+    ///to be processed.
     ///
     ///Returns \c false if there are nodes
-    ///to be processed in the queue
-    bool emptyQueue() { return _stack_head<0; }
+    ///to be processed in the queue (stack).
+    bool emptyQueue() const { return _stack_head<0; }
+
     ///Returns the number of the nodes to be processed.
 
-    ///Returns the number of the nodes to be processed in the queue.
-    int queueSize() { return _stack_head+1; }
+    ///Returns the number of the nodes to be processed in the queue (stack).
+    int queueSize() const { return _stack_head+1; }
 
     ///Executes the algorithm.
@@ -524,14 +534,20 @@
     ///Executes the algorithm.
     ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
-    ///
-    ///This method runs the %DFS algorithm from the root node(s)
-    ///in order to
-    ///compute the
-    ///%DFS path to each node. The algorithm computes
-    ///- The %DFS tree.
-    ///- The distance of each node from the root(s) in the %DFS tree.
-    ///
+    ///This method runs the %DFS algorithm from the root node
+    ///in order to compute the DFS path to each node.
+    ///
+    /// The algorithm computes
+    ///- the %DFS tree,
+    ///- the distance of each node 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.
+    ///
+    ///\note <tt>d.start()</tt> is just a shortcut of the following code.
+    ///\code
+    ///  while ( !d.emptyQueue() ) {
+    ///    d.processNextArc();
+    ///  }
+    ///\endcode
     void start()
     {
@@ -539,18 +555,17 @@
     }
 
-    ///Executes the algorithm until \c dest is reached.
-
-    ///Executes the algorithm until \c dest is reached.
-    ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
-    ///
-    ///This method runs the %DFS algorithm from the root node(s)
-    ///in order to
-    ///compute the
-    ///%DFS path to \c dest. The algorithm computes
-    ///- The %DFS path to \c  dest.
-    ///- The distance of \c dest from the root(s) in the %DFS tree.
-    ///
+    ///Executes the algorithm until the given target node is reached.
+
+    ///Executes the algorithm until the given target node is reached.
+    ///
+    ///This method runs the %DFS algorithm from the root node
+    ///in order to compute the DFS path to \c dest.
+    ///
+    ///The algorithm computes
+    ///- the %DFS path to \c dest,
+    ///- the distance of \c dest 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)
     {
@@ -563,37 +578,84 @@
     ///Executes the algorithm until a condition is met.
     ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
-    ///
-    ///\param em must be a bool (or convertible) arc map. The algorithm
-    ///will stop when it reaches an arc \c e with <tt>em[e]</tt> true.
-    ///
-    ///\return The reached arc \c e with <tt>em[e]</tt> true or
+    ///This method runs the %DFS algorithm from the root node
+    ///until an arc \c a with <tt>am[a]</tt> true is found.
+    ///
+    ///\param am A \c bool (or convertible) arc map. The algorithm
+    ///will stop when it reaches an arc \c a with <tt>am[a]</tt> true.
+    ///
+    ///\return The reached arc \c a with <tt>am[a]</tt> true or
     ///\c INVALID if no such arc was found.
     ///
-    ///\warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an arc map,
+    ///\pre init() must be called and a root node should be
+    ///added with addSource() before using this function.
+    ///
+    ///\warning Contrary to \ref Bfs and \ref Dijkstra, \c am is an arc map,
     ///not a node map.
-    template<class EM>
-    Arc start(const EM &em)
-    {
-      while ( !emptyQueue() && !em[_stack[_stack_head]] )
+    template<class ArcBoolMap>
+    Arc start(const ArcBoolMap &am)
+    {
+      while ( !emptyQueue() && !am[_stack[_stack_head]] )
         processNextArc();
       return emptyQueue() ? INVALID : _stack[_stack_head];
     }
 
-    ///Runs %DFS algorithm to visit all nodes in the digraph.
-
-    ///This method runs the %DFS algorithm in order to
-    ///compute the
-    ///%DFS path to each node. The algorithm computes
-    ///- The %DFS tree.
-    ///- The distance of each node from the root in the %DFS tree.
-    ///
-    ///\note d.run() is just a shortcut of the following code.
+    ///Runs the algorithm from the given node.
+
+    ///This method runs the %DFS algorithm from node \c s
+    ///in order to compute the DFS path to each node.
+    ///
+    ///The algorithm computes
+    ///- the %DFS tree,
+    ///- the distance of each node from the root in the %DFS tree.
+    ///
+    ///\note <tt>d.run(s)</tt> is just a shortcut of the following code.
     ///\code
     ///  d.init();
-    ///  for (NodeIt it(digraph); it != INVALID; ++it) {
-    ///    if (!d.reached(it)) {
-    ///      d.addSource(it);
+    ///  d.addSource(s);
+    ///  d.start();
+    ///\endcode
+    void run(Node s) {
+      init();
+      addSource(s);
+      start();
+    }
+
+    ///Finds the %DFS path between \c s and \c t.
+
+    ///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.
+    ///
+    ///\note Apart from the return value, <tt>d.run(s,t)</tt> is
+    ///just a shortcut of the following code.
+    ///\code
+    ///  d.init();
+    ///  d.addSource(s);
+    ///  d.start(t);
+    ///\endcode
+    int run(Node s,Node t) {
+      init();
+      addSource(s);
+      start(t);
+      return reached(t)?_stack_head+1:0;
+    }
+
+    ///Runs the algorithm to visit all nodes in the digraph.
+
+    ///This method runs the %DFS algorithm in order to compute the
+    ///%DFS path to each node.
+    ///
+    ///The algorithm computes
+    ///- the %DFS tree,
+    ///- the distance of each node from the root in the %DFS tree.
+    ///
+    ///\note <tt>d.run()</tt> is just a shortcut of the following code.
+    ///\code
+    ///  d.init();
+    ///  for (NodeIt n(digraph); n != INVALID; ++n) {
+    ///    if (!d.reached(n)) {
+    ///      d.addSource(n);
     ///      d.start();
     ///    }
@@ -610,45 +672,4 @@
     }
 
-    ///Runs %DFS algorithm from node \c s.
-
-    ///This method runs the %DFS algorithm from a root node \c s
-    ///in order to
-    ///compute the
-    ///%DFS path to each node. The algorithm computes
-    ///- The %DFS tree.
-    ///- The distance of each node from the root in the %DFS tree.
-    ///
-    ///\note d.run(s) is just a shortcut of the following code.
-    ///\code
-    ///  d.init();
-    ///  d.addSource(s);
-    ///  d.start();
-    ///\endcode
-    void run(Node s) {
-      init();
-      addSource(s);
-      start();
-    }
-
-    ///Finds the %DFS path between \c s and \c t.
-
-    ///Finds the %DFS path between \c s and \c t.
-    ///
-    ///\return The length of the %DFS s---t path if there exists one,
-    ///0 otherwise.
-    ///\note Apart from the return value, d.run(s,t) is
-    ///just a shortcut of the following code.
-    ///\code
-    ///  d.init();
-    ///  d.addSource(s);
-    ///  d.start(t);
-    ///\endcode
-    int run(Node s,Node t) {
-      init();
-      addSource(s);
-      start(t);
-      return reached(t)?_stack_head+1:0;
-    }
-
     ///@}
 
@@ -656,37 +677,40 @@
     ///The result of the %DFS algorithm can be obtained using these
     ///functions.\n
-    ///Before the use of these functions,
-    ///either run() or start() must be called.
+    ///Either \ref lemon::Dfs::run() "run()" or \ref lemon::Dfs::start()
+    ///"start()" must be called before using them.
 
     ///@{
 
-    typedef PredMapPath<Digraph, PredMap> Path;
-
-    ///Gives back the shortest path.
-
-    ///Gives back the shortest path.
-    ///\pre The \c t should be reachable from the source.
-    Path path(Node t)
-    {
-      return Path(*G, *_pred, t);
-    }
-
-    ///The distance of a node from the root(s).
-
-    ///Returns the distance of a node from the root(s).
-    ///\pre \ref run() must be called before using this function.
-    ///\warning If node \c v is unreachable from the root(s) then the return
-    ///value of this funcion is undefined.
+    ///The DFS path to a node.
+
+    ///Returns the DFS path to a node.
+    ///
+    ///\warning \c t should be reachable from the root.
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
+    Path path(Node t) const { return Path(*G, *_pred, t); }
+
+    ///The distance of a node from the root.
+
+    ///Returns the distance of a node from the root.
+    ///
+    ///\warning If node \c v is not reachable from the root, then
+    ///the return value of this function is undefined.
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
     int dist(Node v) const { return (*_dist)[v]; }
 
-    ///Returns the 'previous arc' of the %DFS tree.
-
-    ///For a node \c v it returns the 'previous arc'
-    ///of the %DFS path,
-    ///i.e. it returns the last arc of a %DFS path from the root(s) to \c
-    ///v. It is \ref INVALID
-    ///if \c v is unreachable from the root(s) or \c v is a root. The
-    ///%DFS tree used here is equal to the %DFS tree used in
+    ///Returns the 'previous arc' of the %DFS tree for a node.
+
+    ///This function returns the 'previous arc' of the %DFS tree for the
+    ///node \c v, i.e. it returns the last arc of a %DFS path from the
+    ///root to \c v. It is \c INVALID
+    ///if \c v is not reachable from the root(s) or if \c v is a root.
+    ///
+    ///The %DFS tree used here is equal to the %DFS tree used in
     ///\ref predNode().
+    ///
     ///\pre Either \ref run() or \ref start() must be called before using
     ///this function.
@@ -695,12 +719,12 @@
     ///Returns the 'previous node' of the %DFS tree.
 
-    ///For a node \c v it returns the 'previous node'
-    ///of the %DFS tree,
-    ///i.e. it returns the last but one node from a %DFS path from the
-    ///root(s) to \c v.
-    ///It is INVALID if \c v is unreachable from the root(s) or
-    ///if \c v itself a root.
-    ///The %DFS tree used here is equal to the %DFS
-    ///tree used in \ref predArc().
+    ///This function returns the 'previous node' of the %DFS
+    ///tree for the node \c v, i.e. it returns the last but one node
+    ///from a %DFS path from the root to \c v. It is \c INVALID
+    ///if \c v is not reachable from the root(s) or if \c v is a root.
+    ///
+    ///The %DFS tree used here is equal to the %DFS tree used in
+    ///\ref predArc().
+    ///
     ///\pre Either \ref run() or \ref start() must be called before
     ///using this function.
@@ -708,57 +732,62 @@
                                   G->source((*_pred)[v]); }
 
-    ///Returns a reference to the NodeMap of distances.
-
-    ///Returns a reference to the NodeMap of distances.
-    ///\pre Either \ref run() or \ref init() must
-    ///be called before using this function.
+    ///\brief Returns a const reference to the node map that stores the
+    ///distances of the nodes.
+    ///
+    ///Returns a const reference to the node map that stores the
+    ///distances of the nodes calculated by the algorithm.
+    ///
+    ///\pre Either \ref run() or \ref init()
+    ///must be called before using this function.
     const DistMap &distMap() const { return *_dist;}
 
-    ///Returns a reference to the %DFS arc-tree map.
-
-    ///Returns a reference to the NodeMap of the arcs of the
-    ///%DFS tree.
+    ///\brief Returns a const reference to the node map that stores the
+    ///predecessor arcs.
+    ///
+    ///Returns a const reference to the node map that stores the predecessor
+    ///arcs, which form the DFS tree.
+    ///
     ///\pre Either \ref run() or \ref init()
     ///must be called before using this function.
     const PredMap &predMap() const { return *_pred;}
 
-    ///Checks if a node is reachable from the root.
+    ///Checks if a node is reachable from the root(s).
 
     ///Returns \c true if \c v is reachable from the root(s).
-    ///\warning The source nodes are inditated as unreachable.
     ///\pre Either \ref run() or \ref start()
     ///must be called before using this function.
-    ///
-    bool reached(Node v) { return (*_reached)[v]; }
+    bool reached(Node v) const { return (*_reached)[v]; }
 
     ///@}
   };
 
-  ///Default traits class of Dfs function.
-
-  ///Default traits class of Dfs function.
+  ///Default traits class of dfs() function.
+
+  ///Default traits class of dfs() function.
   ///\tparam GR Digraph type.
   template<class GR>
   struct DfsWizardDefaultTraits
   {
-    ///The digraph type the algorithm runs on.
+    ///The type of the digraph the algorithm runs on.
     typedef GR Digraph;
-    ///\brief The type of the map that stores the last
+
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the %DFS paths.
     ///
-    ///The type of the map that stores the last
+    ///The type of the map that stores the predecessor
     ///arcs of the %DFS paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     ///
-    typedef NullMap<typename Digraph::Node,typename GR::Arc> PredMap;
-    ///Instantiates a PredMap.
+    typedef NullMap<typename Digraph::Node,typename Digraph::Arc> PredMap;
+    ///Instantiates a \ref PredMap.
 
     ///This function instantiates a \ref PredMap.
-    ///\param g is the digraph, to which we would like to define the 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
-    static PredMap *createPredMap(const GR &g)
+    static PredMap *createPredMap(const Digraph &g)
 #else
-    static PredMap *createPredMap(const GR &)
+    static PredMap *createPredMap(const Digraph &)
 #endif
     {
@@ -770,41 +799,41 @@
     ///The type of the map that indicates which nodes are processed.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a ProcessedMap.
+    ///Instantiates a \ref ProcessedMap.
 
     ///This function instantiates a \ref ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap
+    ///we would like to define the \ref ProcessedMap.
 #ifdef DOXYGEN
-    static ProcessedMap *createProcessedMap(const GR &g)
+    static ProcessedMap *createProcessedMap(const Digraph &g)
 #else
-    static ProcessedMap *createProcessedMap(const GR &)
+    static ProcessedMap *createProcessedMap(const Digraph &)
 #endif
     {
       return new ProcessedMap();
     }
+
     ///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.
+    typedef typename Digraph::template NodeMap<bool> ReachedMap;
+    ///Instantiates a \ref ReachedMap.
+
+    ///This function instantiates a \ref ReachedMap.
+    ///\param g is the digraph, to which
+    ///we would like to define the \ref ReachedMap.
+    static ReachedMap *createReachedMap(const Digraph &g)
+    {
+      return new ReachedMap(g);
+    }
+
+    ///The type of the map that stores the distances of the nodes.
+
+    ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///\todo named parameter to set this type, function to read and write.
-    typedef typename Digraph::template NodeMap<bool> ReachedMap;
-    ///Instantiates a ReachedMap.
-
-    ///This function instantiates a \ref ReachedMap.
-    ///\param G is the digraph, to which
-    ///we would like to define the \ref ReachedMap.
-    static ReachedMap *createReachedMap(const GR &G)
-    {
-      return new ReachedMap(G);
-    }
-    ///The type of the map that stores the dists of the nodes.
-
-    ///The type of the map that stores the dists of the nodes.
-    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
     ///
     typedef NullMap<typename Digraph::Node,int> DistMap;
-    ///Instantiates a DistMap.
+    ///Instantiates a \ref DistMap.
 
     ///This function instantiates a \ref DistMap.
@@ -812,7 +841,7 @@
     ///the \ref DistMap
 #ifdef DOXYGEN
-    static DistMap *createDistMap(const GR &g)
+    static DistMap *createDistMap(const Digraph &g)
 #else
-    static DistMap *createDistMap(const GR &)
+    static DistMap *createDistMap(const Digraph &)
 #endif
     {
@@ -821,10 +850,10 @@
   };
 
-  /// Default traits used by \ref DfsWizard
+  /// Default traits class used by \ref DfsWizard
 
   /// To make it easier to use Dfs algorithm
-  ///we have created a wizard class.
+  /// we have created a wizard class.
   /// This \ref DfsWizard class needs default traits,
-  ///as well as the \ref Dfs class.
+  /// as well as the \ref Dfs class.
   /// The \ref DfsWizardBase is a class to be the default traits of the
   /// \ref DfsWizard class.
@@ -835,18 +864,18 @@
     typedef DfsWizardDefaultTraits<GR> Base;
   protected:
-    /// Type of the nodes in the digraph.
+    //The type of the nodes in the digraph.
     typedef typename Base::Digraph::Node Node;
 
-    /// Pointer to the underlying digraph.
+    //Pointer to the digraph the algorithm runs on.
     void *_g;
-    ///Pointer to the map of reached nodes.
+    //Pointer to the map of reached nodes.
     void *_reached;
-    ///Pointer to the map of processed nodes.
+    //Pointer to the map of processed nodes.
     void *_processed;
-    ///Pointer to the map of predecessors arcs.
+    //Pointer to the map of predecessors arcs.
     void *_pred;
-    ///Pointer to the map of distances.
+    //Pointer to the map of distances.
     void *_dist;
-    ///Pointer to the source node.
+    //Pointer to the source node.
     Node _source;
 
@@ -857,5 +886,5 @@
     /// all of the attributes to default values (0, INVALID).
     DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
-                           _dist(0), _source(INVALID) {}
+                      _dist(0), _source(INVALID) {}
 
     /// Constructor.
@@ -864,6 +893,6 @@
     /// listed in the parameters list.
     /// Others are initiated to 0.
-    /// \param g is the initial value of  \ref _g
-    /// \param s is the initial value of  \ref _source
+    /// \param g The digraph the algorithm runs on.
+    /// \param s The source node.
     DfsWizardBase(const GR &g, Node s=INVALID) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
@@ -872,9 +901,11 @@
   };
 
-  /// A class to make the usage of the Dfs algorithm easier
-
-  /// This class is created to make it easier to use the Dfs algorithm.
-  /// It uses the functions and features of the plain \ref Dfs,
-  /// but it is much simpler to use it.
+  /// 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.
   ///
   /// Simplicity means that the way to change the types defined
@@ -885,10 +916,10 @@
   /// the original class by using the ::
   /// operator. In the case of \ref DfsWizard only
-  /// a function have to be called and it will
+  /// 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.
+  /// 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.
   template<class TR>
   class DfsWizard : public TR
@@ -896,28 +927,24 @@
     typedef TR Base;
 
-    ///The type of the underlying digraph.
+    ///The type of the digraph the algorithm runs on.
     typedef typename TR::Digraph Digraph;
-    //\e
+
     typedef typename Digraph::Node Node;
-    //\e
     typedef typename Digraph::NodeIt NodeIt;
-    //\e
     typedef typename Digraph::Arc Arc;
-    //\e
     typedef typename Digraph::OutArcIt OutArcIt;
 
-    ///\brief The type of the map that stores
-    ///the reached nodes
+    ///\brief The type of the map that stores the predecessor
+    ///arcs of the shortest paths.
+    typedef typename TR::PredMap PredMap;
+    ///\brief The type of the map that stores the distances of the nodes.
+    typedef typename TR::DistMap DistMap;
+    ///\brief The type of the map that indicates which nodes are reached.
     typedef typename TR::ReachedMap ReachedMap;
-    ///\brief The type of the map that stores
-    ///the processed nodes
+    ///\brief The type of the map that indicates which nodes are processed.
     typedef typename TR::ProcessedMap ProcessedMap;
-    ///\brief The type of the map that stores the last
-    ///arcs of the %DFS paths.
-    typedef typename TR::PredMap PredMap;
-    ///The type of the map that stores the distances of the nodes.
-    typedef typename TR::DistMap DistMap;
 
   public:
+
     /// Constructor.
     DfsWizard() : TR() {}
@@ -935,8 +962,8 @@
     ~DfsWizard() {}
 
-    ///Runs Dfs algorithm from a given node.
-
-    ///Runs Dfs algorithm from a given node.
-    ///The node can be given by the \ref source function.
+    ///Runs DFS algorithm from a source node.
+
+    ///Runs DFS algorithm from a source node.
+    ///The node can be given with the \ref source() function.
     void run()
     {
@@ -954,7 +981,7 @@
     }
 
-    ///Runs Dfs algorithm from the given node.
-
-    ///Runs Dfs algorithm from the given node.
+    ///Runs DFS algorithm from the given node.
+
+    ///Runs DFS algorithm from the given node.
     ///\param s is the given source.
     void run(Node s)
@@ -962,4 +989,14 @@
       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;
     }
 
@@ -970,11 +1007,9 @@
       DefPredMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting PredMap type
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///function for setting PredMap type
-    ///
+    ///for setting \ref PredMap object.
+    ///
+    ///\ref named-templ-param "Named parameter"
+    ///for setting \ref PredMap object.
     template<class T>
     DfsWizard<DefPredMapBase<T> > predMap(const T &t)
@@ -983,5 +1018,4 @@
       return DfsWizard<DefPredMapBase<T> >(*this);
     }
-
 
     template<class T>
@@ -991,11 +1025,9 @@
       DefReachedMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting ReachedMap
+    ///for setting \ref ReachedMap object.
     ///
     /// \ref named-templ-param "Named parameter"
-    ///function for setting ReachedMap
-    ///
+    ///for setting \ref ReachedMap object.
     template<class T>
     DfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
@@ -1004,5 +1036,4 @@
       return DfsWizard<DefReachedMapBase<T> >(*this);
     }
-
 
     template<class T>
@@ -1012,11 +1043,9 @@
       DefProcessedMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting ProcessedMap
+    ///for setting \ref ProcessedMap object.
     ///
     /// \ref named-templ-param "Named parameter"
-    ///function for setting ProcessedMap
-    ///
+    ///for setting \ref ProcessedMap object.
     template<class T>
     DfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
@@ -1032,11 +1061,9 @@
       DefDistMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting DistMap type
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///function for setting DistMap type
-    ///
+    ///for setting \ref DistMap object.
+    ///
+    ///\ref named-templ-param "Named parameter"
+    ///for setting \ref DistMap object.
     template<class T>
     DfsWizard<DefDistMapBase<T> > distMap(const T &t)
@@ -1044,14 +1071,4 @@
       Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
       return DfsWizard<DefDistMapBase<T> >(*this);
-    }
-
-    /// 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;
     }
 
@@ -1083,8 +1100,8 @@
 
 #ifdef DOXYGEN
-  /// \brief Visitor class for dfs.
+  /// \brief Visitor class for DFS.
   ///
-  /// It gives a simple interface for a functional interface for dfs
-  /// traversal. The traversal on a linear data structure.
+  /// This class defines the interface of the DfsVisit events, and
+  /// it could be the base of a real visitor class.
   template <typename _Digraph>
   struct DfsVisitor {
@@ -1092,36 +1109,35 @@
     typedef typename Digraph::Arc Arc;
     typedef typename Digraph::Node Node;
-    /// \brief Called when the arc reach a node.
-    ///
-    /// It is called when the dfs find an arc which target is not
-    /// reached yet.
+    /// \brief Called for the source node of the DFS.
+    ///
+    /// This function is called for the source node of the DFS.
+    void start(const Node& node) {}
+    /// \brief Called when the source node is leaved.
+    ///
+    /// This function is called when the source node is leaved.
+    void stop(const Node& node) {}
+    /// \brief Called when a node is reached first time.
+    ///
+    /// This function is called when a node is reached first time.
+    void reach(const Node& node) {}
+    /// \brief Called when an arc reaches a new node.
+    ///
+    /// This function is called when the DFS finds an arc whose target node
+    /// is not reached yet.
     void discover(const Arc& arc) {}
-    /// \brief Called when the node reached first time.
-    ///
-    /// It is Called when the node reached first time.
-    void reach(const Node& node) {}
-    /// \brief Called when we step back on an arc.
-    ///
-    /// It is called when the dfs should step back on the arc.
-    void backtrack(const Arc& arc) {}
-    /// \brief Called when we step back from the node.
-    ///
-    /// It is called when we step back from the node.
-    void leave(const Node& node) {}
-    /// \brief Called when the arc examined but target of the arc
+    /// \brief Called when an arc is examined but its target node is
     /// already discovered.
     ///
-    /// It called when the arc examined but the target of the arc
+    /// This function is called when an arc is examined but its target node is
     /// already discovered.
     void examine(const Arc& arc) {}
-    /// \brief Called for the source node of the dfs.
-    ///
-    /// It is called for the source node of the dfs.
-    void start(const Node& node) {}
-    /// \brief Called when we leave the source node of the dfs.
-    ///
-    /// It is called when we leave the source node of the dfs.
-    void stop(const Node& node) {}
-
+    /// \brief Called when the DFS steps back from a node.
+    ///
+    /// This function is called when the DFS steps back from a node.
+    void leave(const Node& node) {}
+    /// \brief Called when the DFS steps back on an arc.
+    ///
+    /// This function is called when the DFS steps back on an arc.
+    void backtrack(const Arc& arc) {}
   };
 #else
@@ -1131,11 +1147,11 @@
     typedef typename Digraph::Arc Arc;
     typedef typename Digraph::Node Node;
-    void discover(const Arc&) {}
-    void reach(const Node&) {}
-    void backtrack(const Arc&) {}
-    void leave(const Node&) {}
-    void examine(const Arc&) {}
     void start(const Node&) {}
     void stop(const Node&) {}
+    void reach(const Node&) {}
+    void discover(const Arc&) {}
+    void examine(const Arc&) {}
+    void leave(const Node&) {}
+    void backtrack(const Arc&) {}
 
     template <typename _Visitor>
@@ -1144,11 +1160,11 @@
         Arc arc;
         Node node;
-        visitor.discover(arc);
-        visitor.reach(node);
-        visitor.backtrack(arc);
-        visitor.leave(node);
-        visitor.examine(arc);
         visitor.start(node);
         visitor.stop(arc);
+        visitor.reach(node);
+        visitor.discover(arc);
+        visitor.examine(arc);
+        visitor.leave(node);
+        visitor.backtrack(arc);
       }
       _Visitor& visitor;
@@ -1160,9 +1176,9 @@
   ///
   /// Default traits class of DfsVisit class.
-  /// \tparam _Digraph Digraph type.
+  /// \tparam _Digraph The type of the digraph the algorithm runs on.
   template<class _Digraph>
   struct DfsVisitDefaultTraits {
 
-    /// \brief The digraph type the algorithm runs on.
+    /// \brief The type of the digraph the algorithm runs on.
     typedef _Digraph Digraph;
 
@@ -1170,9 +1186,8 @@
     ///
     /// The type of the map that indicates which nodes are reached.
-    /// It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    /// \todo named parameter to set this type, function to read and write.
+    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
     typedef typename Digraph::template NodeMap<bool> ReachedMap;
 
-    /// \brief Instantiates a ReachedMap.
+    /// \brief Instantiates a \ref ReachedMap.
     ///
     /// This function instantiates a \ref ReachedMap.
@@ -1185,7 +1200,8 @@
   };
 
-  /// %DFS Visit algorithm class.
-
   /// \ingroup search
+  ///
+  /// \brief %DFS algorithm class with visitor interface.
+  ///
   /// This class provides an efficient implementation of the %DFS algorithm
   /// with visitor interface.
@@ -1193,21 +1209,19 @@
   /// The %DfsVisit class provides an alternative interface to the Dfs
   /// class. It works with callback mechanism, the DfsVisit object calls
-  /// on every dfs event the \c Visitor class member functions.
+  /// the member functions of the \c Visitor class on every DFS event.
   ///
-  /// \tparam _Digraph The digraph type the algorithm runs on.
+  /// \tparam _Digraph The type of the digraph the algorithm runs on.
   /// The default value is
-  /// \ref ListDigraph. The value of _Digraph is not used directly by Dfs, it
-  /// is only passed to \ref DfsDefaultTraits.
-  /// \tparam _Visitor The Visitor object for the algorithm. The
-  /// \ref DfsVisitor "DfsVisitor<_Digraph>" is an empty Visitor which
-  /// does not observe the Dfs events. If you want to observe the dfs
-  /// events you should implement your own Visitor class.
+  /// \ref ListDigraph. The value of _Digraph is not used directly by
+  /// \ref DfsVisit, it is only passed to \ref DfsVisitDefaultTraits.
+  /// \tparam _Visitor The Visitor type that is used by the algorithm.
+  /// \ref DfsVisitor "DfsVisitor<_Digraph>" is an empty visitor, which
+  /// does not observe the DFS events. If you want to observe the DFS
+  /// events, you should implement your own visitor class.
   /// \tparam _Traits Traits class to set various data types used by the
   /// algorithm. The default traits class is
   /// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits<_Digraph>".
   /// See \ref DfsVisitDefaultTraits for the documentation of
-  /// a Dfs visit traits class.
-  ///
-  /// \author Jacint Szabo, Alpar Juttner and Balazs Dezso
+  /// a DFS visit traits class.
 #ifdef DOXYGEN
   template <typename _Digraph, typename _Visitor, typename _Traits>
@@ -1223,5 +1237,5 @@
     ///
     /// This error represents problems in the initialization
-    /// of the parameters of the algorithms.
+    /// of the parameters of the algorithm.
     class UninitializedParameter : public lemon::UninitializedParameter {
     public:
@@ -1232,11 +1246,14 @@
     };
 
+    ///The traits class.
     typedef _Traits Traits;
 
+    ///The type of the digraph the algorithm runs on.
     typedef typename Traits::Digraph Digraph;
 
+    ///The visitor type used by the algorithm.
     typedef _Visitor Visitor;
 
-    ///The type of the map indicating which nodes are reached.
+    ///The type of the map that indicates which nodes are reached.
     typedef typename Traits::ReachedMap ReachedMap;
 
@@ -1248,11 +1265,11 @@
     typedef typename Digraph::OutArcIt OutArcIt;
 
-    /// Pointer to the underlying digraph.
+    //Pointer to the underlying digraph.
     const Digraph *_digraph;
-    /// Pointer to the visitor object.
+    //Pointer to the visitor object.
     Visitor *_visitor;
-    ///Pointer to the map of reached status of the nodes.
+    //Pointer to the map of reached status of the nodes.
     ReachedMap *_reached;
-    ///Indicates if \ref _reached is locally allocated (\c true) or not.
+    //Indicates if _reached is locally allocated (true) or not.
     bool local_reached;
 
@@ -1260,7 +1277,6 @@
     int _stack_head;
 
-    /// \brief Creates the maps if necessary.
-    ///
-    /// Creates the maps if necessary.
+    ///Creates the maps if necessary.
+    ///\todo Better memory allocation (instead of new).
     void create_maps() {
       if(!_reached) {
@@ -1289,7 +1305,7 @@
     };
     /// \brief \ref named-templ-param "Named parameter" for setting
-    /// ReachedMap type
-    ///
-    /// \ref named-templ-param "Named parameter" for setting ReachedMap type
+    /// ReachedMap type.
+    ///
+    /// \ref named-templ-param "Named parameter" for setting ReachedMap type.
     template <class T>
     struct DefReachedMap : public DfsVisit< Digraph, Visitor,
@@ -1305,7 +1321,6 @@
     /// Constructor.
     ///
-    /// \param digraph the digraph the algorithm will run on.
-    /// \param visitor The visitor of the algorithm.
-    ///
+    /// \param digraph The digraph the algorithm runs on.
+    /// \param visitor The visitor object of the algorithm.
     DfsVisit(const Digraph& digraph, Visitor& visitor)
       : _digraph(&digraph), _visitor(&visitor),
@@ -1313,15 +1328,13 @@
 
     /// \brief Destructor.
-    ///
-    /// Destructor.
     ~DfsVisit() {
       if(local_reached) delete _reached;
     }
 
-    /// \brief Sets the map indicating if a node is reached.
-    ///
-    /// Sets the map indicating if a node is reached.
+    /// \brief Sets the map that indicates which nodes are reached.
+    ///
+    /// Sets the map that indicates which nodes are reached.
     /// If you don't use this function before calling \ref run(),
-    /// it will allocate one. The destuctor deallocates this
+    /// it will allocate one. The destructor deallocates this
     /// automatically allocated map, of course.
     /// \return <tt> (*this) </tt>
@@ -1336,19 +1349,21 @@
 
   public:
+
     /// \name Execution control
     /// The simplest way to execute the algorithm is to use
-    /// one of the member functions called \c run(...).
+    /// one of the member functions called \ref lemon::DfsVisit::run()
+    /// "run()".
     /// \n
-    /// If you need more control on the execution,
-    /// first you must call \ref init(), then you can adda source node
-    /// with \ref addSource().
-    /// Finally \ref start() will perform the actual path
-    /// computation.
+    /// If you need more control on the execution, first you must call
+    /// \ref lemon::DfsVisit::init() "init()", then you can add several
+    /// source nodes with \ref lemon::DfsVisit::addSource() "addSource()".
+    /// Finally \ref lemon::DfsVisit::start() "start()" will perform the
+    /// actual path computation.
 
     /// @{
+
     /// \brief Initializes the internal data structures.
     ///
     /// Initializes the internal data structures.
-    ///
     void init() {
       create_maps();
@@ -1360,8 +1375,16 @@
     }
 
-    /// \brief Adds a new source node.
-    ///
-    /// Adds a new source node to the set of nodes to be processed.
-    void addSource(Node s) {
+    ///Adds a new source node.
+
+    ///Adds a new source node to the set of nodes to be processed.
+    ///
+    ///\pre The stack must be empty. (Otherwise the algorithm gives
+    ///false results.)
+    ///
+    ///\warning Distances will be wrong (or at least strange) in case of
+    ///multiple sources.
+    void addSource(Node s)
+    {
+      LEMON_DEBUG(emptyQueue(), "The stack is not empty.");
       if(!(*_reached)[s]) {
           _reached->set(s,true);
@@ -1384,5 +1407,5 @@
     /// \return The processed arc.
     ///
-    /// \pre The stack must not be empty!
+    /// \pre The stack must not be empty.
     Arc processNextArc() {
       Arc e = _stack[_stack_head];
@@ -1418,19 +1441,19 @@
     /// \return The next arc to be processed or INVALID if the stack is
     /// empty.
-    Arc nextArc() {
+    Arc nextArc() const {
       return _stack_head >= 0 ? _stack[_stack_head] : INVALID;
     }
 
     /// \brief Returns \c false if there are nodes
-    /// to be processed in the queue
+    /// to be processed.
     ///
     /// Returns \c false if there are nodes
-    /// to be processed in the queue
-    bool emptyQueue() { return _stack_head < 0; }
+    /// to be processed in the queue (stack).
+    bool emptyQueue() const { return _stack_head < 0; }
 
     /// \brief Returns the number of the nodes to be processed.
     ///
-    /// Returns the number of the nodes to be processed in the queue.
-    int queueSize() { return _stack_head + 1; }
+    /// Returns the number of the nodes to be processed in the queue (stack).
+    int queueSize() const { return _stack_head + 1; }
 
     /// \brief Executes the algorithm.
@@ -1438,15 +1461,36 @@
     /// Executes the algorithm.
     ///
-    /// \pre init() must be called and at least one node should be added
-    /// with addSource() before using this function.
+    /// This method runs the %DFS algorithm from the root node
+    /// in order to compute the %DFS path to each node.
+    ///
+    /// The algorithm computes
+    /// - the %DFS tree,
+    /// - the distance of each node 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.
+    ///
+    /// \note <tt>d.start()</tt> is just a shortcut of the following code.
+    /// \code
+    ///   while ( !d.emptyQueue() ) {
+    ///     d.processNextArc();
+    ///   }
+    /// \endcode
     void start() {
       while ( !emptyQueue() ) processNextArc();
     }
 
-    /// \brief Executes the algorithm until \c dest is reached.
-    ///
-    /// Executes the algorithm until \c dest is reached.
-    ///
-    /// \pre init() must be called and at least one node should be added
+    /// \brief Executes the algorithm until the given target node is reached.
+    ///
+    /// Executes the algorithm until the given target node is reached.
+    ///
+    /// This method runs the %DFS algorithm from the root node
+    /// in order to compute the DFS path to \c dest.
+    ///
+    /// The algorithm computes
+    /// - the %DFS path to \c dest,
+    /// - the distance of \c dest 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) {
@@ -1459,26 +1503,35 @@
     /// Executes the algorithm until a condition is met.
     ///
-    /// \pre init() must be called and at least one node should be added
+    /// This method runs the %DFS algorithm from the root node
+    /// until an arc \c a with <tt>am[a]</tt> true is found.
+    ///
+    /// \param am A \c bool (or convertible) arc map. The algorithm
+    /// will stop when it reaches an arc \c a with <tt>am[a]</tt> true.
+    ///
+    /// \return The reached arc \c a with <tt>am[a]</tt> true or
+    /// \c INVALID if no such arc was found.
+    ///
+    /// \pre init() must be called and a root node should be added
     /// with addSource() before using this function.
     ///
-    /// \param em must be a bool (or convertible) arc map. The algorithm
-    /// will stop when it reaches an arc \c e with <tt>em[e]</tt> true.
-    ///
-    ///\return The reached arc \c e with <tt>em[e]</tt> true or
-    ///\c INVALID if no such arc was found.
-    ///
-    /// \warning Contrary to \ref Bfs and \ref Dijkstra, \c em is an arc map,
+    /// \warning Contrary to \ref Bfs and \ref Dijkstra, \c am is an arc map,
     /// not a node map.
-    template <typename EM>
-    Arc start(const EM &em) {
-      while ( !emptyQueue() && !em[_stack[_stack_head]] )
+    template <typename AM>
+    Arc start(const AM &am) {
+      while ( !emptyQueue() && !am[_stack[_stack_head]] )
         processNextArc();
       return emptyQueue() ? INVALID : _stack[_stack_head];
     }
 
-    /// \brief Runs %DFSVisit algorithm from node \c s.
-    ///
-    /// This method runs the %DFS algorithm from a root node \c s.
-    /// \note d.run(s) is just a shortcut of the following code.
+    /// \brief Runs the algorithm from the given node.
+    ///
+    /// This method runs the %DFS algorithm from node \c s.
+    /// in order to compute the DFS path to each node.
+    ///
+    /// The algorithm computes
+    /// - the %DFS tree,
+    /// - the distance of each node from the root in the %DFS tree.
+    ///
+    /// \note <tt>d.run(s)</tt> is just a shortcut of the following code.
     ///\code
     ///   d.init();
@@ -1492,20 +1545,44 @@
     }
 
-    /// \brief Runs %DFSVisit algorithm to visit all nodes in the digraph.
+    /// \brief Finds the %DFS path between \c s and \c t.
+
+    /// 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.
+    ///
+    /// \note Apart from the return value, <tt>d.run(s,t)</tt> is
+    /// just a shortcut of the following code.
+    ///\code
+    ///   d.init();
+    ///   d.addSource(s);
+    ///   d.start(t);
+    ///\endcode
+    int run(Node s,Node t) {
+      init();
+      addSource(s);
+      start(t);
+      return reached(t)?_stack_head+1:0;
+    }
+
+    /// \brief Runs the algorithm to visit all nodes in the digraph.
 
     /// This method runs the %DFS algorithm in order to
-    /// compute the %DFS path to each node. The algorithm computes
-    /// - The %DFS tree.
-    /// - The distance of each node from the root in the %DFS tree.
-    ///
-    ///\note d.run() is just a shortcut of the following code.
+    /// compute the %DFS path to each node.
+    ///
+    /// The algorithm computes
+    /// - the %DFS tree,
+    /// - the distance of each node from the root in the %DFS tree.
+    ///
+    /// \note <tt>d.run()</tt> is just a shortcut of the following code.
     ///\code
-    ///  d.init();
-    ///  for (NodeIt it(digraph); it != INVALID; ++it) {
-    ///    if (!d.reached(it)) {
-    ///      d.addSource(it);
-    ///      d.start();
-    ///    }
-    ///  }
+    ///   d.init();
+    ///   for (NodeIt n(digraph); n != INVALID; ++n) {
+    ///     if (!d.reached(n)) {
+    ///       d.addSource(n);
+    ///       d.start();
+    ///     }
+    ///   }
     ///\endcode
     void run() {
@@ -1518,4 +1595,5 @@
       }
     }
+
     ///@}
 
@@ -1523,21 +1601,21 @@
     /// The result of the %DFS algorithm can be obtained using these
     /// functions.\n
-    /// Before the use of these functions,
-    /// either run() or start() must be called.
+    /// Either \ref lemon::DfsVisit::run() "run()" or
+    /// \ref lemon::DfsVisit::start() "start()" must be called before
+    /// using them.
     ///@{
-    /// \brief Checks if a node is reachable from the root.
+
+    /// \brief Checks if a node is reachable from the root(s).
     ///
     /// Returns \c true if \c v is reachable from the root(s).
-    /// \warning The source nodes are inditated as unreachable.
     /// \pre Either \ref run() or \ref start()
     /// must be called before using this function.
-    ///
     bool reached(Node v) { return (*_reached)[v]; }
+
     ///@}
+
   };
 
-
 } //END OF NAMESPACE LEMON
 
 #endif
-
Index: lemon/dijkstra.h
===================================================================
--- lemon/dijkstra.h	(revision 220)
+++ lemon/dijkstra.h	(revision 244)
@@ -28,5 +28,5 @@
 #include <lemon/bin_heap.h>
 #include <lemon/bits/path_dump.h>
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 #include <lemon/error.h>
 #include <lemon/maps.h>
@@ -34,8 +34,8 @@
 namespace lemon {
 
-  /// \brief Default OperationTraits for the Dijkstra algorithm class.
+  /// \brief Default operation traits for the Dijkstra algorithm class.
   ///
-  /// It defines all computational operations and constants which are
-  /// used in the Dijkstra algorithm.
+  /// This operation traits class defines all computational operations and
+  /// constants which are used in the Dijkstra algorithm.
   template <typename Value>
   struct DijkstraDefaultOperationTraits {
@@ -48,5 +48,5 @@
       return left + right;
     }
-    /// \brief Gives back true only if the first value less than the second.
+    /// \brief Gives back true only if the first value is less than the second.
     static bool less(const Value& left, const Value& right) {
       return left < right;
@@ -54,8 +54,11 @@
   };
 
-  /// \brief Widest path OperationTraits for the Dijkstra algorithm class.
+  /// \brief Widest path operation traits for the Dijkstra algorithm class.
   ///
-  /// It defines all computational operations and constants which are
-  /// used in the Dijkstra algorithm for widest path computation.
+  /// This operation traits class defines all computational operations and
+  /// constants which are used in the Dijkstra algorithm for widest path
+  /// computation.
+  ///
+  /// \see DijkstraDefaultOperationTraits
   template <typename Value>
   struct DijkstraWidestPathOperationTraits {
@@ -68,5 +71,5 @@
       return std::min(left, right);
     }
-    /// \brief Gives back true only if the first value less than the second.
+    /// \brief Gives back true only if the first value is less than the second.
     static bool less(const Value& left, const Value& right) {
       return left < right;
@@ -77,11 +80,12 @@
 
   ///Default traits class of Dijkstra class.
-  ///\tparam GR Digraph type.
-  ///\tparam LM Type of length map.
+  ///\tparam GR The type of the digraph.
+  ///\tparam LM The type of the length map.
   template<class GR, class LM>
   struct DijkstraDefaultTraits
   {
-    ///The digraph type the algorithm runs on.
+    ///The type of the digraph the algorithm runs on.
     typedef GR Digraph;
+
     ///The type of the map that stores the arc lengths.
 
@@ -89,94 +93,96 @@
     ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
     typedef LM LengthMap;
-    //The type of the length of the arcs.
+    ///The type of the length of the arcs.
     typedef typename LM::Value Value;
+
     /// Operation traits for Dijkstra algorithm.
 
-    /// It defines the used operation by the algorithm.
+    /// This class defines the operations that are used in the algorithm.
     /// \see DijkstraDefaultOperationTraits
     typedef DijkstraDefaultOperationTraits<Value> OperationTraits;
-    /// The cross reference type used by heap.
-
-
-    /// The cross reference type used by heap.
+
+    /// The cross reference type used by the heap.
+
+    /// The cross reference type used by the heap.
     /// Usually it is \c Digraph::NodeMap<int>.
     typedef typename Digraph::template NodeMap<int> HeapCrossRef;
-    ///Instantiates a HeapCrossRef.
-
-    ///This function instantiates a \c HeapCrossRef.
-    /// \param G is the digraph, to which we would like to define the
-    /// HeapCrossRef.
-    static HeapCrossRef *createHeapCrossRef(const GR &G)
-    {
-      return new HeapCrossRef(G);
-    }
-
-    ///The heap type used by Dijkstra algorithm.
-
-    ///The heap type used by Dijkstra algorithm.
+    ///Instantiates a \ref HeapCrossRef.
+
+    ///This function instantiates a \ref HeapCrossRef.
+    /// \param g is the digraph, to which we would like to define the
+    /// \ref HeapCrossRef.
+    static HeapCrossRef *createHeapCrossRef(const Digraph &g)
+    {
+      return new HeapCrossRef(g);
+    }
+
+    ///The heap type used by the Dijkstra algorithm.
+
+    ///The heap type used by the Dijkstra algorithm.
     ///
     ///\sa BinHeap
     ///\sa Dijkstra
     typedef BinHeap<typename LM::Value, HeapCrossRef, std::less<Value> > Heap;
-
-    static Heap *createHeap(HeapCrossRef& R)
-    {
-      return new Heap(R);
-    }
-
-    ///\brief The type of the map that stores the last
+    ///Instantiates a \ref Heap.
+
+    ///This function instantiates a \ref Heap.
+    static Heap *createHeap(HeapCrossRef& r)
+    {
+      return new Heap(r);
+    }
+
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///
-    ///The type of the map that stores the last
+    ///The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef typename Digraph::template NodeMap<typename GR::Arc> PredMap;
-    ///Instantiates a PredMap.
-
-    ///This function instantiates a \c PredMap.
-    ///\param G is the digraph, to which we would like to define the PredMap.
+    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
+    ///Instantiates a \ref PredMap.
+
+    ///This function instantiates a \ref 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
-    static PredMap *createPredMap(const GR &G)
-    {
-      return new PredMap(G);
-    }
-
-    ///The type of the map that stores whether a nodes is processed.
-
-    ///The type of the map that stores whether a nodes is processed.
+    static PredMap *createPredMap(const Digraph &g)
+    {
+      return new PredMap(g);
+    }
+
+    ///The type of the map that indicates which nodes are processed.
+
+    ///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.
     ///\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 ProcessedMap.
-
-    ///This function instantiates a \c ProcessedMap.
+    ///Instantiates a \ref ProcessedMap.
+
+    ///This function instantiates a \ref ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \c ProcessedMap
+    ///we would like to define the \ref ProcessedMap
 #ifdef DOXYGEN
-    static ProcessedMap *createProcessedMap(const GR &g)
+    static ProcessedMap *createProcessedMap(const Digraph &g)
 #else
-    static ProcessedMap *createProcessedMap(const GR &)
+    static ProcessedMap *createProcessedMap(const Digraph &)
 #endif
     {
       return new ProcessedMap();
     }
-    ///The type of the map that stores the dists of the nodes.
-
-    ///The type of the map that stores the dists of the nodes.
+
+    ///The type of the map that stores the distances of the nodes.
+
+    ///The type of the map that stores the distances of the nodes.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
     typedef typename Digraph::template NodeMap<typename LM::Value> DistMap;
-    ///Instantiates a DistMap.
+    ///Instantiates a \ref DistMap.
 
     ///This function instantiates a \ref DistMap.
-    ///\param G is the digraph, to which we would like to define
+    ///\param g is the digraph, to which we would like to define
     ///the \ref DistMap
-    static DistMap *createDistMap(const GR &G)
-    {
-      return new DistMap(G);
+    static DistMap *createDistMap(const Digraph &g)
+    {
+      return new DistMap(g);
     }
   };
@@ -185,31 +191,32 @@
 
   /// \ingroup shortest_path
-  ///This class provides an efficient implementation of %Dijkstra algorithm.
+  ///This class provides an efficient implementation of the %Dijkstra algorithm.
+  ///
   ///The arc lengths are passed to the algorithm using a
   ///\ref concepts::ReadMap "ReadMap",
   ///so it is easy to change it to any kind of length.
-  ///
   ///The type of the length is determined by the
   ///\ref concepts::ReadMap::Value "Value" of the length map.
-  ///
   ///It is also possible to change the underlying priority heap.
   ///
-  ///\tparam GR The digraph type the algorithm runs on. The default value
-  ///is \ref ListDigraph. The value of GR is not used directly by
-  ///Dijkstra, it is only passed to \ref DijkstraDefaultTraits.
-  ///\tparam LM This read-only ArcMap determines the lengths of 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.
+  ///
+  ///\tparam GR The type of the digraph the algorithm runs on.
+  ///The default value is \ref ListDigraph.
+  ///The value of GR is not used directly by \ref Dijkstra, it is only
+  ///passed to \ref DijkstraDefaultTraits.
+  ///\tparam LM A readable arc map that determines the lengths of the
   ///arcs. It is read once for each arc, so the map may involve in
-  ///relatively time consuming process to compute the arc length if
+  ///relatively time consuming process to compute the arc lengths if
   ///it is necessary. The default map type is \ref
-  ///concepts::Digraph::ArcMap "Digraph::ArcMap<int>".  The value
-  ///of LM is not used directly by Dijkstra, it is only passed to \ref
-  ///DijkstraDefaultTraits.
-  ///\tparam TR Traits class to set
-  ///various data types used by the algorithm.  The default traits
-  ///class is \ref DijkstraDefaultTraits
-  ///"DijkstraDefaultTraits<GR,LM>".  See \ref
-  ///DijkstraDefaultTraits for the documentation of a Dijkstra traits
-  ///class.
-
+  ///concepts::Digraph::ArcMap "Digraph::ArcMap<int>".
+  ///The value of LM is not used directly by \ref Dijkstra, it is only
+  ///passed to \ref DijkstraDefaultTraits.
+  ///\tparam TR Traits class to set various data types used by the algorithm.
+  ///The default traits class is \ref DijkstraDefaultTraits
+  ///"DijkstraDefaultTraits<GR,LM>". See \ref DijkstraDefaultTraits
+  ///for the documentation of a Dijkstra traits class.
 #ifdef DOXYGEN
   template <typename GR, typename LM, typename TR>
@@ -221,10 +228,8 @@
   class Dijkstra {
   public:
-    /**
-     * \brief \ref Exception for uninitialized parameters.
-     *
-     * This error represents problems in the initialization
-     * of the parameters of the algorithms.
-     */
+    ///\ref Exception for uninitialized parameters.
+
+    ///This error represents problems in the initialization of the
+    ///parameters of the algorithm.
     class UninitializedParameter : public lemon::UninitializedParameter {
     public:
@@ -234,15 +239,6 @@
     };
 
-    typedef TR Traits;
-    ///The type of the underlying digraph.
+    ///The type of the digraph the algorithm runs on.
     typedef typename TR::Digraph Digraph;
-    ///\e
-    typedef typename Digraph::Node Node;
-    ///\e
-    typedef typename Digraph::NodeIt NodeIt;
-    ///\e
-    typedef typename Digraph::Arc Arc;
-    ///\e
-    typedef typename Digraph::OutArcIt OutArcIt;
 
     ///The type of the length of the arcs.
@@ -250,45 +246,56 @@
     ///The type of the map that stores the arc lengths.
     typedef typename TR::LengthMap LengthMap;
-    ///\brief The type of the map that stores the last
-    ///arcs of the shortest paths.
+    ///\brief The type of the map that stores the predecessor arcs of the
+    ///shortest paths.
     typedef typename TR::PredMap PredMap;
-    ///The type of the map indicating if a node is processed.
+    ///The type of the map that stores the distances of the nodes.
+    typedef typename TR::DistMap DistMap;
+    ///The type of the map that indicates which nodes are processed.
     typedef typename TR::ProcessedMap ProcessedMap;
-    ///The type of the map that stores the dists of the nodes.
-    typedef typename TR::DistMap DistMap;
+    ///The type of the paths.
+    typedef PredMapPath<Digraph, PredMap> Path;
     ///The cross reference type used for the current heap.
     typedef typename TR::HeapCrossRef HeapCrossRef;
-    ///The heap type used by the dijkstra algorithm.
+    ///The heap type used by the algorithm.
     typedef typename TR::Heap Heap;
-    ///The operation traits.
+    ///The operation traits class.
     typedef typename TR::OperationTraits OperationTraits;
+
+    ///The traits class.
+    typedef TR Traits;
+
   private:
-    /// Pointer to the underlying digraph.
+
+    typedef typename Digraph::Node Node;
+    typedef typename Digraph::NodeIt NodeIt;
+    typedef typename Digraph::Arc Arc;
+    typedef typename Digraph::OutArcIt OutArcIt;
+
+    //Pointer to the underlying digraph.
     const Digraph *G;
-    /// Pointer to the length map
+    //Pointer to the length map.
     const LengthMap *length;
-    ///Pointer to the map of predecessors arcs.
+    //Pointer to the map of predecessors arcs.
     PredMap *_pred;
-    ///Indicates if \ref _pred is locally allocated (\c true) or not.
+    //Indicates if _pred is locally allocated (true) or not.
     bool local_pred;
-    ///Pointer to the map of distances.
+    //Pointer to the map of distances.
     DistMap *_dist;
-    ///Indicates if \ref _dist is locally allocated (\c true) or not.
+    //Indicates if _dist is locally allocated (true) or not.
     bool local_dist;
-    ///Pointer to the map of processed status of the nodes.
+    //Pointer to the map of processed status of the nodes.
     ProcessedMap *_processed;
-    ///Indicates if \ref _processed is locally allocated (\c true) or not.
+    //Indicates if _processed is locally allocated (true) or not.
     bool local_processed;
-    ///Pointer to the heap cross references.
+    //Pointer to the heap cross references.
     HeapCrossRef *_heap_cross_ref;
-    ///Indicates if \ref _heap_cross_ref is locally allocated (\c true) or not.
+    //Indicates if _heap_cross_ref is locally allocated (true) or not.
     bool local_heap_cross_ref;
-    ///Pointer to the heap.
+    //Pointer to the heap.
     Heap *_heap;
-    ///Indicates if \ref _heap is locally allocated (\c true) or not.
+    //Indicates if _heap is locally allocated (true) or not.
     bool local_heap;
 
     ///Creates the maps if necessary.
-
     ///\todo Better memory allocation (instead of new).
     void create_maps()
@@ -316,5 +323,5 @@
     }
 
-  public :
+  public:
 
     typedef Dijkstra Create;
@@ -332,8 +339,9 @@
       }
     };
-    ///\ref named-templ-param "Named parameter" for setting PredMap type
-
-    ///\ref named-templ-param "Named parameter" for setting PredMap type
-    ///
+    ///\brief \ref named-templ-param "Named parameter" for setting
+    ///\ref PredMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref PredMap type.
     template <class T>
     struct DefPredMap
@@ -350,8 +358,9 @@
       }
     };
-    ///\ref named-templ-param "Named parameter" for setting DistMap type
-
-    ///\ref named-templ-param "Named parameter" for setting DistMap type
-    ///
+    ///\brief \ref named-templ-param "Named parameter" for setting
+    ///\ref DistMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref DistMap type.
     template <class T>
     struct DefDistMap
@@ -363,13 +372,14 @@
     struct DefProcessedMapTraits : public Traits {
       typedef T ProcessedMap;
-      static ProcessedMap *createProcessedMap(const Digraph &G)
+      static ProcessedMap *createProcessedMap(const Digraph &)
       {
         throw UninitializedParameter();
       }
     };
-    ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
-
-    ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
-    ///
+    ///\brief \ref named-templ-param "Named parameter" for setting
+    ///\ref ProcessedMap type.
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref ProcessedMap type.
     template <class T>
     struct DefProcessedMap
@@ -380,15 +390,15 @@
     struct DefDigraphProcessedMapTraits : public Traits {
       typedef typename Digraph::template NodeMap<bool> ProcessedMap;
-      static ProcessedMap *createProcessedMap(const Digraph &G)
+      static ProcessedMap *createProcessedMap(const Digraph &g)
       {
-        return new ProcessedMap(G);
-      }
-    };
-    ///\brief \ref named-templ-param "Named parameter"
-    ///for setting the ProcessedMap type to be Digraph::NodeMap<bool>.
-    ///
-    ///\ref named-templ-param "Named parameter"
-    ///for setting the ProcessedMap type to be Digraph::NodeMap<bool>.
-    ///If you don't set it explicitely, it will be automatically allocated.
+        return new ProcessedMap(g);
+      }
+    };
+    ///\brief \ref named-templ-param "Named parameter" for setting
+    ///\ref 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>.
+    ///If you don't set it explicitly, it will be automatically allocated.
     template <class T>
     struct DefProcessedMapToBeDefaultMap
@@ -414,6 +424,5 @@
     ///
     ///\ref named-templ-param "Named parameter" for setting heap and cross
-    ///reference type
-    ///
+    ///reference type.
     template <class H, class CR = typename Digraph::template NodeMap<int> >
     struct DefHeap
@@ -454,8 +463,8 @@
 
     /// \brief \ref named-templ-param "Named parameter" for setting
-    /// OperationTraits type
-    ///
-    /// \ref named-templ-param "Named parameter" for setting OperationTraits
-    /// type
+    ///\ref OperationTraits type
+    ///
+    ///\ref named-templ-param "Named parameter" for setting
+    ///\ref OperationTraits type.
     template <class T>
     struct DefOperationTraits
@@ -467,5 +476,4 @@
     ///@}
 
-
   protected:
 
@@ -476,8 +484,9 @@
     ///Constructor.
 
-    ///\param _G the digraph the algorithm will run on.
-    ///\param _length the length map used by the algorithm.
-    Dijkstra(const Digraph& _G, const LengthMap& _length) :
-      G(&_G), length(&_length),
+    ///Constructor.
+    ///\param _g The digraph the algorithm runs on.
+    ///\param _length The length map used by the algorithm.
+    Dijkstra(const Digraph& _g, const LengthMap& _length) :
+      G(&_g), length(&_length),
       _pred(NULL), local_pred(false),
       _dist(NULL), local_dist(false),
@@ -507,9 +516,9 @@
     }
 
-    ///Sets the map storing the predecessor arcs.
-
-    ///Sets the map storing the predecessor arcs.
+    ///Sets the map that stores the predecessor arcs.
+
+    ///Sets the map that stores the predecessor arcs.
     ///If you don't use this function before calling \ref run(),
-    ///it will allocate one. The destuctor deallocates this
+    ///it will allocate one. The destructor deallocates this
     ///automatically allocated map, of course.
     ///\return <tt> (*this) </tt>
@@ -524,9 +533,27 @@
     }
 
-    ///Sets the map storing the distances calculated by the algorithm.
-
-    ///Sets the map storing the distances calculated by the algorithm.
+    ///Sets the map that indicates which nodes are processed.
+
+    ///Sets the map that indicates which nodes are processed.
     ///If you don't use this function before calling \ref run(),
-    ///it will allocate one. The destuctor deallocates this
+    ///it will allocate one. The destructor deallocates this
+    ///automatically allocated map, of course.
+    ///\return <tt> (*this) </tt>
+    Dijkstra &processedMap(ProcessedMap &m)
+    {
+      if(local_processed) {
+        delete _processed;
+        local_processed=false;
+      }
+      _processed = &m;
+      return *this;
+    }
+
+    ///Sets the map that stores the distances of the nodes.
+
+    ///Sets the map that stores the distances of the nodes calculated by the
+    ///algorithm.
+    ///If you don't use this function before calling \ref run(),
+    ///it will allocate one. The destructor deallocates this
     ///automatically allocated map, of course.
     ///\return <tt> (*this) </tt>
@@ -545,5 +572,5 @@
     ///Sets the heap and the cross reference used by algorithm.
     ///If you don't use this function before calling \ref run(),
-    ///it will allocate one. The destuctor deallocates this
+    ///it will allocate one. The destructor deallocates this
     ///automatically allocated heap and cross reference, of course.
     ///\return <tt> (*this) </tt>
@@ -564,4 +591,5 @@
 
   private:
+
     void finalizeNodeData(Node v,Value dst)
     {
@@ -572,15 +600,13 @@
   public:
 
-    typedef PredMapPath<Digraph, PredMap> Path;
-
     ///\name Execution control
-    ///The simplest way to execute the algorithm is to use
-    ///one of the member functions called \c run(...).
+    ///The simplest way to execute the algorithm is to use one of the
+    ///member functions called \ref lemon::Dijkstra::run() "run()".
     ///\n
-    ///If you need more control on the execution,
-    ///first you must call \ref init(), then you can add several source nodes
-    ///with \ref addSource().
-    ///Finally \ref start() will perform the actual path
-    ///computation.
+    ///If you need more control on the execution, first you must call
+    ///\ref lemon::Dijkstra::init() "init()", then you can add several
+    ///source nodes with \ref lemon::Dijkstra::addSource() "addSource()".
+    ///Finally \ref lemon::Dijkstra::start() "start()" will perform the
+    ///actual path computation.
 
     ///@{
@@ -604,8 +630,7 @@
 
     ///Adds a new source node to the priority heap.
-    ///
     ///The optional second parameter is the initial distance of the node.
     ///
-    ///It checks if the node has already been added to the heap and
+    ///The function checks if the node has already been added to the heap and
     ///it is pushed to the heap only if either it was not in the heap
     ///or the shortest path found till then is shorter than \c dst.
@@ -626,5 +651,5 @@
     ///\return The processed node.
     ///
-    ///\warning The priority heap must not be empty!
+    ///\warning The priority heap must not be empty.
     Node processNextNode()
     {
@@ -657,11 +682,9 @@
     }
 
-    ///Next node to be processed.
-
-    ///Next node to be processed.
-    ///
-    ///\return The next node to be processed or INVALID if the priority heap
-    /// is empty.
-    Node nextNode()
+    ///The next node to be processed.
+
+    ///Returns the next node to be processed or \c INVALID if the
+    ///priority heap is empty.
+    Node nextNode() const
     {
       return !_heap->empty()?_heap->top():INVALID;
@@ -669,14 +692,15 @@
 
     ///\brief Returns \c false if there are nodes
-    ///to be processed in the priority heap
+    ///to be processed.
     ///
     ///Returns \c false if there are nodes
-    ///to be processed in the priority heap
-    bool emptyQueue() { return _heap->empty(); }
+    ///to be processed in the priority heap.
+    bool emptyQueue() const { return _heap->empty(); }
+
     ///Returns the number of the nodes to be processed in the priority heap
 
-    ///Returns the number of the nodes to be processed in the priority heap
-    ///
-    int queueSize() { return _heap->size(); }
+    ///Returns the number of the nodes to be processed in the priority heap.
+    ///
+    int queueSize() const { return _heap->size(); }
 
     ///Executes the algorithm.
@@ -684,33 +708,38 @@
     ///Executes the algorithm.
     ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
-    ///
     ///This method runs the %Dijkstra algorithm from the root node(s)
-    ///in order to
-    ///compute the
-    ///shortest path to each node. The algorithm computes
-    ///- The shortest path tree.
-    ///- The distance of each node from the root(s).
-    ///
+    ///in order to compute the shortest path to each node.
+    ///
+    ///The algorithm computes
+    ///- the shortest path tree (forest),
+    ///- the distance of each node from the root(s).
+    ///
+    ///\pre init() must be called and at least one root node should be
+    ///added with addSource() before using this function.
+    ///
+    ///\note <tt>d.start()</tt> is just a shortcut of the following code.
+    ///\code
+    ///  while ( !d.emptyQueue() ) {
+    ///    d.processNextNode();
+    ///  }
+    ///\endcode
     void start()
     {
-      while ( !_heap->empty() ) processNextNode();
-    }
-
-    ///Executes the algorithm until \c dest is reached.
-
-    ///Executes the algorithm until \c dest is reached.
-    ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
+      while ( !emptyQueue() ) processNextNode();
+    }
+
+    ///Executes the algorithm until the given target node is reached.
+
+    ///Executes the algorithm until the given target node is reached.
     ///
     ///This method runs the %Dijkstra algorithm from the root node(s)
-    ///in order to
-    ///compute the
-    ///shortest path to \c dest. The algorithm computes
-    ///- The shortest path to \c  dest.
-    ///- The distance of \c dest from the root(s).
-    ///
+    ///in order to compute the shortest path to \c dest.
+    ///
+    ///The algorithm computes
+    ///- the shortest path to \c dest,
+    ///- the distance of \c dest 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)
     {
@@ -723,12 +752,16 @@
     ///Executes the algorithm until a condition is met.
     ///
-    ///\pre init() must be called and at least one node should be added
-    ///with addSource() before using this function.
-    ///
-    ///\param nm must be a bool (or convertible) node map. The algorithm
+    ///This method runs the %Dijkstra algorithm from the root node(s) in
+    ///order to compute the shortest path to a node \c v with
+    /// <tt>nm[v]</tt> true, if such a node can be found.
+    ///
+    ///\param nm A \c bool (or convertible) node map. The algorithm
     ///will stop when it reaches a node \c v with <tt>nm[v]</tt> true.
     ///
     ///\return The reached node \c v with <tt>nm[v]</tt> true or
     ///\c INVALID if no such node was found.
+    ///
+    ///\pre init() must be called and at least one root node should be
+    ///added with addSource() before using this function.
     template<class NodeBoolMap>
     Node start(const NodeBoolMap &nm)
@@ -740,14 +773,14 @@
     }
 
-    ///Runs %Dijkstra algorithm from node \c s.
-
-    ///This method runs the %Dijkstra algorithm from a root node \c s
-    ///in order to
-    ///compute the
-    ///shortest path to each node. The algorithm computes
-    ///- The shortest path tree.
-    ///- The distance of each node from the root.
-    ///
-    ///\note d.run(s) is just a shortcut of the following code.
+    ///Runs the algorithm from the given node.
+
+    ///This method runs the %Dijkstra algorithm from node \c s
+    ///in order to compute the shortest path to each node.
+    ///
+    ///The algorithm computes
+    ///- the shortest path tree,
+    ///- the distance of each node from the root.
+    ///
+    ///\note <tt>d.run(s)</tt> is just a shortcut of the following code.
     ///\code
     ///  d.init();
@@ -763,10 +796,12 @@
     ///Finds the shortest path between \c s and \c t.
 
-    ///Finds the shortest path between \c s and \c t.
-    ///
-    ///\return The length of the shortest s---t path if there exists one,
-    ///0 otherwise.
-    ///\note Apart from the return value, d.run(s) is
-    ///just a shortcut of the following code.
+    ///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.
+    ///
+    ///\note Apart from the return value, <tt>d.run(s,t)</tt> is just a
+    ///shortcut of the following code.
     ///\code
     ///  d.init();
@@ -786,75 +821,87 @@
     ///The result of the %Dijkstra algorithm can be obtained using these
     ///functions.\n
-    ///Before the use of these functions,
-    ///either run() or start() must be called.
+    ///Either \ref lemon::Dijkstra::run() "run()" or
+    ///\ref lemon::Dijkstra::start() "start()" must be called before
+    ///using them.
 
     ///@{
 
-    ///Gives back the shortest path.
-
-    ///Gives back the shortest path.
-    ///\pre The \c t should be reachable from the source.
-    Path path(Node t)
-    {
-      return Path(*G, *_pred, t);
-    }
-
-    ///The distance of a node from the root.
-
-    ///Returns the distance of a node from the root.
-    ///\pre \ref run() must be called before using this function.
-    ///\warning If node \c v in unreachable from the root the return value
-    ///of this funcion is undefined.
+    ///The shortest path to a node.
+
+    ///Returns the shortest path to a node.
+    ///
+    ///\warning \c t should be reachable from the root(s).
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
+    Path path(Node t) const { return Path(*G, *_pred, t); }
+
+    ///The distance of a node from the root(s).
+
+    ///Returns the distance of a node from the root(s).
+    ///
+    ///\warning If node \c v is not reachable from the root(s), then
+    ///the return value of this function is undefined.
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
     Value dist(Node v) const { return (*_dist)[v]; }
 
-    ///The current distance of a node from the root.
-
-    ///Returns the current distance of a node from the root.
-    ///It may be decreased in the following processes.
-    ///\pre \c node should be reached but not processed
-    Value currentDist(Node v) const { return (*_heap)[v]; }
-
-    ///Returns the 'previous arc' of the shortest path tree.
-
-    ///For a node \c v it returns the 'previous arc' of the shortest path tree,
-    ///i.e. it returns the last arc of a shortest path from the root to \c
-    ///v. It is \ref INVALID
-    ///if \c v is unreachable from the root or if \c v=s. The
-    ///shortest path tree used here is equal to the shortest path tree used in
-    ///\ref predNode().  \pre \ref run() must be called before using
-    ///this function.
+    ///Returns the 'previous arc' of the shortest path tree for a node.
+
+    ///This function returns the 'previous arc' of the shortest path
+    ///tree for the node \c v, i.e. it returns the last arc of a
+    ///shortest path from the root(s) to \c v. It is \c INVALID if \c v
+    ///is not reachable from the root(s) or if \c v is a root.
+    ///
+    ///The shortest path tree used here is equal to the shortest path
+    ///tree used in \ref predNode().
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
+    ///using this function.
     Arc predArc(Node v) const { return (*_pred)[v]; }
 
-    ///Returns the 'previous node' of the shortest path tree.
-
-    ///For a node \c v it returns the 'previous node' of the shortest path tree,
-    ///i.e. it returns the last but one node from a shortest path from the
-    ///root to \c /v. It is INVALID if \c v is unreachable from the root or if
-    ///\c v=s. The shortest path tree used here is equal to the shortest path
-    ///tree used in \ref predArc().  \pre \ref run() must be called before
+    ///Returns the 'previous node' of the shortest path tree for a node.
+
+    ///This function returns the 'previous node' of the shortest path
+    ///tree for the node \c v, i.e. it returns the last but one node
+    ///from a shortest path from the root(s) to \c v. It is \c INVALID
+    ///if \c v is not reachable from the root(s) or if \c v is a root.
+    ///
+    ///The shortest path tree used here is equal to the shortest path
+    ///tree used in \ref predArc().
+    ///
+    ///\pre Either \ref run() or \ref start() must be called before
     ///using this function.
     Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
                                   G->source((*_pred)[v]); }
 
-    ///Returns a reference to the NodeMap of distances.
-
-    ///Returns a reference to the NodeMap of distances. \pre \ref run() must
-    ///be called before using this function.
+    ///\brief Returns a const reference to the node map that stores the
+    ///distances of the nodes.
+    ///
+    ///Returns a const reference to the node map that stores the distances
+    ///of the nodes calculated by the algorithm.
+    ///
+    ///\pre Either \ref run() or \ref init()
+    ///must be called before using this function.
     const DistMap &distMap() const { return *_dist;}
 
-    ///Returns a reference to the shortest path tree map.
-
-    ///Returns a reference to the NodeMap of the arcs of the
-    ///shortest path tree.
-    ///\pre \ref run() must be called before using this function.
+    ///\brief Returns a const reference to the node map that stores the
+    ///predecessor arcs.
+    ///
+    ///Returns a const reference to the node map that stores the predecessor
+    ///arcs, which form the shortest path tree.
+    ///
+    ///\pre Either \ref run() or \ref init()
+    ///must be called before using this function.
     const PredMap &predMap() const { return *_pred;}
 
-    ///Checks if a node is reachable from the root.
-
-    ///Returns \c true if \c v is reachable from the root.
-    ///\warning The source nodes are inditated as unreached.
-    ///\pre \ref run() must be called before using this function.
-    ///
-    bool reached(Node v) { return (*_heap_cross_ref)[v] != Heap::PRE_HEAP; }
+    ///Checks if a node is reachable from the root(s).
+
+    ///Returns \c true if \c v is reachable from the root(s).
+    ///\pre Either \ref run() or \ref start()
+    ///must be called before using this function.
+    bool reached(Node v) const { return (*_heap_cross_ref)[v] !=
+                                        Heap::PRE_HEAP; }
 
     ///Checks if a node is processed.
@@ -862,7 +909,15 @@
     ///Returns \c true if \c v is processed, i.e. the shortest
     ///path to \c v has already found.
-    ///\pre \ref run() must be called before using this function.
-    ///
-    bool processed(Node v) { return (*_heap_cross_ref)[v] == Heap::POST_HEAP; }
+    ///\pre Either \ref run() or \ref start()
+    ///must be called before using this function.
+    bool processed(Node v) const { return (*_heap_cross_ref)[v] ==
+                                          Heap::POST_HEAP; }
+
+    ///The current distance of a node from the root(s).
+
+    ///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]; }
 
     ///@}
@@ -870,16 +925,13 @@
 
 
-
-
-
-  ///Default traits class of Dijkstra function.
-
-  ///Default traits class of Dijkstra function.
-  ///\tparam GR Digraph type.
-  ///\tparam LM Type of length map.
+  ///Default traits class of dijkstra() function.
+
+  ///Default traits class of dijkstra() function.
+  ///\tparam GR The type of the digraph.
+  ///\tparam LM The type of the length map.
   template<class GR, class LM>
   struct DijkstraWizardDefaultTraits
   {
-    ///The digraph type the algorithm runs on.
+    ///The type of the digraph the algorithm runs on.
     typedef GR Digraph;
     ///The type of the map that stores the arc lengths.
@@ -888,67 +940,72 @@
     ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
     typedef LM LengthMap;
-    //The type of the length of the arcs.
+    ///The type of the length of the arcs.
     typedef typename LM::Value Value;
+
     /// Operation traits for Dijkstra algorithm.
 
-    /// It defines the used operation by the algorithm.
+    /// This class defines the operations that are used in the algorithm.
     /// \see DijkstraDefaultOperationTraits
     typedef DijkstraDefaultOperationTraits<Value> OperationTraits;
-    ///The heap type used by Dijkstra algorithm.
-
-    /// The cross reference type used by heap.
-
-    /// The cross reference type used by heap.
+
+    /// The cross reference type used by the heap.
+
+    /// The cross reference type used by the heap.
     /// Usually it is \c Digraph::NodeMap<int>.
     typedef typename Digraph::template NodeMap<int> HeapCrossRef;
-    ///Instantiates a HeapCrossRef.
+    ///Instantiates a \ref HeapCrossRef.
 
     ///This function instantiates a \ref HeapCrossRef.
-    /// \param G is the digraph, to which we would like to define the
+    /// \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 GR &G)
-    {
-      return new HeapCrossRef(G);
-    }
-
-    ///The heap type used by Dijkstra algorithm.
-
-    ///The heap type used by Dijkstra algorithm.
+    static HeapCrossRef *createHeapCrossRef(const Digraph &g)
+    {
+      return new HeapCrossRef(g);
+    }
+
+    ///The heap type used by the Dijkstra algorithm.
+
+    ///The heap type used by the Dijkstra algorithm.
     ///
     ///\sa BinHeap
     ///\sa Dijkstra
-    typedef BinHeap<typename LM::Value, typename GR::template NodeMap<int>,
+    typedef BinHeap<Value, typename Digraph::template NodeMap<int>,
                     std::less<Value> > Heap;
 
-    static Heap *createHeap(HeapCrossRef& R)
-    {
-      return new Heap(R);
-    }
-
-    ///\brief The type of the map that stores the last
+    ///Instantiates a \ref Heap.
+
+    ///This function instantiates a \ref Heap.
+    /// \param r is the HeapCrossRef which is used.
+    static Heap *createHeap(HeapCrossRef& r)
+    {
+      return new Heap(r);
+    }
+
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///
-    ///The type of the map that stores the last
+    ///The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
-    ///
-    typedef NullMap <typename GR::Node,typename GR::Arc> PredMap;
-    ///Instantiates a PredMap.
+    typedef NullMap <typename Digraph::Node,typename Digraph::Arc> PredMap;
+    ///Instantiates a \ref PredMap.
 
     ///This function instantiates a \ref PredMap.
-    ///\param g is the digraph, to which we would like to define the PredMap.
-    ///\todo The digraph alone may be insufficient for the initialization
+    ///\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
-    static PredMap *createPredMap(const GR &g)
+    static PredMap *createPredMap(const Digraph &g)
 #else
-    static PredMap *createPredMap(const GR &)
+    static PredMap *createPredMap(const Digraph &)
 #endif
     {
       return new PredMap();
     }
-    ///The type of the map that stores whether a nodes is processed.
-
-    ///The type of the map that stores whether a nodes is processed.
+
+    ///The type of the map that indicates which nodes are processed.
+
+    ///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.
@@ -957,24 +1014,24 @@
     ///\todo named parameter to set this type, function to read and write.
     typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
-    ///Instantiates a ProcessedMap.
+    ///Instantiates a \ref ProcessedMap.
 
     ///This function instantiates a \ref ProcessedMap.
     ///\param g is the digraph, to which
-    ///we would like to define the \ref ProcessedMap
+    ///we would like to define the \ref ProcessedMap.
 #ifdef DOXYGEN
-    static ProcessedMap *createProcessedMap(const GR &g)
+    static ProcessedMap *createProcessedMap(const Digraph &g)
 #else
-    static ProcessedMap *createProcessedMap(const GR &)
+    static ProcessedMap *createProcessedMap(const Digraph &)
 #endif
     {
       return new ProcessedMap();
     }
-    ///The type of the map that stores the dists of the nodes.
-
-    ///The type of the map that stores the dists of the nodes.
+
+    ///The type of the map that stores the distances of the nodes.
+
+    ///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,typename LM::Value> DistMap;
-    ///Instantiates a DistMap.
+    typedef NullMap<typename Digraph::Node,Value> DistMap;
+    ///Instantiates a \ref DistMap.
 
     ///This function instantiates a \ref DistMap.
@@ -982,7 +1039,7 @@
     ///the \ref DistMap
 #ifdef DOXYGEN
-    static DistMap *createDistMap(const GR &g)
+    static DistMap *createDistMap(const Digraph &g)
 #else
-    static DistMap *createDistMap(const GR &)
+    static DistMap *createDistMap(const Digraph &)
 #endif
     {
@@ -991,10 +1048,10 @@
   };
 
-  /// Default traits used by \ref DijkstraWizard
+  /// Default traits class used by \ref DijkstraWizard
 
   /// To make it easier to use Dijkstra algorithm
-  ///we have created a wizard class.
+  /// we have created a wizard class.
   /// This \ref DijkstraWizard class needs default traits,
-  ///as well as the \ref Dijkstra class.
+  /// as well as the \ref Dijkstra class.
   /// The \ref DijkstraWizardBase is a class to be the default traits of the
   /// \ref DijkstraWizard class.
@@ -1003,22 +1060,21 @@
   class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LM>
   {
-
     typedef DijkstraWizardDefaultTraits<GR,LM> Base;
   protected:
-    /// Type of the nodes in the digraph.
+    //The type of the nodes in the digraph.
     typedef typename Base::Digraph::Node Node;
 
-    /// Pointer to the underlying digraph.
+    //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 predecessors arcs.
+    //Pointer to the map of predecessors arcs.
     void *_pred;
-    ///Pointer to the map of distances.
+    //Pointer to the map of distances.
     void *_dist;
-    ///Pointer to the source node.
+    //Pointer to the source node.
     Node _source;
 
-    public:
+  public:
     /// Constructor.
 
@@ -1033,7 +1089,7 @@
     /// listed in the parameters list.
     /// Others are initiated to 0.
-    /// \param g is the initial value of  \ref _g
-    /// \param l is the initial value of  \ref _length
-    /// \param s is the initial value of  \ref _source
+    /// \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) :
       _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
@@ -1043,9 +1099,11 @@
   };
 
-  /// A class to make the usage of Dijkstra algorithm easier
-
-  /// This class is created to make it easier to use Dijkstra algorithm.
-  /// It uses the functions and features of the plain \ref Dijkstra,
-  /// but it is much simpler to use it.
+  /// 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.
   ///
   /// Simplicity means that the way to change the types defined
@@ -1056,10 +1114,10 @@
   /// the original class by using the ::
   /// operator. In the case of \ref DijkstraWizard only
-  /// a function have to be called and it will
+  /// 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 class, and calls the \ref
-  /// Dijkstra::run method of it.
+  /// 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.
   template<class TR>
   class DijkstraWizard : public TR
@@ -1067,13 +1125,10 @@
     typedef TR Base;
 
-    ///The type of the underlying digraph.
+    ///The type of the digraph the algorithm runs on.
     typedef typename TR::Digraph Digraph;
-    //\e
+
     typedef typename Digraph::Node Node;
-    //\e
     typedef typename Digraph::NodeIt NodeIt;
-    //\e
     typedef typename Digraph::Arc Arc;
-    //\e
     typedef typename Digraph::OutArcIt OutArcIt;
 
@@ -1082,12 +1137,16 @@
     ///The type of the length of the arcs.
     typedef typename LengthMap::Value Value;
-    ///\brief The type of the map that stores the last
+    ///\brief The type of the map that stores the predecessor
     ///arcs of the shortest paths.
     typedef typename TR::PredMap PredMap;
-    ///The type of the map that stores the dists of the nodes.
+    ///The type of the map that stores the distances of the nodes.
     typedef typename TR::DistMap DistMap;
+    ///The type of the map that indicates which nodes are processed.
+    typedef typename TR::ProcessedMap ProcessedMap;
     ///The heap type used by the dijkstra algorithm.
     typedef typename TR::Heap Heap;
+
   public:
+
     /// Constructor.
     DijkstraWizard() : TR() {}
@@ -1105,8 +1164,8 @@
     ~DijkstraWizard() {}
 
-    ///Runs Dijkstra algorithm from a given node.
-
-    ///Runs Dijkstra algorithm from a given node.
-    ///The node can be given by the \ref source function.
+    ///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()
     {
@@ -1130,4 +1189,14 @@
     }
 
+    /// 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;
+    }
+
     template<class T>
     struct DefPredMapBase : public Base {
@@ -1136,11 +1205,9 @@
       DefPredMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting PredMap type
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///function for setting PredMap type
-    ///
+    ///for setting \ref PredMap object.
+    ///
+    ///\ref named-templ-param "Named parameter"
+    ///for setting \ref PredMap object.
     template<class T>
     DijkstraWizard<DefPredMapBase<T> > predMap(const T &t)
@@ -1148,4 +1215,22 @@
       Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
       return DijkstraWizard<DefPredMapBase<T> >(*this);
+    }
+
+    template<class T>
+    struct DefProcessedMapBase : 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.
+    template<class T>
+    DijkstraWizard<DefProcessedMapBase<T> > processedMap(const T &t)
+    {
+      Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
+      return DijkstraWizard<DefProcessedMapBase<T> >(*this);
     }
 
@@ -1156,11 +1241,9 @@
       DefDistMapBase(const TR &b) : TR(b) {}
     };
-
     ///\brief \ref named-templ-param "Named parameter"
-    ///function for setting DistMap type
-    ///
-    /// \ref named-templ-param "Named parameter"
-    ///function for setting DistMap type
-    ///
+    ///for setting \ref DistMap object.
+    ///
+    ///\ref named-templ-param "Named parameter"
+    ///for setting \ref DistMap object.
     template<class T>
     DijkstraWizard<DefDistMapBase<T> > distMap(const T &t)
@@ -1168,14 +1251,4 @@
       Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
       return DijkstraWizard<DefDistMapBase<T> >(*this);
-    }
-
-    /// 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;
     }
 
Index: lemon/dim2.h
===================================================================
--- lemon/dim2.h	(revision 241)
+++ lemon/dim2.h	(revision 209)
@@ -21,4 +21,5 @@
 
 #include <iostream>
+#include <lemon/bits/utility.h>
 
 ///\ingroup misc
@@ -45,7 +46,7 @@
   /// @{
 
-  /// A simple two dimensional vector (plain vector) implementation
-
-  /// A simple two dimensional vector (plain vector) implementation
+  /// A simple two dimensional vector (plainvector) implementation
+
+  /// A simple two dimensional vector (plainvector) implementation
   /// with the usual vector operations.
   template<typename T>
@@ -186,7 +187,7 @@
   }
 
-  ///Read a plain vector from a stream
-
-  ///Read a plain vector from a stream.
+  ///Read a plainvector from a stream
+
+  ///Read a plainvector from a stream.
   ///\relates Point
   ///
@@ -214,7 +215,7 @@
   }
 
-  ///Write a plain vector to a stream
-
-  ///Write a plain vector to a stream.
+  ///Write a plainvector to a stream
+
+  ///Write a plainvector to a stream.
   ///\relates Point
   ///
@@ -261,11 +262,11 @@
 
 
-    /// A class to calculate or store the bounding box of plain vectors.
-
-    /// A class to calculate or store the bounding box of plain vectors.
-    ///
+  /// A class to calculate or store the bounding box of plainvectors.
+
+  /// A class to calculate or store the bounding box of plainvectors.
+  ///
     template<typename T>
     class BoundingBox {
-      Point<T> _bottom_left, _top_right;
+      Point<T> bottom_left, top_right;
       bool _empty;
     public:
@@ -275,8 +276,5 @@
 
       ///Construct an instance from one point
-      BoundingBox(Point<T> a) {
-        _bottom_left = _top_right = a;
-        _empty = false;
-      }
+      BoundingBox(Point<T> a) { bottom_left=top_right=a; _empty = false; }
 
       ///Construct an instance from two points
@@ -289,6 +287,6 @@
       BoundingBox(Point<T> a,Point<T> b)
       {
-        _bottom_left = a;
-        _top_right = b;
+        bottom_left=a;
+        top_right=b;
         _empty = false;
       }
@@ -305,6 +303,6 @@
       BoundingBox(T l,T b,T r,T t)
       {
-        _bottom_left=Point<T>(l,b);
-        _top_right=Point<T>(r,t);
+        bottom_left=Point<T>(l,b);
+        top_right=Point<T>(r,t);
         _empty = false;
       }
@@ -323,5 +321,5 @@
       ///Make the BoundingBox empty
       void clear() {
-        _empty = true;
+        _empty=1;
       }
 
@@ -331,5 +329,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       Point<T> bottomLeft() const {
-        return _bottom_left;
+        return bottom_left;
       }
 
@@ -337,7 +335,7 @@
 
       ///Set the bottom left corner of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void bottomLeft(Point<T> p) {
-        _bottom_left = p;
+        bottom_left = p;
       }
 
@@ -347,5 +345,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       Point<T> topRight() const {
-        return _top_right;
+        return top_right;
       }
 
@@ -353,7 +351,7 @@
 
       ///Set the top right corner of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void topRight(Point<T> p) {
-        _top_right = p;
+        top_right = p;
       }
 
@@ -363,5 +361,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       Point<T> bottomRight() const {
-        return Point<T>(_top_right.x,_bottom_left.y);
+        return Point<T>(top_right.x,bottom_left.y);
       }
 
@@ -369,8 +367,8 @@
 
       ///Set the bottom right corner of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void bottomRight(Point<T> p) {
-        _top_right.x = p.x;
-        _bottom_left.y = p.y;
+        top_right.x = p.x;
+        bottom_left.y = p.y;
       }
 
@@ -380,5 +378,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       Point<T> topLeft() const {
-        return Point<T>(_bottom_left.x,_top_right.y);
+        return Point<T>(bottom_left.x,top_right.y);
       }
 
@@ -386,8 +384,8 @@
 
       ///Set the top left corner of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void topLeft(Point<T> p) {
-        _top_right.y = p.y;
-        _bottom_left.x = p.x;
+        top_right.y = p.y;
+        bottom_left.x = p.x;
       }
 
@@ -397,5 +395,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       T bottom() const {
-        return _bottom_left.y;
+        return bottom_left.y;
       }
 
@@ -403,7 +401,7 @@
 
       ///Set the bottom of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void bottom(T t) {
-        _bottom_left.y = t;
+        bottom_left.y = t;
       }
 
@@ -413,5 +411,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       T top() const {
-        return _top_right.y;
+        return top_right.y;
       }
 
@@ -419,7 +417,7 @@
 
       ///Set the top of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void top(T t) {
-        _top_right.y = t;
+        top_right.y = t;
       }
 
@@ -429,5 +427,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       T left() const {
-        return _bottom_left.x;
+        return bottom_left.x;
       }
 
@@ -435,7 +433,7 @@
 
       ///Set the left side of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void left(T t) {
-        _bottom_left.x = t;
+        bottom_left.x = t;
       }
 
@@ -445,5 +443,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       T right() const {
-        return _top_right.x;
+        return top_right.x;
       }
 
@@ -451,7 +449,7 @@
 
       ///Set the right side of the box.
-      ///\pre The box must not be empty.
+      ///It should only be used for non-empty box.
       void right(T t) {
-        _top_right.x = t;
+        top_right.x = t;
       }
 
@@ -461,5 +459,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       T height() const {
-        return _top_right.y-_bottom_left.y;
+        return top_right.y-bottom_left.y;
       }
 
@@ -469,5 +467,5 @@
       ///If the bounding box is empty, then the return value is not defined.
       T width() const {
-        return _top_right.x-_bottom_left.x;
+        return top_right.x-bottom_left.x;
       }
 
@@ -476,7 +474,7 @@
         if (_empty)
           return false;
-        else {
-          return ( (u.x-_bottom_left.x)*(_top_right.x-u.x) >= 0 &&
-                   (u.y-_bottom_left.y)*(_top_right.y-u.y) >= 0 );
+        else{
+          return ((u.x-bottom_left.x)*(top_right.x-u.x) >= 0 &&
+              (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
         }
       }
@@ -487,13 +485,13 @@
       ///
       BoundingBox& add(const Point<T>& u){
-        if (_empty) {
-          _bottom_left = _top_right = u;
+        if (_empty){
+          bottom_left=top_right=u;
           _empty = false;
         }
-        else {
-          if (_bottom_left.x > u.x) _bottom_left.x = u.x;
-          if (_bottom_left.y > u.y) _bottom_left.y = u.y;
-          if (_top_right.x < u.x) _top_right.x = u.x;
-          if (_top_right.y < u.y) _top_right.y = u.y;
+        else{
+          if (bottom_left.x > u.x) bottom_left.x = u.x;
+          if (bottom_left.y > u.y) bottom_left.y = u.y;
+          if (top_right.x < u.x) top_right.x = u.x;
+          if (top_right.y < u.y) top_right.y = u.y;
         }
         return *this;
@@ -506,6 +504,6 @@
       BoundingBox& add(const BoundingBox &u){
         if ( !u.empty() ){
-          add(u._bottom_left);
-          add(u._top_right);
+          this->add(u.bottomLeft());
+          this->add(u.topRight());
         }
         return *this;
@@ -518,13 +516,13 @@
       BoundingBox operator&(const BoundingBox& u) const {
         BoundingBox b;
-        if (_empty || u._empty) {
+        if (this->_empty || u._empty) {
           b._empty = true;
         } else {
-          b._bottom_left.x = std::max(_bottom_left.x, u._bottom_left.x);
-          b._bottom_left.y = std::max(_bottom_left.y, u._bottom_left.y);
-          b._top_right.x = std::min(_top_right.x, u._top_right.x);
-          b._top_right.y = std::min(_top_right.y, u._top_right.y);
-          b._empty = b._bottom_left.x > b._top_right.x ||
-                     b._bottom_left.y > b._top_right.y;
+          b.bottom_left.x = std::max(this->bottom_left.x,u.bottom_left.x);
+          b.bottom_left.y = std::max(this->bottom_left.y,u.bottom_left.y);
+          b.top_right.x = std::min(this->top_right.x,u.top_right.x);
+          b.top_right.y = std::min(this->top_right.y,u.top_right.y);
+          b._empty = b.bottom_left.x > b.top_right.x ||
+                     b.bottom_left.y > b.top_right.y;
         }
         return b;
Index: lemon/graph_to_eps.h
===================================================================
--- lemon/graph_to_eps.h	(revision 220)
+++ lemon/graph_to_eps.h	(revision 212)
@@ -36,5 +36,5 @@
 
 #include<lemon/math.h>
-#include<lemon/core.h>
+#include<lemon/bits/invalid.h>
 #include<lemon/dim2.h>
 #include<lemon/maps.h>
Index: lemon/graph_utils.h
===================================================================
--- lemon/graph_utils.h	(revision 212)
+++ lemon/graph_utils.h	(revision 212)
@@ -0,0 +1,2760 @@
+/* -*- 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_GRAPH_UTILS_H
+#define LEMON_GRAPH_UTILS_H
+
+#include <iterator>
+#include <vector>
+#include <map>
+#include <cmath>
+#include <algorithm>
+
+#include <lemon/bits/invalid.h>
+#include <lemon/bits/utility.h>
+#include <lemon/maps.h>
+#include <lemon/bits/traits.h>
+
+#include <lemon/bits/alteration_notifier.h>
+#include <lemon/bits/default_map.h>
+
+///\ingroup gutils
+///\file
+///\brief Graph utilities.
+
+namespace lemon {
+
+  /// \addtogroup gutils
+  /// @{
+
+  ///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,
+  ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
+  ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap.
+  ///
+  ///\note If the graph type is a dependent type, ie. the graph type depend
+  ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
+  ///macro.
+#define DIGRAPH_TYPEDEFS(Digraph)                                       \
+  typedef Digraph::Node Node;                                           \
+  typedef Digraph::NodeIt NodeIt;                                       \
+  typedef Digraph::Arc Arc;                                             \
+  typedef Digraph::ArcIt ArcIt;                                         \
+  typedef Digraph::InArcIt InArcIt;                                     \
+  typedef Digraph::OutArcIt OutArcIt;                                   \
+  typedef Digraph::NodeMap<bool> BoolNodeMap;                           \
+  typedef Digraph::NodeMap<int> IntNodeMap;                             \
+  typedef Digraph::NodeMap<double> DoubleNodeMap;                       \
+  typedef Digraph::ArcMap<bool> BoolArcMap;                             \
+  typedef Digraph::ArcMap<int> IntArcMap;                               \
+  typedef Digraph::ArcMap<double> DoubleArcMap
+
+  ///Creates convenience typedefs for the digraph types and iterators
+
+  ///\see DIGRAPH_TYPEDEFS
+  ///
+  ///\note Use this macro, if the graph type is a dependent type,
+  ///ie. the graph type depend on a template parameter.
+#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph)                              \
+  typedef typename Digraph::Node Node;                                  \
+  typedef typename Digraph::NodeIt NodeIt;                              \
+  typedef typename Digraph::Arc Arc;                                    \
+  typedef typename Digraph::ArcIt ArcIt;                                \
+  typedef typename Digraph::InArcIt InArcIt;                            \
+  typedef typename Digraph::OutArcIt OutArcIt;                          \
+  typedef typename Digraph::template NodeMap<bool> BoolNodeMap;         \
+  typedef typename Digraph::template NodeMap<int> IntNodeMap;           \
+  typedef typename Digraph::template NodeMap<double> DoubleNodeMap;     \
+  typedef typename Digraph::template ArcMap<bool> BoolArcMap;           \
+  typedef typename Digraph::template ArcMap<int> IntArcMap;             \
+  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
+  ///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates
+  ///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap,
+  ///\c DoubleEdgeMap.
+  ///
+  ///\note If the graph type is a dependent type, ie. the graph type depend
+  ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
+  ///macro.
+#define GRAPH_TYPEDEFS(Graph)                                           \
+  DIGRAPH_TYPEDEFS(Graph);                                              \
+  typedef Graph::Edge Edge;                                             \
+  typedef Graph::EdgeIt EdgeIt;                                         \
+  typedef Graph::IncEdgeIt IncEdgeIt;                                   \
+  typedef Graph::EdgeMap<bool> BoolEdgeMap;                             \
+  typedef Graph::EdgeMap<int> IntEdgeMap;                               \
+  typedef Graph::EdgeMap<double> DoubleEdgeMap
+
+  ///Creates convenience typedefs for the graph types and iterators
+
+  ///\see GRAPH_TYPEDEFS
+  ///
+  ///\note Use this macro, if the graph type is a dependent type,
+  ///ie. the graph type depend on a template parameter.
+#define TEMPLATE_GRAPH_TYPEDEFS(Graph)                                  \
+  TEMPLATE_DIGRAPH_TYPEDEFS(Graph);                                     \
+  typedef typename Graph::Edge Edge;                                    \
+  typedef typename Graph::EdgeIt EdgeIt;                                \
+  typedef typename Graph::IncEdgeIt IncEdgeIt;                          \
+  typedef typename Graph::template EdgeMap<bool> BoolEdgeMap;           \
+  typedef typename Graph::template EdgeMap<int> IntEdgeMap;             \
+  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
+  /// it iterates on all of the items.
+  template <typename Graph, typename Item>
+  inline int countItems(const Graph& g) {
+    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
+    int num = 0;
+    for (ItemIt it(g); it != INVALID; ++it) {
+      ++num;
+    }
+    return num;
+  }
+
+  // Node counting:
+
+  namespace _graph_utils_bits {
+
+    template <typename Graph, typename Enable = void>
+    struct CountNodesSelector {
+      static int count(const Graph &g) {
+        return countItems<Graph, typename Graph::Node>(g);
+      }
+    };
+
+    template <typename Graph>
+    struct CountNodesSelector<
+      Graph, typename
+      enable_if<typename Graph::NodeNumTag, void>::type>
+    {
+      static int count(const Graph &g) {
+        return g.nodeNum();
+      }
+    };
+  }
+
+  /// \brief Function to count the nodes in the graph.
+  ///
+  /// 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
+  /// function to query the cardinality of the node set.
+  template <typename Graph>
+  inline int countNodes(const Graph& g) {
+    return _graph_utils_bits::CountNodesSelector<Graph>::count(g);
+  }
+
+  // Arc counting:
+
+  namespace _graph_utils_bits {
+
+    template <typename Graph, typename Enable = void>
+    struct CountArcsSelector {
+      static int count(const Graph &g) {
+        return countItems<Graph, typename Graph::Arc>(g);
+      }
+    };
+
+    template <typename Graph>
+    struct CountArcsSelector<
+      Graph,
+      typename enable_if<typename Graph::ArcNumTag, void>::type>
+    {
+      static int count(const Graph &g) {
+        return g.arcNum();
+      }
+    };
+  }
+
+  /// \brief Function to count the arcs in the graph.
+  ///
+  /// 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
+  /// function to query the cardinality of the arc set.
+  template <typename Graph>
+  inline int countArcs(const Graph& g) {
+    return _graph_utils_bits::CountArcsSelector<Graph>::count(g);
+  }
+
+  // Edge counting:
+  namespace _graph_utils_bits {
+
+    template <typename Graph, typename Enable = void>
+    struct CountEdgesSelector {
+      static int count(const Graph &g) {
+        return countItems<Graph, typename Graph::Edge>(g);
+      }
+    };
+
+    template <typename Graph>
+    struct CountEdgesSelector<
+      Graph,
+      typename enable_if<typename Graph::EdgeNumTag, void>::type>
+    {
+      static int count(const Graph &g) {
+        return g.edgeNum();
+      }
+    };
+  }
+
+  /// \brief Function to count the edges in the graph.
+  ///
+  /// 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
+  /// function to query the cardinality of the edge set.
+  template <typename Graph>
+  inline int countEdges(const Graph& g) {
+    return _graph_utils_bits::CountEdgesSelector<Graph>::count(g);
+
+  }
+
+
+  template <typename Graph, typename DegIt>
+  inline int countNodeDegree(const Graph& _g, const typename Graph::Node& _n) {
+    int num = 0;
+    for (DegIt it(_g, _n); it != INVALID; ++it) {
+      ++num;
+    }
+    return num;
+  }
+
+  /// \brief Function to count the number of the out-arcs from node \c n.
+  ///
+  /// This function counts the number of the out-arcs from node \c n
+  /// in the graph.
+  template <typename Graph>
+  inline int countOutArcs(const Graph& _g,  const typename Graph::Node& _n) {
+    return countNodeDegree<Graph, typename Graph::OutArcIt>(_g, _n);
+  }
+
+  /// \brief Function to count the number of the in-arcs to node \c n.
+  ///
+  /// This function counts the number of the in-arcs to node \c n
+  /// in the graph.
+  template <typename Graph>
+  inline int countInArcs(const Graph& _g,  const typename Graph::Node& _n) {
+    return countNodeDegree<Graph, typename Graph::InArcIt>(_g, _n);
+  }
+
+  /// \brief Function to count the number of the inc-edges to node \c n.
+  ///
+  /// This function counts the number of the inc-edges to node \c n
+  /// in the graph.
+  template <typename Graph>
+  inline int countIncEdges(const Graph& _g,  const typename Graph::Node& _n) {
+    return countNodeDegree<Graph, typename Graph::IncEdgeIt>(_g, _n);
+  }
+
+  namespace _graph_utils_bits {
+
+    template <typename Graph, typename Enable = void>
+    struct FindArcSelector {
+      typedef typename Graph::Node Node;
+      typedef typename Graph::Arc Arc;
+      static Arc find(const Graph &g, Node u, Node v, Arc e) {
+        if (e == INVALID) {
+          g.firstOut(e, u);
+        } else {
+          g.nextOut(e);
+        }
+        while (e != INVALID && g.target(e) != v) {
+          g.nextOut(e);
+        }
+        return e;
+      }
+    };
+
+    template <typename Graph>
+    struct FindArcSelector<
+      Graph,
+      typename enable_if<typename Graph::FindEdgeTag, void>::type>
+    {
+      typedef typename Graph::Node Node;
+      typedef typename Graph::Arc Arc;
+      static Arc find(const Graph &g, Node u, Node v, Arc prev) {
+        return g.findArc(u, v, prev);
+      }
+    };
+  }
+
+  /// \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.
+  ///
+  /// 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.
+  ///\code
+  /// for(Arc e=findArc(g,u,v);e!=INVALID;e=findArc(g,u,v,e)) {
+  ///   ...
+  /// }
+  ///\endcode
+  ///
+  ///\sa ArcLookUp
+  ///\sa AllArcLookUp
+  ///\sa DynArcLookUp
+  ///\sa ConArcIt
+  template <typename Graph>
+  inline typename Graph::Arc
+  findArc(const Graph &g, typename Graph::Node u, typename Graph::Node v,
+           typename Graph::Arc prev = INVALID) {
+    return _graph_utils_bits::FindArcSelector<Graph>::find(g, u, v, prev);
+  }
+
+  /// \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
+  /// use it the following way:
+  ///\code
+  /// for (ConArcIt<Graph> it(g, src, trg); it != INVALID; ++it) {
+  ///   ...
+  /// }
+  ///\endcode
+  ///
+  ///\sa findArc()
+  ///\sa ArcLookUp
+  ///\sa AllArcLookUp
+  ///\sa DynArcLookUp
+  template <typename _Graph>
+  class ConArcIt : public _Graph::Arc {
+  public:
+
+    typedef _Graph Graph;
+    typedef typename Graph::Arc Parent;
+
+    typedef typename Graph::Arc Arc;
+    typedef typename Graph::Node Node;
+
+    /// \brief Constructor.
+    ///
+    /// Construct a new ConArcIt iterating on the arcs which
+    /// connects the \c u and \c v node.
+    ConArcIt(const Graph& g, Node u, Node v) : _graph(g) {
+      Parent::operator=(findArc(_graph, u, v));
+    }
+
+    /// \brief Constructor.
+    ///
+    /// Construct a new ConArcIt which continues the iterating from
+    /// the \c e arc.
+    ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
+
+    /// \brief Increment operator.
+    ///
+    /// It increments the iterator and gives back the next arc.
+    ConArcIt& operator++() {
+      Parent::operator=(findArc(_graph, _graph.source(*this),
+                                _graph.target(*this), *this));
+      return *this;
+    }
+  private:
+    const Graph& _graph;
+  };
+
+  namespace _graph_utils_bits {
+
+    template <typename Graph, typename Enable = void>
+    struct FindEdgeSelector {
+      typedef typename Graph::Node Node;
+      typedef typename Graph::Edge Edge;
+      static Edge find(const Graph &g, Node u, Node v, Edge e) {
+        bool b;
+        if (u != v) {
+          if (e == INVALID) {
+            g.firstInc(e, b, u);
+          } else {
+            b = g.u(e) == u;
+            g.nextInc(e, b);
+          }
+          while (e != INVALID && (b ? g.v(e) : g.u(e)) != v) {
+            g.nextInc(e, b);
+          }
+        } else {
+          if (e == INVALID) {
+            g.firstInc(e, b, u);
+          } else {
+            b = true;
+            g.nextInc(e, b);
+          }
+          while (e != INVALID && (!b || g.v(e) != v)) {
+            g.nextInc(e, b);
+          }
+        }
+        return e;
+      }
+    };
+
+    template <typename Graph>
+    struct FindEdgeSelector<
+      Graph,
+      typename enable_if<typename Graph::FindEdgeTag, void>::type>
+    {
+      typedef typename Graph::Node Node;
+      typedef typename Graph::Edge Edge;
+      static Edge find(const Graph &g, Node u, Node v, Edge prev) {
+        return g.findEdge(u, v, prev);
+      }
+    };
+  }
+
+  /// \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
+  /// 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.
+  ///\code
+  /// for(Edge e = findEdge(g,u,v); e != INVALID;
+  ///     e = findEdge(g,u,v,e)) {
+  ///   ...
+  /// }
+  ///\endcode
+  ///
+  ///\sa ConEdgeIt
+
+  template <typename Graph>
+  inline typename Graph::Edge
+  findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
+            typename Graph::Edge p = INVALID) {
+    return _graph_utils_bits::FindEdgeSelector<Graph>::find(g, u, v, p);
+  }
+
+  /// \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
+  /// use it the following way:
+  ///\code
+  /// for (ConEdgeIt<Graph> it(g, src, trg); it != INVALID; ++it) {
+  ///   ...
+  /// }
+  ///\endcode
+  ///
+  ///\sa findEdge()
+  template <typename _Graph>
+  class ConEdgeIt : public _Graph::Edge {
+  public:
+
+    typedef _Graph Graph;
+    typedef typename Graph::Edge Parent;
+
+    typedef typename Graph::Edge Edge;
+    typedef typename Graph::Node Node;
+
+    /// \brief Constructor.
+    ///
+    /// Construct a new ConEdgeIt iterating on the edges which
+    /// connects the \c u and \c v node.
+    ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g) {
+      Parent::operator=(findEdge(_graph, u, v));
+    }
+
+    /// \brief Constructor.
+    ///
+    /// Construct a new ConEdgeIt which continues the iterating from
+    /// the \c e edge.
+    ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
+
+    /// \brief Increment operator.
+    ///
+    /// It increments the iterator and gives back the next edge.
+    ConEdgeIt& operator++() {
+      Parent::operator=(findEdge(_graph, _graph.u(*this),
+                                 _graph.v(*this), *this));
+      return *this;
+    }
+  private:
+    const Graph& _graph;
+  };
+
+  namespace _graph_utils_bits {
+
+    template <typename Digraph, typename Item, typename RefMap>
+    class MapCopyBase {
+    public:
+      virtual void copy(const Digraph& from, const RefMap& refMap) = 0;
+
+      virtual ~MapCopyBase() {}
+    };
+
+    template <typename Digraph, typename Item, typename RefMap,
+              typename ToMap, typename FromMap>
+    class MapCopy : public MapCopyBase<Digraph, Item, RefMap> {
+    public:
+
+      MapCopy(ToMap& tmap, const FromMap& map)
+        : _tmap(tmap), _map(map) {}
+
+      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
+        typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
+        for (ItemIt it(digraph); it != INVALID; ++it) {
+          _tmap.set(refMap[it], _map[it]);
+        }
+      }
+
+    private:
+      ToMap& _tmap;
+      const FromMap& _map;
+    };
+
+    template <typename Digraph, typename Item, typename RefMap, typename It>
+    class ItemCopy : public MapCopyBase<Digraph, Item, RefMap> {
+    public:
+
+      ItemCopy(It& it, const Item& item) : _it(it), _item(item) {}
+
+      virtual void copy(const Digraph&, const RefMap& refMap) {
+        _it = refMap[_item];
+      }
+
+    private:
+      It& _it;
+      Item _item;
+    };
+
+    template <typename Digraph, typename Item, typename RefMap, typename Ref>
+    class RefCopy : public MapCopyBase<Digraph, Item, RefMap> {
+    public:
+
+      RefCopy(Ref& map) : _map(map) {}
+
+      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
+        typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
+        for (ItemIt it(digraph); it != INVALID; ++it) {
+          _map.set(it, refMap[it]);
+        }
+      }
+
+    private:
+      Ref& _map;
+    };
+
+    template <typename Digraph, typename Item, typename RefMap,
+              typename CrossRef>
+    class CrossRefCopy : public MapCopyBase<Digraph, Item, RefMap> {
+    public:
+
+      CrossRefCopy(CrossRef& cmap) : _cmap(cmap) {}
+
+      virtual void copy(const Digraph& digraph, const RefMap& refMap) {
+        typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
+        for (ItemIt it(digraph); it != INVALID; ++it) {
+          _cmap.set(refMap[it], it);
+        }
+      }
+
+    private:
+      CrossRef& _cmap;
+    };
+
+    template <typename Digraph, typename Enable = void>
+    struct DigraphCopySelector {
+      template <typename From, typename NodeRefMap, typename ArcRefMap>
+      static void copy(Digraph &to, const From& from,
+                       NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
+        for (typename From::NodeIt it(from); it != INVALID; ++it) {
+          nodeRefMap[it] = to.addNode();
+        }
+        for (typename From::ArcIt it(from); it != INVALID; ++it) {
+          arcRefMap[it] = to.addArc(nodeRefMap[from.source(it)],
+                                    nodeRefMap[from.target(it)]);
+        }
+      }
+    };
+
+    template <typename Digraph>
+    struct DigraphCopySelector<
+      Digraph,
+      typename enable_if<typename Digraph::BuildTag, void>::type>
+    {
+      template <typename From, typename NodeRefMap, typename ArcRefMap>
+      static void copy(Digraph &to, const From& from,
+                       NodeRefMap& nodeRefMap, ArcRefMap& arcRefMap) {
+        to.build(from, nodeRefMap, arcRefMap);
+      }
+    };
+
+    template <typename Graph, typename Enable = void>
+    struct GraphCopySelector {
+      template <typename From, typename NodeRefMap, typename EdgeRefMap>
+      static void copy(Graph &to, const From& from,
+                       NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
+        for (typename From::NodeIt it(from); it != INVALID; ++it) {
+          nodeRefMap[it] = to.addNode();
+        }
+        for (typename From::EdgeIt it(from); it != INVALID; ++it) {
+          edgeRefMap[it] = to.addEdge(nodeRefMap[from.u(it)],
+                                      nodeRefMap[from.v(it)]);
+        }
+      }
+    };
+
+    template <typename Graph>
+    struct GraphCopySelector<
+      Graph,
+      typename enable_if<typename Graph::BuildTag, void>::type>
+    {
+      template <typename From, typename NodeRefMap, typename EdgeRefMap>
+      static void copy(Graph &to, const From& from,
+                       NodeRefMap& nodeRefMap, EdgeRefMap& edgeRefMap) {
+        to.build(from, nodeRefMap, edgeRefMap);
+      }
+    };
+
+  }
+
+  /// \brief Class to copy a digraph.
+  ///
+  /// 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
+  /// 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
+  /// assigned to copy. In the end, the \c run() member should be
+  /// called.
+  ///
+  /// The next code copies a graph with several data:
+  ///\code
+  ///  DigraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
+  ///  // create a reference for the nodes
+  ///  OrigGraph::NodeMap<NewGraph::Node> nr(orig_graph);
+  ///  dc.nodeRef(nr);
+  ///  // create a cross reference (inverse) for the arcs
+  ///  NewGraph::ArcMap<OrigGraph::Arc> acr(new_graph);
+  ///  dc.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
+  ///  OrigGraph::Node on;
+  ///  NewGraph::Node nn;
+  ///  dc.node(nn, on);
+  ///  // Executions of copy
+  ///  dc.run();
+  ///\endcode
+  template <typename To, typename From>
+  class DigraphCopy {
+  private:
+
+    typedef typename From::Node Node;
+    typedef typename From::NodeIt NodeIt;
+    typedef typename From::Arc Arc;
+    typedef typename From::ArcIt ArcIt;
+
+    typedef typename To::Node TNode;
+    typedef typename To::Arc TArc;
+
+    typedef typename From::template NodeMap<TNode> NodeRefMap;
+    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)
+      : _from(from), _to(to) {}
+
+    /// \brief Destructor of the DigraphCopy
+    ///
+    /// Destructor of the DigraphCopy
+    ~DigraphCopy() {
+      for (int i = 0; i < int(_node_maps.size()); ++i) {
+        delete _node_maps[i];
+      }
+      for (int i = 0; i < int(_arc_maps.size()); ++i) {
+        delete _arc_maps[i];
+      }
+
+    }
+
+    /// \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.
+    template <typename NodeRef>
+    DigraphCopy& nodeRef(NodeRef& map) {
+      _node_maps.push_back(new _graph_utils_bits::RefCopy<From, Node,
+                           NodeRefMap, NodeRef>(map));
+      return *this;
+    }
+
+    /// \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.
+    template <typename NodeCrossRef>
+    DigraphCopy& nodeCrossRef(NodeCrossRef& map) {
+      _node_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Node,
+                           NodeRefMap, NodeCrossRef>(map));
+      return *this;
+    }
+
+    /// \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) {
+      _node_maps.push_back(new _graph_utils_bits::MapCopy<From, Node,
+                           NodeRefMap, ToMap, FromMap>(tmap, map));
+      return *this;
+    }
+
+    /// \brief Make a copy of the given node.
+    ///
+    /// Make a copy of the given node.
+    DigraphCopy& node(TNode& tnode, const Node& snode) {
+      _node_maps.push_back(new _graph_utils_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.
+    template <typename ArcRef>
+    DigraphCopy& arcRef(ArcRef& map) {
+      _arc_maps.push_back(new _graph_utils_bits::RefCopy<From, Arc,
+                          ArcRefMap, ArcRef>(map));
+      return *this;
+    }
+
+    /// \brief Copies the arc cross references into the given map.
+    ///
+    ///  Copies the arc cross references (reverse references) into
+    ///  the given map.
+    template <typename ArcCrossRef>
+    DigraphCopy& arcCrossRef(ArcCrossRef& map) {
+      _arc_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Arc,
+                          ArcRefMap, ArcCrossRef>(map));
+      return *this;
+    }
+
+    /// \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) {
+      _arc_maps.push_back(new _graph_utils_bits::MapCopy<From, Arc,
+                          ArcRefMap, ToMap, FromMap>(tmap, map));
+      return *this;
+    }
+
+    /// \brief Make a copy of the given arc.
+    ///
+    /// Make a copy of the given arc.
+    DigraphCopy& arc(TArc& tarc, const Arc& sarc) {
+      _arc_maps.push_back(new _graph_utils_bits::ItemCopy<From, Arc,
+                          ArcRefMap, TArc>(tarc, sarc));
+      return *this;
+    }
+
+    /// \brief Executes the copies.
+    ///
+    /// Executes the copies.
+    void run() {
+      NodeRefMap nodeRefMap(_from);
+      ArcRefMap arcRefMap(_from);
+      _graph_utils_bits::DigraphCopySelector<To>::
+        copy(_to, _from, nodeRefMap, arcRefMap);
+      for (int i = 0; i < int(_node_maps.size()); ++i) {
+        _node_maps[i]->copy(_from, nodeRefMap);
+      }
+      for (int i = 0; i < int(_arc_maps.size()); ++i) {
+        _arc_maps[i]->copy(_from, arcRefMap);
+      }
+    }
+
+  protected:
+
+
+    const From& _from;
+    To& _to;
+
+    std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* >
+    _node_maps;
+
+    std::vector<_graph_utils_bits::MapCopyBase<From, Arc, ArcRefMap>* >
+    _arc_maps;
+
+  };
+
+  /// \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:
+  ///\code
+  /// copyDigraph(trg, src).nodeRef(nr).arcCrossRef(ecr).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
+  /// 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);
+  }
+
+  /// \brief Class to copy a graph.
+  ///
+  /// 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
+  /// 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.
+  ///
+  /// To make a copy from a graph, first an instance of GraphCopy
+  /// should be created, then the data belongs to the graph should
+  /// assigned to copy. In the end, the \c run() member should be
+  /// called.
+  ///
+  /// The next code copies a graph with several data:
+  ///\code
+  ///  GraphCopy<NewGraph, OrigGraph> dc(new_graph, orig_graph);
+  ///  // create a reference 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
+  ///  OrigGraph::Node on;
+  ///  NewGraph::Node nn;
+  ///  dc.node(nn, on);
+  ///  // Executions of copy
+  ///  dc.run();
+  ///\endcode
+  template <typename To, typename From>
+  class GraphCopy {
+  private:
+
+    typedef typename From::Node Node;
+    typedef typename From::NodeIt NodeIt;
+    typedef typename From::Arc Arc;
+    typedef typename From::ArcIt ArcIt;
+    typedef typename From::Edge Edge;
+    typedef typename From::EdgeIt EdgeIt;
+
+    typedef typename To::Node TNode;
+    typedef typename To::Arc TArc;
+    typedef typename To::Edge TEdge;
+
+    typedef typename From::template NodeMap<TNode> NodeRefMap;
+    typedef typename From::template EdgeMap<TEdge> EdgeRefMap;
+
+    struct ArcRefMap {
+      ArcRefMap(const To& to, const From& from,
+                const EdgeRefMap& edge_ref, const NodeRefMap& node_ref)
+        : _to(to), _from(from),
+          _edge_ref(edge_ref), _node_ref(node_ref) {}
+
+      typedef typename From::Arc Key;
+      typedef typename To::Arc Value;
+
+      Value operator[](const Key& key) const {
+        bool forward = _from.u(key) != _from.v(key) ?
+          _node_ref[_from.source(key)] ==
+          _to.source(_to.direct(_edge_ref[key], true)) :
+          _from.direction(key);
+        return _to.direct(_edge_ref[key], forward);
+      }
+
+      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)
+      : _from(from), _to(to) {}
+
+    /// \brief Destructor of the GraphCopy
+    ///
+    /// Destructor of the GraphCopy
+    ~GraphCopy() {
+      for (int i = 0; i < int(_node_maps.size()); ++i) {
+        delete _node_maps[i];
+      }
+      for (int i = 0; i < int(_arc_maps.size()); ++i) {
+        delete _arc_maps[i];
+      }
+      for (int i = 0; i < int(_edge_maps.size()); ++i) {
+        delete _edge_maps[i];
+      }
+
+    }
+
+    /// \brief Copies the node references into the given map.
+    ///
+    /// Copies the node references into the given map.
+    template <typename NodeRef>
+    GraphCopy& nodeRef(NodeRef& map) {
+      _node_maps.push_back(new _graph_utils_bits::RefCopy<From, Node,
+                           NodeRefMap, NodeRef>(map));
+      return *this;
+    }
+
+    /// \brief Copies the node cross references into the given map.
+    ///
+    ///  Copies the node cross references (reverse references) into
+    ///  the given map.
+    template <typename NodeCrossRef>
+    GraphCopy& nodeCrossRef(NodeCrossRef& map) {
+      _node_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Node,
+                           NodeRefMap, NodeCrossRef>(map));
+      return *this;
+    }
+
+    /// \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) {
+      _node_maps.push_back(new _graph_utils_bits::MapCopy<From, Node,
+                           NodeRefMap, ToMap, FromMap>(tmap, map));
+      return *this;
+    }
+
+    /// \brief Make a copy of the given node.
+    ///
+    /// Make a copy of the given node.
+    GraphCopy& node(TNode& tnode, const Node& snode) {
+      _node_maps.push_back(new _graph_utils_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.
+    template <typename ArcRef>
+    GraphCopy& arcRef(ArcRef& map) {
+      _arc_maps.push_back(new _graph_utils_bits::RefCopy<From, Arc,
+                          ArcRefMap, ArcRef>(map));
+      return *this;
+    }
+
+    /// \brief Copies the arc cross references into the given map.
+    ///
+    ///  Copies the arc cross references (reverse references) into
+    ///  the given map.
+    template <typename ArcCrossRef>
+    GraphCopy& arcCrossRef(ArcCrossRef& map) {
+      _arc_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Arc,
+                          ArcRefMap, ArcCrossRef>(map));
+      return *this;
+    }
+
+    /// \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) {
+      _arc_maps.push_back(new _graph_utils_bits::MapCopy<From, Arc,
+                          ArcRefMap, ToMap, FromMap>(tmap, map));
+      return *this;
+    }
+
+    /// \brief Make a copy of the given arc.
+    ///
+    /// Make a copy of the given arc.
+    GraphCopy& arc(TArc& tarc, const Arc& sarc) {
+      _arc_maps.push_back(new _graph_utils_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.
+    template <typename EdgeRef>
+    GraphCopy& edgeRef(EdgeRef& map) {
+      _edge_maps.push_back(new _graph_utils_bits::RefCopy<From, Edge,
+                           EdgeRefMap, EdgeRef>(map));
+      return *this;
+    }
+
+    /// \brief Copies the edge cross references into the given map.
+    ///
+    /// Copies the edge cross references (reverse
+    /// references) into the given map.
+    template <typename EdgeCrossRef>
+    GraphCopy& edgeCrossRef(EdgeCrossRef& map) {
+      _edge_maps.push_back(new _graph_utils_bits::CrossRefCopy<From,
+                           Edge, EdgeRefMap, EdgeCrossRef>(map));
+      return *this;
+    }
+
+    /// \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) {
+      _edge_maps.push_back(new _graph_utils_bits::MapCopy<From, Edge,
+                           EdgeRefMap, ToMap, FromMap>(tmap, map));
+      return *this;
+    }
+
+    /// \brief Make a copy of the given edge.
+    ///
+    /// Make a copy of the given edge.
+    GraphCopy& edge(TEdge& tedge, const Edge& sedge) {
+      _edge_maps.push_back(new _graph_utils_bits::ItemCopy<From, Edge,
+                           EdgeRefMap, TEdge>(tedge, sedge));
+      return *this;
+    }
+
+    /// \brief Executes the copies.
+    ///
+    /// Executes the copies.
+    void run() {
+      NodeRefMap nodeRefMap(_from);
+      EdgeRefMap edgeRefMap(_from);
+      ArcRefMap arcRefMap(_to, _from, edgeRefMap, nodeRefMap);
+      _graph_utils_bits::GraphCopySelector<To>::
+        copy(_to, _from, nodeRefMap, edgeRefMap);
+      for (int i = 0; i < int(_node_maps.size()); ++i) {
+        _node_maps[i]->copy(_from, nodeRefMap);
+      }
+      for (int i = 0; i < int(_edge_maps.size()); ++i) {
+        _edge_maps[i]->copy(_from, edgeRefMap);
+      }
+      for (int i = 0; i < int(_arc_maps.size()); ++i) {
+        _arc_maps[i]->copy(_from, arcRefMap);
+      }
+    }
+
+  private:
+
+    const From& _from;
+    To& _to;
+
+    std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* >
+    _node_maps;
+
+    std::vector<_graph_utils_bits::MapCopyBase<From, Arc, ArcRefMap>* >
+    _arc_maps;
+
+    std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* >
+    _edge_maps;
+
+  };
+
+  /// \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:
+  ///\code
+  /// copyGraph(trg, src).nodeRef(nr).arcCrossRef(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.
+  ///
+  /// \see GraphCopy
+  template <typename To, typename From>
+  GraphCopy<To, From>
+  copyGraph(To& to, const From& from) {
+    return GraphCopy<To, From>(to, from);
+  }
+
+  /// @}
+
+  /// \addtogroup graph_maps
+  /// @{
+
+  /// Provides an immutable and unique id for each item in the graph.
+
+  /// The IdMap class provides a unique and immutable id for each item of the
+  /// same type (e.g. node) in the graph. This id is <ul><li>\b unique:
+  /// different items (nodes) get different ids <li>\b immutable: the id of an
+  /// item (node) does not change (even if you delete other nodes).  </ul>
+  /// Through this map you get access (i.e. can read) the inner id values of
+  /// the items stored in the graph. This map can be inverted with its member
+  /// class \c InverseMap or with the \c operator() member.
+  ///
+  template <typename _Graph, typename _Item>
+  class IdMap {
+  public:
+    typedef _Graph Graph;
+    typedef int Value;
+    typedef _Item Item;
+    typedef _Item Key;
+
+    /// \brief Constructor.
+    ///
+    /// Constructor of the map.
+    explicit IdMap(const Graph& graph) : _graph(&graph) {}
+
+    /// \brief Gives back the \e id of the item.
+    ///
+    /// Gives back the immutable and unique \e id of the item.
+    int operator[](const Item& item) const { return _graph->id(item);}
+
+    /// \brief Gives back the item by its id.
+    ///
+    /// Gives back the item by its id.
+    Item operator()(int id) { return _graph->fromId(id, Item()); }
+
+  private:
+    const Graph* _graph;
+
+  public:
+
+    /// \brief The class represents the inverse of its owner (IdMap).
+    ///
+    /// The class represents the inverse of its owner (IdMap).
+    /// \see inverse()
+    class InverseMap {
+    public:
+
+      /// \brief Constructor.
+      ///
+      /// Constructor for creating an id-to-item map.
+      explicit InverseMap(const Graph& graph) : _graph(&graph) {}
+
+      /// \brief Constructor.
+      ///
+      /// Constructor for creating an id-to-item map.
+      explicit InverseMap(const IdMap& map) : _graph(map._graph) {}
+
+      /// \brief Gives back the given item from its id.
+      ///
+      /// Gives back the given item from its id.
+      ///
+      Item operator[](int id) const { return _graph->fromId(id, Item());}
+
+    private:
+      const Graph* _graph;
+    };
+
+    /// \brief Gives back the inverse of the map.
+    ///
+    /// Gives back the inverse of the IdMap.
+    InverseMap inverse() const { return InverseMap(*_graph);}
+
+  };
+
+
+  /// \brief General invertable graph-map type.
+
+  /// This type provides simple invertable graph-maps.
+  /// The InvertableMap wraps an arbitrary ReadWriteMap
+  /// and if a key is set to a new value then store it
+  /// in the inverse map.
+  ///
+  /// The values of the map can be accessed
+  /// with stl compatible forward iterator.
+  ///
+  /// \tparam _Graph The graph type.
+  /// \tparam _Item The item type of the graph.
+  /// \tparam _Value The value type of the map.
+  ///
+  /// \see IterableValueMap
+  template <typename _Graph, typename _Item, typename _Value>
+  class InvertableMap : protected DefaultMap<_Graph, _Item, _Value> {
+  private:
+
+    typedef DefaultMap<_Graph, _Item, _Value> Map;
+    typedef _Graph Graph;
+
+    typedef std::map<_Value, _Item> Container;
+    Container _inv_map;
+
+  public:
+
+    /// The key type of InvertableMap (Node, Arc, Edge).
+    typedef typename Map::Key Key;
+    /// The value type of the InvertableMap.
+    typedef typename Map::Value Value;
+
+
+
+    /// \brief Constructor.
+    ///
+    /// Construct a new InvertableMap for the graph.
+    ///
+    explicit InvertableMap(const Graph& graph) : Map(graph) {}
+
+    /// \brief Forward iterator for values.
+    ///
+    /// This iterator is an stl compatible forward
+    /// iterator on the values of the map. The values can
+    /// be accessed in the [beginValue, endValue) range.
+    ///
+    class ValueIterator
+      : public std::iterator<std::forward_iterator_tag, Value> {
+      friend class InvertableMap;
+    private:
+      ValueIterator(typename Container::const_iterator _it)
+        : it(_it) {}
+    public:
+
+      ValueIterator() {}
+
+      ValueIterator& operator++() { ++it; return *this; }
+      ValueIterator operator++(int) {
+        ValueIterator tmp(*this);
+        operator++();
+        return tmp;
+      }
+
+      const Value& operator*() const { return it->first; }
+      const Value* operator->() const { return &(it->first); }
+
+      bool operator==(ValueIterator jt) const { return it == jt.it; }
+      bool operator!=(ValueIterator jt) const { return it != jt.it; }
+
+    private:
+      typename Container::const_iterator it;
+    };
+
+    /// \brief Returns an iterator to the first value.
+    ///
+    /// Returns an stl compatible iterator to the
+    /// first value of the map. The values of the
+    /// map can be accessed in the [beginValue, endValue)
+    /// range.
+    ValueIterator beginValue() const {
+      return ValueIterator(_inv_map.begin());
+    }
+
+    /// \brief Returns an iterator after the last value.
+    ///
+    /// Returns an stl compatible iterator after the
+    /// last value of the map. The values of the
+    /// map can be accessed in the [beginValue, endValue)
+    /// range.
+    ValueIterator endValue() const {
+      return ValueIterator(_inv_map.end());
+    }
+
+    /// \brief The setter function of the map.
+    ///
+    /// Sets the mapped value.
+    void set(const Key& key, const Value& val) {
+      Value oldval = Map::operator[](key);
+      typename Container::iterator it = _inv_map.find(oldval);
+      if (it != _inv_map.end() && it->second == key) {
+        _inv_map.erase(it);
+      }
+      _inv_map.insert(make_pair(val, key));
+      Map::set(key, val);
+    }
+
+    /// \brief The getter function of the map.
+    ///
+    /// It gives back the value associated with the key.
+    typename MapTraits<Map>::ConstReturnValue
+    operator[](const Key& key) const {
+      return Map::operator[](key);
+    }
+
+    /// \brief Gives back the item by its value.
+    ///
+    /// Gives back the item by its value.
+    Key operator()(const Value& key) const {
+      typename Container::const_iterator it = _inv_map.find(key);
+      return it != _inv_map.end() ? it->second : INVALID;
+    }
+
+  protected:
+
+    /// \brief Erase the key from the map.
+    ///
+    /// Erase the key to the map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void erase(const Key& key) {
+      Value val = Map::operator[](key);
+      typename Container::iterator it = _inv_map.find(val);
+      if (it != _inv_map.end() && it->second == key) {
+        _inv_map.erase(it);
+      }
+      Map::erase(key);
+    }
+
+    /// \brief Erase more keys from the map.
+    ///
+    /// Erase more keys from the map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void erase(const std::vector<Key>& keys) {
+      for (int i = 0; i < int(keys.size()); ++i) {
+        Value val = Map::operator[](keys[i]);
+        typename Container::iterator it = _inv_map.find(val);
+        if (it != _inv_map.end() && it->second == keys[i]) {
+          _inv_map.erase(it);
+        }
+      }
+      Map::erase(keys);
+    }
+
+    /// \brief Clear the keys from the map and inverse map.
+    ///
+    /// Clear the keys from the map and inverse map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void clear() {
+      _inv_map.clear();
+      Map::clear();
+    }
+
+  public:
+
+    /// \brief The inverse map type.
+    ///
+    /// The inverse of this map. The subscript operator of the map
+    /// gives back always the item what was last assigned to the value.
+    class InverseMap {
+    public:
+      /// \brief Constructor of the InverseMap.
+      ///
+      /// Constructor of the InverseMap.
+      explicit InverseMap(const InvertableMap& inverted)
+        : _inverted(inverted) {}
+
+      /// The value type of the InverseMap.
+      typedef typename InvertableMap::Key Value;
+      /// The key type of the InverseMap.
+      typedef typename InvertableMap::Value Key;
+
+      /// \brief Subscript operator.
+      ///
+      /// Subscript operator. It gives back always the item
+      /// what was last assigned to the value.
+      Value operator[](const Key& key) const {
+        return _inverted(key);
+      }
+
+    private:
+      const InvertableMap& _inverted;
+    };
+
+    /// \brief It gives back the just readable inverse map.
+    ///
+    /// It gives back the just readable inverse map.
+    InverseMap inverse() const {
+      return InverseMap(*this);
+    }
+
+
+
+  };
+
+  /// \brief Provides a mutable, continuous and unique descriptor for each
+  /// item in the graph.
+  ///
+  /// The DescriptorMap class provides a unique and continuous (but mutable)
+  /// descriptor (id) for each item of the same type (e.g. node) in the
+  /// graph. This id is <ul><li>\b unique: different items (nodes) get
+  /// different ids <li>\b continuous: the range of the ids is the set of
+  /// integers between 0 and \c n-1, where \c n is the number of the items of
+  /// this type (e.g. nodes) (so the id of a node can change if you delete an
+  /// other node, i.e. this id is mutable).  </ul> This map can be inverted
+  /// with its member class \c InverseMap, or with the \c operator() member.
+  ///
+  /// \tparam _Graph The graph class the \c DescriptorMap belongs to.
+  /// \tparam _Item The Item is the Key of the Map. It may be Node, Arc or
+  /// Edge.
+  template <typename _Graph, typename _Item>
+  class DescriptorMap : protected DefaultMap<_Graph, _Item, int> {
+
+    typedef _Item Item;
+    typedef DefaultMap<_Graph, _Item, int> Map;
+
+  public:
+    /// The graph class of DescriptorMap.
+    typedef _Graph Graph;
+
+    /// The key type of DescriptorMap (Node, Arc, Edge).
+    typedef typename Map::Key Key;
+    /// The value type of DescriptorMap.
+    typedef typename Map::Value Value;
+
+    /// \brief Constructor.
+    ///
+    /// Constructor for descriptor map.
+    explicit DescriptorMap(const Graph& _graph) : Map(_graph) {
+      Item it;
+      const typename Map::Notifier* nf = Map::notifier();
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+        Map::set(it, _inv_map.size());
+        _inv_map.push_back(it);
+      }
+    }
+
+  protected:
+
+    /// \brief Add a new key to the map.
+    ///
+    /// Add a new key to the map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void add(const Item& item) {
+      Map::add(item);
+      Map::set(item, _inv_map.size());
+      _inv_map.push_back(item);
+    }
+
+    /// \brief Add more new keys to the map.
+    ///
+    /// Add more new keys to the map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void add(const std::vector<Item>& items) {
+      Map::add(items);
+      for (int i = 0; i < int(items.size()); ++i) {
+        Map::set(items[i], _inv_map.size());
+        _inv_map.push_back(items[i]);
+      }
+    }
+
+    /// \brief Erase the key from the map.
+    ///
+    /// Erase the key from the map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void erase(const Item& item) {
+      Map::set(_inv_map.back(), Map::operator[](item));
+      _inv_map[Map::operator[](item)] = _inv_map.back();
+      _inv_map.pop_back();
+      Map::erase(item);
+    }
+
+    /// \brief Erase more keys from the map.
+    ///
+    /// Erase more keys from the map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void erase(const std::vector<Item>& items) {
+      for (int i = 0; i < int(items.size()); ++i) {
+        Map::set(_inv_map.back(), Map::operator[](items[i]));
+        _inv_map[Map::operator[](items[i])] = _inv_map.back();
+        _inv_map.pop_back();
+      }
+      Map::erase(items);
+    }
+
+    /// \brief Build the unique map.
+    ///
+    /// Build the unique map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void build() {
+      Map::build();
+      Item it;
+      const typename Map::Notifier* nf = Map::notifier();
+      for (nf->first(it); it != INVALID; nf->next(it)) {
+        Map::set(it, _inv_map.size());
+        _inv_map.push_back(it);
+      }
+    }
+
+    /// \brief Clear the keys from the map.
+    ///
+    /// Clear the keys from the map. It is called by the
+    /// \c AlterationNotifier.
+    virtual void clear() {
+      _inv_map.clear();
+      Map::clear();
+    }
+
+  public:
+
+    /// \brief Returns the maximal value plus one.
+    ///
+    /// Returns the maximal value plus one in the map.
+    unsigned int size() const {
+      return _inv_map.size();
+    }
+
+    /// \brief Swaps the position of the two items in the map.
+    ///
+    /// Swaps the position of the two items in the map.
+    void swap(const Item& p, const Item& q) {
+      int pi = Map::operator[](p);
+      int qi = Map::operator[](q);
+      Map::set(p, qi);
+      _inv_map[qi] = p;
+      Map::set(q, pi);
+      _inv_map[pi] = q;
+    }
+
+    /// \brief Gives back the \e descriptor of the item.
+    ///
+    /// Gives back the mutable and unique \e descriptor of the map.
+    int operator[](const Item& item) const {
+      return Map::operator[](item);
+    }
+
+    /// \brief Gives back the item by its descriptor.
+    ///
+    /// Gives back th item by its descriptor.
+    Item operator()(int id) const {
+      return _inv_map[id];
+    }
+
+  private:
+
+    typedef std::vector<Item> Container;
+    Container _inv_map;
+
+  public:
+    /// \brief The inverse map type of DescriptorMap.
+    ///
+    /// The inverse map type of DescriptorMap.
+    class InverseMap {
+    public:
+      /// \brief Constructor of the InverseMap.
+      ///
+      /// Constructor of the InverseMap.
+      explicit InverseMap(const DescriptorMap& inverted)
+        : _inverted(inverted) {}
+
+
+      /// The value type of the InverseMap.
+      typedef typename DescriptorMap::Key Value;
+      /// The key type of the InverseMap.
+      typedef typename DescriptorMap::Value Key;
+
+      /// \brief Subscript operator.
+      ///
+      /// Subscript operator. It gives back the item
+      /// that the descriptor belongs to currently.
+      Value operator[](const Key& key) const {
+        return _inverted(key);
+      }
+
+      /// \brief Size of the map.
+      ///
+      /// Returns the size of the map.
+      unsigned int size() const {
+        return _inverted.size();
+      }
+
+    private:
+      const DescriptorMap& _inverted;
+    };
+
+    /// \brief Gives back the inverse of the map.
+    ///
+    /// Gives back the inverse of the map.
+    const InverseMap inverse() const {
+      return InverseMap(*this);
+    }
+  };
+
+  /// \brief Returns the source of the given arc.
+  ///
+  /// The SourceMap gives back the source Node of the given arc.
+  /// \see TargetMap
+  template <typename Digraph>
+  class SourceMap {
+  public:
+
+    typedef typename Digraph::Node Value;
+    typedef typename Digraph::Arc Key;
+
+    /// \brief Constructor
+    ///
+    /// Constructor
+    /// \param _digraph The digraph that the map belongs to.
+    explicit SourceMap(const Digraph& digraph) : _digraph(digraph) {}
+
+    /// \brief The subscript operator.
+    ///
+    /// The subscript operator.
+    /// \param arc The arc
+    /// \return The source of the arc
+    Value operator[](const Key& arc) const {
+      return _digraph.source(arc);
+    }
+
+  private:
+    const Digraph& _digraph;
+  };
+
+  /// \brief Returns a \ref SourceMap class.
+  ///
+  /// This function just returns an \ref SourceMap class.
+  /// \relates SourceMap
+  template <typename Digraph>
+  inline SourceMap<Digraph> sourceMap(const Digraph& digraph) {
+    return SourceMap<Digraph>(digraph);
+  }
+
+  /// \brief Returns the target of the given arc.
+  ///
+  /// The TargetMap gives back the target Node of the given arc.
+  /// \see SourceMap
+  template <typename Digraph>
+  class TargetMap {
+  public:
+
+    typedef typename Digraph::Node Value;
+    typedef typename Digraph::Arc Key;
+
+    /// \brief Constructor
+    ///
+    /// Constructor
+    /// \param _digraph The digraph that the map belongs to.
+    explicit TargetMap(const Digraph& digraph) : _digraph(digraph) {}
+
+    /// \brief The subscript operator.
+    ///
+    /// The subscript operator.
+    /// \param e The arc
+    /// \return The target of the arc
+    Value operator[](const Key& e) const {
+      return _digraph.target(e);
+    }
+
+  private:
+    const Digraph& _digraph;
+  };
+
+  /// \brief Returns a \ref TargetMap class.
+  ///
+  /// This function just returns a \ref TargetMap class.
+  /// \relates TargetMap
+  template <typename Digraph>
+  inline TargetMap<Digraph> targetMap(const Digraph& digraph) {
+    return TargetMap<Digraph>(digraph);
+  }
+
+  /// \brief Returns the "forward" directed arc view of an edge.
+  ///
+  /// Returns the "forward" directed arc view of an edge.
+  /// \see BackwardMap
+  template <typename Graph>
+  class ForwardMap {
+  public:
+
+    typedef typename Graph::Arc Value;
+    typedef typename Graph::Edge Key;
+
+    /// \brief Constructor
+    ///
+    /// Constructor
+    /// \param _graph The graph that the map belongs to.
+    explicit ForwardMap(const Graph& graph) : _graph(graph) {}
+
+    /// \brief The subscript operator.
+    ///
+    /// The subscript operator.
+    /// \param key An edge
+    /// \return The "forward" directed arc view of edge
+    Value operator[](const Key& key) const {
+      return _graph.direct(key, true);
+    }
+
+  private:
+    const Graph& _graph;
+  };
+
+  /// \brief Returns a \ref ForwardMap class.
+  ///
+  /// This function just returns an \ref ForwardMap class.
+  /// \relates ForwardMap
+  template <typename Graph>
+  inline ForwardMap<Graph> forwardMap(const Graph& graph) {
+    return ForwardMap<Graph>(graph);
+  }
+
+  /// \brief Returns the "backward" directed arc view of an edge.
+  ///
+  /// Returns the "backward" directed arc view of an edge.
+  /// \see ForwardMap
+  template <typename Graph>
+  class BackwardMap {
+  public:
+
+    typedef typename Graph::Arc Value;
+    typedef typename Graph::Edge Key;
+
+    /// \brief Constructor
+    ///
+    /// Constructor
+    /// \param _graph The graph that the map belongs to.
+    explicit BackwardMap(const Graph& graph) : _graph(graph) {}
+
+    /// \brief The subscript operator.
+    ///
+    /// The subscript operator.
+    /// \param key An edge
+    /// \return The "backward" directed arc view of edge
+    Value operator[](const Key& key) const {
+      return _graph.direct(key, false);
+    }
+
+  private:
+    const Graph& _graph;
+  };
+
+  /// \brief Returns a \ref BackwardMap class
+
+  /// This function just returns a \ref BackwardMap class.
+  /// \relates BackwardMap
+  template <typename Graph>
+  inline BackwardMap<Graph> backwardMap(const Graph& graph) {
+    return BackwardMap<Graph>(graph);
+  }
+
+  /// \brief Potential difference map
+  ///
+  /// If there is an potential map on the nodes then we
+  /// can get an arc map as we get the substraction of the
+  /// values of the target and source.
+  template <typename Digraph, typename NodeMap>
+  class PotentialDifferenceMap {
+  public:
+    typedef typename Digraph::Arc Key;
+    typedef typename NodeMap::Value Value;
+
+    /// \brief Constructor
+    ///
+    /// Contructor of the map
+    explicit PotentialDifferenceMap(const Digraph& digraph,
+                                    const NodeMap& potential)
+      : _digraph(digraph), _potential(potential) {}
+
+    /// \brief Const subscription operator
+    ///
+    /// Const subscription operator
+    Value operator[](const Key& arc) const {
+      return _potential[_digraph.target(arc)] -
+        _potential[_digraph.source(arc)];
+    }
+
+  private:
+    const Digraph& _digraph;
+    const NodeMap& _potential;
+  };
+
+  /// \brief Returns a PotentialDifferenceMap.
+  ///
+  /// This function just returns a PotentialDifferenceMap.
+  /// \relates PotentialDifferenceMap
+  template <typename Digraph, typename NodeMap>
+  PotentialDifferenceMap<Digraph, NodeMap>
+  potentialDifferenceMap(const Digraph& digraph, const NodeMap& potential) {
+    return PotentialDifferenceMap<Digraph, NodeMap>(digraph, potential);
+  }
+
+  /// \brief Map of the node in-degrees.
+  ///
+  /// This map returns the in-degree of a node. Once it is constructed,
+  /// the degrees are stored in a standard NodeMap, so each query is done
+  /// in constant time. On the other hand, the values are updated automatically
+  /// whenever the digraph changes.
+  ///
+  /// \warning Besides addNode() and addArc(), a digraph structure may provide
+  /// alternative ways to modify the digraph. The correct behavior of InDegMap
+  /// is not guarantied if these additional features are used. For example
+  /// the functions \ref ListDigraph::changeSource() "changeSource()",
+  /// \ref ListDigraph::changeTarget() "changeTarget()" and
+  /// \ref ListDigraph::reverseArc() "reverseArc()"
+  /// of \ref ListDigraph will \e not update the degree values correctly.
+  ///
+  /// \sa OutDegMap
+
+  template <typename _Digraph>
+  class InDegMap
+    : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
+      ::ItemNotifier::ObserverBase {
+
+  public:
+
+    typedef _Digraph Digraph;
+    typedef int Value;
+    typedef typename Digraph::Node Key;
+
+    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
+    ::ItemNotifier::ObserverBase Parent;
+
+  private:
+
+    class AutoNodeMap : public DefaultMap<Digraph, Key, int> {
+    public:
+
+      typedef DefaultMap<Digraph, Key, int> Parent;
+
+      AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
+
+      virtual void add(const Key& key) {
+        Parent::add(key);
+        Parent::set(key, 0);
+      }
+
+      virtual void add(const std::vector<Key>& keys) {
+        Parent::add(keys);
+        for (int i = 0; i < int(keys.size()); ++i) {
+          Parent::set(keys[i], 0);
+        }
+      }
+
+      virtual void build() {
+        Parent::build();
+        Key it;
+        typename Parent::Notifier* nf = Parent::notifier();
+        for (nf->first(it); it != INVALID; nf->next(it)) {
+          Parent::set(it, 0);
+        }
+      }
+    };
+
+  public:
+
+    /// \brief Constructor.
+    ///
+    /// Constructor for creating in-degree map.
+    explicit InDegMap(const Digraph& digraph)
+      : _digraph(digraph), _deg(digraph) {
+      Parent::attach(_digraph.notifier(typename Digraph::Arc()));
+
+      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
+        _deg[it] = countInArcs(_digraph, it);
+      }
+    }
+
+    /// Gives back the in-degree of a Node.
+    int operator[](const Key& key) const {
+      return _deg[key];
+    }
+
+  protected:
+
+    typedef typename Digraph::Arc Arc;
+
+    virtual void add(const Arc& arc) {
+      ++_deg[_digraph.target(arc)];
+    }
+
+    virtual void add(const std::vector<Arc>& arcs) {
+      for (int i = 0; i < int(arcs.size()); ++i) {
+        ++_deg[_digraph.target(arcs[i])];
+      }
+    }
+
+    virtual void erase(const Arc& arc) {
+      --_deg[_digraph.target(arc)];
+    }
+
+    virtual void erase(const std::vector<Arc>& arcs) {
+      for (int i = 0; i < int(arcs.size()); ++i) {
+        --_deg[_digraph.target(arcs[i])];
+      }
+    }
+
+    virtual void build() {
+      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
+        _deg[it] = countInArcs(_digraph, it);
+      }
+    }
+
+    virtual void clear() {
+      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
+        _deg[it] = 0;
+      }
+    }
+  private:
+
+    const Digraph& _digraph;
+    AutoNodeMap _deg;
+  };
+
+  /// \brief Map of the node out-degrees.
+  ///
+  /// This map returns the out-degree of a node. Once it is constructed,
+  /// the degrees are stored in a standard NodeMap, so each query is done
+  /// in constant time. On the other hand, the values are updated automatically
+  /// whenever the digraph changes.
+  ///
+  /// \warning Besides addNode() and addArc(), a digraph structure may provide
+  /// alternative ways to modify the digraph. The correct behavior of OutDegMap
+  /// is not guarantied if these additional features are used. For example
+  /// the functions \ref ListDigraph::changeSource() "changeSource()",
+  /// \ref ListDigraph::changeTarget() "changeTarget()" and
+  /// \ref ListDigraph::reverseArc() "reverseArc()"
+  /// of \ref ListDigraph will \e not update the degree values correctly.
+  ///
+  /// \sa InDegMap
+
+  template <typename _Digraph>
+  class OutDegMap
+    : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
+      ::ItemNotifier::ObserverBase {
+
+  public:
+
+    typedef _Digraph Digraph;
+    typedef int Value;
+    typedef typename Digraph::Node Key;
+
+    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
+    ::ItemNotifier::ObserverBase Parent;
+
+  private:
+
+    class AutoNodeMap : public DefaultMap<Digraph, Key, int> {
+    public:
+
+      typedef DefaultMap<Digraph, Key, int> Parent;
+
+      AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
+
+      virtual void add(const Key& key) {
+        Parent::add(key);
+        Parent::set(key, 0);
+      }
+      virtual void add(const std::vector<Key>& keys) {
+        Parent::add(keys);
+        for (int i = 0; i < int(keys.size()); ++i) {
+          Parent::set(keys[i], 0);
+        }
+      }
+      virtual void build() {
+        Parent::build();
+        Key it;
+        typename Parent::Notifier* nf = Parent::notifier();
+        for (nf->first(it); it != INVALID; nf->next(it)) {
+          Parent::set(it, 0);
+        }
+      }
+    };
+
+  public:
+
+    /// \brief Constructor.
+    ///
+    /// Constructor for creating out-degree map.
+    explicit OutDegMap(const Digraph& digraph)
+      : _digraph(digraph), _deg(digraph) {
+      Parent::attach(_digraph.notifier(typename Digraph::Arc()));
+
+      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
+        _deg[it] = countOutArcs(_digraph, it);
+      }
+    }
+
+    /// Gives back the out-degree of a Node.
+    int operator[](const Key& key) const {
+      return _deg[key];
+    }
+
+  protected:
+
+    typedef typename Digraph::Arc Arc;
+
+    virtual void add(const Arc& arc) {
+      ++_deg[_digraph.source(arc)];
+    }
+
+    virtual void add(const std::vector<Arc>& arcs) {
+      for (int i = 0; i < int(arcs.size()); ++i) {
+        ++_deg[_digraph.source(arcs[i])];
+      }
+    }
+
+    virtual void erase(const Arc& arc) {
+      --_deg[_digraph.source(arc)];
+    }
+
+    virtual void erase(const std::vector<Arc>& arcs) {
+      for (int i = 0; i < int(arcs.size()); ++i) {
+        --_deg[_digraph.source(arcs[i])];
+      }
+    }
+
+    virtual void build() {
+      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
+        _deg[it] = countOutArcs(_digraph, it);
+      }
+    }
+
+    virtual void clear() {
+      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
+        _deg[it] = 0;
+      }
+    }
+  private:
+
+    const Digraph& _digraph;
+    AutoNodeMap _deg;
+  };
+
+
+  ///Dynamic arc look up between given endpoints.
+
+  ///\ingroup gutils
+  ///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 d)</em>,
+  ///where <em>d</em> is the out-degree of the source node.
+  ///
+  ///It is possible to find \e all parallel arcs between two nodes with
+  ///the \c findFirst() and \c findNext() members.
+  ///
+  ///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
+  ///optimal time bound in a constant factor for any distribution of
+  ///queries.
+  ///
+  ///\tparam G The type of the underlying digraph.
+  ///
+  ///\sa ArcLookUp
+  ///\sa AllArcLookUp
+  template<class G>
+  class DynArcLookUp
+    : protected ItemSetTraits<G, typename G::Arc>::ItemNotifier::ObserverBase
+  {
+  public:
+    typedef typename ItemSetTraits<G, typename G::Arc>
+    ::ItemNotifier::ObserverBase Parent;
+
+    TEMPLATE_DIGRAPH_TYPEDEFS(G);
+    typedef G Digraph;
+
+  protected:
+
+    class AutoNodeMap : public DefaultMap<G, Node, Arc> {
+    public:
+
+      typedef DefaultMap<G, Node, Arc> Parent;
+
+      AutoNodeMap(const G& digraph) : Parent(digraph, INVALID) {}
+
+      virtual void add(const Node& node) {
+        Parent::add(node);
+        Parent::set(node, INVALID);
+      }
+
+      virtual void add(const std::vector<Node>& nodes) {
+        Parent::add(nodes);
+        for (int i = 0; i < int(nodes.size()); ++i) {
+          Parent::set(nodes[i], INVALID);
+        }
+      }
+
+      virtual void build() {
+        Parent::build();
+        Node it;
+        typename Parent::Notifier* nf = Parent::notifier();
+        for (nf->first(it); it != INVALID; nf->next(it)) {
+          Parent::set(it, INVALID);
+        }
+      }
+    };
+
+    const Digraph &_g;
+    AutoNodeMap _head;
+    typename Digraph::template ArcMap<Arc> _parent;
+    typename Digraph::template ArcMap<Arc> _left;
+    typename Digraph::template ArcMap<Arc> _right;
+
+    class ArcLess {
+      const Digraph &g;
+    public:
+      ArcLess(const Digraph &_g) : g(_g) {}
+      bool operator()(Arc a,Arc b) const
+      {
+        return g.target(a)<g.target(b);
+      }
+    };
+
+  public:
+
+    ///Constructor
+
+    ///Constructor.
+    ///
+    ///It builds up the search database.
+    DynArcLookUp(const Digraph &g)
+      : _g(g),_head(g),_parent(g),_left(g),_right(g)
+    {
+      Parent::attach(_g.notifier(typename Digraph::Arc()));
+      refresh();
+    }
+
+  protected:
+
+    virtual void add(const Arc& arc) {
+      insert(arc);
+    }
+
+    virtual void add(const std::vector<Arc>& arcs) {
+      for (int i = 0; i < int(arcs.size()); ++i) {
+        insert(arcs[i]);
+      }
+    }
+
+    virtual void erase(const Arc& arc) {
+      remove(arc);
+    }
+
+    virtual void erase(const std::vector<Arc>& arcs) {
+      for (int i = 0; i < int(arcs.size()); ++i) {
+        remove(arcs[i]);
+      }
+    }
+
+    virtual void build() {
+      refresh();
+    }
+
+    virtual void clear() {
+      for(NodeIt n(_g);n!=INVALID;++n) {
+        _head.set(n, INVALID);
+      }
+    }
+
+    void insert(Arc arc) {
+      Node s = _g.source(arc);
+      Node t = _g.target(arc);
+      _left.set(arc, INVALID);
+      _right.set(arc, INVALID);
+
+      Arc e = _head[s];
+      if (e == INVALID) {
+        _head.set(s, arc);
+        _parent.set(arc, INVALID);
+        return;
+      }
+      while (true) {
+        if (t < _g.target(e)) {
+          if (_left[e] == INVALID) {
+            _left.set(e, arc);
+            _parent.set(arc, e);
+            splay(arc);
+            return;
+          } else {
+            e = _left[e];
+          }
+        } else {
+          if (_right[e] == INVALID) {
+            _right.set(e, arc);
+            _parent.set(arc, e);
+            splay(arc);
+            return;
+          } else {
+            e = _right[e];
+          }
+        }
+      }
+    }
+
+    void remove(Arc arc) {
+      if (_left[arc] == INVALID) {
+        if (_right[arc] != INVALID) {
+          _parent.set(_right[arc], _parent[arc]);
+        }
+        if (_parent[arc] != INVALID) {
+          if (_left[_parent[arc]] == arc) {
+            _left.set(_parent[arc], _right[arc]);
+          } else {
+            _right.set(_parent[arc], _right[arc]);
+          }
+        } else {
+          _head.set(_g.source(arc), _right[arc]);
+        }
+      } else if (_right[arc] == INVALID) {
+        _parent.set(_left[arc], _parent[arc]);
+        if (_parent[arc] != INVALID) {
+          if (_left[_parent[arc]] == arc) {
+            _left.set(_parent[arc], _left[arc]);
+          } else {
+            _right.set(_parent[arc], _left[arc]);
+          }
+        } else {
+          _head.set(_g.source(arc), _left[arc]);
+        }
+      } else {
+        Arc e = _left[arc];
+        if (_right[e] != INVALID) {
+          e = _right[e];
+          while (_right[e] != INVALID) {
+            e = _right[e];
+          }
+          Arc s = _parent[e];
+          _right.set(_parent[e], _left[e]);
+          if (_left[e] != INVALID) {
+            _parent.set(_left[e], _parent[e]);
+          }
+
+          _left.set(e, _left[arc]);
+          _parent.set(_left[arc], e);
+          _right.set(e, _right[arc]);
+          _parent.set(_right[arc], e);
+
+          _parent.set(e, _parent[arc]);
+          if (_parent[arc] != INVALID) {
+            if (_left[_parent[arc]] == arc) {
+              _left.set(_parent[arc], e);
+            } else {
+              _right.set(_parent[arc], e);
+            }
+          }
+          splay(s);
+        } else {
+          _right.set(e, _right[arc]);
+          _parent.set(_right[arc], e);
+
+          if (_parent[arc] != INVALID) {
+            if (_left[_parent[arc]] == arc) {
+              _left.set(_parent[arc], e);
+            } else {
+              _right.set(_parent[arc], e);
+            }
+          } else {
+            _head.set(_g.source(arc), e);
+          }
+        }
+      }
+    }
+
+    Arc refreshRec(std::vector<Arc> &v,int a,int b)
+    {
+      int m=(a+b)/2;
+      Arc me=v[m];
+      if (a < m) {
+        Arc left = refreshRec(v,a,m-1);
+        _left.set(me, left);
+        _parent.set(left, me);
+      } else {
+        _left.set(me, INVALID);
+      }
+      if (m < b) {
+        Arc right = refreshRec(v,m+1,b);
+        _right.set(me, right);
+        _parent.set(right, me);
+      } else {
+        _right.set(me, INVALID);
+      }
+      return me;
+    }
+
+    void refresh() {
+      for(NodeIt n(_g);n!=INVALID;++n) {
+        std::vector<Arc> v;
+        for(OutArcIt e(_g,n);e!=INVALID;++e) v.push_back(e);
+        if(v.size()) {
+          std::sort(v.begin(),v.end(),ArcLess(_g));
+          Arc head = refreshRec(v,0,v.size()-1);
+          _head.set(n, head);
+          _parent.set(head, INVALID);
+        }
+        else _head.set(n, INVALID);
+      }
+    }
+
+    void zig(Arc v) {
+      Arc w = _parent[v];
+      _parent.set(v, _parent[w]);
+      _parent.set(w, v);
+      _left.set(w, _right[v]);
+      _right.set(v, w);
+      if (_parent[v] != INVALID) {
+        if (_right[_parent[v]] == w) {
+          _right.set(_parent[v], v);
+        } else {
+          _left.set(_parent[v], v);
+        }
+      }
+      if (_left[w] != INVALID){
+        _parent.set(_left[w], w);
+      }
+    }
+
+    void zag(Arc v) {
+      Arc w = _parent[v];
+      _parent.set(v, _parent[w]);
+      _parent.set(w, v);
+      _right.set(w, _left[v]);
+      _left.set(v, w);
+      if (_parent[v] != INVALID){
+        if (_left[_parent[v]] == w) {
+          _left.set(_parent[v], v);
+        } else {
+          _right.set(_parent[v], v);
+        }
+      }
+      if (_right[w] != INVALID){
+        _parent.set(_right[w], w);
+      }
+    }
+
+    void splay(Arc v) {
+      while (_parent[v] != INVALID) {
+        if (v == _left[_parent[v]]) {
+          if (_parent[_parent[v]] == INVALID) {
+            zig(v);
+          } else {
+            if (_parent[v] == _left[_parent[_parent[v]]]) {
+              zig(_parent[v]);
+              zig(v);
+            } else {
+              zig(v);
+              zag(v);
+            }
+          }
+        } else {
+          if (_parent[_parent[v]] == INVALID) {
+            zag(v);
+          } else {
+            if (_parent[v] == _left[_parent[_parent[v]]]) {
+              zag(v);
+              zig(v);
+            } else {
+              zag(_parent[v]);
+              zag(v);
+            }
+          }
+        }
+      }
+      _head[_g.source(v)] = v;
+    }
+
+
+  public:
+
+    ///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
+    ///\return An arc from \c s to \c t if there exists,
+    ///\ref INVALID otherwise.
+    Arc operator()(Node s, Node t) const
+    {
+      Arc a = _head[s];
+      while (true) {
+        if (_g.target(a) == t) {
+          const_cast<DynArcLookUp&>(*this).splay(a);
+          return a;
+        } else if (t < _g.target(a)) {
+          if (_left[a] == INVALID) {
+            const_cast<DynArcLookUp&>(*this).splay(a);
+            return INVALID;
+          } else {
+            a = _left[a];
+          }
+        } else  {
+          if (_right[a] == INVALID) {
+            const_cast<DynArcLookUp&>(*this).splay(a);
+            return INVALID;
+          } else {
+            a = _right[a];
+          }
+        }
+      }
+    }
+
+    ///Find the first arc between two nodes.
+
+    ///Find the first 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.
+    Arc findFirst(Node s, Node t) const
+    {
+      Arc a = _head[s];
+      Arc r = INVALID;
+      while (true) {
+        if (_g.target(a) < t) {
+          if (_right[a] == INVALID) {
+            const_cast<DynArcLookUp&>(*this).splay(a);
+            return r;
+          } else {
+            a = _right[a];
+          }
+        } else {
+          if (_g.target(a) == t) {
+            r = a;
+          }
+          if (_left[a] == INVALID) {
+            const_cast<DynArcLookUp&>(*this).splay(a);
+            return r;
+          } else {
+            a = _left[a];
+          }
+        }
+      }
+    }
+
+    ///Find the next arc between two nodes.
+
+    ///Find the next 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.
+
+    ///\note If \c e is not the result of the previous \c findFirst()
+    ///operation then the amorized time bound can not be guaranteed.
+#ifdef DOXYGEN
+    Arc findNext(Node s, Node t, Arc a) const
+#else
+    Arc findNext(Node, Node t, Arc a) const
+#endif
+    {
+      if (_right[a] != INVALID) {
+        a = _right[a];
+        while (_left[a] != INVALID) {
+          a = _left[a];
+        }
+        const_cast<DynArcLookUp&>(*this).splay(a);
+      } else {
+        while (_parent[a] != INVALID && _right[_parent[a]] ==  a) {
+          a = _parent[a];
+        }
+        if (_parent[a] == INVALID) {
+          return INVALID;
+        } else {
+          a = _parent[a];
+          const_cast<DynArcLookUp&>(*this).splay(a);
+        }
+      }
+      if (_g.target(a) == t) return a;
+      else return INVALID;
+    }
+
+  };
+
+  ///Fast arc look up between given endpoints.
+
+  ///\ingroup gutils
+  ///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>,
+  ///where <em>d</em> is the out-degree of the source node.
+  ///
+  ///It is not possible to find \e all parallel arcs between two nodes.
+  ///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).
+  ///
+  ///\tparam G The type of the underlying digraph.
+  ///
+  ///\sa DynArcLookUp
+  ///\sa AllArcLookUp
+  template<class G>
+  class ArcLookUp
+  {
+  public:
+    TEMPLATE_DIGRAPH_TYPEDEFS(G);
+    typedef G Digraph;
+
+  protected:
+    const Digraph &_g;
+    typename Digraph::template NodeMap<Arc> _head;
+    typename Digraph::template ArcMap<Arc> _left;
+    typename Digraph::template ArcMap<Arc> _right;
+
+    class ArcLess {
+      const Digraph &g;
+    public:
+      ArcLess(const Digraph &_g) : g(_g) {}
+      bool operator()(Arc a,Arc b) const
+      {
+        return g.target(a)<g.target(b);
+      }
+    };
+
+  public:
+
+    ///Constructor
+
+    ///Constructor.
+    ///
+    ///It builds up the search database, which remains valid until the digraph
+    ///changes.
+    ArcLookUp(const Digraph &g) :_g(g),_head(g),_left(g),_right(g) {refresh();}
+
+  private:
+    Arc refreshRec(std::vector<Arc> &v,int a,int b)
+    {
+      int m=(a+b)/2;
+      Arc me=v[m];
+      _left[me] = a<m?refreshRec(v,a,m-1):INVALID;
+      _right[me] = m<b?refreshRec(v,m+1,b):INVALID;
+      return me;
+    }
+  public:
+    ///Refresh the 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.
+    void refresh(Node n)
+    {
+      std::vector<Arc> v;
+      for(OutArcIt e(_g,n);e!=INVALID;++e) v.push_back(e);
+      if(v.size()) {
+        std::sort(v.begin(),v.end(),ArcLess(_g));
+        _head[n]=refreshRec(v,0,v.size()-1);
+      }
+      else _head[n]=INVALID;
+    }
+    ///Refresh the full data structure.
+
+    ///Build up the full search database. In fact, it simply calls
+    ///\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
+    ///out-degree of the digraph.
+
+    void refresh()
+    {
+      for(NodeIt n(_g);n!=INVALID;++n) refresh(n);
+    }
+
+    ///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
+    ///\return An arc from \c s to \c t if there exists,
+    ///\ref INVALID otherwise.
+    ///
+    ///\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.
+    ///
+    Arc operator()(Node s, Node t) const
+    {
+      Arc e;
+      for(e=_head[s];
+          e!=INVALID&&_g.target(e)!=t;
+          e = t < _g.target(e)?_left[e]:_right[e]) ;
+      return e;
+    }
+
+  };
+
+  ///Fast look up of all arcs between given endpoints.
+
+  ///\ingroup gutils
+  ///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).
+  ///
+  ///\tparam G The type of the underlying digraph.
+  ///
+  ///\sa DynArcLookUp
+  ///\sa ArcLookUp
+  template<class G>
+  class AllArcLookUp : public ArcLookUp<G>
+  {
+    using ArcLookUp<G>::_g;
+    using ArcLookUp<G>::_right;
+    using ArcLookUp<G>::_left;
+    using ArcLookUp<G>::_head;
+
+    TEMPLATE_DIGRAPH_TYPEDEFS(G);
+    typedef G Digraph;
+
+    typename Digraph::template ArcMap<Arc> _next;
+
+    Arc refreshNext(Arc head,Arc next=INVALID)
+    {
+      if(head==INVALID) return next;
+      else {
+        next=refreshNext(_right[head],next);
+//         _next[head]=next;
+        _next[head]=( next!=INVALID && _g.target(next)==_g.target(head))
+          ? next : INVALID;
+        return refreshNext(_left[head],head);
+      }
+    }
+
+    void refreshNext()
+    {
+      for(NodeIt n(_g);n!=INVALID;++n) refreshNext(_head[n]);
+    }
+
+  public:
+    ///Constructor
+
+    ///Constructor.
+    ///
+    ///It builds up the search database, which remains valid until the digraph
+    ///changes.
+    AllArcLookUp(const Digraph &g) : ArcLookUp<G>(g), _next(g) {refreshNext();}
+
+    ///Refresh the 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.
+
+    void refresh(Node n)
+    {
+      ArcLookUp<G>::refresh(n);
+      refreshNext(_head[n]);
+    }
+
+    ///Refresh the full data structure.
+
+    ///Build up the full search database. In fact, it simply calls
+    ///\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
+    ///out-degree of the digraph.
+
+    void refresh()
+    {
+      for(NodeIt n(_g);n!=INVALID;++n) refresh(_head[n]);
+    }
+
+    ///Find an arc between two nodes.
+
+    ///Find an arc between two nodes.
+    ///\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.
+    ///\return An arc from \c s to \c t after \c prev or
+    ///\ref INVALID if there is no more.
+    ///
+    ///For example, you can count the number of arcs from \c u to \c v in the
+    ///following way.
+    ///\code
+    ///AllArcLookUp<ListDigraph> ae(g);
+    ///...
+    ///int n=0;
+    ///for(Arc e=ae(u,v);e!=INVALID;e=ae(u,v,e)) 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
+    ///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.
+    ///
+#ifdef DOXYGEN
+    Arc operator()(Node s, Node t, Arc prev=INVALID) const {}
+#else
+    using ArcLookUp<G>::operator() ;
+    Arc operator()(Node s, Node t, Arc prev) const
+    {
+      return prev==INVALID?(*this)(s,t):_next[prev];
+    }
+#endif
+
+  };
+
+  /// @}
+
+} //END OF NAMESPACE LEMON
+
+#endif
Index: lemon/kruskal.h
===================================================================
--- lemon/kruskal.h	(revision 220)
+++ lemon/kruskal.h	(revision 216)
@@ -23,7 +23,10 @@
 #include <vector>
 #include <lemon/unionfind.h>
+// #include <lemon/graph_utils.h>
 #include <lemon/maps.h>
 
-#include <lemon/core.h>
+// #include <lemon/radix_sort.h>
+
+#include <lemon/bits/utility.h>
 #include <lemon/bits/traits.h>
 
@@ -298,5 +301,5 @@
   /// \return The total cost of the found spanning tree.
   ///
-  /// \note If the input graph is not (weakly) connected, a spanning
+  /// \note If the input graph is not (weakly) connected, a spanning 
   /// forest is calculated instead of a spanning tree.
 
Index: lemon/lgf_reader.h
===================================================================
--- lemon/lgf_reader.h	(revision 236)
+++ lemon/lgf_reader.h	(revision 212)
@@ -19,5 +19,5 @@
 ///\ingroup lemon_io
 ///\file
-///\brief \ref lgf-format "LEMON Graph Format" reader.
+///\brief \ref lgf-format "Lemon Graph Format" reader.
 
 
@@ -33,5 +33,5 @@
 
 #include <lemon/assert.h>
-#include <lemon/core.h>
+#include <lemon/graph_utils.h>
 
 #include <lemon/lgf_writer.h>
@@ -2302,5 +2302,5 @@
   ///
   /// This class can be used to read the sections, the map names and
-  /// the attributes from a file. Usually, the LEMON programs know
+  /// the attributes from a file. Usually, the Lemon programs know
   /// that, which type of graph, which maps and which attributes
   /// should be read from a file, but in general tools (like glemon)
Index: lemon/lgf_writer.h
===================================================================
--- lemon/lgf_writer.h	(revision 240)
+++ lemon/lgf_writer.h	(revision 212)
@@ -19,5 +19,5 @@
 ///\ingroup lemon_io
 ///\file
-///\brief \ref lgf-format "LEMON Graph Format" writer.
+///\brief \ref lgf-format "Lemon Graph Format" writer.
 
 
@@ -35,6 +35,5 @@
 
 #include <lemon/assert.h>
-#include <lemon/core.h>
-#include <lemon/maps.h>
+#include <lemon/graph_utils.h>
 
 namespace lemon {
@@ -935,5 +934,5 @@
     bool local_os;
 
-    const Graph& _graph;
+    Graph& _graph;
 
     std::string _nodes_caption;
Index: lemon/list_graph.h
===================================================================
--- lemon/list_graph.h	(revision 239)
+++ lemon/list_graph.h	(revision 212)
@@ -24,6 +24,4 @@
 ///\brief ListDigraph, ListGraph classes.
 
-#include <lemon/core.h>
-#include <lemon/error.h>
 #include <lemon/bits/graph_extender.h>
 
@@ -364,16 +362,4 @@
     }
 
-    ///\brief Erase a node from the digraph.
-    ///
-    ///Erase a node from the digraph.
-    ///
-    void erase(const Node& n) { Parent::erase(n); }
-
-    ///\brief Erase an arc from the digraph.
-    ///
-    ///Erase an arc from the digraph.
-    ///
-    void erase(const Arc& a) { Parent::erase(a); }
-
     /// Node validity check
 
@@ -396,7 +382,7 @@
     bool valid(Arc a) const { return Parent::valid(a); }
 
-    /// Change the target of \c a to \c n
-
-    /// Change the target of \c a to \c n
+    /// Change the target of \c e to \c n
+
+    /// Change the target of \c e to \c n
     ///
     ///\note The <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s referencing
@@ -406,19 +392,19 @@
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
-    void changeTarget(Arc a, Node n) {
-      Parent::changeTarget(a,n);
-    }
-    /// Change the source of \c a to \c n
-
-    /// Change the source of \c a to \c n
-    ///
-    ///\note The <tt>InArcIt</tt>s referencing the changed arc remain
-    ///valid. However the <tt>ArcIt<tt>s and <tt>OutArcIt</tt>s are
+    void changeTarget(Arc e, Node n) {
+      Parent::changeTarget(e,n);
+    }
+    /// Change the source of \c e to \c n
+
+    /// Change the source of \c e to \c n
+    ///
+    ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s referencing
+    ///the changed arc remain valid. However <tt>OutArcIt</tt>s are
     ///invalidated.
     ///
     ///\warning This functionality cannot be used together with the Snapshot
     ///feature.
-    void changeSource(Arc a, Node n) {
-      Parent::changeSource(a,n);
+    void changeSource(Arc e, Node n) {
+      Parent::changeSource(e,n);
     }
 
@@ -843,7 +829,5 @@
 
     public:
-      operator Edge() const { 
-        return id != -1 ? edgeFromId(id / 2) : INVALID; 
-      }
+      operator Edge() const { return edgeFromId(id / 2); }
 
       Arc() {}
@@ -1117,5 +1101,5 @@
   protected:
 
-    void changeV(Edge e, Node n) {
+    void changeTarget(Edge e, Node n) {
       if(arcs[2 * e.id].next_out != -1) {
         arcs[arcs[2 * e.id].next_out].prev_out = arcs[2 * e.id].prev_out;
@@ -1138,5 +1122,5 @@
     }
 
-    void changeU(Edge e, Node n) {
+    void changeSource(Edge e, Node n) {
       if(arcs[(2 * e.id) | 1].next_out != -1) {
         arcs[arcs[(2 * e.id) | 1].next_out].prev_out =
@@ -1222,16 +1206,4 @@
       return Parent::addEdge(s, t);
     }
-
-    /// \brief Erase a node from the graph.
-    ///
-    /// Erase a node from the graph.
-    ///
-    void erase(const Node& n) { Parent::erase(n); }
-
-    /// \brief Erase an edge from the graph.
-    ///
-    /// Erase an edge from the graph.
-    ///
-    void erase(const Edge& e) { Parent::erase(e); }
     /// Node validity check
 
@@ -1261,30 +1233,64 @@
     /// added to the graph.
     bool valid(Edge e) const { return Parent::valid(e); }
-    /// \brief Change the end \c u of \c e to \c n
-    ///
-    /// This function changes the end \c u of \c e to node \c n.
-    ///
-    ///\note The <tt>EdgeIt</tt>s and <tt>ArcIt</tt>s referencing the
-    ///changed edge are invalidated and if the changed node is the
-    ///base node of an iterator then this iterator is also
-    ///invalidated.
+    /// \brief Change the source of \c e to \c n
+    ///
+    /// This function changes the source of \c e to \c n.
+    ///
+    ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s
+    ///referencing the changed arc remain
+    ///valid. However <tt>OutArcIt</tt>s are invalidated.
     ///
     ///\warning This functionality cannot be used together with the
     ///Snapshot feature.
-    void changeU(Edge e, Node n) {
-      Parent::changeU(e,n);
-    }
-    /// \brief Change the end \c v of \c e to \c n
-    ///
-    /// This function changes the end \c v of \c e to \c n.
-    ///
-    ///\note The <tt>EdgeIt</tt>s referencing the changed edge remain
-    ///valid, however <tt>ArcIt</tt>s and if the changed node is the
-    ///base node of an iterator then this iterator is invalidated.
+    void changeSource(Edge e, Node n) {
+      Parent::changeSource(e,n);
+    }
+    /// \brief Change the target of \c e to \c n
+    ///
+    /// This function changes the target of \c e to \c n.
+    ///
+    /// \note The <tt>ArcIt</tt>s referencing the changed arc remain
+    /// valid. However the other iterators may be invalidated.
     ///
     ///\warning This functionality cannot be used together with the
     ///Snapshot feature.
-    void changeV(Edge e, Node n) {
-      Parent::changeV(e,n);
+    void changeTarget(Edge e, Node n) {
+      Parent::changeTarget(e,n);
+    }
+    /// \brief Change the source of \c e to \c n
+    ///
+    /// This function changes the source of \c e to \c n.
+    /// It also changes the proper node of the represented edge.
+    ///
+    ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s
+    ///referencing the changed arc remain
+    ///valid. However <tt>OutArcIt</tt>s are invalidated.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
+    void changeSource(Arc e, Node n) {
+      if (Parent::direction(e)) {
+        Parent::changeSource(e,n);
+      } else {
+        Parent::changeTarget(e,n);
+      }
+    }
+    /// \brief Change the target of \c e to \c n
+    ///
+    /// This function changes the target of \c e to \c n.
+    /// It also changes the proper node of the represented edge.
+    ///
+    ///\note The <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s
+    ///referencing the changed arc remain
+    ///valid. However <tt>InArcIt</tt>s are invalidated.
+    ///
+    ///\warning This functionality cannot be used together with the
+    ///Snapshot feature.
+    void changeTarget(Arc e, Node n) {
+      if (Parent::direction(e)) {
+        Parent::changeTarget(e,n);
+      } else {
+        Parent::changeSource(e,n);
+      }
     }
     /// \brief Contract two nodes.
@@ -1306,8 +1312,8 @@
         if (r && runningNode(e) == a) {
           erase(e);
-        } else if (u(e) == b) {
-          changeU(e, a);
+        } else if (source(e) == b) {
+          changeSource(e, a);
         } else {
-          changeV(e, a);
+          changeTarget(e, a);
         }
         e = f;
Index: lemon/maps.h
===================================================================
--- lemon/maps.h	(revision 220)
+++ lemon/maps.h	(revision 209)
@@ -24,5 +24,6 @@
 #include <vector>
 
-#include <lemon/core.h>
+#include <lemon/bits/utility.h>
+#include <lemon/bits/traits.h>
 
 ///\file
@@ -1780,924 +1781,4 @@
   }
 
-  /// Provides an immutable and unique id for each item in the graph.
-
-  /// The IdMap class provides a unique and immutable id for each item of the
-  /// same type (e.g. node) in the graph. This id is <ul><li>\b unique:
-  /// different items (nodes) get different ids <li>\b immutable: the id of an
-  /// item (node) does not change (even if you delete other nodes).  </ul>
-  /// Through this map you get access (i.e. can read) the inner id values of
-  /// the items stored in the graph. This map can be inverted with its member
-  /// class \c InverseMap or with the \c operator() member.
-  ///
-  template <typename _Graph, typename _Item>
-  class IdMap {
-  public:
-    typedef _Graph Graph;
-    typedef int Value;
-    typedef _Item Item;
-    typedef _Item Key;
-
-    /// \brief Constructor.
-    ///
-    /// Constructor of the map.
-    explicit IdMap(const Graph& graph) : _graph(&graph) {}
-
-    /// \brief Gives back the \e id of the item.
-    ///
-    /// Gives back the immutable and unique \e id of the item.
-    int operator[](const Item& item) const { return _graph->id(item);}
-
-    /// \brief Gives back the item by its id.
-    ///
-    /// Gives back the item by its id.
-    Item operator()(int id) { return _graph->fromId(id, Item()); }
-
-  private:
-    const Graph* _graph;
-
-  public:
-
-    /// \brief The class represents the inverse of its owner (IdMap).
-    ///
-    /// The class represents the inverse of its owner (IdMap).
-    /// \see inverse()
-    class InverseMap {
-    public:
-
-      /// \brief Constructor.
-      ///
-      /// Constructor for creating an id-to-item map.
-      explicit InverseMap(const Graph& graph) : _graph(&graph) {}
-
-      /// \brief Constructor.
-      ///
-      /// Constructor for creating an id-to-item map.
-      explicit InverseMap(const IdMap& map) : _graph(map._graph) {}
-
-      /// \brief Gives back the given item from its id.
-      ///
-      /// Gives back the given item from its id.
-      ///
-      Item operator[](int id) const { return _graph->fromId(id, Item());}
-
-    private:
-      const Graph* _graph;
-    };
-
-    /// \brief Gives back the inverse of the map.
-    ///
-    /// Gives back the inverse of the IdMap.
-    InverseMap inverse() const { return InverseMap(*_graph);}
-
-  };
-
-
-  /// \brief General invertable graph-map type.
-
-  /// This type provides simple invertable graph-maps.
-  /// The InvertableMap wraps an arbitrary ReadWriteMap
-  /// and if a key is set to a new value then store it
-  /// in the inverse map.
-  ///
-  /// The values of the map can be accessed
-  /// with stl compatible forward iterator.
-  ///
-  /// \tparam _Graph The graph type.
-  /// \tparam _Item The item type of the graph.
-  /// \tparam _Value The value type of the map.
-  ///
-  /// \see IterableValueMap
-  template <typename _Graph, typename _Item, typename _Value>
-  class InvertableMap
-    : protected ItemSetTraits<_Graph, _Item>::template Map<_Value>::Type {
-  private:
-
-    typedef typename ItemSetTraits<_Graph, _Item>::
-    template Map<_Value>::Type Map;
-    typedef _Graph Graph;
-
-    typedef std::map<_Value, _Item> Container;
-    Container _inv_map;
-
-  public:
-
-    /// The key type of InvertableMap (Node, Arc, Edge).
-    typedef typename Map::Key Key;
-    /// The value type of the InvertableMap.
-    typedef typename Map::Value Value;
-
-
-
-    /// \brief Constructor.
-    ///
-    /// Construct a new InvertableMap for the graph.
-    ///
-    explicit InvertableMap(const Graph& graph) : Map(graph) {}
-
-    /// \brief Forward iterator for values.
-    ///
-    /// This iterator is an stl compatible forward
-    /// iterator on the values of the map. The values can
-    /// be accessed in the [beginValue, endValue) range.
-    ///
-    class ValueIterator
-      : public std::iterator<std::forward_iterator_tag, Value> {
-      friend class InvertableMap;
-    private:
-      ValueIterator(typename Container::const_iterator _it)
-        : it(_it) {}
-    public:
-
-      ValueIterator() {}
-
-      ValueIterator& operator++() { ++it; return *this; }
-      ValueIterator operator++(int) {
-        ValueIterator tmp(*this);
-        operator++();
-        return tmp;
-      }
-
-      const Value& operator*() const { return it->first; }
-      const Value* operator->() const { return &(it->first); }
-
-      bool operator==(ValueIterator jt) const { return it == jt.it; }
-      bool operator!=(ValueIterator jt) const { return it != jt.it; }
-
-    private:
-      typename Container::const_iterator it;
-    };
-
-    /// \brief Returns an iterator to the first value.
-    ///
-    /// Returns an stl compatible iterator to the
-    /// first value of the map. The values of the
-    /// map can be accessed in the [beginValue, endValue)
-    /// range.
-    ValueIterator beginValue() const {
-      return ValueIterator(_inv_map.begin());
-    }
-
-    /// \brief Returns an iterator after the last value.
-    ///
-    /// Returns an stl compatible iterator after the
-    /// last value of the map. The values of the
-    /// map can be accessed in the [beginValue, endValue)
-    /// range.
-    ValueIterator endValue() const {
-      return ValueIterator(_inv_map.end());
-    }
-
-    /// \brief The setter function of the map.
-    ///
-    /// Sets the mapped value.
-    void set(const Key& key, const Value& val) {
-      Value oldval = Map::operator[](key);
-      typename Container::iterator it = _inv_map.find(oldval);
-      if (it != _inv_map.end() && it->second == key) {
-        _inv_map.erase(it);
-      }
-      _inv_map.insert(make_pair(val, key));
-      Map::set(key, val);
-    }
-
-    /// \brief The getter function of the map.
-    ///
-    /// It gives back the value associated with the key.
-    typename MapTraits<Map>::ConstReturnValue
-    operator[](const Key& key) const {
-      return Map::operator[](key);
-    }
-
-    /// \brief Gives back the item by its value.
-    ///
-    /// Gives back the item by its value.
-    Key operator()(const Value& key) const {
-      typename Container::const_iterator it = _inv_map.find(key);
-      return it != _inv_map.end() ? it->second : INVALID;
-    }
-
-  protected:
-
-    /// \brief Erase the key from the map.
-    ///
-    /// Erase the key to the map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void erase(const Key& key) {
-      Value val = Map::operator[](key);
-      typename Container::iterator it = _inv_map.find(val);
-      if (it != _inv_map.end() && it->second == key) {
-        _inv_map.erase(it);
-      }
-      Map::erase(key);
-    }
-
-    /// \brief Erase more keys from the map.
-    ///
-    /// Erase more keys from the map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void erase(const std::vector<Key>& keys) {
-      for (int i = 0; i < int(keys.size()); ++i) {
-        Value val = Map::operator[](keys[i]);
-        typename Container::iterator it = _inv_map.find(val);
-        if (it != _inv_map.end() && it->second == keys[i]) {
-          _inv_map.erase(it);
-        }
-      }
-      Map::erase(keys);
-    }
-
-    /// \brief Clear the keys from the map and inverse map.
-    ///
-    /// Clear the keys from the map and inverse map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void clear() {
-      _inv_map.clear();
-      Map::clear();
-    }
-
-  public:
-
-    /// \brief The inverse map type.
-    ///
-    /// The inverse of this map. The subscript operator of the map
-    /// gives back always the item what was last assigned to the value.
-    class InverseMap {
-    public:
-      /// \brief Constructor of the InverseMap.
-      ///
-      /// Constructor of the InverseMap.
-      explicit InverseMap(const InvertableMap& inverted)
-        : _inverted(inverted) {}
-
-      /// The value type of the InverseMap.
-      typedef typename InvertableMap::Key Value;
-      /// The key type of the InverseMap.
-      typedef typename InvertableMap::Value Key;
-
-      /// \brief Subscript operator.
-      ///
-      /// Subscript operator. It gives back always the item
-      /// what was last assigned to the value.
-      Value operator[](const Key& key) const {
-        return _inverted(key);
-      }
-
-    private:
-      const InvertableMap& _inverted;
-    };
-
-    /// \brief It gives back the just readable inverse map.
-    ///
-    /// It gives back the just readable inverse map.
-    InverseMap inverse() const {
-      return InverseMap(*this);
-    }
-
-
-
-  };
-
-  /// \brief Provides a mutable, continuous and unique descriptor for each
-  /// item in the graph.
-  ///
-  /// The DescriptorMap class provides a unique and continuous (but mutable)
-  /// descriptor (id) for each item of the same type (e.g. node) in the
-  /// graph. This id is <ul><li>\b unique: different items (nodes) get
-  /// different ids <li>\b continuous: the range of the ids is the set of
-  /// integers between 0 and \c n-1, where \c n is the number of the items of
-  /// this type (e.g. nodes) (so the id of a node can change if you delete an
-  /// other node, i.e. this id is mutable).  </ul> This map can be inverted
-  /// with its member class \c InverseMap, or with the \c operator() member.
-  ///
-  /// \tparam _Graph The graph class the \c DescriptorMap belongs to.
-  /// \tparam _Item The Item is the Key of the Map. It may be Node, Arc or
-  /// Edge.
-  template <typename _Graph, typename _Item>
-  class DescriptorMap
-    : protected ItemSetTraits<_Graph, _Item>::template Map<int>::Type {
-
-    typedef _Item Item;
-    typedef typename ItemSetTraits<_Graph, _Item>::template Map<int>::Type Map;
-
-  public:
-    /// The graph class of DescriptorMap.
-    typedef _Graph Graph;
-
-    /// The key type of DescriptorMap (Node, Arc, Edge).
-    typedef typename Map::Key Key;
-    /// The value type of DescriptorMap.
-    typedef typename Map::Value Value;
-
-    /// \brief Constructor.
-    ///
-    /// Constructor for descriptor map.
-    explicit DescriptorMap(const Graph& _graph) : Map(_graph) {
-      Item it;
-      const typename Map::Notifier* nf = Map::notifier();
-      for (nf->first(it); it != INVALID; nf->next(it)) {
-        Map::set(it, _inv_map.size());
-        _inv_map.push_back(it);
-      }
-    }
-
-  protected:
-
-    /// \brief Add a new key to the map.
-    ///
-    /// Add a new key to the map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void add(const Item& item) {
-      Map::add(item);
-      Map::set(item, _inv_map.size());
-      _inv_map.push_back(item);
-    }
-
-    /// \brief Add more new keys to the map.
-    ///
-    /// Add more new keys to the map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void add(const std::vector<Item>& items) {
-      Map::add(items);
-      for (int i = 0; i < int(items.size()); ++i) {
-        Map::set(items[i], _inv_map.size());
-        _inv_map.push_back(items[i]);
-      }
-    }
-
-    /// \brief Erase the key from the map.
-    ///
-    /// Erase the key from the map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void erase(const Item& item) {
-      Map::set(_inv_map.back(), Map::operator[](item));
-      _inv_map[Map::operator[](item)] = _inv_map.back();
-      _inv_map.pop_back();
-      Map::erase(item);
-    }
-
-    /// \brief Erase more keys from the map.
-    ///
-    /// Erase more keys from the map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void erase(const std::vector<Item>& items) {
-      for (int i = 0; i < int(items.size()); ++i) {
-        Map::set(_inv_map.back(), Map::operator[](items[i]));
-        _inv_map[Map::operator[](items[i])] = _inv_map.back();
-        _inv_map.pop_back();
-      }
-      Map::erase(items);
-    }
-
-    /// \brief Build the unique map.
-    ///
-    /// Build the unique map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void build() {
-      Map::build();
-      Item it;
-      const typename Map::Notifier* nf = Map::notifier();
-      for (nf->first(it); it != INVALID; nf->next(it)) {
-        Map::set(it, _inv_map.size());
-        _inv_map.push_back(it);
-      }
-    }
-
-    /// \brief Clear the keys from the map.
-    ///
-    /// Clear the keys from the map. It is called by the
-    /// \c AlterationNotifier.
-    virtual void clear() {
-      _inv_map.clear();
-      Map::clear();
-    }
-
-  public:
-
-    /// \brief Returns the maximal value plus one.
-    ///
-    /// Returns the maximal value plus one in the map.
-    unsigned int size() const {
-      return _inv_map.size();
-    }
-
-    /// \brief Swaps the position of the two items in the map.
-    ///
-    /// Swaps the position of the two items in the map.
-    void swap(const Item& p, const Item& q) {
-      int pi = Map::operator[](p);
-      int qi = Map::operator[](q);
-      Map::set(p, qi);
-      _inv_map[qi] = p;
-      Map::set(q, pi);
-      _inv_map[pi] = q;
-    }
-
-    /// \brief Gives back the \e descriptor of the item.
-    ///
-    /// Gives back the mutable and unique \e descriptor of the map.
-    int operator[](const Item& item) const {
-      return Map::operator[](item);
-    }
-
-    /// \brief Gives back the item by its descriptor.
-    ///
-    /// Gives back th item by its descriptor.
-    Item operator()(int id) const {
-      return _inv_map[id];
-    }
-
-  private:
-
-    typedef std::vector<Item> Container;
-    Container _inv_map;
-
-  public:
-    /// \brief The inverse map type of DescriptorMap.
-    ///
-    /// The inverse map type of DescriptorMap.
-    class InverseMap {
-    public:
-      /// \brief Constructor of the InverseMap.
-      ///
-      /// Constructor of the InverseMap.
-      explicit InverseMap(const DescriptorMap& inverted)
-        : _inverted(inverted) {}
-
-
-      /// The value type of the InverseMap.
-      typedef typename DescriptorMap::Key Value;
-      /// The key type of the InverseMap.
-      typedef typename DescriptorMap::Value Key;
-
-      /// \brief Subscript operator.
-      ///
-      /// Subscript operator. It gives back the item
-      /// that the descriptor belongs to currently.
-      Value operator[](const Key& key) const {
-        return _inverted(key);
-      }
-
-      /// \brief Size of the map.
-      ///
-      /// Returns the size of the map.
-      unsigned int size() const {
-        return _inverted.size();
-      }
-
-    private:
-      const DescriptorMap& _inverted;
-    };
-
-    /// \brief Gives back the inverse of the map.
-    ///
-    /// Gives back the inverse of the map.
-    const InverseMap inverse() const {
-      return InverseMap(*this);
-    }
-  };
-
-  /// \brief Returns the source of the given arc.
-  ///
-  /// The SourceMap gives back the source Node of the given arc.
-  /// \see TargetMap
-  template <typename Digraph>
-  class SourceMap {
-  public:
-
-    typedef typename Digraph::Node Value;
-    typedef typename Digraph::Arc Key;
-
-    /// \brief Constructor
-    ///
-    /// Constructor
-    /// \param _digraph The digraph that the map belongs to.
-    explicit SourceMap(const Digraph& digraph) : _digraph(digraph) {}
-
-    /// \brief The subscript operator.
-    ///
-    /// The subscript operator.
-    /// \param arc The arc
-    /// \return The source of the arc
-    Value operator[](const Key& arc) const {
-      return _digraph.source(arc);
-    }
-
-  private:
-    const Digraph& _digraph;
-  };
-
-  /// \brief Returns a \ref SourceMap class.
-  ///
-  /// This function just returns an \ref SourceMap class.
-  /// \relates SourceMap
-  template <typename Digraph>
-  inline SourceMap<Digraph> sourceMap(const Digraph& digraph) {
-    return SourceMap<Digraph>(digraph);
-  }
-
-  /// \brief Returns the target of the given arc.
-  ///
-  /// The TargetMap gives back the target Node of the given arc.
-  /// \see SourceMap
-  template <typename Digraph>
-  class TargetMap {
-  public:
-
-    typedef typename Digraph::Node Value;
-    typedef typename Digraph::Arc Key;
-
-    /// \brief Constructor
-    ///
-    /// Constructor
-    /// \param _digraph The digraph that the map belongs to.
-    explicit TargetMap(const Digraph& digraph) : _digraph(digraph) {}
-
-    /// \brief The subscript operator.
-    ///
-    /// The subscript operator.
-    /// \param e The arc
-    /// \return The target of the arc
-    Value operator[](const Key& e) const {
-      return _digraph.target(e);
-    }
-
-  private:
-    const Digraph& _digraph;
-  };
-
-  /// \brief Returns a \ref TargetMap class.
-  ///
-  /// This function just returns a \ref TargetMap class.
-  /// \relates TargetMap
-  template <typename Digraph>
-  inline TargetMap<Digraph> targetMap(const Digraph& digraph) {
-    return TargetMap<Digraph>(digraph);
-  }
-
-  /// \brief Returns the "forward" directed arc view of an edge.
-  ///
-  /// Returns the "forward" directed arc view of an edge.
-  /// \see BackwardMap
-  template <typename Graph>
-  class ForwardMap {
-  public:
-
-    typedef typename Graph::Arc Value;
-    typedef typename Graph::Edge Key;
-
-    /// \brief Constructor
-    ///
-    /// Constructor
-    /// \param _graph The graph that the map belongs to.
-    explicit ForwardMap(const Graph& graph) : _graph(graph) {}
-
-    /// \brief The subscript operator.
-    ///
-    /// The subscript operator.
-    /// \param key An edge
-    /// \return The "forward" directed arc view of edge
-    Value operator[](const Key& key) const {
-      return _graph.direct(key, true);
-    }
-
-  private:
-    const Graph& _graph;
-  };
-
-  /// \brief Returns a \ref ForwardMap class.
-  ///
-  /// This function just returns an \ref ForwardMap class.
-  /// \relates ForwardMap
-  template <typename Graph>
-  inline ForwardMap<Graph> forwardMap(const Graph& graph) {
-    return ForwardMap<Graph>(graph);
-  }
-
-  /// \brief Returns the "backward" directed arc view of an edge.
-  ///
-  /// Returns the "backward" directed arc view of an edge.
-  /// \see ForwardMap
-  template <typename Graph>
-  class BackwardMap {
-  public:
-
-    typedef typename Graph::Arc Value;
-    typedef typename Graph::Edge Key;
-
-    /// \brief Constructor
-    ///
-    /// Constructor
-    /// \param _graph The graph that the map belongs to.
-    explicit BackwardMap(const Graph& graph) : _graph(graph) {}
-
-    /// \brief The subscript operator.
-    ///
-    /// The subscript operator.
-    /// \param key An edge
-    /// \return The "backward" directed arc view of edge
-    Value operator[](const Key& key) const {
-      return _graph.direct(key, false);
-    }
-
-  private:
-    const Graph& _graph;
-  };
-
-  /// \brief Returns a \ref BackwardMap class
-
-  /// This function just returns a \ref BackwardMap class.
-  /// \relates BackwardMap
-  template <typename Graph>
-  inline BackwardMap<Graph> backwardMap(const Graph& graph) {
-    return BackwardMap<Graph>(graph);
-  }
-
-  /// \brief Potential difference map
-  ///
-  /// If there is an potential map on the nodes then we
-  /// can get an arc map as we get the substraction of the
-  /// values of the target and source.
-  template <typename Digraph, typename NodeMap>
-  class PotentialDifferenceMap {
-  public:
-    typedef typename Digraph::Arc Key;
-    typedef typename NodeMap::Value Value;
-
-    /// \brief Constructor
-    ///
-    /// Contructor of the map
-    explicit PotentialDifferenceMap(const Digraph& digraph,
-                                    const NodeMap& potential)
-      : _digraph(digraph), _potential(potential) {}
-
-    /// \brief Const subscription operator
-    ///
-    /// Const subscription operator
-    Value operator[](const Key& arc) const {
-      return _potential[_digraph.target(arc)] -
-        _potential[_digraph.source(arc)];
-    }
-
-  private:
-    const Digraph& _digraph;
-    const NodeMap& _potential;
-  };
-
-  /// \brief Returns a PotentialDifferenceMap.
-  ///
-  /// This function just returns a PotentialDifferenceMap.
-  /// \relates PotentialDifferenceMap
-  template <typename Digraph, typename NodeMap>
-  PotentialDifferenceMap<Digraph, NodeMap>
-  potentialDifferenceMap(const Digraph& digraph, const NodeMap& potential) {
-    return PotentialDifferenceMap<Digraph, NodeMap>(digraph, potential);
-  }
-
-  /// \brief Map of the node in-degrees.
-  ///
-  /// This map returns the in-degree of a node. Once it is constructed,
-  /// the degrees are stored in a standard NodeMap, so each query is done
-  /// in constant time. On the other hand, the values are updated automatically
-  /// whenever the digraph changes.
-  ///
-  /// \warning Besides addNode() and addArc(), a digraph structure may provide
-  /// alternative ways to modify the digraph. The correct behavior of InDegMap
-  /// is not guarantied if these additional features are used. For example
-  /// the functions \ref ListDigraph::changeSource() "changeSource()",
-  /// \ref ListDigraph::changeTarget() "changeTarget()" and
-  /// \ref ListDigraph::reverseArc() "reverseArc()"
-  /// of \ref ListDigraph will \e not update the degree values correctly.
-  ///
-  /// \sa OutDegMap
-
-  template <typename _Digraph>
-  class InDegMap
-    : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
-      ::ItemNotifier::ObserverBase {
-
-  public:
-
-    typedef _Digraph Digraph;
-    typedef int Value;
-    typedef typename Digraph::Node Key;
-
-    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
-    ::ItemNotifier::ObserverBase Parent;
-
-  private:
-
-    class AutoNodeMap
-      : public ItemSetTraits<Digraph, Key>::template Map<int>::Type {
-    public:
-
-      typedef typename ItemSetTraits<Digraph, Key>::
-      template Map<int>::Type Parent;
-
-      AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
-
-      virtual void add(const Key& key) {
-        Parent::add(key);
-        Parent::set(key, 0);
-      }
-
-      virtual void add(const std::vector<Key>& keys) {
-        Parent::add(keys);
-        for (int i = 0; i < int(keys.size()); ++i) {
-          Parent::set(keys[i], 0);
-        }
-      }
-
-      virtual void build() {
-        Parent::build();
-        Key it;
-        typename Parent::Notifier* nf = Parent::notifier();
-        for (nf->first(it); it != INVALID; nf->next(it)) {
-          Parent::set(it, 0);
-        }
-      }
-    };
-
-  public:
-
-    /// \brief Constructor.
-    ///
-    /// Constructor for creating in-degree map.
-    explicit InDegMap(const Digraph& digraph)
-      : _digraph(digraph), _deg(digraph) {
-      Parent::attach(_digraph.notifier(typename Digraph::Arc()));
-
-      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
-        _deg[it] = countInArcs(_digraph, it);
-      }
-    }
-
-    /// Gives back the in-degree of a Node.
-    int operator[](const Key& key) const {
-      return _deg[key];
-    }
-
-  protected:
-
-    typedef typename Digraph::Arc Arc;
-
-    virtual void add(const Arc& arc) {
-      ++_deg[_digraph.target(arc)];
-    }
-
-    virtual void add(const std::vector<Arc>& arcs) {
-      for (int i = 0; i < int(arcs.size()); ++i) {
-        ++_deg[_digraph.target(arcs[i])];
-      }
-    }
-
-    virtual void erase(const Arc& arc) {
-      --_deg[_digraph.target(arc)];
-    }
-
-    virtual void erase(const std::vector<Arc>& arcs) {
-      for (int i = 0; i < int(arcs.size()); ++i) {
-        --_deg[_digraph.target(arcs[i])];
-      }
-    }
-
-    virtual void build() {
-      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
-        _deg[it] = countInArcs(_digraph, it);
-      }
-    }
-
-    virtual void clear() {
-      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
-        _deg[it] = 0;
-      }
-    }
-  private:
-
-    const Digraph& _digraph;
-    AutoNodeMap _deg;
-  };
-
-  /// \brief Map of the node out-degrees.
-  ///
-  /// This map returns the out-degree of a node. Once it is constructed,
-  /// the degrees are stored in a standard NodeMap, so each query is done
-  /// in constant time. On the other hand, the values are updated automatically
-  /// whenever the digraph changes.
-  ///
-  /// \warning Besides addNode() and addArc(), a digraph structure may provide
-  /// alternative ways to modify the digraph. The correct behavior of OutDegMap
-  /// is not guarantied if these additional features are used. For example
-  /// the functions \ref ListDigraph::changeSource() "changeSource()",
-  /// \ref ListDigraph::changeTarget() "changeTarget()" and
-  /// \ref ListDigraph::reverseArc() "reverseArc()"
-  /// of \ref ListDigraph will \e not update the degree values correctly.
-  ///
-  /// \sa InDegMap
-
-  template <typename _Digraph>
-  class OutDegMap
-    : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
-      ::ItemNotifier::ObserverBase {
-
-  public:
-
-    typedef _Digraph Digraph;
-    typedef int Value;
-    typedef typename Digraph::Node Key;
-
-    typedef typename ItemSetTraits<Digraph, typename Digraph::Arc>
-    ::ItemNotifier::ObserverBase Parent;
-
-  private:
-
-    class AutoNodeMap
-      : public ItemSetTraits<Digraph, Key>::template Map<int>::Type {
-    public:
-
-      typedef typename ItemSetTraits<Digraph, Key>::
-      template Map<int>::Type Parent;
-
-      AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
-
-      virtual void add(const Key& key) {
-        Parent::add(key);
-        Parent::set(key, 0);
-      }
-      virtual void add(const std::vector<Key>& keys) {
-        Parent::add(keys);
-        for (int i = 0; i < int(keys.size()); ++i) {
-          Parent::set(keys[i], 0);
-        }
-      }
-      virtual void build() {
-        Parent::build();
-        Key it;
-        typename Parent::Notifier* nf = Parent::notifier();
-        for (nf->first(it); it != INVALID; nf->next(it)) {
-          Parent::set(it, 0);
-        }
-      }
-    };
-
-  public:
-
-    /// \brief Constructor.
-    ///
-    /// Constructor for creating out-degree map.
-    explicit OutDegMap(const Digraph& digraph)
-      : _digraph(digraph), _deg(digraph) {
-      Parent::attach(_digraph.notifier(typename Digraph::Arc()));
-
-      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
-        _deg[it] = countOutArcs(_digraph, it);
-      }
-    }
-
-    /// Gives back the out-degree of a Node.
-    int operator[](const Key& key) const {
-      return _deg[key];
-    }
-
-  protected:
-
-    typedef typename Digraph::Arc Arc;
-
-    virtual void add(const Arc& arc) {
-      ++_deg[_digraph.source(arc)];
-    }
-
-    virtual void add(const std::vector<Arc>& arcs) {
-      for (int i = 0; i < int(arcs.size()); ++i) {
-        ++_deg[_digraph.source(arcs[i])];
-      }
-    }
-
-    virtual void erase(const Arc& arc) {
-      --_deg[_digraph.source(arc)];
-    }
-
-    virtual void erase(const std::vector<Arc>& arcs) {
-      for (int i = 0; i < int(arcs.size()); ++i) {
-        --_deg[_digraph.source(arcs[i])];
-      }
-    }
-
-    virtual void build() {
-      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
-        _deg[it] = countOutArcs(_digraph, it);
-      }
-    }
-
-    virtual void clear() {
-      for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
-        _deg[it] = 0;
-      }
-    }
-  private:
-
-    const Digraph& _digraph;
-    AutoNodeMap _deg;
-  };
-
   /// @}
 }
Index: lemon/path.h
===================================================================
--- lemon/path.h	(revision 236)
+++ lemon/path.h	(revision 209)
@@ -29,5 +29,5 @@
 
 #include <lemon/error.h>
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 #include <lemon/concepts/path.h>
 
@@ -83,5 +83,5 @@
     }
 
-    /// \brief LEMON style iterator for path arcs
+    /// \brief Lemon style iterator for path arcs
     ///
     /// This class is used to iterate on the arcs of the paths.
Index: lemon/smart_graph.h
===================================================================
--- lemon/smart_graph.h	(revision 238)
+++ lemon/smart_graph.h	(revision 209)
@@ -26,6 +26,12 @@
 #include <vector>
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
+
+#include <lemon/bits/base_extender.h>
+#include <lemon/bits/graph_extender.h>
+
+#include <lemon/bits/utility.h>
 #include <lemon/error.h>
+
 #include <lemon/bits/graph_extender.h>
 
@@ -466,7 +472,5 @@
 
     public:
-      operator Edge() const { 
-        return _id != -1 ? edgeFromId(_id / 2) : INVALID; 
-      }
+      operator Edge() const { return edgeFromId(_id / 2); }
 
       Arc() {}
Index: lemon/unionfind.h
===================================================================
--- lemon/unionfind.h	(revision 236)
+++ lemon/unionfind.h	(revision 209)
@@ -31,5 +31,5 @@
 #include <functional>
 
-#include <lemon/core.h>
+#include <lemon/bits/invalid.h>
 
 namespace lemon {
@@ -498,5 +498,5 @@
     }
 
-    /// \brief LEMON style iterator for the representant items.
+    /// \brief Lemon style iterator for the representant items.
     ///
     /// ClassIt is a lemon style iterator for the components. It iterates
@@ -550,5 +550,5 @@
     };
 
-    /// \brief LEMON style iterator for the items of a component.
+    /// \brief Lemon style iterator for the items of a component.
     ///
     /// ClassIt is a lemon style iterator for the components. It iterates
@@ -808,5 +808,5 @@
     }
 
-    /// \brief LEMON style iterator for the classes.
+    /// \brief Lemon style iterator for the classes.
     ///
     /// ClassIt is a lemon style iterator for the components. It iterates
@@ -860,5 +860,5 @@
     };
 
-    /// \brief LEMON style iterator for the items of a component.
+    /// \brief Lemon style iterator for the items of a component.
     ///
     /// ClassIt is a lemon style iterator for the components. It iterates
@@ -1656,5 +1656,5 @@
     }
 
-    /// \brief LEMON style iterator for the items of a class.
+    /// \brief Lemon style iterator for the items of a class.
     ///
     /// ClassIt is a lemon style iterator for the components. It iterates
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt	(revision 225)
+++ test/CMakeLists.txt	(revision 203)
@@ -1,7 +1,7 @@
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
+include_directories (${LEMON_SOURCE_DIR})
 
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
+link_directories (${LEMON_BINARY_DIR}/lemon)
 
-SET(TESTS
+set (TESTS
   bfs_test
   counter_test
@@ -17,12 +17,12 @@
   kruskal_test
   maps_test
+  path_test
   random_test
-  path_test
   time_measure_test
   unionfind_test)
 
-FOREACH(TEST_NAME ${TESTS})
-  ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
-  TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
-  ADD_TEST(${TEST_NAME} ${TEST_NAME})
-ENDFOREACH(TEST_NAME)
+foreach (TEST_NAME ${TESTS})
+  add_executable (${TEST_NAME} ${TEST_NAME}.cc)
+  target_link_libraries (${TEST_NAME} lemon)
+  add_test(${TEST_NAME} ${TEST_NAME})
+endforeach (TEST_NAME)
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 228)
+++ test/Makefile.am	(revision 203)
@@ -4,4 +4,5 @@
 noinst_HEADERS += \
 	test/graph_test.h \
+	test/graph_maps_test.h \
         test/test_tools.h
 
Index: test/bfs_test.cc
===================================================================
--- test/bfs_test.cc	(revision 228)
+++ test/bfs_test.cc	(revision 209)
@@ -20,5 +20,4 @@
 #include <lemon/smart_graph.h>
 #include <lemon/list_graph.h>
-#include <lemon/lgf_reader.h>
 #include <lemon/bfs.h>
 #include <lemon/path.h>
@@ -28,26 +27,4 @@
 
 using namespace lemon;
-
-char test_lgf[] =
-  "@nodes\n"
-  "label\n"
-  "0\n"
-  "1\n"
-  "2\n"
-  "3\n"
-  "4\n"
-  "5\n"
-  "@arcs\n"
-  "     label\n"
-  "0 1  0\n"
-  "1 2  1\n"
-  "2 3  2\n"
-  "3 4  3\n"
-  "0 3  4\n"
-  "0 3  5\n"
-  "5 2  6\n"
-  "@attributes\n"
-  "source 0\n"
-  "target 4\n";
 
 void checkBfsCompile()
@@ -73,5 +50,4 @@
   n  = bfs_test.predNode(n);
   d  = bfs_test.distMap();
-
   p  = bfs_test.predMap();
   //  pn = bfs_test.predNodeMap();
@@ -105,18 +81,16 @@
   Digraph G;
   Node s, t;
+  PetStruct<Digraph> ps = addPetersen(G, 5);
 
-  std::istringstream input(test_lgf);
-  digraphReader(input, G).
-    node("source", s).
-    node("target", t).
-    run();
+  s=ps.outer[2];
+  t=ps.inner[0];
 
   Bfs<Digraph> bfs_test(G);
   bfs_test.run(s);
 
-  check(bfs_test.dist(t)==2,"Bfs found a wrong path." << bfs_test.dist(t));
+  check(bfs_test.dist(t)==3,"Bfs found a wrong path." << bfs_test.dist(t));
 
   Path<Digraph> p = bfs_test.path(t);
-  check(p.length()==2,"path() 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.");
@@ -124,24 +98,22 @@
 
 
-  for(ArcIt a(G); a!=INVALID; ++a) {
-    Node u=G.source(a);
-    Node v=G.target(a);
+  for(ArcIt e(G); e==INVALID; ++e) {
+    Node u=G.source(e);
+    Node v=G.target(e);
     check( !bfs_test.reached(u) ||
-           (bfs_test.dist(v) <= bfs_test.dist(u)+1),
-           "Wrong output." << G.id(v) << ' ' << G.id(u));
+           (bfs_test.dist(v) > bfs_test.dist(u)+1),
+           "Wrong output.");
   }
 
-  for(NodeIt v(G); v!=INVALID; ++v) {
-    if (bfs_test.reached(v)) {
-      check(v==s || bfs_test.predArc(v)!=INVALID, "Wrong tree.");
-      if (bfs_test.predArc(v)!=INVALID ) {
-        Arc a=bfs_test.predArc(v);
-        Node u=G.source(a);
-        check(u==bfs_test.predNode(v),"Wrong tree.");
-        check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
-              "Wrong distance. Difference: "
-              << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
-                          - 1));
-      }
+  for(NodeIt v(G); v==INVALID; ++v) {
+    check(bfs_test.reached(v),"Each node should be reached.");
+    if ( bfs_test.predArc(v)!=INVALID ) {
+      Arc e=bfs_test.predArc(v);
+      Node u=G.source(e);
+      check(u==bfs_test.predNode(v),"Wrong tree.");
+      check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
+            "Wrong distance. Difference: "
+            << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
+                        - 1));
     }
   }
Index: test/dfs_test.cc
===================================================================
--- test/dfs_test.cc	(revision 228)
+++ test/dfs_test.cc	(revision 209)
@@ -20,6 +20,4 @@
 #include <lemon/smart_graph.h>
 #include <lemon/list_graph.h>
-#include <lemon/lgf_reader.h>
-
 #include <lemon/dfs.h>
 #include <lemon/path.h>
@@ -29,28 +27,4 @@
 
 using namespace lemon;
-
-char test_lgf[] =
-  "@nodes\n"
-  "label\n"
-  "0\n"
-  "1\n"
-  "2\n"
-  "3\n"
-  "4\n"
-  "5\n"
-  "6\n"
-  "@arcs\n"
-  "     label\n"
-  "0 1  0\n"
-  "1 2  1\n"
-  "2 3  2\n"
-  "1 4  3\n"
-  "4 2  4\n"
-  "4 5  5\n"
-  "5 0  6\n"
-  "6 3  7\n"
-  "@attributes\n"
-  "source 0\n"
-  "target 5\n";
 
 void checkDfsCompile()
@@ -66,4 +40,5 @@
   DType::DistMap d(G);
   DType::PredMap p(G);
+  //  DType::PredNodeMap pn(G);
 
   DType dfs_test(G);
@@ -76,4 +51,5 @@
   d  = dfs_test.distMap();
   p  = dfs_test.predMap();
+  //  pn = dfs_test.predNodeMap();
   b  = dfs_test.reached(n);
 
@@ -105,10 +81,8 @@
   Digraph G;
   Node s, t;
+  PetStruct<Digraph> ps = addPetersen(G, 5);
 
-  std::istringstream input(test_lgf);
-  digraphReader(input, G).
-    node("source", s).
-    node("target", t).
-    run();
+  s=ps.outer[2];
+  t=ps.inner[0];
 
   Dfs<Digraph> dfs_test(G);
@@ -122,14 +96,12 @@
 
   for(NodeIt v(G); v!=INVALID; ++v) {
-    if (dfs_test.reached(v)) {
-      check(v==s || dfs_test.predArc(v)!=INVALID, "Wrong tree.");
-      if (dfs_test.predArc(v)!=INVALID ) {
-        Arc e=dfs_test.predArc(v);
-        Node u=G.source(e);
-        check(u==dfs_test.predNode(v),"Wrong tree.");
-        check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
-              "Wrong distance. (" << dfs_test.dist(u) << "->"
-              <<dfs_test.dist(v) << ')');
-      }
+    check(dfs_test.reached(v),"Each node should be reached.");
+    if ( dfs_test.predArc(v)!=INVALID ) {
+      Arc e=dfs_test.predArc(v);
+      Node u=G.source(e);
+      check(u==dfs_test.predNode(v),"Wrong tree.");
+      check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
+            "Wrong distance. (" << dfs_test.dist(u) << "->"
+            <<dfs_test.dist(v) << ')');
     }
   }
Index: test/digraph_test.cc
===================================================================
--- test/digraph_test.cc	(revision 228)
+++ test/digraph_test.cc	(revision 209)
@@ -25,61 +25,10 @@
 #include "test_tools.h"
 #include "graph_test.h"
+#include "graph_maps_test.h"
 
 using namespace lemon;
 using namespace lemon::concepts;
 
-template <class Digraph>
-void checkDigraph() {
-  TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
-  Digraph G;
-
-  checkGraphNodeList(G, 0);
-  checkGraphArcList(G, 0);
-
-  Node
-    n1 = G.addNode(),
-    n2 = G.addNode(),
-    n3 = G.addNode();
-  checkGraphNodeList(G, 3);
-  checkGraphArcList(G, 0);
-
-  Arc a1 = G.addArc(n1, n2);
-  check(G.source(a1) == n1 && G.target(a1) == n2, "Wrong arc");
-  checkGraphNodeList(G, 3);
-  checkGraphArcList(G, 1);
-
-  checkGraphOutArcList(G, n1, 1);
-  checkGraphOutArcList(G, n2, 0);
-  checkGraphOutArcList(G, n3, 0);
-
-  checkGraphInArcList(G, n1, 0);
-  checkGraphInArcList(G, n2, 1);
-  checkGraphInArcList(G, n3, 0);
-
-  checkGraphConArcList(G, 1);
-
-  Arc a2 = G.addArc(n2, n1), a3 = G.addArc(n2, n3), a4 = G.addArc(n2, n3);
-  checkGraphNodeList(G, 3);
-  checkGraphArcList(G, 4);
-
-  checkGraphOutArcList(G, n1, 1);
-  checkGraphOutArcList(G, n2, 3);
-  checkGraphOutArcList(G, n3, 0);
-
-  checkGraphInArcList(G, n1, 1);
-  checkGraphInArcList(G, n2, 1);
-  checkGraphInArcList(G, n3, 2);
-
-  checkGraphConArcList(G, 4);
-
-  checkNodeIds(G);
-  checkArcIds(G);
-  checkGraphNodeMap(G);
-  checkGraphArcMap(G);
-
-}
-
-
-void checkConcepts() {
+void check_concepts() {
   { // Checking digraph components
     checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
@@ -103,4 +52,5 @@
     checkConcept<ClearableDigraphComponent<>, ListDigraph>();
     checkConcept<ErasableDigraphComponent<>, ListDigraph>();
+    checkDigraphIterators<ListDigraph>();
   }
   { // Checking SmartDigraph
@@ -109,15 +59,18 @@
     checkConcept<ExtendableDigraphComponent<>, SmartDigraph>();
     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
+    checkDigraphIterators<SmartDigraph>();
   }
 //  { // Checking FullDigraph
 //    checkConcept<Digraph, FullDigraph>();
+//    checkDigraphIterators<FullDigraph>();
 //  }
 //  { // Checking HyperCubeDigraph
 //    checkConcept<Digraph, HyperCubeDigraph>();
+//    checkDigraphIterators<HyperCubeDigraph>();
 //  }
 }
 
 template <typename Digraph>
-void checkDigraphValidity() {
+void check_graph_validity() {
   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   Digraph g;
@@ -140,5 +93,5 @@
 
 template <typename Digraph>
-void checkDigraphValidityErase() {
+void check_graph_validity_erase() {
   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
   Digraph g;
@@ -168,18 +121,24 @@
 }
 
-void checkDigraphs() {
+void check_digraphs() {
   { // Checking ListDigraph
     checkDigraph<ListDigraph>();
-    checkDigraphValidityErase<ListDigraph>();
+    checkGraphNodeMap<ListDigraph>();
+    checkGraphArcMap<ListDigraph>();
+
+    check_graph_validity_erase<ListDigraph>();
   }
   { // Checking SmartDigraph
     checkDigraph<SmartDigraph>();
-    checkDigraphValidity<SmartDigraph>();
+    checkGraphNodeMap<SmartDigraph>();
+    checkGraphArcMap<SmartDigraph>();
+
+    check_graph_validity<SmartDigraph>();
   }
 }
 
 int main() {
-  checkDigraphs();
-  checkConcepts();
+  check_concepts();
+  check_digraphs();
   return 0;
 }
Index: test/dijkstra_test.cc
===================================================================
--- test/dijkstra_test.cc	(revision 228)
+++ test/dijkstra_test.cc	(revision 210)
@@ -20,6 +20,5 @@
 #include <lemon/smart_graph.h>
 #include <lemon/list_graph.h>
-#include <lemon/lgf_reader.h>
-
+#include <lemon/graph_utils.h>
 #include <lemon/dijkstra.h>
 #include <lemon/path.h>
@@ -29,25 +28,4 @@
 
 using namespace lemon;
-
-char test_lgf[] =
-  "@nodes\n"
-  "label\n"
-  "0\n"
-  "1\n"
-  "2\n"
-  "3\n"
-  "4\n"
-  "@arcs\n"
-  "     label length\n"
-  "0 1  0     1\n"
-  "1 2  1     1\n"
-  "2 3  2     1\n"
-  "0 3  4     5\n"
-  "0 3  5     10\n"
-  "0 3  6     7\n"
-  "4 2  7     1\n"
-  "@attributes\n"
-  "source 0\n"
-  "target 3\n";
 
 void checkDijkstraCompile()
@@ -108,11 +86,13 @@
   Node s, t;
   LengthMap length(G);
+  PetStruct<Digraph> ps = addPetersen(G, 5);
 
-  std::istringstream input(test_lgf);
-  digraphReader(input, G).
-    arcMap("length", length).
-    node("source", s).
-    node("target", t).
-    run();
+  for(int i=0;i<5;i++) {
+    length[ps.outcir[i]]=4;
+    length[ps.incir[i]]=1;
+    length[ps.chords[i]]=10;
+  }
+  s=ps.outer[0];
+  t=ps.inner[1];
 
   Dijkstra<Digraph, LengthMap>
@@ -120,8 +100,8 @@
   dijkstra_test.run(s);
 
-  check(dijkstra_test.dist(t)==3,"Dijkstra found a wrong path.");
+  check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
 
   Path<Digraph> p = dijkstra_test.path(t);
-  check(p.length()==3,"getPath() found a wrong path.");
+  check(p.length()==4,"getPath() found a wrong path.");
   check(checkPath(G, p),"path() found a wrong path.");
   check(pathSource(G, p) == s,"path() found a wrong path.");
@@ -137,15 +117,13 @@
   }
 
-  for(NodeIt v(G); v!=INVALID; ++v) {
-    if (dijkstra_test.reached(v)) {
-      check(v==s || dijkstra_test.predArc(v)!=INVALID, "Wrong tree.");
-      if (dijkstra_test.predArc(v)!=INVALID ) {
-        Arc e=dijkstra_test.predArc(v);
-        Node u=G.source(e);
-        check(u==dijkstra_test.predNode(v),"Wrong tree.");
-        check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == length[e],
-              "Wrong distance! Difference: " <<
-              std::abs(dijkstra_test.dist(v)-dijkstra_test.dist(u)-length[e]));
-      }
+  for(NodeIt v(G); v!=INVALID; ++v){
+    check(dijkstra_test.reached(v),"Each node should be reached.");
+    if ( dijkstra_test.predArc(v)!=INVALID ) {
+      Arc e=dijkstra_test.predArc(v);
+      Node u=G.source(e);
+      check(u==dijkstra_test.predNode(v),"Wrong tree.");
+      check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == length[e],
+            "Wrong distance! Difference: " <<
+            std::abs(dijkstra_test.dist(v)-dijkstra_test.dist(u)-length[e]));
     }
   }
Index: test/dim_test.cc
===================================================================
--- test/dim_test.cc	(revision 242)
+++ test/dim_test.cc	(revision 209)
@@ -59,28 +59,24 @@
   box1.add(b);
 
-  check(box1.left()==1 && box1.bottom()==2 &&
-        box1.right()==3 && box1.top()==4,
+  check(box1.bottomLeft().x==1 &&
+        box1.bottomLeft().y==2 &&
+        box1.topRight().x==3 &&
+        box1.topRight().y==4,
         "Wrong addition of points to dim2::BoundingBox.");
 
-  check(box1.inside(Point(2,3)), "Wrong inside() in dim2::BoundingBox.");
-  check(box1.inside(Point(1,3)), "Wrong inside() in dim2::BoundingBox.");
-  check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::BoundingBox.");
+  p.x=2; p.y=3;
+  check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
 
-  BB box2(Point(2,2));
+  p.x=1; p.y=3;
+  check(box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
+
+  p.x=0; p.y=3;
+  check(!box1.inside(p), "Wrong inside() in dim2::BoundingBox.");
+
+  BB box2(p);
   check(!box2.empty(), "Wrong empty() in dim2::BoundingBox.");
-  
-  box2.bottomLeft(Point(2,0));
-  box2.topRight(Point(5,3));
-  BB box3 = box1 & box2;
-  check(!box3.empty() &&
-        box3.left()==2 && box3.bottom()==2 && 
-        box3.right()==3 && box3.top()==3,
-        "Wrong intersection of two dim2::BoundingBox objects.");
-  
-  box1.add(box2);
-  check(!box1.empty() &&
-        box1.left()==1 && box1.bottom()==0 &&
-        box1.right()==5 && box1.top()==4,
-        "Wrong addition of two dim2::BoundingBox objects.");
+
+  box2.add(box1);
+  check(box2.inside(p), "Wrong inside() in dim2::BoundingBox.");
 
   return 0;
Index: test/error_test.cc
===================================================================
--- test/error_test.cc	(revision 223)
+++ test/error_test.cc	(revision 209)
@@ -30,8 +30,4 @@
 #ifdef LEMON_DISABLE_ASSERTS
 #undef LEMON_DISABLE_ASSERTS
-#endif
-
-#ifdef NDEBUG
-#undef NDEBUG
 #endif
 
Index: test/graph_copy_test.cc
===================================================================
--- test/graph_copy_test.cc	(revision 220)
+++ test/graph_copy_test.cc	(revision 209)
@@ -20,4 +20,5 @@
 #include <lemon/list_graph.h>
 #include <lemon/lgf_reader.h>
+#include <lemon/graph_utils.h>
 #include <lemon/error.h>
 
Index: test/graph_maps_test.h
===================================================================
--- test/graph_maps_test.h	(revision 209)
+++ test/graph_maps_test.h	(revision 209)
@@ -0,0 +1,144 @@
+/* -*- 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_TEST_MAP_TEST_H
+#define LEMON_TEST_MAP_TEST_H
+
+#include <vector>
+#include <lemon/maps.h>
+
+#include "test_tools.h"
+
+namespace lemon {
+
+  template <typename Graph>
+  void checkGraphNodeMap() {
+    Graph graph;
+    const int num = 16;
+
+    typedef typename Graph::Node Node;
+
+    std::vector<Node> nodes;
+    for (int i = 0; i < num; ++i) {
+      nodes.push_back(graph.addNode());
+    }
+    typedef typename Graph::template NodeMap<int> IntNodeMap;
+    IntNodeMap map(graph, 42);
+    for (int i = 0; i < int(nodes.size()); ++i) {
+      check(map[nodes[i]] == 42, "Wrong map constructor.");
+    }
+    for (int i = 0; i < num; ++i) {
+      nodes.push_back(graph.addNode());
+      map[nodes.back()] = 23;
+      check(map[nodes.back()] == 23, "Wrong operator[].");
+    }
+    map = constMap<Node>(12);
+    for (int i = 0; i < int(nodes.size()); ++i) {
+      check(map[nodes[i]] == 12, "Wrong map constructor.");
+    }
+    graph.clear();
+    nodes.clear();
+  }
+
+  template <typename Graph>
+  void checkGraphArcMap() {
+    Graph graph;
+    const int num = 16;
+
+    typedef typename Graph::Node Node;
+    typedef typename Graph::Arc Arc;
+
+    std::vector<Node> nodes;
+    for (int i = 0; i < num; ++i) {
+      nodes.push_back(graph.addNode());
+    }
+
+    std::vector<Arc> arcs;
+    for (int i = 0; i < num; ++i) {
+      for (int j = 0; j < i; ++j) {
+        arcs.push_back(graph.addArc(nodes[i], nodes[j]));
+      }
+    }
+
+    typedef typename Graph::template ArcMap<int> IntArcMap;
+    IntArcMap map(graph, 42);
+
+    for (int i = 0; i < int(arcs.size()); ++i) {
+      check(map[arcs[i]] == 42, "Wrong map constructor.");
+    }
+
+    for (int i = 0; i < num; ++i) {
+      for (int j = i + 1; j < num; ++j) {
+        arcs.push_back(graph.addArc(nodes[i], nodes[j]));
+        map[arcs.back()] = 23;
+        check(map[arcs.back()] == 23, "Wrong operator[].");
+      }
+    }
+    map = constMap<Arc>(12);
+    for (int i = 0; i < int(arcs.size()); ++i) {
+      check(map[arcs[i]] == 12, "Wrong map constructor.");
+    }
+    graph.clear();
+    arcs.clear();
+  }
+
+  template <typename Graph>
+  void checkGraphEdgeMap() {
+    Graph graph;
+    const int num = 16;
+
+    typedef typename Graph::Node Node;
+    typedef typename Graph::Edge Edge;
+
+    std::vector<Node> nodes;
+    for (int i = 0; i < num; ++i) {
+      nodes.push_back(graph.addNode());
+    }
+
+    std::vector<Edge> edges;
+    for (int i = 0; i < num; ++i) {
+      for (int j = 0; j < i; ++j) {
+        edges.push_back(graph.addEdge(nodes[i], nodes[j]));
+      }
+    }
+
+    typedef typename Graph::template EdgeMap<int> IntEdgeMap;
+    IntEdgeMap map(graph, 42);
+
+    for (int i = 0; i < int(edges.size()); ++i) {
+      check(map[edges[i]] == 42, "Wrong map constructor.");
+    }
+
+    for (int i = 0; i < num; ++i) {
+      for (int j = i + 1; j < num; ++j) {
+        edges.push_back(graph.addEdge(nodes[i], nodes[j]));
+        map[edges.back()] = 23;
+        check(map[edges.back()] == 23, "Wrong operator[].");
+      }
+    }
+    map = constMap<Edge>(12);
+    for (int i = 0; i < int(edges.size()); ++i) {
+      check(map[edges[i]] == 12, "Wrong map constructor.");
+    }
+    graph.clear();
+    edges.clear();
+  }
+
+}
+
+#endif
Index: test/graph_test.cc
===================================================================
--- test/graph_test.cc	(revision 228)
+++ test/graph_test.cc	(revision 209)
@@ -25,76 +25,10 @@
 #include "test_tools.h"
 #include "graph_test.h"
+#include "graph_maps_test.h"
 
 using namespace lemon;
 using namespace lemon::concepts;
 
-template <class Graph>
-void checkGraph() {
-  TEMPLATE_GRAPH_TYPEDEFS(Graph);
-
-  Graph G;
-  checkGraphNodeList(G, 0);
-  checkGraphEdgeList(G, 0);
-
-  Node
-    n1 = G.addNode(),
-    n2 = G.addNode(),
-    n3 = G.addNode();
-  checkGraphNodeList(G, 3);
-  checkGraphEdgeList(G, 0);
-
-  Edge e1 = G.addEdge(n1, n2);
-  check((G.u(e1) == n1 && G.v(e1) == n2) || (G.u(e1) == n2 && G.v(e1) == n1),
-        "Wrong edge");
-  checkGraphNodeList(G, 3);
-  checkGraphArcList(G, 2);
-  checkGraphEdgeList(G, 1);
-
-  checkGraphOutArcList(G, n1, 1);
-  checkGraphOutArcList(G, n2, 1);
-  checkGraphOutArcList(G, n3, 0);
-
-  checkGraphInArcList(G, n1, 1);
-  checkGraphInArcList(G, n2, 1);
-  checkGraphInArcList(G, n3, 0);
-
-  checkGraphIncEdgeList(G, n1, 1);
-  checkGraphIncEdgeList(G, n2, 1);
-  checkGraphIncEdgeList(G, n3, 0);
-
-  checkGraphConArcList(G, 2);
-  checkGraphConEdgeList(G, 1);
-
-  Edge e2 = G.addEdge(n2, n1), e3 = G.addEdge(n2, n3);
-  checkGraphNodeList(G, 3);
-  checkGraphArcList(G, 6);
-  checkGraphEdgeList(G, 3);
-
-  checkGraphOutArcList(G, n1, 2);
-  checkGraphOutArcList(G, n2, 3);
-  checkGraphOutArcList(G, n3, 1);
-
-  checkGraphInArcList(G, n1, 2);
-  checkGraphInArcList(G, n2, 3);
-  checkGraphInArcList(G, n3, 1);
-
-  checkGraphIncEdgeList(G, n1, 2);
-  checkGraphIncEdgeList(G, n2, 3);
-  checkGraphIncEdgeList(G, n3, 1);
-
-  checkGraphConArcList(G, 6);
-  checkGraphConEdgeList(G, 3);
-
-  checkArcDirections(G);
-
-  checkNodeIds(G);
-  checkArcIds(G);
-  checkEdgeIds(G);
-  checkGraphNodeMap(G);
-  checkGraphArcMap(G);
-  checkGraphEdgeMap(G);
-}
-
-void checkConcepts() {
+void check_concepts() {
   { // Checking graph components
     checkConcept<BaseGraphComponent, BaseGraphComponent >();
@@ -118,4 +52,5 @@
     checkConcept<ClearableGraphComponent<>, ListGraph>();
     checkConcept<ErasableGraphComponent<>, ListGraph>();
+    checkGraphIterators<ListGraph>();
   }
   { // Checking SmartGraph
@@ -124,4 +59,5 @@
     checkConcept<ExtendableGraphComponent<>, SmartGraph>();
     checkConcept<ClearableGraphComponent<>, SmartGraph>();
+    checkGraphIterators<SmartGraph>();
   }
 //  { // Checking FullGraph
@@ -136,5 +72,5 @@
 
 template <typename Graph>
-void checkGraphValidity() {
+void check_graph_validity() {
   TEMPLATE_GRAPH_TYPEDEFS(Graph);
   Graph g;
@@ -159,5 +95,5 @@
 
 template <typename Graph>
-void checkGraphValidityErase() {
+void check_graph_validity_erase() {
   TEMPLATE_GRAPH_TYPEDEFS(Graph);
   Graph g;
@@ -233,12 +169,18 @@
 // }
 
-void checkGraphs() {
+void check_graphs() {
   { // Checking ListGraph
     checkGraph<ListGraph>();
-    checkGraphValidityErase<ListGraph>();
+    checkGraphNodeMap<ListGraph>();
+    checkGraphEdgeMap<ListGraph>();
+
+    check_graph_validity_erase<ListGraph>();
   }
   { // Checking SmartGraph
     checkGraph<SmartGraph>();
-    checkGraphValidity<SmartGraph>();
+    checkGraphNodeMap<SmartGraph>();
+    checkGraphEdgeMap<SmartGraph>();
+
+    check_graph_validity<SmartGraph>();
   }
 //   { // Checking FullGraph
@@ -256,6 +198,6 @@
 
 int main() {
-  checkConcepts();
-  checkGraphs();
+  check_concepts();
+  check_graphs();
   return 0;
 }
Index: test/graph_test.h
===================================================================
--- test/graph_test.h	(revision 228)
+++ test/graph_test.h	(revision 209)
@@ -20,9 +20,5 @@
 #define LEMON_TEST_GRAPH_TEST_H
 
-#include <set>
-
-#include <lemon/core.h>
-#include <lemon/maps.h>
-
+#include <lemon/graph_utils.h>
 #include "test_tools.h"
 
@@ -47,8 +43,4 @@
     for(int i=0;i<cnt;i++) {
       check(e!=INVALID,"Wrong Arc list linking.");
-      check(G.oppositeNode(G.source(e), e) == G.target(e),
-            "Wrong opposite node");
-      check(G.oppositeNode(G.target(e), e) == G.source(e),
-            "Wrong opposite node");
       ++e;
     }
@@ -64,6 +56,4 @@
       check(e!=INVALID,"Wrong OutArc list linking.");
       check(n==G.source(e),"Wrong OutArc list linking.");
-      check(n==G.baseNode(e),"Wrong OutArc list linking.");
-      check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
       ++e;
     }
@@ -79,6 +69,4 @@
       check(e!=INVALID,"Wrong InArc list linking.");
       check(n==G.target(e),"Wrong InArc list linking.");
-      check(n==G.baseNode(e),"Wrong OutArc list linking.");
-      check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
       ++e;
     }
@@ -93,6 +81,4 @@
     for(int i=0;i<cnt;i++) {
       check(e!=INVALID,"Wrong Edge list linking.");
-      check(G.oppositeNode(G.u(e), e) == G.v(e), "Wrong opposite node");
-      check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
       ++e;
     }
@@ -108,7 +94,4 @@
       check(e!=INVALID,"Wrong IncEdge list linking.");
       check(n==G.u(e) || n==G.v(e),"Wrong IncEdge list linking.");
-      check(n==G.baseNode(e),"Wrong OutArc list linking.");
-      check(G.u(e)==G.runningNode(e) || G.v(e)==G.runningNode(e),
-            "Wrong OutArc list linking.");
       ++e;
     }
@@ -117,166 +100,161 @@
   }
 
+  template <class Digraph>
+  void checkDigraphIterators() {
+    typedef typename Digraph::Node Node;
+    typedef typename Digraph::NodeIt NodeIt;
+    typedef typename Digraph::Arc Arc;
+    typedef typename Digraph::ArcIt ArcIt;
+    typedef typename Digraph::InArcIt InArcIt;
+    typedef typename Digraph::OutArcIt OutArcIt;
+  }
+
   template <class Graph>
-  void checkGraphConArcList(const Graph &G, int cnt) {
-    int i = 0;
-    for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
-      for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
-        for (ConArcIt<Graph> a(G, u, v); a != INVALID; ++a) {
-          check(G.source(a) == u, "Wrong iterator.");
-          check(G.target(a) == v, "Wrong iterator.");
-          ++i;
-        }
-      }
-    }
-    check(cnt == i, "Wrong iterator.");
-  }
-
-  template <class Graph>
-  void checkGraphConEdgeList(const Graph &G, int cnt) {
-    int i = 0;
-    for (typename Graph::NodeIt u(G); u != INVALID; ++u) {
-      for (typename Graph::NodeIt v(G); v != INVALID; ++v) {
-        for (ConEdgeIt<Graph> e(G, u, v); e != INVALID; ++e) {
-          check((G.u(e) == u && G.v(e) == v) ||
-                (G.u(e) == v && G.v(e) == u), "Wrong iterator.");
-          i += u == v ? 2 : 1;
-        }
-      }
-    }
-    check(2 * cnt == i, "Wrong iterator.");
-  }
-
-  template <typename Graph>
-  void checkArcDirections(const Graph& G) {
-    for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
-      check(G.source(a) == G.target(G.oppositeArc(a)), "Wrong direction");
-      check(G.target(a) == G.source(G.oppositeArc(a)), "Wrong direction");
-      check(G.direct(a, G.direction(a)) == a, "Wrong direction");
-    }
-  }
-
-  template <typename Graph>
-  void checkNodeIds(const Graph& G) {
-    std::set<int> values;
-    for (typename Graph::NodeIt n(G); n != INVALID; ++n) {
-      check(G.nodeFromId(G.id(n)) == n, "Wrong id");
-      check(values.find(G.id(n)) == values.end(), "Wrong id");
-      check(G.id(n) <= G.maxNodeId(), "Wrong maximum id");
-      values.insert(G.id(n));
-    }
-  }
-
-  template <typename Graph>
-  void checkArcIds(const Graph& G) {
-    std::set<int> values;
-    for (typename Graph::ArcIt a(G); a != INVALID; ++a) {
-      check(G.arcFromId(G.id(a)) == a, "Wrong id");
-      check(values.find(G.id(a)) == values.end(), "Wrong id");
-      check(G.id(a) <= G.maxArcId(), "Wrong maximum id");
-      values.insert(G.id(a));
-    }
-  }
-
-  template <typename Graph>
-  void checkEdgeIds(const Graph& G) {
-    std::set<int> values;
-    for (typename Graph::EdgeIt e(G); e != INVALID; ++e) {
-      check(G.edgeFromId(G.id(e)) == e, "Wrong id");
-      check(values.find(G.id(e)) == values.end(), "Wrong id");
-      check(G.id(e) <= G.maxEdgeId(), "Wrong maximum id");
-      values.insert(G.id(e));
-    }
-  }
-
-  template <typename Graph>
-  void checkGraphNodeMap(const Graph& G) {
-    typedef typename Graph::Node Node;
-    typedef typename Graph::NodeIt NodeIt;
-
-    typedef typename Graph::template NodeMap<int> IntNodeMap;
-    IntNodeMap map(G, 42);
-    for (NodeIt it(G); it != INVALID; ++it) {
-      check(map[it] == 42, "Wrong map constructor.");
-    }
-    int s = 0;
-    for (NodeIt it(G); it != INVALID; ++it) {
-      map[it] = 0;
-      check(map[it] == 0, "Wrong operator[].");
-      map.set(it, s);
-      check(map[it] == s, "Wrong set.");
-      ++s;
-    }
-    s = s * (s - 1) / 2;
-    for (NodeIt it(G); it != INVALID; ++it) {
-      s -= map[it];
-    }
-    check(s == 0, "Wrong sum.");
-
-    map = constMap<Node>(12);
-    for (NodeIt it(G); it != INVALID; ++it) {
-      check(map[it] == 12, "Wrong operator[].");
-    }
-  }
-
-  template <typename Graph>
-  void checkGraphArcMap(const Graph& G) {
-    typedef typename Graph::Arc Arc;
-    typedef typename Graph::ArcIt ArcIt;
-
-    typedef typename Graph::template ArcMap<int> IntArcMap;
-    IntArcMap map(G, 42);
-    for (ArcIt it(G); it != INVALID; ++it) {
-      check(map[it] == 42, "Wrong map constructor.");
-    }
-    int s = 0;
-    for (ArcIt it(G); it != INVALID; ++it) {
-      map[it] = 0;
-      check(map[it] == 0, "Wrong operator[].");
-      map.set(it, s);
-      check(map[it] == s, "Wrong set.");
-      ++s;
-    }
-    s = s * (s - 1) / 2;
-    for (ArcIt it(G); it != INVALID; ++it) {
-      s -= map[it];
-    }
-    check(s == 0, "Wrong sum.");
-
-    map = constMap<Arc>(12);
-    for (ArcIt it(G); it != INVALID; ++it) {
-      check(map[it] == 12, "Wrong operator[].");
-    }
-  }
-
-  template <typename Graph>
-  void checkGraphEdgeMap(const Graph& G) {
+  void checkGraphIterators() {
+    checkDigraphIterators<Graph>();
     typedef typename Graph::Edge Edge;
     typedef typename Graph::EdgeIt EdgeIt;
-
-    typedef typename Graph::template EdgeMap<int> IntEdgeMap;
-    IntEdgeMap map(G, 42);
-    for (EdgeIt it(G); it != INVALID; ++it) {
-      check(map[it] == 42, "Wrong map constructor.");
-    }
-    int s = 0;
-    for (EdgeIt it(G); it != INVALID; ++it) {
-      map[it] = 0;
-      check(map[it] == 0, "Wrong operator[].");
-      map.set(it, s);
-      check(map[it] == s, "Wrong set.");
-      ++s;
-    }
-    s = s * (s - 1) / 2;
-    for (EdgeIt it(G); it != INVALID; ++it) {
-      s -= map[it];
-    }
-    check(s == 0, "Wrong sum.");
-
-    map = constMap<Edge>(12);
-    for (EdgeIt it(G); it != INVALID; ++it) {
-      check(map[it] == 12, "Wrong operator[].");
-    }
-  }
-
+    typedef typename Graph::IncEdgeIt IncEdgeIt;
+  }
+
+  // Structure returned by addPetersen()
+  template<class Digraph>
+  struct PetStruct
+  {
+    // Vector containing the outer nodes
+    std::vector<typename Digraph::Node> outer;
+    // Vector containing the inner nodes
+    std::vector<typename Digraph::Node> inner;
+    // Vector containing the arcs of the inner circle
+    std::vector<typename Digraph::Arc> incir;
+    // Vector containing the arcs of the outer circle
+    std::vector<typename Digraph::Arc> outcir;
+    // Vector containing the chord arcs
+    std::vector<typename Digraph::Arc> chords;
+  };
+
+  // Adds the reverse pair of all arcs to a digraph
+  template<class Digraph>
+  void bidirDigraph(Digraph &G)
+  {
+    typedef typename Digraph::Arc Arc;
+    typedef typename Digraph::ArcIt ArcIt;
+
+    std::vector<Arc> ee;
+
+    for(ArcIt e(G);e!=INVALID;++e) ee.push_back(e);
+
+    for(int i=0;i<int(ee.size());++i)
+      G.addArc(G.target(ee[i]),G.source(ee[i]));
+  }
+
+  // Adds a Petersen digraph to G.
+  // Returns the nodes and arcs of the generated digraph.
+  template<typename Digraph>
+  PetStruct<Digraph> addPetersen(Digraph &G,int num = 5)
+  {
+    PetStruct<Digraph> n;
+
+    for(int i=0;i<num;i++) {
+      n.outer.push_back(G.addNode());
+      n.inner.push_back(G.addNode());
+    }
+
+    for(int i=0;i<num;i++) {
+      n.chords.push_back(G.addArc(n.outer[i],n.inner[i]));
+      n.outcir.push_back(G.addArc(n.outer[i],n.outer[(i+1) % num]));
+      n.incir.push_back(G.addArc(n.inner[i],n.inner[(i+2) % num]));
+    }
+
+    return n;
+  }
+
+  // Checks the bidirectioned Petersen digraph
+  template<class Digraph>
+  void checkBidirPetersen(const Digraph &G, int num = 5)
+  {
+    typedef typename Digraph::NodeIt NodeIt;
+
+    checkGraphNodeList(G, 2 * num);
+    checkGraphArcList(G, 6 * num);
+
+    for(NodeIt n(G);n!=INVALID;++n) {
+      checkGraphInArcList(G, n, 3);
+      checkGraphOutArcList(G, n, 3);
+    }
+  }
+
+  // Structure returned by addUPetersen()
+  template<class Graph>
+  struct UPetStruct
+  {
+    // Vector containing the outer nodes
+    std::vector<typename Graph::Node> outer;
+    // Vector containing the inner nodes
+    std::vector<typename Graph::Node> inner;
+    // Vector containing the edges of the inner circle
+    std::vector<typename Graph::Edge> incir;
+    // Vector containing the edges of the outer circle
+    std::vector<typename Graph::Edge> outcir;
+    // Vector containing the chord edges
+    std::vector<typename Graph::Edge> chords;
+  };
+
+  // Adds a Petersen graph to \c G.
+  // Returns the nodes and edges of the generated graph.
+  template<typename Graph>
+  UPetStruct<Graph> addUPetersen(Graph &G,int num=5)
+  {
+    UPetStruct<Graph> n;
+
+    for(int i=0;i<num;i++) {
+      n.outer.push_back(G.addNode());
+      n.inner.push_back(G.addNode());
+    }
+
+    for(int i=0;i<num;i++) {
+      n.chords.push_back(G.addEdge(n.outer[i],n.inner[i]));
+      n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1)%num]));
+      n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%num]));
+    }
+
+    return n;
+  }
+
+  // Checks the undirected Petersen graph
+  template<class Graph>
+  void checkUndirPetersen(const Graph &G, int num = 5)
+  {
+    typedef typename Graph::NodeIt NodeIt;
+
+    checkGraphNodeList(G, 2 * num);
+    checkGraphEdgeList(G, 3 * num);
+    checkGraphArcList(G, 6 * num);
+
+    for(NodeIt n(G);n!=INVALID;++n) {
+      checkGraphIncEdgeList(G, n, 3);
+    }
+  }
+
+  template <class Digraph>
+  void checkDigraph() {
+    const int num = 5;
+    Digraph G;
+    checkGraphNodeList(G, 0);
+    checkGraphArcList(G, 0);
+    addPetersen(G, num);
+    bidirDigraph(G);
+    checkBidirPetersen(G, num);
+  }
+
+  template <class Graph>
+  void checkGraph() {
+    const int num = 5;
+    Graph G;
+    checkGraphNodeList(G, 0);
+    checkGraphEdgeList(G, 0);
+    addUPetersen(G, num);
+    checkUndirPetersen(G, num);
+  }
 
 } //namespace lemon
Index: test/graph_utils_test.cc
===================================================================
--- test/graph_utils_test.cc	(revision 220)
+++ test/graph_utils_test.cc	(revision 210)
@@ -21,7 +21,7 @@
 
 #include <lemon/random.h>
+#include <lemon/graph_utils.h>
 #include <lemon/list_graph.h>
 #include <lemon/smart_graph.h>
-#include <lemon/maps.h>
 
 #include "graph_test.h"
