Merge >=1.2 branch heads
authorAlpar Juttner <alpar@cs.elte.hu>
Sun, 11 Aug 2013 15:28:12 +0200
changeset 993ad40f7d32846
parent 987 70b199792735
parent 984 a337a0dd3f75
child 994 6c8e2d8712d8
Merge >=1.2 branch heads
lemon/connectivity.h
test/connectivity_test.cc
     1.1 --- a/.hgignore	Fri Aug 09 11:07:27 2013 +0200
     1.2 +++ b/.hgignore	Sun Aug 11 15:28:12 2013 +0200
     1.3 @@ -22,6 +22,7 @@
     1.4  lemon/libemon.la
     1.5  lemon/stamp-h2
     1.6  doc/Doxyfile
     1.7 +doc/references.dox
     1.8  cmake/version.cmake
     1.9  .dirstamp
    1.10  .libs/*
     2.1 --- a/CMakeLists.txt	Fri Aug 09 11:07:27 2013 +0200
     2.2 +++ b/CMakeLists.txt	Sun Aug 11 15:28:12 2013 +0200
     2.3 @@ -114,6 +114,8 @@
     2.4  CHECK_TYPE_SIZE("long long" LONG_LONG)
     2.5  SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
     2.6  
     2.7 +INCLUDE(FindPythonInterp)
     2.8 +
     2.9  ENABLE_TESTING()
    2.10  
    2.11  IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
     3.1 --- a/INSTALL	Fri Aug 09 11:07:27 2013 +0200
     3.2 +++ b/INSTALL	Sun Aug 11 15:28:12 2013 +0200
     3.3 @@ -173,3 +173,25 @@
     3.4  --without-coin
     3.5  
     3.6     Disable COIN-OR support.
     3.7 +
     3.8 +
     3.9 +Makefile Variables
    3.10 +==================
    3.11 +
    3.12 +Some Makefile variables are reserved by the GNU Coding Standards for
    3.13 +the use of the "user" - the person building the package. For instance,
    3.14 +CXX and CXXFLAGS are such variables, and have the same meaning as
    3.15 +explained in the previous section. These variables can be set on the
    3.16 +command line when invoking `make' like this:
    3.17 +`make [VARIABLE=VALUE]...'
    3.18 +
    3.19 +WARNINGCXXFLAGS is a non-standard Makefile variable introduced by us
    3.20 +to hold several compiler flags related to warnings. Its default value
    3.21 +can be overridden when invoking `make'. For example to disable all
    3.22 +warning flags use `make WARNINGCXXFLAGS='.
    3.23 +
    3.24 +In order to turn off a single flag from the default set of warning
    3.25 +flags, you can use the CXXFLAGS variable, since this is passed after
    3.26 +WARNINGCXXFLAGS. For example to turn off `-Wold-style-cast' (which is
    3.27 +used by default when g++ is detected) you can use
    3.28 +`make CXXFLAGS="-g -O2 -Wno-old-style-cast"'.
     4.1 --- a/LICENSE	Fri Aug 09 11:07:27 2013 +0200
     4.2 +++ b/LICENSE	Sun Aug 11 15:28:12 2013 +0200
     4.3 @@ -1,7 +1,7 @@
     4.4  LEMON code without an explicit copyright notice is covered by the following
     4.5  copyright/license.
     4.6  
     4.7 -Copyright (C) 2003-2009 Egervary Jeno Kombinatorikus Optimalizalasi
     4.8 +Copyright (C) 2003-2010 Egervary Jeno Kombinatorikus Optimalizalasi
     4.9  Kutatocsoport (Egervary Combinatorial Optimization Research Group,
    4.10  EGRES).
    4.11  
     5.1 --- a/Makefile.am	Fri Aug 09 11:07:27 2013 +0200
     5.2 +++ b/Makefile.am	Sun Aug 11 15:28:12 2013 +0200
     5.3 @@ -44,6 +44,7 @@
     5.4  include test/Makefile.am
     5.5  include doc/Makefile.am
     5.6  include tools/Makefile.am
     5.7 +include scripts/Makefile.am
     5.8  
     5.9  DIST_SUBDIRS = demo
    5.10  
     6.1 --- a/NEWS	Fri Aug 09 11:07:27 2013 +0200
     6.2 +++ b/NEWS	Sun Aug 11 15:28:12 2013 +0200
     6.3 @@ -1,3 +1,83 @@
     6.4 +2010-03-19 Version 1.2 released
     6.5 +
     6.6 +        This is major feature release
     6.7 +
     6.8 +        * New algorithms
     6.9 +          * Bellman-Ford algorithm (#51)
    6.10 +          * Minimum mean cycle algorithms (#179)
    6.11 +            * Karp, Hartman-Orlin and Howard algorithms
    6.12 +          * New minimum cost flow algorithms (#180)
    6.13 +            * Cost Scaling algorithms
    6.14 +            * Capacity Scaling algorithm
    6.15 +            * Cycle-Canceling algorithms
    6.16 +          * Planarity related algorithms (#62)
    6.17 +            * Planarity checking algorithm
    6.18 +            * Planar embedding algorithm
    6.19 +            * Schnyder's planar drawing algorithm
    6.20 +            * Coloring planar graphs with five or six colors
    6.21 +          * Fractional matching algorithms (#314)
    6.22 +        * New data structures
    6.23 +          * StaticDigraph structure (#68)
    6.24 +          * Several new priority queue structures (#50, #301)
    6.25 +            * Fibonacci, Radix, Bucket, Pairing, Binomial
    6.26 +              D-ary and fourary heaps (#301)
    6.27 +          * Iterable map structures (#73)
    6.28 +        * Other new tools and functionality
    6.29 +          * Map utility functions (#320)
    6.30 +          * Reserve functions are added to ListGraph and SmartGraph (#311)
    6.31 +          * A resize() function is added to HypercubeGraph (#311)
    6.32 +          * A count() function is added to CrossRefMap (#302)
    6.33 +          * Support for multiple targets in Suurballe using fullInit() (#181)
    6.34 +          * Traits class and named parameters for Suurballe (#323)
    6.35 +          * Separate reset() and resetParams() functions in NetworkSimplex
    6.36 +            to handle graph changes (#327)
    6.37 +          * tolerance() functions are added to HaoOrlin (#306)
    6.38 +        * Implementation improvements
    6.39 +          * Improvements in weighted matching algorithms (#314)
    6.40 +            * Jumpstart initialization
    6.41 +          * ArcIt iteration is based on out-arc lists instead of in-arc lists
    6.42 +            in ListDigraph (#311)
    6.43 +          * Faster add row operation in CbcMip (#203)
    6.44 +          * Better implementation for split() in ListDigraph (#311)
    6.45 +          * ArgParser can also throw exception instead of exit(1) (#332)
    6.46 +        * Miscellaneous
    6.47 +          * A simple interactive bootstrap script
    6.48 +          * Doc improvements (#62,#180,#299,#302,#303,#304,#307,#311,#331,#315,
    6.49 +                #316,#319)
    6.50 +            * BibTeX references in the doc (#184)
    6.51 +          * Optionally use valgrind when running tests
    6.52 +          * Also check ReferenceMapTag in concept checks (#312)
    6.53 +          * dimacs-solver uses long long type by default.
    6.54 +        * Several bugfixes (compared to release 1.1):
    6.55 +          #295: Suppress MSVC warnings using pragmas
    6.56 +          ----: Various CMAKE related improvements
    6.57 +                * Remove duplications from doc/CMakeLists.txt
    6.58 +                * Rename documentation install folder from 'docs' to 'html'
    6.59 +                * Add tools/CMakeLists.txt to the tarball
    6.60 +                * Generate and install LEMONConfig.cmake
    6.61 +                * Change the label of the html project in Visual Studio
    6.62 +                * Fix the check for the 'long long' type
    6.63 +                * Put the version string into config.h
    6.64 +                * Minor CMake improvements
    6.65 +                * Set the version to 'hg-tip' if everything fails
    6.66 +          #311: Add missing 'explicit' keywords
    6.67 +          #302: Fix the implementation and doc of CrossRefMap
    6.68 +          #308: Remove duplicate list_graph.h entry from source list
    6.69 +          #307: Bugfix in Preflow and Circulation
    6.70 +          #305: Bugfix and extension in the rename script
    6.71 +          #312: Also check ReferenceMapTag in concept checks
    6.72 +          #250: Bugfix in pathSource() and pathTarget()
    6.73 +          #321: Use pathCopy(from,to) instead of copyPath(to,from)
    6.74 +          #322: Distribure LEMONConfig.cmake.in
    6.75 +          #330: Bug fix in map_extender.h
    6.76 +          #336: Fix the date field comment of graphToEps() output
    6.77 +          #323: Bug fix in Suurballe
    6.78 +          #335: Fix clear() function in ExtendFindEnum
    6.79 +          #337: Use void* as the LPX object pointer
    6.80 +          #317: Fix (and improve) error message in mip_test.cc
    6.81 +                Remove unnecessary OsiCbc dependency
    6.82 +          #356: Allow multiple executions of weighted matching algorithms (#356)
    6.83 +
    6.84  2009-05-13 Version 1.1 released
    6.85  
    6.86          This is the second stable release of the 1.x series. It
    6.87 @@ -72,7 +152,7 @@
    6.88            ----: Minor clarification in the LICENSE file
    6.89            ----: Add missing unistd.h include to time_measure.h
    6.90            #204: Compilation bug fixed in graph_to_eps.h with VS2005
    6.91 -          #214,#215: windows.h should never be included by lemon headers
    6.92 +          #214,#215: windows.h should never be included by LEMON headers
    6.93            #230: Build systems check the availability of 'long long' type
    6.94            #229: Default implementation of Tolerance<> is used for integer types
    6.95            #211,#212: Various fixes for compiling on AIX
    6.96 @@ -94,51 +174,51 @@
    6.97  
    6.98  2008-10-13 Version 1.0 released
    6.99  
   6.100 -	This is the first stable release of LEMON. Compared to the 0.x
   6.101 -	release series, it features a considerably smaller but more
   6.102 -	matured set of tools. The API has also completely revised and
   6.103 -	changed in several places.
   6.104 +        This is the first stable release of LEMON. Compared to the 0.x
   6.105 +        release series, it features a considerably smaller but more
   6.106 +        matured set of tools. The API has also completely revised and
   6.107 +        changed in several places.
   6.108  
   6.109 -	* The major name changes compared to the 0.x series (see the
   6.110 +        * The major name changes compared to the 0.x series (see the
   6.111            Migration Guide in the doc for more details)
   6.112            * Graph -> Digraph, UGraph -> Graph
   6.113            * Edge -> Arc, UEdge -> Edge
   6.114 -	  * source(UEdge)/target(UEdge) -> u(Edge)/v(Edge)
   6.115 -	* Other improvements
   6.116 -	  * Better documentation
   6.117 -	  * Reviewed and cleaned up codebase
   6.118 -	  * CMake based build system (along with the autotools based one)
   6.119 -	* Contents of the library (ported from 0.x)
   6.120 -	  * Algorithms
   6.121 -       	    * breadth-first search (bfs.h)
   6.122 -       	    * depth-first search (dfs.h)
   6.123 -       	    * Dijkstra's algorithm (dijkstra.h)
   6.124 -       	    * Kruskal's algorithm (kruskal.h)
   6.125 -    	  * Data structures
   6.126 -       	    * graph data structures (list_graph.h, smart_graph.h)
   6.127 -       	    * path data structures (path.h)
   6.128 -       	    * binary heap data structure (bin_heap.h)
   6.129 -       	    * union-find data structures (unionfind.h)
   6.130 -       	    * miscellaneous property maps (maps.h)
   6.131 -       	    * two dimensional vector and bounding box (dim2.h)
   6.132 +          * source(UEdge)/target(UEdge) -> u(Edge)/v(Edge)
   6.133 +        * Other improvements
   6.134 +          * Better documentation
   6.135 +          * Reviewed and cleaned up codebase
   6.136 +          * CMake based build system (along with the autotools based one)
   6.137 +        * Contents of the library (ported from 0.x)
   6.138 +          * Algorithms
   6.139 +            * breadth-first search (bfs.h)
   6.140 +            * depth-first search (dfs.h)
   6.141 +            * Dijkstra's algorithm (dijkstra.h)
   6.142 +            * Kruskal's algorithm (kruskal.h)
   6.143 +          * Data structures
   6.144 +            * graph data structures (list_graph.h, smart_graph.h)
   6.145 +            * path data structures (path.h)
   6.146 +            * binary heap data structure (bin_heap.h)
   6.147 +            * union-find data structures (unionfind.h)
   6.148 +            * miscellaneous property maps (maps.h)
   6.149 +            * two dimensional vector and bounding box (dim2.h)
   6.150            * Concepts
   6.151 -       	    * graph structure concepts (concepts/digraph.h, concepts/graph.h,
   6.152 +            * graph structure concepts (concepts/digraph.h, concepts/graph.h,
   6.153                concepts/graph_components.h)
   6.154 -       	    * concepts for other structures (concepts/heap.h, concepts/maps.h,
   6.155 -	      concepts/path.h)
   6.156 -    	  * Tools
   6.157 -       	    * Mersenne twister random number generator (random.h)
   6.158 -       	    * tools for measuring cpu and wall clock time (time_measure.h)
   6.159 -       	    * tools for counting steps and events (counter.h)
   6.160 -       	    * tool for parsing command line arguments (arg_parser.h)
   6.161 -       	    * tool for visualizing graphs (graph_to_eps.h)
   6.162 -       	    * tools for reading and writing data in LEMON Graph Format
   6.163 +            * concepts for other structures (concepts/heap.h, concepts/maps.h,
   6.164 +              concepts/path.h)
   6.165 +          * Tools
   6.166 +            * Mersenne twister random number generator (random.h)
   6.167 +            * tools for measuring cpu and wall clock time (time_measure.h)
   6.168 +            * tools for counting steps and events (counter.h)
   6.169 +            * tool for parsing command line arguments (arg_parser.h)
   6.170 +            * tool for visualizing graphs (graph_to_eps.h)
   6.171 +            * tools for reading and writing data in LEMON Graph Format
   6.172                (lgf_reader.h, lgf_writer.h)
   6.173              * tools to handle the anomalies of calculations with
   6.174 -	      floating point numbers (tolerance.h)
   6.175 +              floating point numbers (tolerance.h)
   6.176              * tools to manage RGB colors (color.h)
   6.177 -    	  * Infrastructure
   6.178 -       	    * extended assertion handling (assert.h)
   6.179 -       	    * exception classes and error handling (error.h)
   6.180 -      	    * concept checking (concept_check.h)
   6.181 -       	    * commonly used mathematical constants (math.h)
   6.182 +          * Infrastructure
   6.183 +            * extended assertion handling (assert.h)
   6.184 +            * exception classes and error handling (error.h)
   6.185 +            * concept checking (concept_check.h)
   6.186 +            * commonly used mathematical constants (math.h)
     7.1 --- a/README	Fri Aug 09 11:07:27 2013 +0200
     7.2 +++ b/README	Sun Aug 11 15:28:12 2013 +0200
     7.3 @@ -17,6 +17,10 @@
     7.4  
     7.5     Copying, distribution and modification conditions and terms.
     7.6  
     7.7 +NEWS
     7.8 +
     7.9 +   News and version history.
    7.10 +
    7.11  INSTALL
    7.12  
    7.13     General building and installation instructions.
    7.14 @@ -33,6 +37,10 @@
    7.15  
    7.16     Some example programs to make you easier to get familiar with LEMON.
    7.17  
    7.18 +scripts/
    7.19 +
    7.20 +   Scripts that make it easier to develop LEMON.
    7.21 +
    7.22  test/
    7.23  
    7.24     Programs to check the integrity and correctness of LEMON.
     8.1 --- a/configure.ac	Fri Aug 09 11:07:27 2013 +0200
     8.2 +++ b/configure.ac	Sun Aug 11 15:28:12 2013 +0200
     8.3 @@ -41,6 +41,7 @@
     8.4  AC_PROG_LIBTOOL
     8.5  
     8.6  AC_CHECK_PROG([doxygen_found],[doxygen],[yes],[no])
     8.7 +AC_CHECK_PROG([python_found],[python],[yes],[no])
     8.8  AC_CHECK_PROG([gs_found],[gs],[yes],[no])
     8.9  
    8.10  dnl Detect Intel compiler.
    8.11 @@ -82,6 +83,21 @@
    8.12  fi
    8.13  AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"])
    8.14  
    8.15 +dnl Support for running test cases using valgrind.
    8.16 +use_valgrind=no
    8.17 +AC_ARG_ENABLE([valgrind],
    8.18 +AS_HELP_STRING([--enable-valgrind], [use valgrind when running tests]),
    8.19 +              [use_valgrind=yes])
    8.20 +
    8.21 +if [[ "$use_valgrind" = "yes" ]]; then
    8.22 +  AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
    8.23 +
    8.24 +  if [[ "$HAVE_VALGRIND" = "no" ]]; then
    8.25 +    AC_MSG_ERROR([Valgrind not found in PATH.])
    8.26 +  fi
    8.27 +fi
    8.28 +AM_CONDITIONAL(USE_VALGRIND, [test "$use_valgrind" = "yes"])
    8.29 +
    8.30  dnl Checks for header files.
    8.31  AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h unistd.h)
    8.32  
    8.33 @@ -128,6 +144,7 @@
    8.34  echo CBC support................... : $lx_cbc_found
    8.35  echo
    8.36  echo Build additional tools........ : $enable_tools
    8.37 +echo Use valgrind for tests........ : $use_valgrind
    8.38  echo
    8.39  echo The packace will be installed in
    8.40  echo -n '  '
     9.1 --- a/demo/arg_parser_demo.cc	Fri Aug 09 11:07:27 2013 +0200
     9.2 +++ b/demo/arg_parser_demo.cc	Sun Aug 11 15:28:12 2013 +0200
     9.3 @@ -2,7 +2,7 @@
     9.4   *
     9.5   * This file is a part of LEMON, a generic C++ optimization library.
     9.6   *
     9.7 - * Copyright (C) 2003-2009
     9.8 + * Copyright (C) 2003-2010
     9.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    9.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    9.11   *
    9.12 @@ -65,9 +65,18 @@
    9.13    ap.other("infile", "The input file.")
    9.14      .other("...");
    9.15  
    9.16 +  // Throw an exception when problems occurs. The default behavior is to
    9.17 +  // exit(1) on these cases, but this makes Valgrind falsely warn
    9.18 +  // about memory leaks.
    9.19 +  ap.throwOnProblems();
    9.20 +
    9.21    // Perform the parsing process
    9.22    // (in case of any error it terminates the program)
    9.23 -  ap.parse();
    9.24 +  // The try {} construct is necessary only if the ap.trowOnProblems()
    9.25 +  // setting is in use.
    9.26 +  try {
    9.27 +    ap.parse();
    9.28 +  } catch (ArgParserException &) { return 1; }
    9.29  
    9.30    // Check each option if it has been given and print its value
    9.31    std::cout << "Parameters of '" << ap.commandName() << "':\n";
    10.1 --- a/doc/CMakeLists.txt	Fri Aug 09 11:07:27 2013 +0200
    10.2 +++ b/doc/CMakeLists.txt	Sun Aug 11 15:28:12 2013 +0200
    10.3 @@ -17,7 +17,7 @@
    10.4    @ONLY
    10.5  )
    10.6  
    10.7 -IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
    10.8 +IF(DOXYGEN_EXECUTABLE AND PYTHONINTERP_FOUND AND GHOSTSCRIPT_EXECUTABLE)
    10.9    FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
   10.10    SET(GHOSTSCRIPT_OPTIONS -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha)
   10.11    ADD_CUSTOM_TARGET(html
   10.12 @@ -28,14 +28,17 @@
   10.13      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
   10.14      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
   10.15      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
   10.16 +    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/matching.eps
   10.17      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
   10.18      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
   10.19      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
   10.20      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
   10.21      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
   10.22      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
   10.23 +    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/planar.png ${CMAKE_CURRENT_SOURCE_DIR}/images/planar.eps
   10.24      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
   10.25      COMMAND ${CMAKE_COMMAND} -E remove_directory html
   10.26 +    COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/bib2dox.py ${CMAKE_CURRENT_SOURCE_DIR}/references.bib >references.dox
   10.27      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
   10.28      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
   10.29    )
    11.1 --- a/doc/Doxyfile.in	Fri Aug 09 11:07:27 2013 +0200
    11.2 +++ b/doc/Doxyfile.in	Sun Aug 11 15:28:12 2013 +0200
    11.3 @@ -97,7 +97,8 @@
    11.4                           "@abs_top_srcdir@/demo" \
    11.5                           "@abs_top_srcdir@/tools" \
    11.6                           "@abs_top_srcdir@/test/test_tools.h" \
    11.7 -                         "@abs_top_builddir@/doc/mainpage.dox"
    11.8 +                         "@abs_top_builddir@/doc/mainpage.dox" \
    11.9 +                         "@abs_top_builddir@/doc/references.dox"
   11.10  INPUT_ENCODING         = UTF-8
   11.11  FILE_PATTERNS          = *.h \
   11.12                           *.cc \
    12.1 --- a/doc/Makefile.am	Fri Aug 09 11:07:27 2013 +0200
    12.2 +++ b/doc/Makefile.am	Sun Aug 11 15:28:12 2013 +0200
    12.3 @@ -11,6 +11,7 @@
    12.4  	doc/min_cost_flow.dox \
    12.5  	doc/named-param.dox \
    12.6  	doc/namespaces.dox \
    12.7 +	doc/references.bib \
    12.8  	doc/template.h \
    12.9  	doc/html \
   12.10  	doc/CMakeLists.txt
   12.11 @@ -28,7 +29,9 @@
   12.12  	bipartite_partitions.eps \
   12.13  	connected_components.eps \
   12.14  	edge_biconnected_components.eps \
   12.15 +	matching.eps \
   12.16  	node_biconnected_components.eps \
   12.17 +	planar.eps \
   12.18  	strongly_connected_components.eps
   12.19  
   12.20  DOC_EPS_IMAGES = \
   12.21 @@ -67,7 +70,19 @@
   12.22  	  exit 1; \
   12.23  	fi
   12.24  
   12.25 -html-local: $(DOC_PNG_IMAGES)
   12.26 +references.dox: doc/references.bib
   12.27 +	if test ${python_found} = yes; then \
   12.28 +	  cd doc; \
   12.29 +	  python @abs_top_srcdir@/scripts/bib2dox.py @abs_top_builddir@/$< >$@; \
   12.30 +	  cd ..; \
   12.31 +	else \
   12.32 +	  echo; \
   12.33 +	  echo "Python not found."; \
   12.34 +	  echo; \
   12.35 +	  exit 1; \
   12.36 +	fi
   12.37 +
   12.38 +html-local: $(DOC_PNG_IMAGES) references.dox
   12.39  	if test ${doxygen_found} = yes; then \
   12.40  	  cd doc; \
   12.41  	  doxygen Doxyfile; \
    13.1 --- a/doc/groups.dox	Fri Aug 09 11:07:27 2013 +0200
    13.2 +++ b/doc/groups.dox	Sun Aug 11 15:28:12 2013 +0200
    13.3 @@ -2,7 +2,7 @@
    13.4   *
    13.5   * This file is a part of LEMON, a generic C++ optimization library.
    13.6   *
    13.7 - * Copyright (C) 2003-2009
    13.8 + * Copyright (C) 2003-2010
    13.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   13.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   13.11   *
   13.12 @@ -226,14 +226,6 @@
   13.13  */
   13.14  
   13.15  /**
   13.16 -@defgroup matrices Matrices
   13.17 -@ingroup datas
   13.18 -\brief Two dimensional data storages implemented in LEMON.
   13.19 -
   13.20 -This group contains two dimensional data storages implemented in LEMON.
   13.21 -*/
   13.22 -
   13.23 -/**
   13.24  @defgroup paths Path Structures
   13.25  @ingroup datas
   13.26  \brief %Path structures implemented in LEMON.
   13.27 @@ -246,7 +238,28 @@
   13.28  efficient to have e.g. the Dijkstra algorithm to store its result in
   13.29  any kind of path structure.
   13.30  
   13.31 -\sa lemon::concepts::Path
   13.32 +\sa \ref concepts::Path "Path concept"
   13.33 +*/
   13.34 +
   13.35 +/**
   13.36 +@defgroup heaps Heap Structures
   13.37 +@ingroup datas
   13.38 +\brief %Heap structures implemented in LEMON.
   13.39 +
   13.40 +This group contains the heap structures implemented in LEMON.
   13.41 +
   13.42 +LEMON provides several heap classes. They are efficient implementations
   13.43 +of the abstract data type \e priority \e queue. They store items with
   13.44 +specified values called \e priorities in such a way that finding and
   13.45 +removing the item with minimum priority are efficient.
   13.46 +The basic operations are adding and erasing items, changing the priority
   13.47 +of an item, etc.
   13.48 +
   13.49 +Heaps are crucial in several algorithms, such as Dijkstra and Prim.
   13.50 +The heap implementations have the same interface, thus any of them can be
   13.51 +used easily in such algorithms.
   13.52 +
   13.53 +\sa \ref concepts::Heap "Heap concept"
   13.54  */
   13.55  
   13.56  /**
   13.57 @@ -259,6 +272,28 @@
   13.58  */
   13.59  
   13.60  /**
   13.61 +@defgroup geomdat Geometric Data Structures
   13.62 +@ingroup auxdat
   13.63 +\brief Geometric data structures implemented in LEMON.
   13.64 +
   13.65 +This group contains geometric data structures implemented in LEMON.
   13.66 +
   13.67 + - \ref lemon::dim2::Point "dim2::Point" implements a two dimensional
   13.68 +   vector with the usual operations.
   13.69 + - \ref lemon::dim2::Box "dim2::Box" can be used to determine the
   13.70 +   rectangular bounding box of a set of \ref lemon::dim2::Point
   13.71 +   "dim2::Point"'s.
   13.72 +*/
   13.73 +
   13.74 +/**
   13.75 +@defgroup matrices Matrices
   13.76 +@ingroup auxdat
   13.77 +\brief Two dimensional data storages implemented in LEMON.
   13.78 +
   13.79 +This group contains two dimensional data storages implemented in LEMON.
   13.80 +*/
   13.81 +
   13.82 +/**
   13.83  @defgroup algs Algorithms
   13.84  \brief This group contains the several algorithms
   13.85  implemented in LEMON.
   13.86 @@ -273,7 +308,8 @@
   13.87  \brief Common graph search algorithms.
   13.88  
   13.89  This group contains the common graph search algorithms, namely
   13.90 -\e breadth-first \e search (BFS) and \e depth-first \e search (DFS).
   13.91 +\e breadth-first \e search (BFS) and \e depth-first \e search (DFS)
   13.92 +\ref clrs01algorithms.
   13.93  */
   13.94  
   13.95  /**
   13.96 @@ -281,7 +317,8 @@
   13.97  @ingroup algs
   13.98  \brief Algorithms for finding shortest paths.
   13.99  
  13.100 -This group contains the algorithms for finding shortest paths in digraphs.
  13.101 +This group contains the algorithms for finding shortest paths in digraphs
  13.102 +\ref clrs01algorithms.
  13.103  
  13.104   - \ref Dijkstra algorithm for finding shortest paths from a source node
  13.105     when all arc lengths are non-negative.
  13.106 @@ -298,12 +335,21 @@
  13.107  */
  13.108  
  13.109  /**
  13.110 +@defgroup spantree Minimum Spanning Tree Algorithms
  13.111 +@ingroup algs
  13.112 +\brief Algorithms for finding minimum cost spanning trees and arborescences.
  13.113 +
  13.114 +This group contains the algorithms for finding minimum cost spanning
  13.115 +trees and arborescences \ref clrs01algorithms.
  13.116 +*/
  13.117 +
  13.118 +/**
  13.119  @defgroup max_flow Maximum Flow Algorithms
  13.120  @ingroup algs
  13.121  \brief Algorithms for finding maximum flows.
  13.122  
  13.123  This group contains the algorithms for finding maximum flows and
  13.124 -feasible circulations.
  13.125 +feasible circulations \ref clrs01algorithms, \ref amo93networkflows.
  13.126  
  13.127  The \e maximum \e flow \e problem is to find a flow of maximum value between
  13.128  a single source and a single target. Formally, there is a \f$G=(V,A)\f$
  13.129 @@ -318,17 +364,21 @@
  13.130  \f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f]
  13.131  
  13.132  LEMON contains several algorithms for solving maximum flow problems:
  13.133 -- \ref EdmondsKarp Edmonds-Karp algorithm.
  13.134 -- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm.
  13.135 -- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees.
  13.136 -- \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees.
  13.137 +- \ref EdmondsKarp Edmonds-Karp algorithm
  13.138 +  \ref edmondskarp72theoretical.
  13.139 +- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm
  13.140 +  \ref goldberg88newapproach.
  13.141 +- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees
  13.142 +  \ref dinic70algorithm, \ref sleator83dynamic.
  13.143 +- \ref GoldbergTarjan !Preflow push-relabel algorithm with dynamic trees
  13.144 +  \ref goldberg88newapproach, \ref sleator83dynamic.
  13.145  
  13.146 -In most cases the \ref Preflow "Preflow" algorithm provides the
  13.147 +In most cases the \ref Preflow algorithm provides the
  13.148  fastest method for computing a maximum flow. All implementations
  13.149  also provide functions to query the minimum cut, which is the dual
  13.150  problem of maximum flow.
  13.151  
  13.152 -\ref Circulation is a preflow push-relabel algorithm implemented directly 
  13.153 +\ref Circulation is a preflow push-relabel algorithm implemented directly
  13.154  for finding feasible circulations, which is a somewhat different problem,
  13.155  but it is strongly related to maximum flow.
  13.156  For more information, see \ref Circulation.
  13.157 @@ -341,18 +391,20 @@
  13.158  \brief Algorithms for finding minimum cost flows and circulations.
  13.159  
  13.160  This group contains the algorithms for finding minimum cost flows and
  13.161 -circulations. For more information about this problem and its dual
  13.162 -solution see \ref min_cost_flow "Minimum Cost Flow Problem".
  13.163 +circulations \ref amo93networkflows. For more information about this
  13.164 +problem and its dual solution, see \ref min_cost_flow
  13.165 +"Minimum Cost Flow Problem".
  13.166  
  13.167  LEMON contains several algorithms for this problem.
  13.168   - \ref NetworkSimplex Primal Network Simplex algorithm with various
  13.169 -   pivot strategies.
  13.170 - - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on
  13.171 -   cost scaling.
  13.172 - - \ref CapacityScaling Successive Shortest %Path algorithm with optional
  13.173 -   capacity scaling.
  13.174 - - \ref CancelAndTighten The Cancel and Tighten algorithm.
  13.175 - - \ref CycleCanceling Cycle-Canceling algorithms.
  13.176 +   pivot strategies \ref dantzig63linearprog, \ref kellyoneill91netsimplex.
  13.177 + - \ref CostScaling Cost Scaling algorithm based on push/augment and
  13.178 +   relabel operations \ref goldberg90approximation, \ref goldberg97efficient,
  13.179 +   \ref bunnagel98efficient.
  13.180 + - \ref CapacityScaling Capacity Scaling algorithm based on the successive
  13.181 +   shortest path method \ref edmondskarp72theoretical.
  13.182 + - \ref CycleCanceling Cycle-Canceling algorithms, two of which are
  13.183 +   strongly polynomial \ref klein67primal, \ref goldberg89cyclecanceling.
  13.184  
  13.185  In general NetworkSimplex is the most efficient implementation,
  13.186  but in special cases other algorithms could be faster.
  13.187 @@ -375,7 +427,7 @@
  13.188  cut is the \f$X\f$ solution of the next optimization problem:
  13.189  
  13.190  \f[ \min_{X \subset V, X\not\in \{\emptyset, V\}}
  13.191 -    \sum_{uv\in A, u\in X, v\not\in X}cap(uv) \f]
  13.192 +    \sum_{uv\in A: u\in X, v\not\in X}cap(uv) \f]
  13.193  
  13.194  LEMON contains several algorithms related to minimum cut problems:
  13.195  
  13.196 @@ -391,27 +443,40 @@
  13.197  */
  13.198  
  13.199  /**
  13.200 -@defgroup graph_properties Connectivity and Other Graph Properties
  13.201 +@defgroup min_mean_cycle Minimum Mean Cycle Algorithms
  13.202  @ingroup algs
  13.203 -\brief Algorithms for discovering the graph properties
  13.204 +\brief Algorithms for finding minimum mean cycles.
  13.205  
  13.206 -This group contains the algorithms for discovering the graph properties
  13.207 -like connectivity, bipartiteness, euler property, simplicity etc.
  13.208 +This group contains the algorithms for finding minimum mean cycles
  13.209 +\ref clrs01algorithms, \ref amo93networkflows.
  13.210  
  13.211 -\image html edge_biconnected_components.png
  13.212 -\image latex edge_biconnected_components.eps "bi-edge-connected components" width=\textwidth
  13.213 -*/
  13.214 +The \e minimum \e mean \e cycle \e problem is to find a directed cycle
  13.215 +of minimum mean length (cost) in a digraph.
  13.216 +The mean length of a cycle is the average length of its arcs, i.e. the
  13.217 +ratio between the total length of the cycle and the number of arcs on it.
  13.218  
  13.219 -/**
  13.220 -@defgroup planar Planarity Embedding and Drawing
  13.221 -@ingroup algs
  13.222 -\brief Algorithms for planarity checking, embedding and drawing
  13.223 +This problem has an important connection to \e conservative \e length
  13.224 +\e functions, too. A length function on the arcs of a digraph is called
  13.225 +conservative if and only if there is no directed cycle of negative total
  13.226 +length. For an arbitrary length function, the negative of the minimum
  13.227 +cycle mean is the smallest \f$\epsilon\f$ value so that increasing the
  13.228 +arc lengths uniformly by \f$\epsilon\f$ results in a conservative length
  13.229 +function.
  13.230  
  13.231 -This group contains the algorithms for planarity checking,
  13.232 -embedding and drawing.
  13.233 +LEMON contains three algorithms for solving the minimum mean cycle problem:
  13.234 +- \ref KarpMmc Karp's original algorithm \ref amo93networkflows,
  13.235 +  \ref dasdan98minmeancycle.
  13.236 +- \ref HartmannOrlinMmc Hartmann-Orlin's algorithm, which is an improved
  13.237 +  version of Karp's algorithm \ref dasdan98minmeancycle.
  13.238 +- \ref HowardMmc Howard's policy iteration algorithm
  13.239 +  \ref dasdan98minmeancycle.
  13.240  
  13.241 -\image html planar.png
  13.242 -\image latex planar.eps "Plane graph" width=\textwidth
  13.243 +In practice, the \ref HowardMmc "Howard" algorithm proved to be by far the
  13.244 +most efficient one, though the best known theoretical bound on its running
  13.245 +time is exponential.
  13.246 +Both \ref KarpMmc "Karp" and \ref HartmannOrlinMmc "Hartmann-Orlin" algorithms
  13.247 +run in time O(ne) and use space O(n<sup>2</sup>+e), but the latter one is
  13.248 +typically faster due to the applied early termination scheme.
  13.249  */
  13.250  
  13.251  /**
  13.252 @@ -449,18 +514,49 @@
  13.253  - \ref MaxWeightedPerfectMatching
  13.254    Edmond's blossom shrinking algorithm for calculating maximum weighted
  13.255    perfect matching in general graphs.
  13.256 +- \ref MaxFractionalMatching Push-relabel algorithm for calculating
  13.257 +  maximum cardinality fractional matching in general graphs.
  13.258 +- \ref MaxWeightedFractionalMatching Augmenting path algorithm for calculating
  13.259 +  maximum weighted fractional matching in general graphs.
  13.260 +- \ref MaxWeightedPerfectFractionalMatching
  13.261 +  Augmenting path algorithm for calculating maximum weighted
  13.262 +  perfect fractional matching in general graphs.
  13.263  
  13.264 -\image html bipartite_matching.png
  13.265 -\image latex bipartite_matching.eps "Bipartite Matching" width=\textwidth
  13.266 +\image html matching.png
  13.267 +\image latex matching.eps "Min Cost Perfect Matching" width=\textwidth
  13.268  */
  13.269  
  13.270  /**
  13.271 -@defgroup spantree Minimum Spanning Tree Algorithms
  13.272 +@defgroup graph_properties Connectivity and Other Graph Properties
  13.273  @ingroup algs
  13.274 -\brief Algorithms for finding minimum cost spanning trees and arborescences.
  13.275 +\brief Algorithms for discovering the graph properties
  13.276  
  13.277 -This group contains the algorithms for finding minimum cost spanning
  13.278 -trees and arborescences.
  13.279 +This group contains the algorithms for discovering the graph properties
  13.280 +like connectivity, bipartiteness, euler property, simplicity etc.
  13.281 +
  13.282 +\image html connected_components.png
  13.283 +\image latex connected_components.eps "Connected components" width=\textwidth
  13.284 +*/
  13.285 +
  13.286 +/**
  13.287 +@defgroup planar Planarity Embedding and Drawing
  13.288 +@ingroup algs
  13.289 +\brief Algorithms for planarity checking, embedding and drawing
  13.290 +
  13.291 +This group contains the algorithms for planarity checking,
  13.292 +embedding and drawing.
  13.293 +
  13.294 +\image html planar.png
  13.295 +\image latex planar.eps "Plane graph" width=\textwidth
  13.296 +*/
  13.297 +
  13.298 +/**
  13.299 +@defgroup approx Approximation Algorithms
  13.300 +@ingroup algs
  13.301 +\brief Approximation algorithms.
  13.302 +
  13.303 +This group contains the approximation and heuristic algorithms
  13.304 +implemented in LEMON.
  13.305  */
  13.306  
  13.307  /**
  13.308 @@ -473,15 +569,6 @@
  13.309  */
  13.310  
  13.311  /**
  13.312 -@defgroup approx Approximation Algorithms
  13.313 -@ingroup algs
  13.314 -\brief Approximation algorithms.
  13.315 -
  13.316 -This group contains the approximation and heuristic algorithms
  13.317 -implemented in LEMON.
  13.318 -*/
  13.319 -
  13.320 -/**
  13.321  @defgroup gen_opt_group General Optimization Tools
  13.322  \brief This group contains some general optimization frameworks
  13.323  implemented in LEMON.
  13.324 @@ -491,13 +578,16 @@
  13.325  */
  13.326  
  13.327  /**
  13.328 -@defgroup lp_group Lp and Mip Solvers
  13.329 +@defgroup lp_group LP and MIP Solvers
  13.330  @ingroup gen_opt_group
  13.331 -\brief Lp and Mip solver interfaces for LEMON.
  13.332 +\brief LP and MIP solver interfaces for LEMON.
  13.333  
  13.334 -This group contains Lp and Mip solver interfaces for LEMON. The
  13.335 -various LP solvers could be used in the same manner with this
  13.336 -interface.
  13.337 +This group contains LP and MIP solver interfaces for LEMON.
  13.338 +Various LP solvers could be used in the same manner with this
  13.339 +high-level interface.
  13.340 +
  13.341 +The currently supported solvers are \ref glpk, \ref clp, \ref cbc,
  13.342 +\ref cplex, \ref soplex.
  13.343  */
  13.344  
  13.345  /**
  13.346 @@ -587,7 +677,7 @@
  13.347  */
  13.348  
  13.349  /**
  13.350 -@defgroup dimacs_group DIMACS format
  13.351 +@defgroup dimacs_group DIMACS Format
  13.352  @ingroup io_group
  13.353  \brief Read and write files in DIMACS format
  13.354  
  13.355 @@ -636,8 +726,8 @@
  13.356  @ingroup concept
  13.357  \brief Skeleton and concept checking classes for graph structures
  13.358  
  13.359 -This group contains the skeletons and concept checking classes of LEMON's
  13.360 -graph structures and helper classes used to implement these.
  13.361 +This group contains the skeletons and concept checking classes of
  13.362 +graph structures.
  13.363  */
  13.364  
  13.365  /**
  13.366 @@ -649,6 +739,15 @@
  13.367  */
  13.368  
  13.369  /**
  13.370 +@defgroup tools Standalone Utility Applications
  13.371 +
  13.372 +Some utility applications are listed here.
  13.373 +
  13.374 +The standard compilation procedure (<tt>./configure;make</tt>) will compile
  13.375 +them, as well.
  13.376 +*/
  13.377 +
  13.378 +/**
  13.379  \anchor demoprograms
  13.380  
  13.381  @defgroup demos Demo Programs
  13.382 @@ -660,13 +759,4 @@
  13.383  <tt>make check</tt> commands.
  13.384  */
  13.385  
  13.386 -/**
  13.387 -@defgroup tools Standalone Utility Applications
  13.388 -
  13.389 -Some utility applications are listed here.
  13.390 -
  13.391 -The standard compilation procedure (<tt>./configure;make</tt>) will compile
  13.392 -them, as well.
  13.393 -*/
  13.394 -
  13.395  }
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/doc/images/matching.eps	Sun Aug 11 15:28:12 2013 +0200
    14.3 @@ -0,0 +1,130 @@
    14.4 +%!PS-Adobe-2.0 EPSF-2.0
    14.5 +%%Creator: LEMON, graphToEps()
    14.6 +%%CreationDate: Sun Mar 14 09:08:34 2010
    14.7 +%%BoundingBox: -353 -264 559 292
    14.8 +%%EndComments
    14.9 +/lb { setlinewidth setrgbcolor newpath moveto
   14.10 +      4 2 roll 1 index 1 index curveto stroke } bind def
   14.11 +/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def
   14.12 +/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def
   14.13 +/sq { newpath 2 index 1 index add 2 index 2 index add moveto
   14.14 +      2 index 1 index sub 2 index 2 index add lineto
   14.15 +      2 index 1 index sub 2 index 2 index sub lineto
   14.16 +      2 index 1 index add 2 index 2 index sub lineto
   14.17 +      closepath pop pop pop} bind def
   14.18 +/di { newpath 2 index 1 index add 2 index moveto
   14.19 +      2 index             2 index 2 index add lineto
   14.20 +      2 index 1 index sub 2 index             lineto
   14.21 +      2 index             2 index 2 index sub lineto
   14.22 +      closepath pop pop pop} bind def
   14.23 +/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill
   14.24 +     setrgbcolor 1.1 div c fill
   14.25 +   } bind def
   14.26 +/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill
   14.27 +     setrgbcolor 1.1 div sq fill
   14.28 +   } bind def
   14.29 +/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill
   14.30 +     setrgbcolor 1.1 div di fill
   14.31 +   } bind def
   14.32 +/nfemale { 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   14.33 +  newpath 5 index 5 index moveto 5 index 5 index 5 index 3.01 mul sub
   14.34 +  lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto
   14.35 +  5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke
   14.36 +  5 index 5 index 5 index c fill
   14.37 +  setrgbcolor 1.1 div c fill
   14.38 +  } bind def
   14.39 +/nmale {
   14.40 +  0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   14.41 +  newpath 5 index 5 index moveto
   14.42 +  5 index 4 index 1 mul 1.5 mul add
   14.43 +  5 index 5 index 3 sqrt 1.5 mul mul add
   14.44 +  1 index 1 index lineto
   14.45 +  1 index 1 index 7 index sub moveto
   14.46 +  1 index 1 index lineto
   14.47 +  exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto
   14.48 +  stroke
   14.49 +  5 index 5 index 5 index c fill
   14.50 +  setrgbcolor 1.1 div c fill
   14.51 +  } bind def
   14.52 +/arrl 1 def
   14.53 +/arrw 0.3 def
   14.54 +/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def
   14.55 +/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def
   14.56 +       /w exch def /len exch def
   14.57 +       newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto
   14.58 +       len w sub arrl sub dx dy lrl
   14.59 +       arrw dy dx neg lrl
   14.60 +       dx arrl w add mul dy w 2 div arrw add mul sub
   14.61 +       dy arrl w add mul dx w 2 div arrw add mul add rlineto
   14.62 +       dx arrl w add mul neg dy w 2 div arrw add mul sub
   14.63 +       dy arrl w add mul neg dx w 2 div arrw add mul add rlineto
   14.64 +       arrw dy dx neg lrl
   14.65 +       len w sub arrl sub neg dx dy lrl
   14.66 +       closepath fill } bind def
   14.67 +/cshow { 2 index 2 index moveto dup stringwidth pop
   14.68 +         neg 2 div fosi .35 mul neg rmoveto show pop pop} def
   14.69 +
   14.70 +gsave
   14.71 +%Arcs:
   14.72 +gsave
   14.73 +140.321 266.249 -327.729 150.06 0 0 0 4.99223 l
   14.74 +82.1207 -238.726 -245.288 -110.743 0 0 0 4.99223 l
   14.75 +336.635 -229.036 533.603 13.109 0 0 0 4.99223 l
   14.76 +53.8598 -45.8071 -245.288 -110.743 0 0 0 4.99223 l
   14.77 +-75.5617 118.579 -327.729 150.06 0 0 0 4.99223 l
   14.78 +-327.729 150.06 -245.288 -110.743 1 0 0 11.9813 l
   14.79 +533.603 13.109 218.184 -84.2955 0 0 0 4.99223 l
   14.80 +39.87 175.035 141.163 67.2575 0 0 0 4.99223 l
   14.81 +53.8598 -45.8071 -75.5617 118.579 0 0 0 4.99223 l
   14.82 +-102.406 -141.267 82.1207 -238.726 0 0 0 4.99223 l
   14.83 +399.144 166.894 533.603 13.109 1 0 0 11.9813 l
   14.84 +39.87 175.035 140.321 266.249 1 0 0 11.9813 l
   14.85 +399.144 166.894 140.321 266.249 0 0 0 4.99223 l
   14.86 +399.144 166.894 141.163 67.2575 0 0 0 4.99223 l
   14.87 +53.8598 -45.8071 204.765 -173.77 0 0 0 4.99223 l
   14.88 +82.1207 -238.726 204.765 -173.77 0 0 0 4.99223 l
   14.89 +258.227 61.658 399.144 166.894 0 0 0 4.99223 l
   14.90 +53.8598 -45.8071 -102.406 -141.267 1 0 0 11.9813 l
   14.91 +175.073 -37.4477 141.163 67.2575 0 0 0 4.99223 l
   14.92 +258.227 61.658 380 0 0 0 0 4.99223 l
   14.93 +34.6739 40.8267 -75.5617 118.579 1 0 0 11.9813 l
   14.94 +380 0 533.603 13.109 0 0 0 4.99223 l
   14.95 +175.073 -37.4477 380 0 0 0 0 4.99223 l
   14.96 +218.184 -84.2955 204.765 -173.77 0 0 0 4.99223 l
   14.97 +53.8598 -45.8071 34.6739 40.8267 0 0 0 4.99223 l
   14.98 +167.905 -213.988 82.1207 -238.726 1 0 0 11.9813 l
   14.99 +336.635 -229.036 204.765 -173.77 1 0 0 11.9813 l
  14.100 +336.635 -229.036 167.905 -213.988 0 0 0 4.99223 l
  14.101 +329.08 -26.3098 218.184 -84.2955 0 0 0 4.99223 l
  14.102 +39.87 175.035 -75.5617 118.579 0 0 0 4.99223 l
  14.103 +53.8598 -45.8071 175.073 -37.4477 0 0 0 4.99223 l
  14.104 +34.6739 40.8267 141.163 67.2575 0 0 0 4.99223 l
  14.105 +258.227 61.658 141.163 67.2575 1 0 0 11.9813 l
  14.106 +175.073 -37.4477 218.184 -84.2955 1 0 0 11.9813 l
  14.107 +380 0 329.08 -26.3098 1 0 0 11.9813 l
  14.108 +grestore
  14.109 +%Nodes:
  14.110 +gsave
  14.111 +-245.288 -110.743 14.9767 1 1 1 nc
  14.112 +204.765 -173.77 14.9767 1 1 1 nc
  14.113 +-327.729 150.06 14.9767 1 1 1 nc
  14.114 +-75.5617 118.579 14.9767 1 1 1 nc
  14.115 +218.184 -84.2955 14.9767 1 1 1 nc
  14.116 +140.321 266.249 14.9767 1 1 1 nc
  14.117 +141.163 67.2575 14.9767 1 1 1 nc
  14.118 +82.1207 -238.726 14.9767 1 1 1 nc
  14.119 +329.08 -26.3098 14.9767 1 1 1 nc
  14.120 +-102.406 -141.267 14.9767 1 1 1 nc
  14.121 +533.603 13.109 14.9767 1 1 1 nc
  14.122 +167.905 -213.988 14.9767 1 1 1 nc
  14.123 +336.635 -229.036 14.9767 1 1 1 nc
  14.124 +380 0 14.9767 1 1 1 nc
  14.125 +399.144 166.894 14.9767 1 1 1 nc
  14.126 +34.6739 40.8267 14.9767 1 1 1 nc
  14.127 +39.87 175.035 14.9767 1 1 1 nc
  14.128 +175.073 -37.4477 14.9767 1 1 1 nc
  14.129 +53.8598 -45.8071 14.9767 1 1 1 nc
  14.130 +258.227 61.658 14.9767 1 1 1 nc
  14.131 +grestore
  14.132 +grestore
  14.133 +showpage
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/doc/images/planar.eps	Sun Aug 11 15:28:12 2013 +0200
    15.3 @@ -0,0 +1,181 @@
    15.4 +%!PS-Adobe-2.0 EPSF-2.0
    15.5 +%%Creator: LEMON, graphToEps()
    15.6 +%%CreationDate: Fri Oct 19 18:32:32 2007
    15.7 +%%BoundingBox: 0 0 596 842
    15.8 +%%DocumentPaperSizes: a4
    15.9 +%%EndComments
   15.10 +/lb { setlinewidth setrgbcolor newpath moveto
   15.11 +      4 2 roll 1 index 1 index curveto stroke } bind def
   15.12 +/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def
   15.13 +/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def
   15.14 +/sq { newpath 2 index 1 index add 2 index 2 index add moveto
   15.15 +      2 index 1 index sub 2 index 2 index add lineto
   15.16 +      2 index 1 index sub 2 index 2 index sub lineto
   15.17 +      2 index 1 index add 2 index 2 index sub lineto
   15.18 +      closepath pop pop pop} bind def
   15.19 +/di { newpath 2 index 1 index add 2 index moveto
   15.20 +      2 index             2 index 2 index add lineto
   15.21 +      2 index 1 index sub 2 index             lineto
   15.22 +      2 index             2 index 2 index sub lineto
   15.23 +      closepath pop pop pop} bind def
   15.24 +/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill
   15.25 +     setrgbcolor 1.1 div c fill
   15.26 +   } bind def
   15.27 +/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill
   15.28 +     setrgbcolor 1.1 div sq fill
   15.29 +   } bind def
   15.30 +/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill
   15.31 +     setrgbcolor 1.1 div di fill
   15.32 +   } bind def
   15.33 +/nfemale { 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   15.34 +  newpath 5 index 5 index moveto 5 index 5 index 5 index 3.01 mul sub
   15.35 +  lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto
   15.36 +  5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke
   15.37 +  5 index 5 index 5 index c fill
   15.38 +  setrgbcolor 1.1 div c fill
   15.39 +  } bind def
   15.40 +/nmale {
   15.41 +  0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   15.42 +  newpath 5 index 5 index moveto
   15.43 +  5 index 4 index 1 mul 1.5 mul add
   15.44 +  5 index 5 index 3 sqrt 1.5 mul mul add
   15.45 +  1 index 1 index lineto
   15.46 +  1 index 1 index 7 index sub moveto
   15.47 +  1 index 1 index lineto
   15.48 +  exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto
   15.49 +  stroke
   15.50 +  5 index 5 index 5 index c fill
   15.51 +  setrgbcolor 1.1 div c fill
   15.52 +  } bind def
   15.53 +/arrl 1 def
   15.54 +/arrw 0.3 def
   15.55 +/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def
   15.56 +/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def
   15.57 +       /w exch def /len exch def
   15.58 +       newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto
   15.59 +       len w sub arrl sub dx dy lrl
   15.60 +       arrw dy dx neg lrl
   15.61 +       dx arrl w add mul dy w 2 div arrw add mul sub
   15.62 +       dy arrl w add mul dx w 2 div arrw add mul add rlineto
   15.63 +       dx arrl w add mul neg dy w 2 div arrw add mul sub
   15.64 +       dy arrl w add mul neg dx w 2 div arrw add mul add rlineto
   15.65 +       arrw dy dx neg lrl
   15.66 +       len w sub arrl sub neg dx dy lrl
   15.67 +       closepath fill } bind def
   15.68 +/cshow { 2 index 2 index moveto dup stringwidth pop
   15.69 +         neg 2 div fosi .35 mul neg rmoveto show pop pop} def
   15.70 +
   15.71 +gsave
   15.72 +15 138.307 translate
   15.73 +12.7843 dup scale
   15.74 +90 rotate
   15.75 +0.608112 -43.6081 translate
   15.76 +%Edges:
   15.77 +gsave
   15.78 +9 31 9.5 30.5 10 30 0 0 0 0.091217 lb
   15.79 +9 31 5.5 34.5 2 38 0 0 0 0.091217 lb
   15.80 +9 31 25.5 16 42 1 0 0 0 0.091217 lb
   15.81 +3 40 23 20.5 43 1 0 0 0 0.091217 lb
   15.82 +3 40 22.5 20.5 42 1 0 0 0 0.091217 lb
   15.83 +3 40 2.5 40.5 2 41 0 0 0 0.091217 lb
   15.84 +13 25 10.5 24.5 8 24 0 0 0 0.091217 lb
   15.85 +13 25 12 27 11 29 0 0 0 0.091217 lb
   15.86 +3 4 2.5 3 2 2 0 0 0 0.091217 lb
   15.87 +3 4 4.5 3 6 2 0 0 0 0.091217 lb
   15.88 +6 25 7 24.5 8 24 0 0 0 0.091217 lb
   15.89 +6 25 6 24.5 6 24 0 0 0 0.091217 lb
   15.90 +34 2 33.5 2 33 2 0 0 0 0.091217 lb
   15.91 +34 2 35 2 36 2 0 0 0 0.091217 lb
   15.92 +6 8 16 9 26 10 0 0 0 0.091217 lb
   15.93 +6 8 6 10.5 6 13 0 0 0 0.091217 lb
   15.94 +6 8 6 7.5 6 7 0 0 0 0.091217 lb
   15.95 +26 10 27.5 8.5 29 7 0 0 0 0.091217 lb
   15.96 +26 10 27.5 9 29 8 0 0 0 0.091217 lb
   15.97 +10 30 10.5 29.5 11 29 0 0 0 0.091217 lb
   15.98 +8 24 7 23.5 6 23 0 0 0 0.091217 lb
   15.99 +8 24 8 24.5 8 25 0 0 0 0.091217 lb
  15.100 +33 2 32.5 2 32 2 0 0 0 0.091217 lb
  15.101 +29 7 17.5 7 6 7 0 0 0 0.091217 lb
  15.102 +2 2 1.5 22 1 42 0 0 0 0.091217 lb
  15.103 +2 2 3.5 2 5 2 0 0 0 0.091217 lb
  15.104 +21 15 13.5 14.5 6 14 0 0 0 0.091217 lb
  15.105 +21 15 21 15.5 21 16 0 0 0 0.091217 lb
  15.106 +1 42 0.5 42.5 0 43 0 0 0 0.091217 lb
  15.107 +1 42 1.5 41.5 2 41 0 0 0 0.091217 lb
  15.108 +6 15 6 15.5 6 16 0 0 0 0.091217 lb
  15.109 +6 15 6 14.5 6 14 0 0 0 0.091217 lb
  15.110 +43 1 22 0.5 1 0 0 0 0 0.091217 lb
  15.111 +31 2 18.5 2 6 2 0 0 0 0.091217 lb
  15.112 +31 2 31.5 2 32 2 0 0 0 0.091217 lb
  15.113 +6 24 6 23.5 6 23 0 0 0 0.091217 lb
  15.114 +6 16 6 16.5 6 17 0 0 0 0.091217 lb
  15.115 +6 23 6 20 6 17 0 0 0 0.091217 lb
  15.116 +6 2 5.5 2 5 2 0 0 0 0.091217 lb
  15.117 +6 2 6 4.5 6 7 0 0 0 0.091217 lb
  15.118 +0 43 0.5 21.5 1 0 0 0 0 0.091217 lb
  15.119 +1 1 19.5 1.5 38 2 0 0 0 0.091217 lb
  15.120 +1 1 1 0.5 1 0 0 0 0 0.091217 lb
  15.121 +2 38 5.5 31.5 9 25 0 0 0 0.091217 lb
  15.122 +25 13 15.5 13 6 13 0 0 0 0.091217 lb
  15.123 +25 13 15.5 13.5 6 14 0 0 0 0.091217 lb
  15.124 +8 25 8.5 25 9 25 0 0 0 0.091217 lb
  15.125 +11 29 24.5 15.5 38 2 0 0 0 0.091217 lb
  15.126 +6 17 11.5 18 17 19 0 0 0 0.091217 lb
  15.127 +16 23 26.5 12.5 37 2 0 0 0 0.091217 lb
  15.128 +16 23 18.5 19.5 21 16 0 0 0 0.091217 lb
  15.129 +36 2 36.5 2 37 2 0 0 0 0.091217 lb
  15.130 +36 2 32.5 5 29 8 0 0 0 0.091217 lb
  15.131 +6 13 6 13.5 6 14 0 0 0 0.091217 lb
  15.132 +37 2 37.5 2 38 2 0 0 0 0.091217 lb
  15.133 +21 16 19 17.5 17 19 0 0 0 0.091217 lb
  15.134 +grestore
  15.135 +%Nodes:
  15.136 +gsave
  15.137 +29 8 0.304556 1 1 1 nc
  15.138 +2 41 0.304556 1 1 1 nc
  15.139 +6 7 0.304556 1 1 1 nc
  15.140 +5 2 0.304556 1 1 1 nc
  15.141 +17 19 0.304556 1 1 1 nc
  15.142 +21 16 0.304556 1 1 1 nc
  15.143 +1 0 0.304556 1 1 1 nc
  15.144 +9 25 0.304556 1 1 1 nc
  15.145 +6 14 0.304556 1 1 1 nc
  15.146 +42 1 0.304556 1 1 1 nc
  15.147 +38 2 0.304556 1 1 1 nc
  15.148 +37 2 0.304556 1 1 1 nc
  15.149 +6 13 0.304556 1 1 1 nc
  15.150 +36 2 0.304556 1 1 1 nc
  15.151 +16 23 0.304556 1 1 1 nc
  15.152 +6 17 0.304556 1 1 1 nc
  15.153 +11 29 0.304556 1 1 1 nc
  15.154 +8 25 0.304556 1 1 1 nc
  15.155 +32 2 0.304556 1 1 1 nc
  15.156 +25 13 0.304556 1 1 1 nc
  15.157 +2 38 0.304556 1 1 1 nc
  15.158 +1 1 0.304556 1 1 1 nc
  15.159 +0 43 0.304556 1 1 1 nc
  15.160 +6 2 0.304556 1 1 1 nc
  15.161 +6 23 0.304556 1 1 1 nc
  15.162 +6 16 0.304556 1 1 1 nc
  15.163 +6 24 0.304556 1 1 1 nc
  15.164 +31 2 0.304556 1 1 1 nc
  15.165 +43 1 0.304556 1 1 1 nc
  15.166 +6 15 0.304556 1 1 1 nc
  15.167 +1 42 0.304556 1 1 1 nc
  15.168 +21 15 0.304556 1 1 1 nc
  15.169 +2 2 0.304556 1 1 1 nc
  15.170 +29 7 0.304556 1 1 1 nc
  15.171 +33 2 0.304556 1 1 1 nc
  15.172 +8 24 0.304556 1 1 1 nc
  15.173 +10 30 0.304556 1 1 1 nc
  15.174 +26 10 0.304556 1 1 1 nc
  15.175 +6 8 0.304556 1 1 1 nc
  15.176 +34 2 0.304556 1 1 1 nc
  15.177 +6 25 0.304556 1 1 1 nc
  15.178 +3 4 0.304556 1 1 1 nc
  15.179 +13 25 0.304556 1 1 1 nc
  15.180 +3 40 0.304556 1 1 1 nc
  15.181 +9 31 0.304556 1 1 1 nc
  15.182 +grestore
  15.183 +grestore
  15.184 +showpage
    16.1 --- a/doc/mainpage.dox.in	Fri Aug 09 11:07:27 2013 +0200
    16.2 +++ b/doc/mainpage.dox.in	Sun Aug 11 15:28:12 2013 +0200
    16.3 @@ -2,7 +2,7 @@
    16.4   *
    16.5   * This file is a part of LEMON, a generic C++ optimization library.
    16.6   *
    16.7 - * Copyright (C) 2003-2009
    16.8 + * Copyright (C) 2003-2010
    16.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   16.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   16.11   *
   16.12 @@ -21,14 +21,11 @@
   16.13  
   16.14  \section intro Introduction
   16.15  
   16.16 -\subsection whatis What is LEMON
   16.17 -
   16.18 -LEMON stands for <b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
   16.19 -and <b>O</b>ptimization in <b>N</b>etworks.
   16.20 -It is a C++ template
   16.21 -library aimed at combinatorial optimization tasks which
   16.22 -often involve in working
   16.23 -with graphs.
   16.24 +<b>LEMON</b> stands for <i><b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
   16.25 +and <b>O</b>ptimization in <b>N</b>etworks</i>.
   16.26 +It is a C++ template library providing efficient implementations of common
   16.27 +data structures and algorithms with focus on combinatorial optimization
   16.28 +tasks connected mainly with graphs and networks.
   16.29  
   16.30  <b>
   16.31  LEMON is an <a class="el" href="http://opensource.org/">open&nbsp;source</a>
   16.32 @@ -38,11 +35,24 @@
   16.33  \ref license "license terms".
   16.34  </b>
   16.35  
   16.36 -\subsection howtoread How to read the documentation
   16.37 +The project is maintained by the
   16.38 +<a href="http://www.cs.elte.hu/egres/">Egerv&aacute;ry Research Group on
   16.39 +Combinatorial Optimization</a> \ref egres
   16.40 +at the Operations Research Department of the
   16.41 +<a href="http://www.elte.hu/en/">E&ouml;tv&ouml;s Lor&aacute;nd University</a>,
   16.42 +Budapest, Hungary.
   16.43 +LEMON is also a member of the <a href="http://www.coin-or.org/">COIN-OR</a>
   16.44 +initiative \ref coinor.
   16.45 +
   16.46 +\section howtoread How to Read the Documentation
   16.47  
   16.48  If you would like to get to know the library, see
   16.49  <a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>.
   16.50  
   16.51 +If you are interested in starting to use the library, see the <a class="el"
   16.52 +href="http://lemon.cs.elte.hu/trac/lemon/wiki/InstallGuide/">Installation
   16.53 +Guide</a>.
   16.54 +
   16.55  If you know what you are looking for, then try to find it under the
   16.56  <a class="el" href="modules.html">Modules</a> section.
   16.57  
    17.1 --- a/doc/min_cost_flow.dox	Fri Aug 09 11:07:27 2013 +0200
    17.2 +++ b/doc/min_cost_flow.dox	Sun Aug 11 15:28:12 2013 +0200
    17.3 @@ -2,7 +2,7 @@
    17.4   *
    17.5   * This file is a part of LEMON, a generic C++ optimization library.
    17.6   *
    17.7 - * Copyright (C) 2003-2009
    17.8 + * Copyright (C) 2003-2010
    17.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   17.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   17.11   *
   17.12 @@ -26,7 +26,7 @@
   17.13  The \e minimum \e cost \e flow \e problem is to find a feasible flow of
   17.14  minimum total cost from a set of supply nodes to a set of demand nodes
   17.15  in a network with capacity constraints (lower and upper bounds)
   17.16 -and arc costs.
   17.17 +and arc costs \ref amo93networkflows.
   17.18  
   17.19  Formally, let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$,
   17.20  \f$upper: A\rightarrow\mathbf{R}\cup\{+\infty\}\f$ denote the lower and
   17.21 @@ -78,10 +78,10 @@
   17.22     - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$;
   17.23     - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$.
   17.24   - For all \f$u\in V\f$ nodes:
   17.25 -   - \f$\pi(u)<=0\f$;
   17.26 +   - \f$\pi(u)\leq 0\f$;
   17.27     - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$,
   17.28       then \f$\pi(u)=0\f$.
   17.29 - 
   17.30 +
   17.31  Here \f$cost^\pi(uv)\f$ denotes the \e reduced \e cost of the arc
   17.32  \f$uv\in A\f$ with respect to the potential function \f$\pi\f$, i.e.
   17.33  \f[ cost^\pi(uv) = cost(uv) + \pi(u) - \pi(v).\f]
   17.34 @@ -119,7 +119,7 @@
   17.35      sup(u) \quad \forall u\in V \f]
   17.36  \f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f]
   17.37  
   17.38 -It means that the total demand must be less or equal to the 
   17.39 +It means that the total demand must be less or equal to the
   17.40  total supply (i.e. \f$\sum_{u\in V} sup(u)\f$ must be zero or
   17.41  positive) and all the demands have to be satisfied, but there
   17.42  could be supplies that are not carried out from the supply
   17.43 @@ -145,7 +145,7 @@
   17.44     - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$;
   17.45     - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$.
   17.46   - For all \f$u\in V\f$ nodes:
   17.47 -   - \f$\pi(u)>=0\f$;
   17.48 +   - \f$\pi(u)\geq 0\f$;
   17.49     - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$,
   17.50       then \f$\pi(u)=0\f$.
   17.51  
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/doc/references.bib	Sun Aug 11 15:28:12 2013 +0200
    18.3 @@ -0,0 +1,301 @@
    18.4 +%%%%% Defining LEMON %%%%%
    18.5 +
    18.6 +@misc{lemon,
    18.7 +  key =          {LEMON},
    18.8 +  title =        {{LEMON} -- {L}ibrary for {E}fficient {M}odeling and
    18.9 +                  {O}ptimization in {N}etworks},
   18.10 +  howpublished = {\url{http://lemon.cs.elte.hu/}},
   18.11 +  year =         2009
   18.12 +}
   18.13 +
   18.14 +@misc{egres,
   18.15 +  key =          {EGRES},
   18.16 +  title =        {{EGRES} -- {E}gerv{\'a}ry {R}esearch {G}roup on
   18.17 +                  {C}ombinatorial {O}ptimization},
   18.18 +  url =          {http://www.cs.elte.hu/egres/}
   18.19 +}
   18.20 +
   18.21 +@misc{coinor,
   18.22 +  key =          {COIN-OR},
   18.23 +  title =        {{COIN-OR} -- {C}omputational {I}nfrastructure for
   18.24 +                  {O}perations {R}esearch},
   18.25 +  url =          {http://www.coin-or.org/}
   18.26 +}
   18.27 +
   18.28 +
   18.29 +%%%%% Other libraries %%%%%%
   18.30 +
   18.31 +@misc{boost,
   18.32 +  key =          {Boost},
   18.33 +  title =        {{B}oost {C++} {L}ibraries},
   18.34 +  url =          {http://www.boost.org/}
   18.35 +}
   18.36 +
   18.37 +@book{bglbook,
   18.38 +  author =       {Jeremy G. Siek and Lee-Quan Lee and Andrew
   18.39 +                  Lumsdaine},
   18.40 +  title =        {The Boost Graph Library: User Guide and Reference
   18.41 +                  Manual},
   18.42 +  publisher =    {Addison-Wesley},
   18.43 +  year =         2002
   18.44 +}
   18.45 +
   18.46 +@misc{leda,
   18.47 +  key =          {LEDA},
   18.48 +  title =        {{LEDA} -- {L}ibrary of {E}fficient {D}ata {T}ypes and
   18.49 +                  {A}lgorithms},
   18.50 +  url =          {http://www.algorithmic-solutions.com/}
   18.51 +}
   18.52 +
   18.53 +@book{ledabook,
   18.54 +  author =       {Kurt Mehlhorn and Stefan N{\"a}her},
   18.55 +  title =        {{LEDA}: {A} platform for combinatorial and geometric
   18.56 +                  computing},
   18.57 +  isbn =         {0-521-56329-1},
   18.58 +  publisher =    {Cambridge University Press},
   18.59 +  address =      {New York, NY, USA},
   18.60 +  year =         1999
   18.61 +}
   18.62 +
   18.63 +
   18.64 +%%%%% Tools that LEMON depends on %%%%%
   18.65 +
   18.66 +@misc{cmake,
   18.67 +  key =          {CMake},
   18.68 +  title =        {{CMake} -- {C}ross {P}latform {M}ake},
   18.69 +  url =          {http://www.cmake.org/}
   18.70 +}
   18.71 +
   18.72 +@misc{doxygen,
   18.73 +  key =          {Doxygen},
   18.74 +  title =        {{Doxygen} -- {S}ource code documentation generator
   18.75 +                  tool},
   18.76 +  url =          {http://www.doxygen.org/}
   18.77 +}
   18.78 +
   18.79 +
   18.80 +%%%%% LP/MIP libraries %%%%%
   18.81 +
   18.82 +@misc{glpk,
   18.83 +  key =          {GLPK},
   18.84 +  title =        {{GLPK} -- {GNU} {L}inear {P}rogramming {K}it},
   18.85 +  url =          {http://www.gnu.org/software/glpk/}
   18.86 +}
   18.87 +
   18.88 +@misc{clp,
   18.89 +  key =          {Clp},
   18.90 +  title =        {{Clp} -- {Coin-Or} {L}inear {P}rogramming},
   18.91 +  url =          {http://projects.coin-or.org/Clp/}
   18.92 +}
   18.93 +
   18.94 +@misc{cbc,
   18.95 +  key =          {Cbc},
   18.96 +  title =        {{Cbc} -- {Coin-Or} {B}ranch and {C}ut},
   18.97 +  url =          {http://projects.coin-or.org/Cbc/}
   18.98 +}
   18.99 +
  18.100 +@misc{cplex,
  18.101 +  key =          {CPLEX},
  18.102 +  title =        {{ILOG} {CPLEX}},
  18.103 +  url =          {http://www.ilog.com/}
  18.104 +}
  18.105 +
  18.106 +@misc{soplex,
  18.107 +  key =          {SoPlex},
  18.108 +  title =        {{SoPlex} -- {T}he {S}equential {O}bject-{O}riented
  18.109 +                  {S}implex},
  18.110 +  url =          {http://soplex.zib.de/}
  18.111 +}
  18.112 +
  18.113 +
  18.114 +%%%%% General books %%%%%
  18.115 +
  18.116 +@book{amo93networkflows,
  18.117 +  author =       {Ravindra K. Ahuja and Thomas L. Magnanti and James
  18.118 +                  B. Orlin},
  18.119 +  title =        {Network Flows: Theory, Algorithms, and Applications},
  18.120 +  publisher =    {Prentice-Hall, Inc.},
  18.121 +  year =         1993,
  18.122 +  month =        feb,
  18.123 +  isbn =         {978-0136175490}
  18.124 +}
  18.125 +
  18.126 +@book{schrijver03combinatorial,
  18.127 +  author =       {Alexander Schrijver},
  18.128 +  title =        {Combinatorial Optimization: Polyhedra and Efficiency},
  18.129 +  publisher =    {Springer-Verlag},
  18.130 +  year =         2003,
  18.131 +  isbn =         {978-3540443896}
  18.132 +}
  18.133 +
  18.134 +@book{clrs01algorithms,
  18.135 +  author =       {Thomas H. Cormen and Charles E. Leiserson and Ronald
  18.136 +                  L. Rivest and Clifford Stein},
  18.137 +  title =        {Introduction to Algorithms},
  18.138 +  publisher =    {The MIT Press},
  18.139 +  year =         2001,
  18.140 +  edition =      {2nd}
  18.141 +}
  18.142 +
  18.143 +@book{stroustrup00cpp,
  18.144 +  author =       {Bjarne Stroustrup},
  18.145 +  title =        {The C++ Programming Language},
  18.146 +  edition =      {3rd},
  18.147 +  publisher =    {Addison-Wesley Professional},
  18.148 +  isbn =         0201700735,
  18.149 +  month =        {February},
  18.150 +  year =         2000
  18.151 +}
  18.152 +
  18.153 +
  18.154 +%%%%% Maximum flow algorithms %%%%%
  18.155 +
  18.156 +@article{edmondskarp72theoretical,
  18.157 +  author =       {Jack Edmonds and Richard M. Karp},
  18.158 +  title =        {Theoretical improvements in algorithmic efficiency
  18.159 +                  for network flow problems},
  18.160 +  journal =      {Journal of the ACM},
  18.161 +  year =         1972,
  18.162 +  volume =       19,
  18.163 +  number =       2,
  18.164 +  pages =        {248-264}
  18.165 +}
  18.166 +
  18.167 +@article{goldberg88newapproach,
  18.168 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  18.169 +  title =        {A new approach to the maximum flow problem},
  18.170 +  journal =      {Journal of the ACM},
  18.171 +  year =         1988,
  18.172 +  volume =       35,
  18.173 +  number =       4,
  18.174 +  pages =        {921-940}
  18.175 +}
  18.176 +
  18.177 +@article{dinic70algorithm,
  18.178 +  author =       {E. A. Dinic},
  18.179 +  title =        {Algorithm for solution of a problem of maximum flow
  18.180 +                  in a network with power estimation},
  18.181 +  journal =      {Soviet Math. Doklady},
  18.182 +  year =         1970,
  18.183 +  volume =       11,
  18.184 +  pages =        {1277-1280}
  18.185 +}
  18.186 +
  18.187 +@article{goldberg08partial,
  18.188 +  author =       {Andrew V. Goldberg},
  18.189 +  title =        {The Partial Augment-Relabel Algorithm for the
  18.190 +                  Maximum Flow Problem},
  18.191 +  journal =      {16th Annual European Symposium on Algorithms},
  18.192 +  year =         2008,
  18.193 +  pages =        {466-477}
  18.194 +}
  18.195 +
  18.196 +@article{sleator83dynamic,
  18.197 +  author =       {Daniel D. Sleator and Robert E. Tarjan},
  18.198 +  title =        {A data structure for dynamic trees},
  18.199 +  journal =      {Journal of Computer and System Sciences},
  18.200 +  year =         1983,
  18.201 +  volume =       26,
  18.202 +  number =       3,
  18.203 +  pages =        {362-391}
  18.204 +}
  18.205 +
  18.206 +
  18.207 +%%%%% Minimum mean cycle algorithms %%%%%
  18.208 +
  18.209 +@article{karp78characterization,
  18.210 +  author =       {Richard M. Karp},
  18.211 +  title =        {A characterization of the minimum cycle mean in a
  18.212 +                  digraph},
  18.213 +  journal =      {Discrete Math.},
  18.214 +  year =         1978,
  18.215 +  volume =       23,
  18.216 +  pages =        {309-311}
  18.217 +}
  18.218 +
  18.219 +@article{dasdan98minmeancycle,
  18.220 +  author =       {Ali Dasdan and Rajesh K. Gupta},
  18.221 +  title =        {Faster Maximum and Minimum Mean Cycle Alogrithms for
  18.222 +                  System Performance Analysis},
  18.223 +  journal =      {IEEE Transactions on Computer-Aided Design of
  18.224 +                  Integrated Circuits and Systems},
  18.225 +  year =         1998,
  18.226 +  volume =       17,
  18.227 +  number =       10,
  18.228 +  pages =        {889-899}
  18.229 +}
  18.230 +
  18.231 +
  18.232 +%%%%% Minimum cost flow algorithms %%%%%
  18.233 +
  18.234 +@article{klein67primal,
  18.235 +  author =       {Morton Klein},
  18.236 +  title =        {A primal method for minimal cost flows with
  18.237 +                  applications to the assignment and transportation
  18.238 +                  problems},
  18.239 +  journal =      {Management Science},
  18.240 +  year =         1967,
  18.241 +  volume =       14,
  18.242 +  pages =        {205-220}
  18.243 +}
  18.244 +
  18.245 +@article{goldberg89cyclecanceling,
  18.246 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  18.247 +  title =        {Finding minimum-cost circulations by canceling
  18.248 +                  negative cycles},
  18.249 +  journal =      {Journal of the ACM},
  18.250 +  year =         1989,
  18.251 +  volume =       36,
  18.252 +  number =       4,
  18.253 +  pages =        {873-886}
  18.254 +}
  18.255 +
  18.256 +@article{goldberg90approximation,
  18.257 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  18.258 +  title =        {Finding Minimum-Cost Circulations by Successive
  18.259 +                  Approximation},
  18.260 +  journal =      {Mathematics of Operations Research},
  18.261 +  year =         1990,
  18.262 +  volume =       15,
  18.263 +  number =       3,
  18.264 +  pages =        {430-466}
  18.265 +}
  18.266 +
  18.267 +@article{goldberg97efficient,
  18.268 +  author =       {Andrew V. Goldberg},
  18.269 +  title =        {An Efficient Implementation of a Scaling
  18.270 +                  Minimum-Cost Flow Algorithm},
  18.271 +  journal =      {Journal of Algorithms},
  18.272 +  year =         1997,
  18.273 +  volume =       22,
  18.274 +  number =       1,
  18.275 +  pages =        {1-29}
  18.276 +}
  18.277 +
  18.278 +@article{bunnagel98efficient,
  18.279 +  author =       {Ursula B{\"u}nnagel and Bernhard Korte and Jens
  18.280 +                  Vygen},
  18.281 +  title =        {Efficient implementation of the {G}oldberg-{T}arjan
  18.282 +                  minimum-cost flow algorithm},
  18.283 +  journal =      {Optimization Methods and Software},
  18.284 +  year =         1998,
  18.285 +  volume =       10,
  18.286 +  pages =        {157-174}
  18.287 +}
  18.288 +
  18.289 +@book{dantzig63linearprog,
  18.290 +  author =       {George B. Dantzig},
  18.291 +  title =        {Linear Programming and Extensions},
  18.292 +  publisher =    {Princeton University Press},
  18.293 +  year =         1963
  18.294 +}
  18.295 +
  18.296 +@mastersthesis{kellyoneill91netsimplex,
  18.297 +  author =       {Damian J. Kelly and Garrett M. O'Neill},
  18.298 +  title =        {The Minimum Cost Flow Problem and The Network
  18.299 +                  Simplex Method},
  18.300 +  school =       {University College},
  18.301 +  address =      {Dublin, Ireland},
  18.302 +  year =         1991,
  18.303 +  month =        sep,
  18.304 +}
    19.1 --- a/lemon/Makefile.am	Fri Aug 09 11:07:27 2013 +0200
    19.2 +++ b/lemon/Makefile.am	Sun Aug 11 15:28:12 2013 +0200
    19.3 @@ -58,19 +58,25 @@
    19.4  	lemon/adaptors.h \
    19.5  	lemon/arg_parser.h \
    19.6  	lemon/assert.h \
    19.7 +	lemon/bellman_ford.h \
    19.8  	lemon/bfs.h \
    19.9  	lemon/bin_heap.h \
   19.10 +	lemon/binomial_heap.h \
   19.11  	lemon/bucket_heap.h \
   19.12 +	lemon/capacity_scaling.h \
   19.13  	lemon/cbc.h \
   19.14  	lemon/circulation.h \
   19.15  	lemon/clp.h \
   19.16  	lemon/color.h \
   19.17  	lemon/concept_check.h \
   19.18  	lemon/connectivity.h \
   19.19 +	lemon/core.h \
   19.20 +	lemon/cost_scaling.h \
   19.21  	lemon/counter.h \
   19.22 -	lemon/core.h \
   19.23  	lemon/cplex.h \
   19.24 +	lemon/cycle_canceling.h \
   19.25  	lemon/dfs.h \
   19.26 +	lemon/dheap.h \
   19.27  	lemon/dijkstra.h \
   19.28  	lemon/dim2.h \
   19.29  	lemon/dimacs.h \
   19.30 @@ -79,12 +85,16 @@
   19.31  	lemon/error.h \
   19.32  	lemon/euler.h \
   19.33  	lemon/fib_heap.h \
   19.34 +	lemon/fractional_matching.h \
   19.35  	lemon/full_graph.h \
   19.36  	lemon/glpk.h \
   19.37  	lemon/gomory_hu.h \
   19.38  	lemon/graph_to_eps.h \
   19.39  	lemon/grid_graph.h \
   19.40 +	lemon/hartmann_orlin_mmc.h \
   19.41 +	lemon/howard_mmc.h \
   19.42  	lemon/hypercube_graph.h \
   19.43 +	lemon/karp_mmc.h \
   19.44  	lemon/kruskal.h \
   19.45  	lemon/hao_orlin.h \
   19.46  	lemon/lgf_reader.h \
   19.47 @@ -99,13 +109,17 @@
   19.48  	lemon/min_cost_arborescence.h \
   19.49  	lemon/nauty_reader.h \
   19.50  	lemon/network_simplex.h \
   19.51 +	lemon/pairing_heap.h \
   19.52  	lemon/path.h \
   19.53 +	lemon/planarity.h \
   19.54  	lemon/preflow.h \
   19.55 +	lemon/quad_heap.h \
   19.56  	lemon/radix_heap.h \
   19.57  	lemon/radix_sort.h \
   19.58  	lemon/random.h \
   19.59  	lemon/smart_graph.h \
   19.60  	lemon/soplex.h \
   19.61 +	lemon/static_graph.h \
   19.62  	lemon/suurballe.h \
   19.63  	lemon/time_measure.h \
   19.64  	lemon/tolerance.h \
    20.1 --- a/lemon/adaptors.h	Fri Aug 09 11:07:27 2013 +0200
    20.2 +++ b/lemon/adaptors.h	Sun Aug 11 15:28:12 2013 +0200
    20.3 @@ -2,7 +2,7 @@
    20.4   *
    20.5   * This file is a part of LEMON, a generic C++ optimization library.
    20.6   *
    20.7 - * Copyright (C) 2003-2009
    20.8 + * Copyright (C) 2003-2010
    20.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   20.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   20.11   *
   20.12 @@ -360,6 +360,9 @@
   20.13    /// by adding or removing nodes or arcs, unless the \c GR template
   20.14    /// parameter is set to be \c const.
   20.15    ///
   20.16 +  /// This class provides item counting in the same time as the adapted
   20.17 +  /// digraph structure.
   20.18 +  ///
   20.19    /// \tparam DGR The type of the adapted digraph.
   20.20    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
   20.21    /// It can also be specified to be \c const.
   20.22 @@ -418,7 +421,7 @@
   20.23      void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
   20.24        Parent::initialize(digraph);
   20.25        _node_filter = &node_filter;
   20.26 -      _arc_filter = &arc_filter;      
   20.27 +      _arc_filter = &arc_filter;
   20.28      }
   20.29  
   20.30    public:
   20.31 @@ -505,11 +508,11 @@
   20.32    public:
   20.33  
   20.34      template <typename V>
   20.35 -    class NodeMap 
   20.36 -      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 
   20.37 -	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
   20.38 +    class NodeMap
   20.39 +      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   20.40 +              LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
   20.41        typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   20.42 -	LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
   20.43 +        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
   20.44  
   20.45      public:
   20.46        typedef V Value;
   20.47 @@ -532,9 +535,9 @@
   20.48      };
   20.49  
   20.50      template <typename V>
   20.51 -    class ArcMap 
   20.52 +    class ArcMap
   20.53        : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   20.54 -	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
   20.55 +              LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
   20.56        typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   20.57          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
   20.58  
   20.59 @@ -579,7 +582,7 @@
   20.60      void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
   20.61        Parent::initialize(digraph);
   20.62        _node_filter = &node_filter;
   20.63 -      _arc_filter = &arc_filter;      
   20.64 +      _arc_filter = &arc_filter;
   20.65      }
   20.66  
   20.67    public:
   20.68 @@ -648,10 +651,10 @@
   20.69      }
   20.70  
   20.71      template <typename V>
   20.72 -    class NodeMap 
   20.73 +    class NodeMap
   20.74        : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   20.75            LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
   20.76 -      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 
   20.77 +      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   20.78          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
   20.79  
   20.80      public:
   20.81 @@ -675,7 +678,7 @@
   20.82      };
   20.83  
   20.84      template <typename V>
   20.85 -    class ArcMap 
   20.86 +    class ArcMap
   20.87        : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   20.88            LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
   20.89        typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   20.90 @@ -719,6 +722,8 @@
   20.91    /// by adding or removing nodes or arcs, unless the \c GR template
   20.92    /// parameter is set to be \c const.
   20.93    ///
   20.94 +  /// This class provides only linear time counting for nodes and arcs.
   20.95 +  ///
   20.96    /// \tparam DGR The type of the adapted digraph.
   20.97    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
   20.98    /// It can also be specified to be \c const.
   20.99 @@ -1016,10 +1021,10 @@
  20.100      }
  20.101  
  20.102      template <typename V>
  20.103 -    class NodeMap 
  20.104 +    class NodeMap
  20.105        : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  20.106            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
  20.107 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
  20.108 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  20.109          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
  20.110  
  20.111      public:
  20.112 @@ -1043,10 +1048,10 @@
  20.113      };
  20.114  
  20.115      template <typename V>
  20.116 -    class ArcMap 
  20.117 +    class ArcMap
  20.118        : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  20.119            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
  20.120 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
  20.121 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  20.122          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
  20.123  
  20.124      public:
  20.125 @@ -1070,10 +1075,10 @@
  20.126      };
  20.127  
  20.128      template <typename V>
  20.129 -    class EdgeMap 
  20.130 +    class EdgeMap
  20.131        : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  20.132          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
  20.133 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
  20.134 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  20.135          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
  20.136  
  20.137      public:
  20.138 @@ -1112,8 +1117,8 @@
  20.139    protected:
  20.140      NF* _node_filter;
  20.141      EF* _edge_filter;
  20.142 -    SubGraphBase() 
  20.143 -	  : Parent(), _node_filter(0), _edge_filter(0) { }
  20.144 +    SubGraphBase()
  20.145 +          : Parent(), _node_filter(0), _edge_filter(0) { }
  20.146  
  20.147      void initialize(GR& graph, NF& node_filter, EF& edge_filter) {
  20.148        Parent::initialize(graph);
  20.149 @@ -1214,10 +1219,10 @@
  20.150      }
  20.151  
  20.152      template <typename V>
  20.153 -    class NodeMap 
  20.154 +    class NodeMap
  20.155        : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  20.156            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
  20.157 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
  20.158 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  20.159          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
  20.160  
  20.161      public:
  20.162 @@ -1241,10 +1246,10 @@
  20.163      };
  20.164  
  20.165      template <typename V>
  20.166 -    class ArcMap 
  20.167 +    class ArcMap
  20.168        : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  20.169            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
  20.170 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
  20.171 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  20.172          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
  20.173  
  20.174      public:
  20.175 @@ -1268,11 +1273,11 @@
  20.176      };
  20.177  
  20.178      template <typename V>
  20.179 -    class EdgeMap 
  20.180 +    class EdgeMap
  20.181        : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  20.182          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
  20.183 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
  20.184 -	LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
  20.185 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  20.186 +        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
  20.187  
  20.188      public:
  20.189        typedef V Value;
  20.190 @@ -1314,6 +1319,8 @@
  20.191    /// by adding or removing nodes or edges, unless the \c GR template
  20.192    /// parameter is set to be \c const.
  20.193    ///
  20.194 +  /// This class provides only linear time counting for nodes, edges and arcs.
  20.195 +  ///
  20.196    /// \tparam GR The type of the adapted graph.
  20.197    /// It must conform to the \ref concepts::Graph "Graph" concept.
  20.198    /// It can also be specified to be \c const.
  20.199 @@ -1471,6 +1478,8 @@
  20.200    /// by adding or removing nodes or arcs/edges, unless the \c GR template
  20.201    /// parameter is set to be \c const.
  20.202    ///
  20.203 +  /// This class provides only linear time item counting.
  20.204 +  ///
  20.205    /// \tparam GR The type of the adapted digraph or graph.
  20.206    /// It must conform to the \ref concepts::Digraph "Digraph" concept
  20.207    /// or the \ref concepts::Graph "Graph" concept.
  20.208 @@ -1495,7 +1504,7 @@
  20.209                       true> > {
  20.210  #endif
  20.211      typedef DigraphAdaptorExtender<
  20.212 -      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 
  20.213 +      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >,
  20.214                       true> > Parent;
  20.215  
  20.216    public:
  20.217 @@ -1516,7 +1525,7 @@
  20.218      ///
  20.219      /// Creates a subgraph for the given digraph or graph with the
  20.220      /// given node filter map.
  20.221 -    FilterNodes(GR& graph, NF& node_filter) 
  20.222 +    FilterNodes(GR& graph, NF& node_filter)
  20.223        : Parent(), const_true_map()
  20.224      {
  20.225        Parent::initialize(graph, node_filter, const_true_map);
  20.226 @@ -1554,11 +1563,11 @@
  20.227    class FilterNodes<GR, NF,
  20.228                      typename enable_if<UndirectedTagIndicator<GR> >::type> :
  20.229      public GraphAdaptorExtender<
  20.230 -      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
  20.231 +      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >,
  20.232                     true> > {
  20.233  
  20.234      typedef GraphAdaptorExtender<
  20.235 -      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
  20.236 +      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >,
  20.237                     true> > Parent;
  20.238  
  20.239    public:
  20.240 @@ -1619,6 +1628,8 @@
  20.241    /// by adding or removing nodes or arcs, unless the \c GR template
  20.242    /// parameter is set to be \c const.
  20.243    ///
  20.244 +  /// This class provides only linear time counting for nodes and arcs.
  20.245 +  ///
  20.246    /// \tparam DGR The type of the adapted digraph.
  20.247    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  20.248    /// It can also be specified to be \c const.
  20.249 @@ -1642,7 +1653,7 @@
  20.250                       AF, false> > {
  20.251  #endif
  20.252      typedef DigraphAdaptorExtender<
  20.253 -      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 
  20.254 +      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >,
  20.255                       AF, false> > Parent;
  20.256  
  20.257    public:
  20.258 @@ -1729,6 +1740,8 @@
  20.259    /// by adding or removing nodes or edges, unless the \c GR template
  20.260    /// parameter is set to be \c const.
  20.261    ///
  20.262 +  /// This class provides only linear time counting for nodes, edges and arcs.
  20.263 +  ///
  20.264    /// \tparam GR The type of the adapted graph.
  20.265    /// It must conform to the \ref concepts::Graph "Graph" concept.
  20.266    /// It can also be specified to be \c const.
  20.267 @@ -1748,11 +1761,11 @@
  20.268             typename EF = typename GR::template EdgeMap<bool> >
  20.269    class FilterEdges :
  20.270      public GraphAdaptorExtender<
  20.271 -      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, 
  20.272 +      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >,
  20.273                     EF, false> > {
  20.274  #endif
  20.275      typedef GraphAdaptorExtender<
  20.276 -      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 
  20.277 +      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >,
  20.278                     EF, false> > Parent;
  20.279  
  20.280    public:
  20.281 @@ -1777,7 +1790,7 @@
  20.282      ///
  20.283      /// Creates a subgraph for the given graph with the given edge
  20.284      /// filter map.
  20.285 -    FilterEdges(GR& graph, EF& edge_filter) 
  20.286 +    FilterEdges(GR& graph, EF& edge_filter)
  20.287        : Parent(), const_true_map() {
  20.288        Parent::initialize(graph, const_true_map, edge_filter);
  20.289      }
  20.290 @@ -1845,7 +1858,7 @@
  20.291        Edge _edge;
  20.292        bool _forward;
  20.293  
  20.294 -      Arc(const Edge& edge, bool forward) 
  20.295 +      Arc(const Edge& edge, bool forward)
  20.296          : _edge(edge), _forward(forward) {}
  20.297  
  20.298      public:
  20.299 @@ -2085,7 +2098,7 @@
  20.300          _forward(*adaptor._digraph), _backward(*adaptor._digraph) {}
  20.301  
  20.302        ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value)
  20.303 -        : _forward(*adaptor._digraph, value), 
  20.304 +        : _forward(*adaptor._digraph, value),
  20.305            _backward(*adaptor._digraph, value) {}
  20.306  
  20.307        void set(const Arc& a, const V& value) {
  20.308 @@ -2203,7 +2216,7 @@
  20.309  
  20.310      typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier;
  20.311      EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
  20.312 -    
  20.313 +
  20.314      typedef EdgeNotifier ArcNotifier;
  20.315      ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); }
  20.316  
  20.317 @@ -2232,6 +2245,9 @@
  20.318    /// by adding or removing nodes or edges, unless the \c GR template
  20.319    /// parameter is set to be \c const.
  20.320    ///
  20.321 +  /// This class provides item counting in the same time as the adapted
  20.322 +  /// digraph structure.
  20.323 +  ///
  20.324    /// \tparam DGR The type of the adapted digraph.
  20.325    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  20.326    /// It can also be specified to be \c const.
  20.327 @@ -2535,6 +2551,9 @@
  20.328    /// by adding or removing nodes or arcs, unless the \c GR template
  20.329    /// parameter is set to be \c const.
  20.330    ///
  20.331 +  /// This class provides item counting in the same time as the adapted
  20.332 +  /// graph structure.
  20.333 +  ///
  20.334    /// \tparam GR The type of the adapted graph.
  20.335    /// It must conform to the \ref concepts::Graph "Graph" concept.
  20.336    /// It can also be specified to be \c const.
  20.337 @@ -2678,6 +2697,8 @@
  20.338    /// arcs).
  20.339    /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
  20.340    ///
  20.341 +  /// This class provides only linear time counting for nodes and arcs.
  20.342 +  ///
  20.343    /// \tparam DGR The type of the adapted digraph.
  20.344    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  20.345    /// It is implicitly \c const.
  20.346 @@ -2707,7 +2728,7 @@
  20.347             typename CM = typename DGR::template ArcMap<int>,
  20.348             typename FM = CM,
  20.349             typename TL = Tolerance<typename CM::Value> >
  20.350 -  class ResidualDigraph 
  20.351 +  class ResidualDigraph
  20.352      : public SubDigraph<
  20.353          Undirector<const DGR>,
  20.354          ConstMap<typename DGR::Node, Const<bool, true> >,
  20.355 @@ -2764,7 +2785,7 @@
  20.356      /// digraph, the capacity map, the flow map, and a tolerance object.
  20.357      ResidualDigraph(const DGR& digraph, const CM& capacity,
  20.358                      FM& flow, const TL& tolerance = Tolerance())
  20.359 -      : Parent(), _capacity(&capacity), _flow(&flow), 
  20.360 +      : Parent(), _capacity(&capacity), _flow(&flow),
  20.361          _graph(digraph), _node_filter(),
  20.362          _forward_filter(capacity, flow, tolerance),
  20.363          _backward_filter(capacity, flow, tolerance),
  20.364 @@ -2846,7 +2867,7 @@
  20.365        typedef typename CapacityMap::Value Value;
  20.366  
  20.367        /// Constructor
  20.368 -      ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) 
  20.369 +      ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor)
  20.370          : _adaptor(&adaptor) {}
  20.371  
  20.372        /// Returns the value associated with the given residual arc
  20.373 @@ -3325,6 +3346,9 @@
  20.374    /// costs/capacities of the original digraph to the \e bind \e arcs
  20.375    /// in the adaptor.
  20.376    ///
  20.377 +  /// This class provides item counting in the same time as the adapted
  20.378 +  /// digraph structure.
  20.379 +  ///
  20.380    /// \tparam DGR The type of the adapted digraph.
  20.381    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  20.382    /// It is implicitly \c const.
  20.383 @@ -3423,7 +3447,7 @@
  20.384      /// This map adaptor class adapts two node maps of the original digraph
  20.385      /// to get a node map of the split digraph.
  20.386      /// Its value type is inherited from the first node map type (\c IN).
  20.387 -    /// \tparam IN The type of the node map for the in-nodes. 
  20.388 +    /// \tparam IN The type of the node map for the in-nodes.
  20.389      /// \tparam OUT The type of the node map for the out-nodes.
  20.390      template <typename IN, typename OUT>
  20.391      class CombinedNodeMap {
    21.1 --- a/lemon/arg_parser.cc	Fri Aug 09 11:07:27 2013 +0200
    21.2 +++ b/lemon/arg_parser.cc	Sun Aug 11 15:28:12 2013 +0200
    21.3 @@ -2,7 +2,7 @@
    21.4   *
    21.5   * This file is a part of LEMON, a generic C++ optimization library.
    21.6   *
    21.7 - * Copyright (C) 2003-2009
    21.8 + * Copyright (C) 2003-2010
    21.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   21.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   21.11   *
   21.12 @@ -20,14 +20,23 @@
   21.13  
   21.14  namespace lemon {
   21.15  
   21.16 +  void ArgParser::_terminate(ArgParserException::Reason reason) const
   21.17 +  {
   21.18 +    if(_exit_on_problems)
   21.19 +      exit(1);
   21.20 +    else throw(ArgParserException(reason));
   21.21 +  }
   21.22 +
   21.23 +
   21.24    void ArgParser::_showHelp(void *p)
   21.25    {
   21.26      (static_cast<ArgParser*>(p))->showHelp();
   21.27 -    exit(1);
   21.28 +    (static_cast<ArgParser*>(p))->_terminate(ArgParserException::HELP);
   21.29    }
   21.30  
   21.31    ArgParser::ArgParser(int argc, const char * const *argv)
   21.32 -    :_argc(argc), _argv(argv), _command_name(argv[0]) {
   21.33 +    :_argc(argc), _argv(argv), _command_name(argv[0]),
   21.34 +    _exit_on_problems(true) {
   21.35      funcOption("-help","Print a short help message",_showHelp,this);
   21.36      synonym("help","-help");
   21.37      synonym("h","-help");
   21.38 @@ -342,7 +351,7 @@
   21.39      for(std::vector<OtherArg>::const_iterator i=_others_help.begin();
   21.40          i!=_others_help.end();++i) showHelp(i);
   21.41      for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i) showHelp(i);
   21.42 -    exit(1);
   21.43 +    _terminate(ArgParserException::HELP);
   21.44    }
   21.45  
   21.46  
   21.47 @@ -351,7 +360,7 @@
   21.48      std::cerr << "\nUnknown option: " << arg << "\n";
   21.49      std::cerr << "\nType '" << _command_name <<
   21.50        " --help' to obtain a short summary on the usage.\n\n";
   21.51 -    exit(1);
   21.52 +    _terminate(ArgParserException::UNKNOWN_OPT);
   21.53    }
   21.54  
   21.55    void ArgParser::requiresValue(std::string arg, OptType t) const
   21.56 @@ -414,7 +423,7 @@
   21.57      if(!ok) {
   21.58        std::cerr << "\nType '" << _command_name <<
   21.59          " --help' to obtain a short summary on the usage.\n\n";
   21.60 -      exit(1);
   21.61 +      _terminate(ArgParserException::INVALID_OPT);
   21.62      }
   21.63    }
   21.64  
    22.1 --- a/lemon/arg_parser.h	Fri Aug 09 11:07:27 2013 +0200
    22.2 +++ b/lemon/arg_parser.h	Sun Aug 11 15:28:12 2013 +0200
    22.3 @@ -2,7 +2,7 @@
    22.4   *
    22.5   * This file is a part of LEMON, a generic C++ optimization library.
    22.6   *
    22.7 - * Copyright (C) 2003-2009
    22.8 + * Copyright (C) 2003-2010
    22.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   22.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   22.11   *
   22.12 @@ -34,6 +34,51 @@
   22.13  
   22.14  namespace lemon {
   22.15  
   22.16 +  ///Exception used by ArgParser
   22.17 +
   22.18 +  ///Exception used by ArgParser.
   22.19 +  ///
   22.20 +  class ArgParserException : public Exception {
   22.21 +  public:
   22.22 +    /// Reasons for failure
   22.23 +
   22.24 +    /// Reasons for failure.
   22.25 +    ///
   22.26 +    enum Reason {
   22.27 +      HELP,         ///< <tt>--help</tt> option was given.
   22.28 +      UNKNOWN_OPT,  ///< Unknown option was given.
   22.29 +      INVALID_OPT   ///< Invalid combination of options.
   22.30 +    };
   22.31 +
   22.32 +  private:
   22.33 +    Reason _reason;
   22.34 +
   22.35 +  public:
   22.36 +    ///Constructor
   22.37 +    ArgParserException(Reason r) throw() : _reason(r) {}
   22.38 +    ///Virtual destructor
   22.39 +    virtual ~ArgParserException() throw() {}
   22.40 +    ///A short description of the exception
   22.41 +    virtual const char* what() const throw() {
   22.42 +      switch(_reason)
   22.43 +        {
   22.44 +        case HELP:
   22.45 +          return "lemon::ArgParseException: ask for help";
   22.46 +          break;
   22.47 +        case UNKNOWN_OPT:
   22.48 +          return "lemon::ArgParseException: unknown option";
   22.49 +          break;
   22.50 +        case INVALID_OPT:
   22.51 +          return "lemon::ArgParseException: invalid combination of options";
   22.52 +          break;
   22.53 +        }
   22.54 +      return "";
   22.55 +    }
   22.56 +    ///Return the reason for the failure
   22.57 +    Reason reason() const {return _reason; }
   22.58 +  };
   22.59 +
   22.60 +
   22.61    ///Command line arguments parser
   22.62  
   22.63    ///\ingroup misc
   22.64 @@ -116,6 +161,10 @@
   22.65                      const std::string &help,
   22.66                      void (*func)(void *),void *data);
   22.67  
   22.68 +    bool _exit_on_problems;
   22.69 +
   22.70 +    void _terminate(ArgParserException::Reason reason) const;
   22.71 +
   22.72    public:
   22.73  
   22.74      ///Constructor
   22.75 @@ -380,6 +429,11 @@
   22.76      ///not starting with a '-' character.
   22.77      const std::vector<std::string> &files() const { return _file_args; }
   22.78  
   22.79 +    ///Throw instead of exit in case of problems
   22.80 +    void throwOnProblems()
   22.81 +    {
   22.82 +      _exit_on_problems=false;
   22.83 +    }
   22.84    };
   22.85  }
   22.86  
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/lemon/bellman_ford.h	Sun Aug 11 15:28:12 2013 +0200
    23.3 @@ -0,0 +1,1115 @@
    23.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    23.5 + *
    23.6 + * This file is a part of LEMON, a generic C++ optimization library.
    23.7 + *
    23.8 + * Copyright (C) 2003-2010
    23.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   23.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   23.11 + *
   23.12 + * Permission to use, modify and distribute this software is granted
   23.13 + * provided that this copyright notice appears in all copies. For
   23.14 + * precise terms see the accompanying LICENSE file.
   23.15 + *
   23.16 + * This software is provided "AS IS" with no warranty of any kind,
   23.17 + * express or implied, and with no claim as to its suitability for any
   23.18 + * purpose.
   23.19 + *
   23.20 + */
   23.21 +
   23.22 +#ifndef LEMON_BELLMAN_FORD_H
   23.23 +#define LEMON_BELLMAN_FORD_H
   23.24 +
   23.25 +/// \ingroup shortest_path
   23.26 +/// \file
   23.27 +/// \brief Bellman-Ford algorithm.
   23.28 +
   23.29 +#include <lemon/list_graph.h>
   23.30 +#include <lemon/bits/path_dump.h>
   23.31 +#include <lemon/core.h>
   23.32 +#include <lemon/error.h>
   23.33 +#include <lemon/maps.h>
   23.34 +#include <lemon/path.h>
   23.35 +
   23.36 +#include <limits>
   23.37 +
   23.38 +namespace lemon {
   23.39 +
   23.40 +  /// \brief Default OperationTraits for the BellmanFord algorithm class.
   23.41 +  ///
   23.42 +  /// This operation traits class defines all computational operations
   23.43 +  /// and constants that are used in the Bellman-Ford algorithm.
   23.44 +  /// The default implementation is based on the \c numeric_limits class.
   23.45 +  /// If the numeric type does not have infinity value, then the maximum
   23.46 +  /// value is used as extremal infinity value.
   23.47 +  template <
   23.48 +    typename V,
   23.49 +    bool has_inf = std::numeric_limits<V>::has_infinity>
   23.50 +  struct BellmanFordDefaultOperationTraits {
   23.51 +    /// \e
   23.52 +    typedef V Value;
   23.53 +    /// \brief Gives back the zero value of the type.
   23.54 +    static Value zero() {
   23.55 +      return static_cast<Value>(0);
   23.56 +    }
   23.57 +    /// \brief Gives back the positive infinity value of the type.
   23.58 +    static Value infinity() {
   23.59 +      return std::numeric_limits<Value>::infinity();
   23.60 +    }
   23.61 +    /// \brief Gives back the sum of the given two elements.
   23.62 +    static Value plus(const Value& left, const Value& right) {
   23.63 +      return left + right;
   23.64 +    }
   23.65 +    /// \brief Gives back \c true only if the first value is less than
   23.66 +    /// the second.
   23.67 +    static bool less(const Value& left, const Value& right) {
   23.68 +      return left < right;
   23.69 +    }
   23.70 +  };
   23.71 +
   23.72 +  template <typename V>
   23.73 +  struct BellmanFordDefaultOperationTraits<V, false> {
   23.74 +    typedef V Value;
   23.75 +    static Value zero() {
   23.76 +      return static_cast<Value>(0);
   23.77 +    }
   23.78 +    static Value infinity() {
   23.79 +      return std::numeric_limits<Value>::max();
   23.80 +    }
   23.81 +    static Value plus(const Value& left, const Value& right) {
   23.82 +      if (left == infinity() || right == infinity()) return infinity();
   23.83 +      return left + right;
   23.84 +    }
   23.85 +    static bool less(const Value& left, const Value& right) {
   23.86 +      return left < right;
   23.87 +    }
   23.88 +  };
   23.89 +
   23.90 +  /// \brief Default traits class of BellmanFord class.
   23.91 +  ///
   23.92 +  /// Default traits class of BellmanFord class.
   23.93 +  /// \param GR The type of the digraph.
   23.94 +  /// \param LEN The type of the length map.
   23.95 +  template<typename GR, typename LEN>
   23.96 +  struct BellmanFordDefaultTraits {
   23.97 +    /// The type of the digraph the algorithm runs on.
   23.98 +    typedef GR Digraph;
   23.99 +
  23.100 +    /// \brief The type of the map that stores the arc lengths.
  23.101 +    ///
  23.102 +    /// The type of the map that stores the arc lengths.
  23.103 +    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
  23.104 +    typedef LEN LengthMap;
  23.105 +
  23.106 +    /// The type of the arc lengths.
  23.107 +    typedef typename LEN::Value Value;
  23.108 +
  23.109 +    /// \brief Operation traits for Bellman-Ford algorithm.
  23.110 +    ///
  23.111 +    /// It defines the used operations and the infinity value for the
  23.112 +    /// given \c Value type.
  23.113 +    /// \see BellmanFordDefaultOperationTraits
  23.114 +    typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
  23.115 +
  23.116 +    /// \brief The type of the map that stores the last arcs of the
  23.117 +    /// shortest paths.
  23.118 +    ///
  23.119 +    /// The type of the map that stores the last
  23.120 +    /// arcs of the shortest paths.
  23.121 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  23.122 +    typedef typename GR::template NodeMap<typename GR::Arc> PredMap;
  23.123 +
  23.124 +    /// \brief Instantiates a \c PredMap.
  23.125 +    ///
  23.126 +    /// This function instantiates a \ref PredMap.
  23.127 +    /// \param g is the digraph to which we would like to define the
  23.128 +    /// \ref PredMap.
  23.129 +    static PredMap *createPredMap(const GR& g) {
  23.130 +      return new PredMap(g);
  23.131 +    }
  23.132 +
  23.133 +    /// \brief The type of the map that stores the distances of the nodes.
  23.134 +    ///
  23.135 +    /// The type of the map that stores the distances of the nodes.
  23.136 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  23.137 +    typedef typename GR::template NodeMap<typename LEN::Value> DistMap;
  23.138 +
  23.139 +    /// \brief Instantiates a \c DistMap.
  23.140 +    ///
  23.141 +    /// This function instantiates a \ref DistMap.
  23.142 +    /// \param g is the digraph to which we would like to define the
  23.143 +    /// \ref DistMap.
  23.144 +    static DistMap *createDistMap(const GR& g) {
  23.145 +      return new DistMap(g);
  23.146 +    }
  23.147 +
  23.148 +  };
  23.149 +
  23.150 +  /// \brief %BellmanFord algorithm class.
  23.151 +  ///
  23.152 +  /// \ingroup shortest_path
  23.153 +  /// This class provides an efficient implementation of the Bellman-Ford
  23.154 +  /// algorithm. The maximum time complexity of the algorithm is
  23.155 +  /// <tt>O(ne)</tt>.
  23.156 +  ///
  23.157 +  /// The Bellman-Ford algorithm solves the single-source shortest path
  23.158 +  /// problem when the arcs can have negative lengths, but the digraph
  23.159 +  /// should not contain directed cycles with negative total length.
  23.160 +  /// If all arc costs are non-negative, consider to use the Dijkstra
  23.161 +  /// algorithm instead, since it is more efficient.
  23.162 +  ///
  23.163 +  /// The arc lengths are passed to the algorithm using a
  23.164 +  /// \ref concepts::ReadMap "ReadMap", so it is easy to change it to any
  23.165 +  /// kind of length. The type of the length values is determined by the
  23.166 +  /// \ref concepts::ReadMap::Value "Value" type of the length map.
  23.167 +  ///
  23.168 +  /// There is also a \ref bellmanFord() "function-type interface" for the
  23.169 +  /// Bellman-Ford algorithm, which is convenient in the simplier cases and
  23.170 +  /// it can be used easier.
  23.171 +  ///
  23.172 +  /// \tparam GR The type of the digraph the algorithm runs on.
  23.173 +  /// The default type is \ref ListDigraph.
  23.174 +  /// \tparam LEN A \ref concepts::ReadMap "readable" arc map that specifies
  23.175 +  /// the lengths of the arcs. The default map type is
  23.176 +  /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
  23.177 +  /// \tparam TR The traits class that defines various types used by the
  23.178 +  /// algorithm. By default, it is \ref BellmanFordDefaultTraits
  23.179 +  /// "BellmanFordDefaultTraits<GR, LEN>".
  23.180 +  /// In most cases, this parameter should not be set directly,
  23.181 +  /// consider to use the named template parameters instead.
  23.182 +#ifdef DOXYGEN
  23.183 +  template <typename GR, typename LEN, typename TR>
  23.184 +#else
  23.185 +  template <typename GR=ListDigraph,
  23.186 +            typename LEN=typename GR::template ArcMap<int>,
  23.187 +            typename TR=BellmanFordDefaultTraits<GR,LEN> >
  23.188 +#endif
  23.189 +  class BellmanFord {
  23.190 +  public:
  23.191 +
  23.192 +    ///The type of the underlying digraph.
  23.193 +    typedef typename TR::Digraph Digraph;
  23.194 +
  23.195 +    /// \brief The type of the arc lengths.
  23.196 +    typedef typename TR::LengthMap::Value Value;
  23.197 +    /// \brief The type of the map that stores the arc lengths.
  23.198 +    typedef typename TR::LengthMap LengthMap;
  23.199 +    /// \brief The type of the map that stores the last
  23.200 +    /// arcs of the shortest paths.
  23.201 +    typedef typename TR::PredMap PredMap;
  23.202 +    /// \brief The type of the map that stores the distances of the nodes.
  23.203 +    typedef typename TR::DistMap DistMap;
  23.204 +    /// The type of the paths.
  23.205 +    typedef PredMapPath<Digraph, PredMap> Path;
  23.206 +    ///\brief The \ref BellmanFordDefaultOperationTraits
  23.207 +    /// "operation traits class" of the algorithm.
  23.208 +    typedef typename TR::OperationTraits OperationTraits;
  23.209 +
  23.210 +    ///The \ref BellmanFordDefaultTraits "traits class" of the algorithm.
  23.211 +    typedef TR Traits;
  23.212 +
  23.213 +  private:
  23.214 +
  23.215 +    typedef typename Digraph::Node Node;
  23.216 +    typedef typename Digraph::NodeIt NodeIt;
  23.217 +    typedef typename Digraph::Arc Arc;
  23.218 +    typedef typename Digraph::OutArcIt OutArcIt;
  23.219 +
  23.220 +    // Pointer to the underlying digraph.
  23.221 +    const Digraph *_gr;
  23.222 +    // Pointer to the length map
  23.223 +    const LengthMap *_length;
  23.224 +    // Pointer to the map of predecessors arcs.
  23.225 +    PredMap *_pred;
  23.226 +    // Indicates if _pred is locally allocated (true) or not.
  23.227 +    bool _local_pred;
  23.228 +    // Pointer to the map of distances.
  23.229 +    DistMap *_dist;
  23.230 +    // Indicates if _dist is locally allocated (true) or not.
  23.231 +    bool _local_dist;
  23.232 +
  23.233 +    typedef typename Digraph::template NodeMap<bool> MaskMap;
  23.234 +    MaskMap *_mask;
  23.235 +
  23.236 +    std::vector<Node> _process;
  23.237 +
  23.238 +    // Creates the maps if necessary.
  23.239 +    void create_maps() {
  23.240 +      if(!_pred) {
  23.241 +        _local_pred = true;
  23.242 +        _pred = Traits::createPredMap(*_gr);
  23.243 +      }
  23.244 +      if(!_dist) {
  23.245 +        _local_dist = true;
  23.246 +        _dist = Traits::createDistMap(*_gr);
  23.247 +      }
  23.248 +      if(!_mask) {
  23.249 +        _mask = new MaskMap(*_gr);
  23.250 +      }
  23.251 +    }
  23.252 +
  23.253 +  public :
  23.254 +
  23.255 +    typedef BellmanFord Create;
  23.256 +
  23.257 +    /// \name Named Template Parameters
  23.258 +
  23.259 +    ///@{
  23.260 +
  23.261 +    template <class T>
  23.262 +    struct SetPredMapTraits : public Traits {
  23.263 +      typedef T PredMap;
  23.264 +      static PredMap *createPredMap(const Digraph&) {
  23.265 +        LEMON_ASSERT(false, "PredMap is not initialized");
  23.266 +        return 0; // ignore warnings
  23.267 +      }
  23.268 +    };
  23.269 +
  23.270 +    /// \brief \ref named-templ-param "Named parameter" for setting
  23.271 +    /// \c PredMap type.
  23.272 +    ///
  23.273 +    /// \ref named-templ-param "Named parameter" for setting
  23.274 +    /// \c PredMap type.
  23.275 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  23.276 +    template <class T>
  23.277 +    struct SetPredMap
  23.278 +      : public BellmanFord< Digraph, LengthMap, SetPredMapTraits<T> > {
  23.279 +      typedef BellmanFord< Digraph, LengthMap, SetPredMapTraits<T> > Create;
  23.280 +    };
  23.281 +
  23.282 +    template <class T>
  23.283 +    struct SetDistMapTraits : public Traits {
  23.284 +      typedef T DistMap;
  23.285 +      static DistMap *createDistMap(const Digraph&) {
  23.286 +        LEMON_ASSERT(false, "DistMap is not initialized");
  23.287 +        return 0; // ignore warnings
  23.288 +      }
  23.289 +    };
  23.290 +
  23.291 +    /// \brief \ref named-templ-param "Named parameter" for setting
  23.292 +    /// \c DistMap type.
  23.293 +    ///
  23.294 +    /// \ref named-templ-param "Named parameter" for setting
  23.295 +    /// \c DistMap type.
  23.296 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  23.297 +    template <class T>
  23.298 +    struct SetDistMap
  23.299 +      : public BellmanFord< Digraph, LengthMap, SetDistMapTraits<T> > {
  23.300 +      typedef BellmanFord< Digraph, LengthMap, SetDistMapTraits<T> > Create;
  23.301 +    };
  23.302 +
  23.303 +    template <class T>
  23.304 +    struct SetOperationTraitsTraits : public Traits {
  23.305 +      typedef T OperationTraits;
  23.306 +    };
  23.307 +
  23.308 +    /// \brief \ref named-templ-param "Named parameter" for setting
  23.309 +    /// \c OperationTraits type.
  23.310 +    ///
  23.311 +    /// \ref named-templ-param "Named parameter" for setting
  23.312 +    /// \c OperationTraits type.
  23.313 +    /// For more information, see \ref BellmanFordDefaultOperationTraits.
  23.314 +    template <class T>
  23.315 +    struct SetOperationTraits
  23.316 +      : public BellmanFord< Digraph, LengthMap, SetOperationTraitsTraits<T> > {
  23.317 +      typedef BellmanFord< Digraph, LengthMap, SetOperationTraitsTraits<T> >
  23.318 +      Create;
  23.319 +    };
  23.320 +
  23.321 +    ///@}
  23.322 +
  23.323 +  protected:
  23.324 +
  23.325 +    BellmanFord() {}
  23.326 +
  23.327 +  public:
  23.328 +
  23.329 +    /// \brief Constructor.
  23.330 +    ///
  23.331 +    /// Constructor.
  23.332 +    /// \param g The digraph the algorithm runs on.
  23.333 +    /// \param length The length map used by the algorithm.
  23.334 +    BellmanFord(const Digraph& g, const LengthMap& length) :
  23.335 +      _gr(&g), _length(&length),
  23.336 +      _pred(0), _local_pred(false),
  23.337 +      _dist(0), _local_dist(false), _mask(0) {}
  23.338 +
  23.339 +    ///Destructor.
  23.340 +    ~BellmanFord() {
  23.341 +      if(_local_pred) delete _pred;
  23.342 +      if(_local_dist) delete _dist;
  23.343 +      if(_mask) delete _mask;
  23.344 +    }
  23.345 +
  23.346 +    /// \brief Sets the length map.
  23.347 +    ///
  23.348 +    /// Sets the length map.
  23.349 +    /// \return <tt>(*this)</tt>
  23.350 +    BellmanFord &lengthMap(const LengthMap &map) {
  23.351 +      _length = &map;
  23.352 +      return *this;
  23.353 +    }
  23.354 +
  23.355 +    /// \brief Sets the map that stores the predecessor arcs.
  23.356 +    ///
  23.357 +    /// Sets the map that stores the predecessor arcs.
  23.358 +    /// If you don't use this function before calling \ref run()
  23.359 +    /// or \ref init(), an instance will be allocated automatically.
  23.360 +    /// The destructor deallocates this automatically allocated map,
  23.361 +    /// of course.
  23.362 +    /// \return <tt>(*this)</tt>
  23.363 +    BellmanFord &predMap(PredMap &map) {
  23.364 +      if(_local_pred) {
  23.365 +        delete _pred;
  23.366 +        _local_pred=false;
  23.367 +      }
  23.368 +      _pred = &map;
  23.369 +      return *this;
  23.370 +    }
  23.371 +
  23.372 +    /// \brief Sets the map that stores the distances of the nodes.
  23.373 +    ///
  23.374 +    /// Sets the map that stores the distances of the nodes calculated
  23.375 +    /// by the algorithm.
  23.376 +    /// If you don't use this function before calling \ref run()
  23.377 +    /// or \ref init(), an instance will be allocated automatically.
  23.378 +    /// The destructor deallocates this automatically allocated map,
  23.379 +    /// of course.
  23.380 +    /// \return <tt>(*this)</tt>
  23.381 +    BellmanFord &distMap(DistMap &map) {
  23.382 +      if(_local_dist) {
  23.383 +        delete _dist;
  23.384 +        _local_dist=false;
  23.385 +      }
  23.386 +      _dist = &map;
  23.387 +      return *this;
  23.388 +    }
  23.389 +
  23.390 +    /// \name Execution Control
  23.391 +    /// The simplest way to execute the Bellman-Ford algorithm is to use
  23.392 +    /// one of the member functions called \ref run().\n
  23.393 +    /// If you need better control on the execution, you have to call
  23.394 +    /// \ref init() first, then you can add several source nodes
  23.395 +    /// with \ref addSource(). Finally the actual path computation can be
  23.396 +    /// performed with \ref start(), \ref checkedStart() or
  23.397 +    /// \ref limitedStart().
  23.398 +
  23.399 +    ///@{
  23.400 +
  23.401 +    /// \brief Initializes the internal data structures.
  23.402 +    ///
  23.403 +    /// Initializes the internal data structures. The optional parameter
  23.404 +    /// is the initial distance of each node.
  23.405 +    void init(const Value value = OperationTraits::infinity()) {
  23.406 +      create_maps();
  23.407 +      for (NodeIt it(*_gr); it != INVALID; ++it) {
  23.408 +        _pred->set(it, INVALID);
  23.409 +        _dist->set(it, value);
  23.410 +      }
  23.411 +      _process.clear();
  23.412 +      if (OperationTraits::less(value, OperationTraits::infinity())) {
  23.413 +        for (NodeIt it(*_gr); it != INVALID; ++it) {
  23.414 +          _process.push_back(it);
  23.415 +          _mask->set(it, true);
  23.416 +        }
  23.417 +      } else {
  23.418 +        for (NodeIt it(*_gr); it != INVALID; ++it) {
  23.419 +          _mask->set(it, false);
  23.420 +        }
  23.421 +      }
  23.422 +    }
  23.423 +
  23.424 +    /// \brief Adds a new source node.
  23.425 +    ///
  23.426 +    /// This function adds a new source node. The optional second parameter
  23.427 +    /// is the initial distance of the node.
  23.428 +    void addSource(Node source, Value dst = OperationTraits::zero()) {
  23.429 +      _dist->set(source, dst);
  23.430 +      if (!(*_mask)[source]) {
  23.431 +        _process.push_back(source);
  23.432 +        _mask->set(source, true);
  23.433 +      }
  23.434 +    }
  23.435 +
  23.436 +    /// \brief Executes one round from the Bellman-Ford algorithm.
  23.437 +    ///
  23.438 +    /// If the algoritm calculated the distances in the previous round
  23.439 +    /// exactly for the paths of at most \c k arcs, then this function
  23.440 +    /// will calculate the distances exactly for the paths of at most
  23.441 +    /// <tt>k+1</tt> arcs. Performing \c k iterations using this function
  23.442 +    /// calculates the shortest path distances exactly for the paths
  23.443 +    /// consisting of at most \c k arcs.
  23.444 +    ///
  23.445 +    /// \warning The paths with limited arc number cannot be retrieved
  23.446 +    /// easily with \ref path() or \ref predArc() functions. If you also
  23.447 +    /// need the shortest paths and not only the distances, you should
  23.448 +    /// store the \ref predMap() "predecessor map" after each iteration
  23.449 +    /// and build the path manually.
  23.450 +    ///
  23.451 +    /// \return \c true when the algorithm have not found more shorter
  23.452 +    /// paths.
  23.453 +    ///
  23.454 +    /// \see ActiveIt
  23.455 +    bool processNextRound() {
  23.456 +      for (int i = 0; i < int(_process.size()); ++i) {
  23.457 +        _mask->set(_process[i], false);
  23.458 +      }
  23.459 +      std::vector<Node> nextProcess;
  23.460 +      std::vector<Value> values(_process.size());
  23.461 +      for (int i = 0; i < int(_process.size()); ++i) {
  23.462 +        values[i] = (*_dist)[_process[i]];
  23.463 +      }
  23.464 +      for (int i = 0; i < int(_process.size()); ++i) {
  23.465 +        for (OutArcIt it(*_gr, _process[i]); it != INVALID; ++it) {
  23.466 +          Node target = _gr->target(it);
  23.467 +          Value relaxed = OperationTraits::plus(values[i], (*_length)[it]);
  23.468 +          if (OperationTraits::less(relaxed, (*_dist)[target])) {
  23.469 +            _pred->set(target, it);
  23.470 +            _dist->set(target, relaxed);
  23.471 +            if (!(*_mask)[target]) {
  23.472 +              _mask->set(target, true);
  23.473 +              nextProcess.push_back(target);
  23.474 +            }
  23.475 +          }
  23.476 +        }
  23.477 +      }
  23.478 +      _process.swap(nextProcess);
  23.479 +      return _process.empty();
  23.480 +    }
  23.481 +
  23.482 +    /// \brief Executes one weak round from the Bellman-Ford algorithm.
  23.483 +    ///
  23.484 +    /// If the algorithm calculated the distances in the previous round
  23.485 +    /// at least for the paths of at most \c k arcs, then this function
  23.486 +    /// will calculate the distances at least for the paths of at most
  23.487 +    /// <tt>k+1</tt> arcs.
  23.488 +    /// This function does not make it possible to calculate the shortest
  23.489 +    /// path distances exactly for paths consisting of at most \c k arcs,
  23.490 +    /// this is why it is called weak round.
  23.491 +    ///
  23.492 +    /// \return \c true when the algorithm have not found more shorter
  23.493 +    /// paths.
  23.494 +    ///
  23.495 +    /// \see ActiveIt
  23.496 +    bool processNextWeakRound() {
  23.497 +      for (int i = 0; i < int(_process.size()); ++i) {
  23.498 +        _mask->set(_process[i], false);
  23.499 +      }
  23.500 +      std::vector<Node> nextProcess;
  23.501 +      for (int i = 0; i < int(_process.size()); ++i) {
  23.502 +        for (OutArcIt it(*_gr, _process[i]); it != INVALID; ++it) {
  23.503 +          Node target = _gr->target(it);
  23.504 +          Value relaxed =
  23.505 +            OperationTraits::plus((*_dist)[_process[i]], (*_length)[it]);
  23.506 +          if (OperationTraits::less(relaxed, (*_dist)[target])) {
  23.507 +            _pred->set(target, it);
  23.508 +            _dist->set(target, relaxed);
  23.509 +            if (!(*_mask)[target]) {
  23.510 +              _mask->set(target, true);
  23.511 +              nextProcess.push_back(target);
  23.512 +            }
  23.513 +          }
  23.514 +        }
  23.515 +      }
  23.516 +      _process.swap(nextProcess);
  23.517 +      return _process.empty();
  23.518 +    }
  23.519 +
  23.520 +    /// \brief Executes the algorithm.
  23.521 +    ///
  23.522 +    /// Executes the algorithm.
  23.523 +    ///
  23.524 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  23.525 +    /// in order to compute the shortest path to each node.
  23.526 +    ///
  23.527 +    /// The algorithm computes
  23.528 +    /// - the shortest path tree (forest),
  23.529 +    /// - the distance of each node from the root(s).
  23.530 +    ///
  23.531 +    /// \pre init() must be called and at least one root node should be
  23.532 +    /// added with addSource() before using this function.
  23.533 +    void start() {
  23.534 +      int num = countNodes(*_gr) - 1;
  23.535 +      for (int i = 0; i < num; ++i) {
  23.536 +        if (processNextWeakRound()) break;
  23.537 +      }
  23.538 +    }
  23.539 +
  23.540 +    /// \brief Executes the algorithm and checks the negative cycles.
  23.541 +    ///
  23.542 +    /// Executes the algorithm and checks the negative cycles.
  23.543 +    ///
  23.544 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  23.545 +    /// in order to compute the shortest path to each node and also checks
  23.546 +    /// if the digraph contains cycles with negative total length.
  23.547 +    ///
  23.548 +    /// The algorithm computes
  23.549 +    /// - the shortest path tree (forest),
  23.550 +    /// - the distance of each node from the root(s).
  23.551 +    ///
  23.552 +    /// \return \c false if there is a negative cycle in the digraph.
  23.553 +    ///
  23.554 +    /// \pre init() must be called and at least one root node should be
  23.555 +    /// added with addSource() before using this function.
  23.556 +    bool checkedStart() {
  23.557 +      int num = countNodes(*_gr);
  23.558 +      for (int i = 0; i < num; ++i) {
  23.559 +        if (processNextWeakRound()) return true;
  23.560 +      }
  23.561 +      return _process.empty();
  23.562 +    }
  23.563 +
  23.564 +    /// \brief Executes the algorithm with arc number limit.
  23.565 +    ///
  23.566 +    /// Executes the algorithm with arc number limit.
  23.567 +    ///
  23.568 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  23.569 +    /// in order to compute the shortest path distance for each node
  23.570 +    /// using only the paths consisting of at most \c num arcs.
  23.571 +    ///
  23.572 +    /// The algorithm computes
  23.573 +    /// - the limited distance of each node from the root(s),
  23.574 +    /// - the predecessor arc for each node.
  23.575 +    ///
  23.576 +    /// \warning The paths with limited arc number cannot be retrieved
  23.577 +    /// easily with \ref path() or \ref predArc() functions. If you also
  23.578 +    /// need the shortest paths and not only the distances, you should
  23.579 +    /// store the \ref predMap() "predecessor map" after each iteration
  23.580 +    /// and build the path manually.
  23.581 +    ///
  23.582 +    /// \pre init() must be called and at least one root node should be
  23.583 +    /// added with addSource() before using this function.
  23.584 +    void limitedStart(int num) {
  23.585 +      for (int i = 0; i < num; ++i) {
  23.586 +        if (processNextRound()) break;
  23.587 +      }
  23.588 +    }
  23.589 +
  23.590 +    /// \brief Runs the algorithm from the given root node.
  23.591 +    ///
  23.592 +    /// This method runs the Bellman-Ford algorithm from the given root
  23.593 +    /// node \c s in order to compute the shortest path to each node.
  23.594 +    ///
  23.595 +    /// The algorithm computes
  23.596 +    /// - the shortest path tree (forest),
  23.597 +    /// - the distance of each node from the root(s).
  23.598 +    ///
  23.599 +    /// \note bf.run(s) is just a shortcut of the following code.
  23.600 +    /// \code
  23.601 +    ///   bf.init();
  23.602 +    ///   bf.addSource(s);
  23.603 +    ///   bf.start();
  23.604 +    /// \endcode
  23.605 +    void run(Node s) {
  23.606 +      init();
  23.607 +      addSource(s);
  23.608 +      start();
  23.609 +    }
  23.610 +
  23.611 +    /// \brief Runs the algorithm from the given root node with arc
  23.612 +    /// number limit.
  23.613 +    ///
  23.614 +    /// This method runs the Bellman-Ford algorithm from the given root
  23.615 +    /// node \c s in order to compute the shortest path distance for each
  23.616 +    /// node using only the paths consisting of at most \c num arcs.
  23.617 +    ///
  23.618 +    /// The algorithm computes
  23.619 +    /// - the limited distance of each node from the root(s),
  23.620 +    /// - the predecessor arc for each node.
  23.621 +    ///
  23.622 +    /// \warning The paths with limited arc number cannot be retrieved
  23.623 +    /// easily with \ref path() or \ref predArc() functions. If you also
  23.624 +    /// need the shortest paths and not only the distances, you should
  23.625 +    /// store the \ref predMap() "predecessor map" after each iteration
  23.626 +    /// and build the path manually.
  23.627 +    ///
  23.628 +    /// \note bf.run(s, num) is just a shortcut of the following code.
  23.629 +    /// \code
  23.630 +    ///   bf.init();
  23.631 +    ///   bf.addSource(s);
  23.632 +    ///   bf.limitedStart(num);
  23.633 +    /// \endcode
  23.634 +    void run(Node s, int num) {
  23.635 +      init();
  23.636 +      addSource(s);
  23.637 +      limitedStart(num);
  23.638 +    }
  23.639 +
  23.640 +    ///@}
  23.641 +
  23.642 +    /// \brief LEMON iterator for getting the active nodes.
  23.643 +    ///
  23.644 +    /// This class provides a common style LEMON iterator that traverses
  23.645 +    /// the active nodes of the Bellman-Ford algorithm after the last
  23.646 +    /// phase. These nodes should be checked in the next phase to
  23.647 +    /// find augmenting arcs outgoing from them.
  23.648 +    class ActiveIt {
  23.649 +    public:
  23.650 +
  23.651 +      /// \brief Constructor.
  23.652 +      ///
  23.653 +      /// Constructor for getting the active nodes of the given BellmanFord
  23.654 +      /// instance.
  23.655 +      ActiveIt(const BellmanFord& algorithm) : _algorithm(&algorithm)
  23.656 +      {
  23.657 +        _index = _algorithm->_process.size() - 1;
  23.658 +      }
  23.659 +
  23.660 +      /// \brief Invalid constructor.
  23.661 +      ///
  23.662 +      /// Invalid constructor.
  23.663 +      ActiveIt(Invalid) : _algorithm(0), _index(-1) {}
  23.664 +
  23.665 +      /// \brief Conversion to \c Node.
  23.666 +      ///
  23.667 +      /// Conversion to \c Node.
  23.668 +      operator Node() const {
  23.669 +        return _index >= 0 ? _algorithm->_process[_index] : INVALID;
  23.670 +      }
  23.671 +
  23.672 +      /// \brief Increment operator.
  23.673 +      ///
  23.674 +      /// Increment operator.
  23.675 +      ActiveIt& operator++() {
  23.676 +        --_index;
  23.677 +        return *this;
  23.678 +      }
  23.679 +
  23.680 +      bool operator==(const ActiveIt& it) const {
  23.681 +        return static_cast<Node>(*this) == static_cast<Node>(it);
  23.682 +      }
  23.683 +      bool operator!=(const ActiveIt& it) const {
  23.684 +        return static_cast<Node>(*this) != static_cast<Node>(it);
  23.685 +      }
  23.686 +      bool operator<(const ActiveIt& it) const {
  23.687 +        return static_cast<Node>(*this) < static_cast<Node>(it);
  23.688 +      }
  23.689 +
  23.690 +    private:
  23.691 +      const BellmanFord* _algorithm;
  23.692 +      int _index;
  23.693 +    };
  23.694 +
  23.695 +    /// \name Query Functions
  23.696 +    /// The result of the Bellman-Ford algorithm can be obtained using these
  23.697 +    /// functions.\n
  23.698 +    /// Either \ref run() or \ref init() should be called before using them.
  23.699 +
  23.700 +    ///@{
  23.701 +
  23.702 +    /// \brief The shortest path to the given node.
  23.703 +    ///
  23.704 +    /// Gives back the shortest path to the given node from the root(s).
  23.705 +    ///
  23.706 +    /// \warning \c t should be reached from the root(s).
  23.707 +    ///
  23.708 +    /// \pre Either \ref run() or \ref init() must be called before
  23.709 +    /// using this function.
  23.710 +    Path path(Node t) const
  23.711 +    {
  23.712 +      return Path(*_gr, *_pred, t);
  23.713 +    }
  23.714 +
  23.715 +    /// \brief The distance of the given node from the root(s).
  23.716 +    ///
  23.717 +    /// Returns the distance of the given node from the root(s).
  23.718 +    ///
  23.719 +    /// \warning If node \c v is not reached from the root(s), then
  23.720 +    /// the return value of this function is undefined.
  23.721 +    ///
  23.722 +    /// \pre Either \ref run() or \ref init() must be called before
  23.723 +    /// using this function.
  23.724 +    Value dist(Node v) const { return (*_dist)[v]; }
  23.725 +
  23.726 +    /// \brief Returns the 'previous arc' of the shortest path tree for
  23.727 +    /// the given node.
  23.728 +    ///
  23.729 +    /// This function returns the 'previous arc' of the shortest path
  23.730 +    /// tree for node \c v, i.e. it returns the last arc of a
  23.731 +    /// shortest path from a root to \c v. It is \c INVALID if \c v
  23.732 +    /// is not reached from the root(s) or if \c v is a root.
  23.733 +    ///
  23.734 +    /// The shortest path tree used here is equal to the shortest path
  23.735 +    /// tree used in \ref predNode() and \ref predMap().
  23.736 +    ///
  23.737 +    /// \pre Either \ref run() or \ref init() must be called before
  23.738 +    /// using this function.
  23.739 +    Arc predArc(Node v) const { return (*_pred)[v]; }
  23.740 +
  23.741 +    /// \brief Returns the 'previous node' of the shortest path tree for
  23.742 +    /// the given node.
  23.743 +    ///
  23.744 +    /// This function returns the 'previous node' of the shortest path
  23.745 +    /// tree for node \c v, i.e. it returns the last but one node of
  23.746 +    /// a shortest path from a root to \c v. It is \c INVALID if \c v
  23.747 +    /// is not reached from the root(s) or if \c v is a root.
  23.748 +    ///
  23.749 +    /// The shortest path tree used here is equal to the shortest path
  23.750 +    /// tree used in \ref predArc() and \ref predMap().
  23.751 +    ///
  23.752 +    /// \pre Either \ref run() or \ref init() must be called before
  23.753 +    /// using this function.
  23.754 +    Node predNode(Node v) const {
  23.755 +      return (*_pred)[v] == INVALID ? INVALID : _gr->source((*_pred)[v]);
  23.756 +    }
  23.757 +
  23.758 +    /// \brief Returns a const reference to the node map that stores the
  23.759 +    /// distances of the nodes.
  23.760 +    ///
  23.761 +    /// Returns a const reference to the node map that stores the distances
  23.762 +    /// of the nodes calculated by the algorithm.
  23.763 +    ///
  23.764 +    /// \pre Either \ref run() or \ref init() must be called before
  23.765 +    /// using this function.
  23.766 +    const DistMap &distMap() const { return *_dist;}
  23.767 +
  23.768 +    /// \brief Returns a const reference to the node map that stores the
  23.769 +    /// predecessor arcs.
  23.770 +    ///
  23.771 +    /// Returns a const reference to the node map that stores the predecessor
  23.772 +    /// arcs, which form the shortest path tree (forest).
  23.773 +    ///
  23.774 +    /// \pre Either \ref run() or \ref init() must be called before
  23.775 +    /// using this function.
  23.776 +    const PredMap &predMap() const { return *_pred; }
  23.777 +
  23.778 +    /// \brief Checks if a node is reached from the root(s).
  23.779 +    ///
  23.780 +    /// Returns \c true if \c v is reached from the root(s).
  23.781 +    ///
  23.782 +    /// \pre Either \ref run() or \ref init() must be called before
  23.783 +    /// using this function.
  23.784 +    bool reached(Node v) const {
  23.785 +      return (*_dist)[v] != OperationTraits::infinity();
  23.786 +    }
  23.787 +
  23.788 +    /// \brief Gives back a negative cycle.
  23.789 +    ///
  23.790 +    /// This function gives back a directed cycle with negative total
  23.791 +    /// length if the algorithm has already found one.
  23.792 +    /// Otherwise it gives back an empty path.
  23.793 +    lemon::Path<Digraph> negativeCycle() const {
  23.794 +      typename Digraph::template NodeMap<int> state(*_gr, -1);
  23.795 +      lemon::Path<Digraph> cycle;
  23.796 +      for (int i = 0; i < int(_process.size()); ++i) {
  23.797 +        if (state[_process[i]] != -1) continue;
  23.798 +        for (Node v = _process[i]; (*_pred)[v] != INVALID;
  23.799 +             v = _gr->source((*_pred)[v])) {
  23.800 +          if (state[v] == i) {
  23.801 +            cycle.addFront((*_pred)[v]);
  23.802 +            for (Node u = _gr->source((*_pred)[v]); u != v;
  23.803 +                 u = _gr->source((*_pred)[u])) {
  23.804 +              cycle.addFront((*_pred)[u]);
  23.805 +            }
  23.806 +            return cycle;
  23.807 +          }
  23.808 +          else if (state[v] >= 0) {
  23.809 +            break;
  23.810 +          }
  23.811 +          state[v] = i;
  23.812 +        }
  23.813 +      }
  23.814 +      return cycle;
  23.815 +    }
  23.816 +
  23.817 +    ///@}
  23.818 +  };
  23.819 +
  23.820 +  /// \brief Default traits class of bellmanFord() function.
  23.821 +  ///
  23.822 +  /// Default traits class of bellmanFord() function.
  23.823 +  /// \tparam GR The type of the digraph.
  23.824 +  /// \tparam LEN The type of the length map.
  23.825 +  template <typename GR, typename LEN>
  23.826 +  struct BellmanFordWizardDefaultTraits {
  23.827 +    /// The type of the digraph the algorithm runs on.
  23.828 +    typedef GR Digraph;
  23.829 +
  23.830 +    /// \brief The type of the map that stores the arc lengths.
  23.831 +    ///
  23.832 +    /// The type of the map that stores the arc lengths.
  23.833 +    /// It must meet the \ref concepts::ReadMap "ReadMap" concept.
  23.834 +    typedef LEN LengthMap;
  23.835 +
  23.836 +    /// The type of the arc lengths.
  23.837 +    typedef typename LEN::Value Value;
  23.838 +
  23.839 +    /// \brief Operation traits for Bellman-Ford algorithm.
  23.840 +    ///
  23.841 +    /// It defines the used operations and the infinity value for the
  23.842 +    /// given \c Value type.
  23.843 +    /// \see BellmanFordDefaultOperationTraits
  23.844 +    typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
  23.845 +
  23.846 +    /// \brief The type of the map that stores the last
  23.847 +    /// arcs of the shortest paths.
  23.848 +    ///
  23.849 +    /// The type of the map that stores the last arcs of the shortest paths.
  23.850 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  23.851 +    typedef typename GR::template NodeMap<typename GR::Arc> PredMap;
  23.852 +
  23.853 +    /// \brief Instantiates a \c PredMap.
  23.854 +    ///
  23.855 +    /// This function instantiates a \ref PredMap.
  23.856 +    /// \param g is the digraph to which we would like to define the
  23.857 +    /// \ref PredMap.
  23.858 +    static PredMap *createPredMap(const GR &g) {
  23.859 +      return new PredMap(g);
  23.860 +    }
  23.861 +
  23.862 +    /// \brief The type of the map that stores the distances of the nodes.
  23.863 +    ///
  23.864 +    /// The type of the map that stores the distances of the nodes.
  23.865 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  23.866 +    typedef typename GR::template NodeMap<Value> DistMap;
  23.867 +
  23.868 +    /// \brief Instantiates a \c DistMap.
  23.869 +    ///
  23.870 +    /// This function instantiates a \ref DistMap.
  23.871 +    /// \param g is the digraph to which we would like to define the
  23.872 +    /// \ref DistMap.
  23.873 +    static DistMap *createDistMap(const GR &g) {
  23.874 +      return new DistMap(g);
  23.875 +    }
  23.876 +
  23.877 +    ///The type of the shortest paths.
  23.878 +
  23.879 +    ///The type of the shortest paths.
  23.880 +    ///It must meet the \ref concepts::Path "Path" concept.
  23.881 +    typedef lemon::Path<Digraph> Path;
  23.882 +  };
  23.883 +
  23.884 +  /// \brief Default traits class used by BellmanFordWizard.
  23.885 +  ///
  23.886 +  /// Default traits class used by BellmanFordWizard.
  23.887 +  /// \tparam GR The type of the digraph.
  23.888 +  /// \tparam LEN The type of the length map.
  23.889 +  template <typename GR, typename LEN>
  23.890 +  class BellmanFordWizardBase
  23.891 +    : public BellmanFordWizardDefaultTraits<GR, LEN> {
  23.892 +
  23.893 +    typedef BellmanFordWizardDefaultTraits<GR, LEN> Base;
  23.894 +  protected:
  23.895 +    // Type of the nodes in the digraph.
  23.896 +    typedef typename Base::Digraph::Node Node;
  23.897 +
  23.898 +    // Pointer to the underlying digraph.
  23.899 +    void *_graph;
  23.900 +    // Pointer to the length map
  23.901 +    void *_length;
  23.902 +    // Pointer to the map of predecessors arcs.
  23.903 +    void *_pred;
  23.904 +    // Pointer to the map of distances.
  23.905 +    void *_dist;
  23.906 +    //Pointer to the shortest path to the target node.
  23.907 +    void *_path;
  23.908 +    //Pointer to the distance of the target node.
  23.909 +    void *_di;
  23.910 +
  23.911 +    public:
  23.912 +    /// Constructor.
  23.913 +
  23.914 +    /// This constructor does not require parameters, it initiates
  23.915 +    /// all of the attributes to default values \c 0.
  23.916 +    BellmanFordWizardBase() :
  23.917 +      _graph(0), _length(0), _pred(0), _dist(0), _path(0), _di(0) {}
  23.918 +
  23.919 +    /// Constructor.
  23.920 +
  23.921 +    /// This constructor requires two parameters,
  23.922 +    /// others are initiated to \c 0.
  23.923 +    /// \param gr The digraph the algorithm runs on.
  23.924 +    /// \param len The length map.
  23.925 +    BellmanFordWizardBase(const GR& gr,
  23.926 +                          const LEN& len) :
  23.927 +      _graph(reinterpret_cast<void*>(const_cast<GR*>(&gr))),
  23.928 +      _length(reinterpret_cast<void*>(const_cast<LEN*>(&len))),
  23.929 +      _pred(0), _dist(0), _path(0), _di(0) {}
  23.930 +
  23.931 +  };
  23.932 +
  23.933 +  /// \brief Auxiliary class for the function-type interface of the
  23.934 +  /// \ref BellmanFord "Bellman-Ford" algorithm.
  23.935 +  ///
  23.936 +  /// This auxiliary class is created to implement the
  23.937 +  /// \ref bellmanFord() "function-type interface" of the
  23.938 +  /// \ref BellmanFord "Bellman-Ford" algorithm.
  23.939 +  /// It does not have own \ref run() method, it uses the
  23.940 +  /// functions and features of the plain \ref BellmanFord.
  23.941 +  ///
  23.942 +  /// This class should only be used through the \ref bellmanFord()
  23.943 +  /// function, which makes it easier to use the algorithm.
  23.944 +  ///
  23.945 +  /// \tparam TR The traits class that defines various types used by the
  23.946 +  /// algorithm.
  23.947 +  template<class TR>
  23.948 +  class BellmanFordWizard : public TR {
  23.949 +    typedef TR Base;
  23.950 +
  23.951 +    typedef typename TR::Digraph Digraph;
  23.952 +
  23.953 +    typedef typename Digraph::Node Node;
  23.954 +    typedef typename Digraph::NodeIt NodeIt;
  23.955 +    typedef typename Digraph::Arc Arc;
  23.956 +    typedef typename Digraph::OutArcIt ArcIt;
  23.957 +
  23.958 +    typedef typename TR::LengthMap LengthMap;
  23.959 +    typedef typename LengthMap::Value Value;
  23.960 +    typedef typename TR::PredMap PredMap;
  23.961 +    typedef typename TR::DistMap DistMap;
  23.962 +    typedef typename TR::Path Path;
  23.963 +
  23.964 +  public:
  23.965 +    /// Constructor.
  23.966 +    BellmanFordWizard() : TR() {}
  23.967 +
  23.968 +    /// \brief Constructor that requires parameters.
  23.969 +    ///
  23.970 +    /// Constructor that requires parameters.
  23.971 +    /// These parameters will be the default values for the traits class.
  23.972 +    /// \param gr The digraph the algorithm runs on.
  23.973 +    /// \param len The length map.
  23.974 +    BellmanFordWizard(const Digraph& gr, const LengthMap& len)
  23.975 +      : TR(gr, len) {}
  23.976 +
  23.977 +    /// \brief Copy constructor
  23.978 +    BellmanFordWizard(const TR &b) : TR(b) {}
  23.979 +
  23.980 +    ~BellmanFordWizard() {}
  23.981 +
  23.982 +    /// \brief Runs the Bellman-Ford algorithm from the given source node.
  23.983 +    ///
  23.984 +    /// This method runs the Bellman-Ford algorithm from the given source
  23.985 +    /// node in order to compute the shortest path to each node.
  23.986 +    void run(Node s) {
  23.987 +      BellmanFord<Digraph,LengthMap,TR>
  23.988 +        bf(*reinterpret_cast<const Digraph*>(Base::_graph),
  23.989 +           *reinterpret_cast<const LengthMap*>(Base::_length));
  23.990 +      if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
  23.991 +      if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
  23.992 +      bf.run(s);
  23.993 +    }
  23.994 +
  23.995 +    /// \brief Runs the Bellman-Ford algorithm to find the shortest path
  23.996 +    /// between \c s and \c t.
  23.997 +    ///
  23.998 +    /// This method runs the Bellman-Ford algorithm from node \c s
  23.999 +    /// in order to compute the shortest path to node \c t.
 23.1000 +    /// Actually, it computes the shortest path to each node, but using
 23.1001 +    /// this function you can retrieve the distance and the shortest path
 23.1002 +    /// for a single target node easier.
 23.1003 +    ///
 23.1004 +    /// \return \c true if \c t is reachable form \c s.
 23.1005 +    bool run(Node s, Node t) {
 23.1006 +      BellmanFord<Digraph,LengthMap,TR>
 23.1007 +        bf(*reinterpret_cast<const Digraph*>(Base::_graph),
 23.1008 +           *reinterpret_cast<const LengthMap*>(Base::_length));
 23.1009 +      if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
 23.1010 +      if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
 23.1011 +      bf.run(s);
 23.1012 +      if (Base::_path) *reinterpret_cast<Path*>(Base::_path) = bf.path(t);
 23.1013 +      if (Base::_di) *reinterpret_cast<Value*>(Base::_di) = bf.dist(t);
 23.1014 +      return bf.reached(t);
 23.1015 +    }
 23.1016 +
 23.1017 +    template<class T>
 23.1018 +    struct SetPredMapBase : public Base {
 23.1019 +      typedef T PredMap;
 23.1020 +      static PredMap *createPredMap(const Digraph &) { return 0; };
 23.1021 +      SetPredMapBase(const TR &b) : TR(b) {}
 23.1022 +    };
 23.1023 +
 23.1024 +    /// \brief \ref named-templ-param "Named parameter" for setting
 23.1025 +    /// the predecessor map.
 23.1026 +    ///
 23.1027 +    /// \ref named-templ-param "Named parameter" for setting
 23.1028 +    /// the map that stores the predecessor arcs of the nodes.
 23.1029 +    template<class T>
 23.1030 +    BellmanFordWizard<SetPredMapBase<T> > predMap(const T &t) {
 23.1031 +      Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
 23.1032 +      return BellmanFordWizard<SetPredMapBase<T> >(*this);
 23.1033 +    }
 23.1034 +
 23.1035 +    template<class T>
 23.1036 +    struct SetDistMapBase : public Base {
 23.1037 +      typedef T DistMap;
 23.1038 +      static DistMap *createDistMap(const Digraph &) { return 0; };
 23.1039 +      SetDistMapBase(const TR &b) : TR(b) {}
 23.1040 +    };
 23.1041 +
 23.1042 +    /// \brief \ref named-templ-param "Named parameter" for setting
 23.1043 +    /// the distance map.
 23.1044 +    ///
 23.1045 +    /// \ref named-templ-param "Named parameter" for setting
 23.1046 +    /// the map that stores the distances of the nodes calculated
 23.1047 +    /// by the algorithm.
 23.1048 +    template<class T>
 23.1049 +    BellmanFordWizard<SetDistMapBase<T> > distMap(const T &t) {
 23.1050 +      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
 23.1051 +      return BellmanFordWizard<SetDistMapBase<T> >(*this);
 23.1052 +    }
 23.1053 +
 23.1054 +    template<class T>
 23.1055 +    struct SetPathBase : public Base {
 23.1056 +      typedef T Path;
 23.1057 +      SetPathBase(const TR &b) : TR(b) {}
 23.1058 +    };
 23.1059 +
 23.1060 +    /// \brief \ref named-func-param "Named parameter" for getting
 23.1061 +    /// the shortest path to the target node.
 23.1062 +    ///
 23.1063 +    /// \ref named-func-param "Named parameter" for getting
 23.1064 +    /// the shortest path to the target node.
 23.1065 +    template<class T>
 23.1066 +    BellmanFordWizard<SetPathBase<T> > path(const T &t)
 23.1067 +    {
 23.1068 +      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
 23.1069 +      return BellmanFordWizard<SetPathBase<T> >(*this);
 23.1070 +    }
 23.1071 +
 23.1072 +    /// \brief \ref named-func-param "Named parameter" for getting
 23.1073 +    /// the distance of the target node.
 23.1074 +    ///
 23.1075 +    /// \ref named-func-param "Named parameter" for getting
 23.1076 +    /// the distance of the target node.
 23.1077 +    BellmanFordWizard dist(const Value &d)
 23.1078 +    {
 23.1079 +      Base::_di=reinterpret_cast<void*>(const_cast<Value*>(&d));
 23.1080 +      return *this;
 23.1081 +    }
 23.1082 +
 23.1083 +  };
 23.1084 +
 23.1085 +  /// \brief Function type interface for the \ref BellmanFord "Bellman-Ford"
 23.1086 +  /// algorithm.
 23.1087 +  ///
 23.1088 +  /// \ingroup shortest_path
 23.1089 +  /// Function type interface for the \ref BellmanFord "Bellman-Ford"
 23.1090 +  /// algorithm.
 23.1091 +  ///
 23.1092 +  /// This function also has several \ref named-templ-func-param
 23.1093 +  /// "named parameters", they are declared as the members of class
 23.1094 +  /// \ref BellmanFordWizard.
 23.1095 +  /// The following examples show how to use these parameters.
 23.1096 +  /// \code
 23.1097 +  ///   // Compute shortest path from node s to each node
 23.1098 +  ///   bellmanFord(g,length).predMap(preds).distMap(dists).run(s);
 23.1099 +  ///
 23.1100 +  ///   // Compute shortest path from s to t
 23.1101 +  ///   bool reached = bellmanFord(g,length).path(p).dist(d).run(s,t);
 23.1102 +  /// \endcode
 23.1103 +  /// \warning Don't forget to put the \ref BellmanFordWizard::run() "run()"
 23.1104 +  /// to the end of the parameter list.
 23.1105 +  /// \sa BellmanFordWizard
 23.1106 +  /// \sa BellmanFord
 23.1107 +  template<typename GR, typename LEN>
 23.1108 +  BellmanFordWizard<BellmanFordWizardBase<GR,LEN> >
 23.1109 +  bellmanFord(const GR& digraph,
 23.1110 +              const LEN& length)
 23.1111 +  {
 23.1112 +    return BellmanFordWizard<BellmanFordWizardBase<GR,LEN> >(digraph, length);
 23.1113 +  }
 23.1114 +
 23.1115 +} //END OF NAMESPACE LEMON
 23.1116 +
 23.1117 +#endif
 23.1118 +
    24.1 --- a/lemon/bfs.h	Fri Aug 09 11:07:27 2013 +0200
    24.2 +++ b/lemon/bfs.h	Sun Aug 11 15:28:12 2013 +0200
    24.3 @@ -2,7 +2,7 @@
    24.4   *
    24.5   * This file is a part of LEMON, a generic C++ optimization library.
    24.6   *
    24.7 - * Copyright (C) 2003-2009
    24.8 + * Copyright (C) 2003-2010
    24.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   24.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   24.11   *
   24.12 @@ -47,7 +47,7 @@
   24.13      ///
   24.14      ///The type of the map that stores the predecessor
   24.15      ///arcs of the shortest paths.
   24.16 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   24.17 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   24.18      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
   24.19      ///Instantiates a \c PredMap.
   24.20  
   24.21 @@ -62,7 +62,8 @@
   24.22      ///The type of the map that indicates which nodes are processed.
   24.23  
   24.24      ///The type of the map that indicates which nodes are processed.
   24.25 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   24.26 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   24.27 +    ///By default, it is a NullMap.
   24.28      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   24.29      ///Instantiates a \c ProcessedMap.
   24.30  
   24.31 @@ -81,7 +82,8 @@
   24.32      ///The type of the map that indicates which nodes are reached.
   24.33  
   24.34      ///The type of the map that indicates which nodes are reached.
   24.35 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   24.36 +    ///It must conform to
   24.37 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   24.38      typedef typename Digraph::template NodeMap<bool> ReachedMap;
   24.39      ///Instantiates a \c ReachedMap.
   24.40  
   24.41 @@ -96,7 +98,7 @@
   24.42      ///The type of the map that stores the distances of the nodes.
   24.43  
   24.44      ///The type of the map that stores the distances of the nodes.
   24.45 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   24.46 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   24.47      typedef typename Digraph::template NodeMap<int> DistMap;
   24.48      ///Instantiates a \c DistMap.
   24.49  
   24.50 @@ -120,6 +122,11 @@
   24.51    ///
   24.52    ///\tparam GR The type of the digraph the algorithm runs on.
   24.53    ///The default type is \ref ListDigraph.
   24.54 +  ///\tparam TR The traits class that defines various types used by the
   24.55 +  ///algorithm. By default, it is \ref BfsDefaultTraits
   24.56 +  ///"BfsDefaultTraits<GR>".
   24.57 +  ///In most cases, this parameter should not be set directly,
   24.58 +  ///consider to use the named template parameters instead.
   24.59  #ifdef DOXYGEN
   24.60    template <typename GR,
   24.61              typename TR>
   24.62 @@ -225,7 +232,7 @@
   24.63      ///
   24.64      ///\ref named-templ-param "Named parameter" for setting
   24.65      ///\c PredMap type.
   24.66 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   24.67 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   24.68      template <class T>
   24.69      struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
   24.70        typedef Bfs< Digraph, SetPredMapTraits<T> > Create;
   24.71 @@ -245,7 +252,7 @@
   24.72      ///
   24.73      ///\ref named-templ-param "Named parameter" for setting
   24.74      ///\c DistMap type.
   24.75 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   24.76 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   24.77      template <class T>
   24.78      struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
   24.79        typedef Bfs< Digraph, SetDistMapTraits<T> > Create;
   24.80 @@ -265,7 +272,8 @@
   24.81      ///
   24.82      ///\ref named-templ-param "Named parameter" for setting
   24.83      ///\c ReachedMap type.
   24.84 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   24.85 +    ///It must conform to
   24.86 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   24.87      template <class T>
   24.88      struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
   24.89        typedef Bfs< Digraph, SetReachedMapTraits<T> > Create;
   24.90 @@ -285,7 +293,7 @@
   24.91      ///
   24.92      ///\ref named-templ-param "Named parameter" for setting
   24.93      ///\c ProcessedMap type.
   24.94 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   24.95 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   24.96      template <class T>
   24.97      struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
   24.98        typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create;
   24.99 @@ -413,8 +421,8 @@
  24.100      ///\name Execution Control
  24.101      ///The simplest way to execute the BFS algorithm is to use one of the
  24.102      ///member functions called \ref run(Node) "run()".\n
  24.103 -    ///If you need more control on the execution, first you have to call
  24.104 -    ///\ref init(), then you can add several source nodes with
  24.105 +    ///If you need better control on the execution, you have to call
  24.106 +    ///\ref init() first, then you can add several source nodes with
  24.107      ///\ref addSource(). Finally the actual path computation can be
  24.108      ///performed with one of the \ref start() functions.
  24.109  
  24.110 @@ -700,12 +708,8 @@
  24.111  
  24.112      ///Runs the algorithm to visit all nodes in the digraph.
  24.113  
  24.114 -    ///This method runs the %BFS algorithm in order to
  24.115 -    ///compute the shortest path to each node.
  24.116 -    ///
  24.117 -    ///The algorithm computes
  24.118 -    ///- the shortest path tree (forest),
  24.119 -    ///- the distance of each node from the root(s).
  24.120 +    ///This method runs the %BFS algorithm in order to visit all nodes
  24.121 +    ///in the digraph.
  24.122      ///
  24.123      ///\note <tt>b.run(s)</tt> is just a shortcut of the following code.
  24.124      ///\code
  24.125 @@ -737,9 +741,9 @@
  24.126  
  24.127      ///@{
  24.128  
  24.129 -    ///The shortest path to a node.
  24.130 +    ///The shortest path to the given node.
  24.131  
  24.132 -    ///Returns the shortest path to a node.
  24.133 +    ///Returns the shortest path to the given node from the root(s).
  24.134      ///
  24.135      ///\warning \c t should be reached from the root(s).
  24.136      ///
  24.137 @@ -747,9 +751,9 @@
  24.138      ///must be called before using this function.
  24.139      Path path(Node t) const { return Path(*G, *_pred, t); }
  24.140  
  24.141 -    ///The distance of a node from the root(s).
  24.142 +    ///The distance of the given node from the root(s).
  24.143  
  24.144 -    ///Returns the distance of a node from the root(s).
  24.145 +    ///Returns the distance of the given node from the root(s).
  24.146      ///
  24.147      ///\warning If node \c v is not reached from the root(s), then
  24.148      ///the return value of this function is undefined.
  24.149 @@ -758,29 +762,31 @@
  24.150      ///must be called before using this function.
  24.151      int dist(Node v) const { return (*_dist)[v]; }
  24.152  
  24.153 -    ///Returns the 'previous arc' of the shortest path tree for a node.
  24.154 -
  24.155 +    ///\brief Returns the 'previous arc' of the shortest path tree for
  24.156 +    ///the given node.
  24.157 +    ///
  24.158      ///This function returns the 'previous arc' of the shortest path
  24.159      ///tree for the node \c v, i.e. it returns the last arc of a
  24.160      ///shortest path from a root to \c v. It is \c INVALID if \c v
  24.161      ///is not reached from the root(s) or if \c v is a root.
  24.162      ///
  24.163      ///The shortest path tree used here is equal to the shortest path
  24.164 -    ///tree used in \ref predNode().
  24.165 +    ///tree used in \ref predNode() and \ref predMap().
  24.166      ///
  24.167      ///\pre Either \ref run(Node) "run()" or \ref init()
  24.168      ///must be called before using this function.
  24.169      Arc predArc(Node v) const { return (*_pred)[v];}
  24.170  
  24.171 -    ///Returns the 'previous node' of the shortest path tree for a node.
  24.172 -
  24.173 +    ///\brief Returns the 'previous node' of the shortest path tree for
  24.174 +    ///the given node.
  24.175 +    ///
  24.176      ///This function returns the 'previous node' of the shortest path
  24.177      ///tree for the node \c v, i.e. it returns the last but one node
  24.178 -    ///from a shortest path from a root to \c v. It is \c INVALID
  24.179 +    ///of a shortest path from a root to \c v. It is \c INVALID
  24.180      ///if \c v is not reached from the root(s) or if \c v is a root.
  24.181      ///
  24.182      ///The shortest path tree used here is equal to the shortest path
  24.183 -    ///tree used in \ref predArc().
  24.184 +    ///tree used in \ref predArc() and \ref predMap().
  24.185      ///
  24.186      ///\pre Either \ref run(Node) "run()" or \ref init()
  24.187      ///must be called before using this function.
  24.188 @@ -801,13 +807,13 @@
  24.189      ///predecessor arcs.
  24.190      ///
  24.191      ///Returns a const reference to the node map that stores the predecessor
  24.192 -    ///arcs, which form the shortest path tree.
  24.193 +    ///arcs, which form the shortest path tree (forest).
  24.194      ///
  24.195      ///\pre Either \ref run(Node) "run()" or \ref init()
  24.196      ///must be called before using this function.
  24.197      const PredMap &predMap() const { return *_pred;}
  24.198  
  24.199 -    ///Checks if a node is reached from the root(s).
  24.200 +    ///Checks if the given node is reached from the root(s).
  24.201  
  24.202      ///Returns \c true if \c v is reached from the root(s).
  24.203      ///
  24.204 @@ -833,7 +839,7 @@
  24.205      ///
  24.206      ///The type of the map that stores the predecessor
  24.207      ///arcs of the shortest paths.
  24.208 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  24.209 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  24.210      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
  24.211      ///Instantiates a PredMap.
  24.212  
  24.213 @@ -848,8 +854,8 @@
  24.214      ///The type of the map that indicates which nodes are processed.
  24.215  
  24.216      ///The type of the map that indicates which nodes are processed.
  24.217 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  24.218 -    ///By default it is a NullMap.
  24.219 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  24.220 +    ///By default, it is a NullMap.
  24.221      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
  24.222      ///Instantiates a ProcessedMap.
  24.223  
  24.224 @@ -868,7 +874,8 @@
  24.225      ///The type of the map that indicates which nodes are reached.
  24.226  
  24.227      ///The type of the map that indicates which nodes are reached.
  24.228 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  24.229 +    ///It must conform to
  24.230 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  24.231      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  24.232      ///Instantiates a ReachedMap.
  24.233  
  24.234 @@ -883,7 +890,7 @@
  24.235      ///The type of the map that stores the distances of the nodes.
  24.236  
  24.237      ///The type of the map that stores the distances of the nodes.
  24.238 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  24.239 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  24.240      typedef typename Digraph::template NodeMap<int> DistMap;
  24.241      ///Instantiates a DistMap.
  24.242  
  24.243 @@ -898,18 +905,14 @@
  24.244      ///The type of the shortest paths.
  24.245  
  24.246      ///The type of the shortest paths.
  24.247 -    ///It must meet the \ref concepts::Path "Path" concept.
  24.248 +    ///It must conform to the \ref concepts::Path "Path" concept.
  24.249      typedef lemon::Path<Digraph> Path;
  24.250    };
  24.251  
  24.252    /// Default traits class used by BfsWizard
  24.253  
  24.254 -  /// To make it easier to use Bfs algorithm
  24.255 -  /// we have created a wizard class.
  24.256 -  /// This \ref BfsWizard class needs default traits,
  24.257 -  /// as well as the \ref Bfs class.
  24.258 -  /// The \ref BfsWizardBase is a class to be the default traits of the
  24.259 -  /// \ref BfsWizard class.
  24.260 +  /// Default traits class used by BfsWizard.
  24.261 +  /// \tparam GR The type of the digraph.
  24.262    template<class GR>
  24.263    class BfsWizardBase : public BfsWizardDefaultTraits<GR>
  24.264    {
  24.265 @@ -937,7 +940,7 @@
  24.266      public:
  24.267      /// Constructor.
  24.268  
  24.269 -    /// This constructor does not require parameters, therefore it initiates
  24.270 +    /// This constructor does not require parameters, it initiates
  24.271      /// all of the attributes to \c 0.
  24.272      BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
  24.273                        _dist(0), _path(0), _di(0) {}
  24.274 @@ -962,12 +965,14 @@
  24.275    ///
  24.276    /// This class should only be used through the \ref bfs() function,
  24.277    /// which makes it easier to use the algorithm.
  24.278 +  ///
  24.279 +  /// \tparam TR The traits class that defines various types used by the
  24.280 +  /// algorithm.
  24.281    template<class TR>
  24.282    class BfsWizard : public TR
  24.283    {
  24.284      typedef TR Base;
  24.285  
  24.286 -    ///The type of the digraph the algorithm runs on.
  24.287      typedef typename TR::Digraph Digraph;
  24.288  
  24.289      typedef typename Digraph::Node Node;
  24.290 @@ -975,16 +980,10 @@
  24.291      typedef typename Digraph::Arc Arc;
  24.292      typedef typename Digraph::OutArcIt OutArcIt;
  24.293  
  24.294 -    ///\brief The type of the map that stores the predecessor
  24.295 -    ///arcs of the shortest paths.
  24.296      typedef typename TR::PredMap PredMap;
  24.297 -    ///\brief The type of the map that stores the distances of the nodes.
  24.298      typedef typename TR::DistMap DistMap;
  24.299 -    ///\brief The type of the map that indicates which nodes are reached.
  24.300      typedef typename TR::ReachedMap ReachedMap;
  24.301 -    ///\brief The type of the map that indicates which nodes are processed.
  24.302      typedef typename TR::ProcessedMap ProcessedMap;
  24.303 -    ///The type of the shortest paths
  24.304      typedef typename TR::Path Path;
  24.305  
  24.306    public:
  24.307 @@ -1054,8 +1053,8 @@
  24.308  
  24.309      ///Runs BFS algorithm to visit all nodes in the digraph.
  24.310  
  24.311 -    ///This method runs BFS algorithm in order to compute
  24.312 -    ///the shortest path to each node.
  24.313 +    ///This method runs BFS algorithm in order to visit all nodes
  24.314 +    ///in the digraph.
  24.315      void run()
  24.316      {
  24.317        run(INVALID);
  24.318 @@ -1067,11 +1066,12 @@
  24.319        static PredMap *createPredMap(const Digraph &) { return 0; };
  24.320        SetPredMapBase(const TR &b) : TR(b) {}
  24.321      };
  24.322 -    ///\brief \ref named-func-param "Named parameter"
  24.323 -    ///for setting PredMap object.
  24.324 +
  24.325 +    ///\brief \ref named-templ-param "Named parameter" for setting
  24.326 +    ///the predecessor map.
  24.327      ///
  24.328 -    ///\ref named-func-param "Named parameter"
  24.329 -    ///for setting PredMap object.
  24.330 +    ///\ref named-templ-param "Named parameter" function for setting
  24.331 +    ///the map that stores the predecessor arcs of the nodes.
  24.332      template<class T>
  24.333      BfsWizard<SetPredMapBase<T> > predMap(const T &t)
  24.334      {
  24.335 @@ -1085,11 +1085,12 @@
  24.336        static ReachedMap *createReachedMap(const Digraph &) { return 0; };
  24.337        SetReachedMapBase(const TR &b) : TR(b) {}
  24.338      };
  24.339 -    ///\brief \ref named-func-param "Named parameter"
  24.340 -    ///for setting ReachedMap object.
  24.341 +
  24.342 +    ///\brief \ref named-templ-param "Named parameter" for setting
  24.343 +    ///the reached map.
  24.344      ///
  24.345 -    /// \ref named-func-param "Named parameter"
  24.346 -    ///for setting ReachedMap object.
  24.347 +    ///\ref named-templ-param "Named parameter" function for setting
  24.348 +    ///the map that indicates which nodes are reached.
  24.349      template<class T>
  24.350      BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
  24.351      {
  24.352 @@ -1103,11 +1104,13 @@
  24.353        static DistMap *createDistMap(const Digraph &) { return 0; };
  24.354        SetDistMapBase(const TR &b) : TR(b) {}
  24.355      };
  24.356 -    ///\brief \ref named-func-param "Named parameter"
  24.357 -    ///for setting DistMap object.
  24.358 +
  24.359 +    ///\brief \ref named-templ-param "Named parameter" for setting
  24.360 +    ///the distance map.
  24.361      ///
  24.362 -    /// \ref named-func-param "Named parameter"
  24.363 -    ///for setting DistMap object.
  24.364 +    ///\ref named-templ-param "Named parameter" function for setting
  24.365 +    ///the map that stores the distances of the nodes calculated
  24.366 +    ///by the algorithm.
  24.367      template<class T>
  24.368      BfsWizard<SetDistMapBase<T> > distMap(const T &t)
  24.369      {
  24.370 @@ -1121,11 +1124,12 @@
  24.371        static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
  24.372        SetProcessedMapBase(const TR &b) : TR(b) {}
  24.373      };
  24.374 -    ///\brief \ref named-func-param "Named parameter"
  24.375 -    ///for setting ProcessedMap object.
  24.376 +
  24.377 +    ///\brief \ref named-func-param "Named parameter" for setting
  24.378 +    ///the processed map.
  24.379      ///
  24.380 -    /// \ref named-func-param "Named parameter"
  24.381 -    ///for setting ProcessedMap object.
  24.382 +    ///\ref named-templ-param "Named parameter" function for setting
  24.383 +    ///the map that indicates which nodes are processed.
  24.384      template<class T>
  24.385      BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
  24.386      {
  24.387 @@ -1265,7 +1269,8 @@
  24.388      /// \brief The type of the map that indicates which nodes are reached.
  24.389      ///
  24.390      /// The type of the map that indicates which nodes are reached.
  24.391 -    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  24.392 +    /// It must conform to
  24.393 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  24.394      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  24.395  
  24.396      /// \brief Instantiates a ReachedMap.
  24.397 @@ -1303,11 +1308,11 @@
  24.398    /// \ref BfsVisitor "BfsVisitor<GR>" is an empty visitor, which
  24.399    /// does not observe the BFS events. If you want to observe the BFS
  24.400    /// events, you should implement your own visitor class.
  24.401 -  /// \tparam TR Traits class to set various data types used by the
  24.402 -  /// algorithm. The default traits class is
  24.403 -  /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>".
  24.404 -  /// See \ref BfsVisitDefaultTraits for the documentation of
  24.405 -  /// a BFS visit traits class.
  24.406 +  /// \tparam TR The traits class that defines various types used by the
  24.407 +  /// algorithm. By default, it is \ref BfsVisitDefaultTraits
  24.408 +  /// "BfsVisitDefaultTraits<GR>".
  24.409 +  /// In most cases, this parameter should not be set directly,
  24.410 +  /// consider to use the named template parameters instead.
  24.411  #ifdef DOXYGEN
  24.412    template <typename GR, typename VS, typename TR>
  24.413  #else
  24.414 @@ -1426,8 +1431,8 @@
  24.415      /// \name Execution Control
  24.416      /// The simplest way to execute the BFS algorithm is to use one of the
  24.417      /// member functions called \ref run(Node) "run()".\n
  24.418 -    /// If you need more control on the execution, first you have to call
  24.419 -    /// \ref init(), then you can add several source nodes with
  24.420 +    /// If you need better control on the execution, you have to call
  24.421 +    /// \ref init() first, then you can add several source nodes with
  24.422      /// \ref addSource(). Finally the actual path computation can be
  24.423      /// performed with one of the \ref start() functions.
  24.424  
  24.425 @@ -1699,12 +1704,8 @@
  24.426  
  24.427      /// \brief Runs the algorithm to visit all nodes in the digraph.
  24.428      ///
  24.429 -    /// This method runs the %BFS algorithm in order to
  24.430 -    /// compute the shortest path to each node.
  24.431 -    ///
  24.432 -    /// The algorithm computes
  24.433 -    /// - the shortest path tree (forest),
  24.434 -    /// - the distance of each node from the root(s).
  24.435 +    /// This method runs the %BFS algorithm in order to visit all nodes
  24.436 +    /// in the digraph.
  24.437      ///
  24.438      /// \note <tt>b.run(s)</tt> is just a shortcut of the following code.
  24.439      ///\code
  24.440 @@ -1736,7 +1737,7 @@
  24.441  
  24.442      ///@{
  24.443  
  24.444 -    /// \brief Checks if a node is reached from the root(s).
  24.445 +    /// \brief Checks if the given node is reached from the root(s).
  24.446      ///
  24.447      /// Returns \c true if \c v is reached from the root(s).
  24.448      ///
    25.1 --- a/lemon/bin_heap.h	Fri Aug 09 11:07:27 2013 +0200
    25.2 +++ b/lemon/bin_heap.h	Sun Aug 11 15:28:12 2013 +0200
    25.3 @@ -19,9 +19,9 @@
    25.4  #ifndef LEMON_BIN_HEAP_H
    25.5  #define LEMON_BIN_HEAP_H
    25.6  
    25.7 -///\ingroup auxdat
    25.8 +///\ingroup heaps
    25.9  ///\file
   25.10 -///\brief Binary Heap implementation.
   25.11 +///\brief Binary heap implementation.
   25.12  
   25.13  #include <vector>
   25.14  #include <utility>
   25.15 @@ -29,45 +29,41 @@
   25.16  
   25.17  namespace lemon {
   25.18  
   25.19 -  ///\ingroup auxdat
   25.20 +  /// \ingroup heaps
   25.21    ///
   25.22 -  ///\brief A Binary Heap implementation.
   25.23 +  /// \brief Binary heap data structure.
   25.24    ///
   25.25 -  ///This class implements the \e binary \e heap data structure.
   25.26 +  /// This class implements the \e binary \e heap data structure.
   25.27 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   25.28    ///
   25.29 -  ///A \e heap is a data structure for storing items with specified values
   25.30 -  ///called \e priorities in such a way that finding the item with minimum
   25.31 -  ///priority is efficient. \c CMP specifies the ordering of the priorities.
   25.32 -  ///In a heap one can change the priority of an item, add or erase an
   25.33 -  ///item, etc.
   25.34 -  ///
   25.35 -  ///\tparam PR Type of the priority of the items.
   25.36 -  ///\tparam IM A read and writable item map with int values, used internally
   25.37 -  ///to handle the cross references.
   25.38 -  ///\tparam CMP A functor class for the ordering of the priorities.
   25.39 -  ///The default is \c std::less<PR>.
   25.40 -  ///
   25.41 -  ///\sa FibHeap
   25.42 -  ///\sa Dijkstra
   25.43 +  /// \tparam PR Type of the priorities of the items.
   25.44 +  /// \tparam IM A read-writable item map with \c int values, used
   25.45 +  /// internally to handle the cross references.
   25.46 +  /// \tparam CMP A functor class for comparing the priorities.
   25.47 +  /// The default is \c std::less<PR>.
   25.48 +#ifdef DOXYGEN
   25.49 +  template <typename PR, typename IM, typename CMP>
   25.50 +#else
   25.51    template <typename PR, typename IM, typename CMP = std::less<PR> >
   25.52 +#endif
   25.53    class BinHeap {
   25.54 +  public:
   25.55  
   25.56 -  public:
   25.57 -    ///\e
   25.58 +    /// Type of the item-int map.
   25.59      typedef IM ItemIntMap;
   25.60 -    ///\e
   25.61 +    /// Type of the priorities.
   25.62      typedef PR Prio;
   25.63 -    ///\e
   25.64 +    /// Type of the items stored in the heap.
   25.65      typedef typename ItemIntMap::Key Item;
   25.66 -    ///\e
   25.67 +    /// Type of the item-priority pairs.
   25.68      typedef std::pair<Item,Prio> Pair;
   25.69 -    ///\e
   25.70 +    /// Functor type for comparing the priorities.
   25.71      typedef CMP Compare;
   25.72  
   25.73 -    /// \brief Type to represent the items states.
   25.74 +    /// \brief Type to represent the states of the items.
   25.75      ///
   25.76 -    /// Each Item element have a state associated to it. It may be "in heap",
   25.77 -    /// "pre heap" or "post heap". The latter two are indifferent from the
   25.78 +    /// Each item has a state associated to it. It can be "in heap",
   25.79 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   25.80      /// heap's point of view, but may be useful to the user.
   25.81      ///
   25.82      /// The item-int map must be initialized in such way that it assigns
   25.83 @@ -84,42 +80,43 @@
   25.84      ItemIntMap &_iim;
   25.85  
   25.86    public:
   25.87 -    /// \brief The constructor.
   25.88 +
   25.89 +    /// \brief Constructor.
   25.90      ///
   25.91 -    /// The constructor.
   25.92 -    /// \param map should be given to the constructor, since it is used
   25.93 -    /// internally to handle the cross references. The value of the map
   25.94 -    /// must be \c PRE_HEAP (<tt>-1</tt>) for every item.
   25.95 +    /// Constructor.
   25.96 +    /// \param map A map that assigns \c int values to the items.
   25.97 +    /// It is used internally to handle the cross references.
   25.98 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
   25.99      explicit BinHeap(ItemIntMap &map) : _iim(map) {}
  25.100  
  25.101 -    /// \brief The constructor.
  25.102 +    /// \brief Constructor.
  25.103      ///
  25.104 -    /// The constructor.
  25.105 -    /// \param map should be given to the constructor, since it is used
  25.106 -    /// internally to handle the cross references. The value of the map
  25.107 -    /// should be PRE_HEAP (-1) for each element.
  25.108 -    ///
  25.109 -    /// \param comp The comparator function object.
  25.110 +    /// Constructor.
  25.111 +    /// \param map A map that assigns \c int values to the items.
  25.112 +    /// It is used internally to handle the cross references.
  25.113 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  25.114 +    /// \param comp The function object used for comparing the priorities.
  25.115      BinHeap(ItemIntMap &map, const Compare &comp)
  25.116        : _iim(map), _comp(comp) {}
  25.117  
  25.118  
  25.119 -    /// The number of items stored in the heap.
  25.120 +    /// \brief The number of items stored in the heap.
  25.121      ///
  25.122 -    /// \brief Returns the number of items stored in the heap.
  25.123 +    /// This function returns the number of items stored in the heap.
  25.124      int size() const { return _data.size(); }
  25.125  
  25.126 -    /// \brief Checks if the heap stores no items.
  25.127 +    /// \brief Check if the heap is empty.
  25.128      ///
  25.129 -    /// Returns \c true if and only if the heap stores no items.
  25.130 +    /// This function returns \c true if the heap is empty.
  25.131      bool empty() const { return _data.empty(); }
  25.132  
  25.133 -    /// \brief Make empty this heap.
  25.134 +    /// \brief Make the heap empty.
  25.135      ///
  25.136 -    /// Make empty this heap. It does not change the cross reference map.
  25.137 -    /// If you want to reuse what is not surely empty you should first clear
  25.138 -    /// the heap and after that you should set the cross reference map for
  25.139 -    /// each item to \c PRE_HEAP.
  25.140 +    /// This functon makes the heap empty.
  25.141 +    /// It does not change the cross reference map. If you want to reuse
  25.142 +    /// a heap that is not surely empty, you should first clear it and
  25.143 +    /// then you should set the cross reference map to \c PRE_HEAP
  25.144 +    /// for each item.
  25.145      void clear() {
  25.146        _data.clear();
  25.147      }
  25.148 @@ -127,12 +124,12 @@
  25.149    private:
  25.150      static int parent(int i) { return (i-1)/2; }
  25.151  
  25.152 -    static int second_child(int i) { return 2*i+2; }
  25.153 +    static int secondChild(int i) { return 2*i+2; }
  25.154      bool less(const Pair &p1, const Pair &p2) const {
  25.155        return _comp(p1.second, p2.second);
  25.156      }
  25.157  
  25.158 -    int bubble_up(int hole, Pair p) {
  25.159 +    int bubbleUp(int hole, Pair p) {
  25.160        int par = parent(hole);
  25.161        while( hole>0 && less(p,_data[par]) ) {
  25.162          move(_data[par],hole);
  25.163 @@ -143,8 +140,8 @@
  25.164        return hole;
  25.165      }
  25.166  
  25.167 -    int bubble_down(int hole, Pair p, int length) {
  25.168 -      int child = second_child(hole);
  25.169 +    int bubbleDown(int hole, Pair p, int length) {
  25.170 +      int child = secondChild(hole);
  25.171        while(child < length) {
  25.172          if( less(_data[child-1], _data[child]) ) {
  25.173            --child;
  25.174 @@ -153,7 +150,7 @@
  25.175            goto ok;
  25.176          move(_data[child], hole);
  25.177          hole = child;
  25.178 -        child = second_child(hole);
  25.179 +        child = secondChild(hole);
  25.180        }
  25.181        child--;
  25.182        if( child<length && less(_data[child], p) ) {
  25.183 @@ -171,87 +168,91 @@
  25.184      }
  25.185  
  25.186    public:
  25.187 +
  25.188      /// \brief Insert a pair of item and priority into the heap.
  25.189      ///
  25.190 -    /// Adds \c p.first to the heap with priority \c p.second.
  25.191 +    /// This function inserts \c p.first to the heap with priority
  25.192 +    /// \c p.second.
  25.193      /// \param p The pair to insert.
  25.194 +    /// \pre \c p.first must not be stored in the heap.
  25.195      void push(const Pair &p) {
  25.196        int n = _data.size();
  25.197        _data.resize(n+1);
  25.198 -      bubble_up(n, p);
  25.199 +      bubbleUp(n, p);
  25.200      }
  25.201  
  25.202 -    /// \brief Insert an item into the heap with the given heap.
  25.203 +    /// \brief Insert an item into the heap with the given priority.
  25.204      ///
  25.205 -    /// Adds \c i to the heap with priority \c p.
  25.206 +    /// This function inserts the given item into the heap with the
  25.207 +    /// given priority.
  25.208      /// \param i The item to insert.
  25.209      /// \param p The priority of the item.
  25.210 +    /// \pre \e i must not be stored in the heap.
  25.211      void push(const Item &i, const Prio &p) { push(Pair(i,p)); }
  25.212  
  25.213 -    /// \brief Returns the item with minimum priority relative to \c Compare.
  25.214 +    /// \brief Return the item having minimum priority.
  25.215      ///
  25.216 -    /// This method returns the item with minimum priority relative to \c
  25.217 -    /// Compare.
  25.218 -    /// \pre The heap must be nonempty.
  25.219 +    /// This function returns the item having minimum priority.
  25.220 +    /// \pre The heap must be non-empty.
  25.221      Item top() const {
  25.222        return _data[0].first;
  25.223      }
  25.224  
  25.225 -    /// \brief Returns the minimum priority relative to \c Compare.
  25.226 +    /// \brief The minimum priority.
  25.227      ///
  25.228 -    /// It returns the minimum priority relative to \c Compare.
  25.229 -    /// \pre The heap must be nonempty.
  25.230 +    /// This function returns the minimum priority.
  25.231 +    /// \pre The heap must be non-empty.
  25.232      Prio prio() const {
  25.233        return _data[0].second;
  25.234      }
  25.235  
  25.236 -    /// \brief Deletes the item with minimum priority relative to \c Compare.
  25.237 +    /// \brief Remove the item having minimum priority.
  25.238      ///
  25.239 -    /// This method deletes the item with minimum priority relative to \c
  25.240 -    /// Compare from the heap.
  25.241 +    /// This function removes the item having minimum priority.
  25.242      /// \pre The heap must be non-empty.
  25.243      void pop() {
  25.244        int n = _data.size()-1;
  25.245        _iim.set(_data[0].first, POST_HEAP);
  25.246        if (n > 0) {
  25.247 -        bubble_down(0, _data[n], n);
  25.248 +        bubbleDown(0, _data[n], n);
  25.249        }
  25.250        _data.pop_back();
  25.251      }
  25.252  
  25.253 -    /// \brief Deletes \c i from the heap.
  25.254 +    /// \brief Remove the given item from the heap.
  25.255      ///
  25.256 -    /// This method deletes item \c i from the heap.
  25.257 -    /// \param i The item to erase.
  25.258 -    /// \pre The item should be in the heap.
  25.259 +    /// This function removes the given item from the heap if it is
  25.260 +    /// already stored.
  25.261 +    /// \param i The item to delete.
  25.262 +    /// \pre \e i must be in the heap.
  25.263      void erase(const Item &i) {
  25.264        int h = _iim[i];
  25.265        int n = _data.size()-1;
  25.266        _iim.set(_data[h].first, POST_HEAP);
  25.267        if( h < n ) {
  25.268 -        if ( bubble_up(h, _data[n]) == h) {
  25.269 -          bubble_down(h, _data[n], n);
  25.270 +        if ( bubbleUp(h, _data[n]) == h) {
  25.271 +          bubbleDown(h, _data[n], n);
  25.272          }
  25.273        }
  25.274        _data.pop_back();
  25.275      }
  25.276  
  25.277 -
  25.278 -    /// \brief Returns the priority of \c i.
  25.279 +    /// \brief The priority of the given item.
  25.280      ///
  25.281 -    /// This function returns the priority of item \c i.
  25.282 +    /// This function returns the priority of the given item.
  25.283      /// \param i The item.
  25.284 -    /// \pre \c i must be in the heap.
  25.285 +    /// \pre \e i must be in the heap.
  25.286      Prio operator[](const Item &i) const {
  25.287        int idx = _iim[i];
  25.288        return _data[idx].second;
  25.289      }
  25.290  
  25.291 -    /// \brief \c i gets to the heap with priority \c p independently
  25.292 -    /// if \c i was already there.
  25.293 +    /// \brief Set the priority of an item or insert it, if it is
  25.294 +    /// not stored in the heap.
  25.295      ///
  25.296 -    /// This method calls \ref push(\c i, \c p) if \c i is not stored
  25.297 -    /// in the heap and sets the priority of \c i to \c p otherwise.
  25.298 +    /// This method sets the priority of the given item if it is
  25.299 +    /// already stored in the heap. Otherwise it inserts the given
  25.300 +    /// item into the heap with the given priority.
  25.301      /// \param i The item.
  25.302      /// \param p The priority.
  25.303      void set(const Item &i, const Prio &p) {
  25.304 @@ -260,44 +261,42 @@
  25.305          push(i,p);
  25.306        }
  25.307        else if( _comp(p, _data[idx].second) ) {
  25.308 -        bubble_up(idx, Pair(i,p));
  25.309 +        bubbleUp(idx, Pair(i,p));
  25.310        }
  25.311        else {
  25.312 -        bubble_down(idx, Pair(i,p), _data.size());
  25.313 +        bubbleDown(idx, Pair(i,p), _data.size());
  25.314        }
  25.315      }
  25.316  
  25.317 -    /// \brief Decreases the priority of \c i to \c p.
  25.318 +    /// \brief Decrease the priority of an item to the given value.
  25.319      ///
  25.320 -    /// This method decreases the priority of item \c i to \c p.
  25.321 +    /// This function decreases the priority of an item to the given value.
  25.322      /// \param i The item.
  25.323      /// \param p The priority.
  25.324 -    /// \pre \c i must be stored in the heap with priority at least \c
  25.325 -    /// p relative to \c Compare.
  25.326 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  25.327      void decrease(const Item &i, const Prio &p) {
  25.328        int idx = _iim[i];
  25.329 -      bubble_up(idx, Pair(i,p));
  25.330 +      bubbleUp(idx, Pair(i,p));
  25.331      }
  25.332  
  25.333 -    /// \brief Increases the priority of \c i to \c p.
  25.334 +    /// \brief Increase the priority of an item to the given value.
  25.335      ///
  25.336 -    /// This method sets the priority of item \c i to \c p.
  25.337 +    /// This function increases the priority of an item to the given value.
  25.338      /// \param i The item.
  25.339      /// \param p The priority.
  25.340 -    /// \pre \c i must be stored in the heap with priority at most \c
  25.341 -    /// p relative to \c Compare.
  25.342 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  25.343      void increase(const Item &i, const Prio &p) {
  25.344        int idx = _iim[i];
  25.345 -      bubble_down(idx, Pair(i,p), _data.size());
  25.346 +      bubbleDown(idx, Pair(i,p), _data.size());
  25.347      }
  25.348  
  25.349 -    /// \brief Returns if \c item is in, has already been in, or has
  25.350 -    /// never been in the heap.
  25.351 +    /// \brief Return the state of an item.
  25.352      ///
  25.353 -    /// This method returns PRE_HEAP if \c item has never been in the
  25.354 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  25.355 -    /// otherwise. In the latter case it is possible that \c item will
  25.356 -    /// get back to the heap again.
  25.357 +    /// This method returns \c PRE_HEAP if the given item has never
  25.358 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  25.359 +    /// and \c POST_HEAP otherwise.
  25.360 +    /// In the latter case it is possible that the item will get back
  25.361 +    /// to the heap again.
  25.362      /// \param i The item.
  25.363      State state(const Item &i) const {
  25.364        int s = _iim[i];
  25.365 @@ -306,11 +305,11 @@
  25.366        return State(s);
  25.367      }
  25.368  
  25.369 -    /// \brief Sets the state of the \c item in the heap.
  25.370 +    /// \brief Set the state of an item in the heap.
  25.371      ///
  25.372 -    /// Sets the state of the \c item in the heap. It can be used to
  25.373 -    /// manually clear the heap when it is important to achive the
  25.374 -    /// better time complexity.
  25.375 +    /// This function sets the state of the given item in the heap.
  25.376 +    /// It can be used to manually clear the heap when it is important
  25.377 +    /// to achive better time complexity.
  25.378      /// \param i The item.
  25.379      /// \param st The state. It should not be \c IN_HEAP.
  25.380      void state(const Item& i, State st) {
  25.381 @@ -327,12 +326,13 @@
  25.382        }
  25.383      }
  25.384  
  25.385 -    /// \brief Replaces an item in the heap.
  25.386 +    /// \brief Replace an item in the heap.
  25.387      ///
  25.388 -    /// The \c i item is replaced with \c j item. The \c i item should
  25.389 -    /// be in the heap, while the \c j should be out of the heap. The
  25.390 -    /// \c i item will out of the heap and \c j will be in the heap
  25.391 -    /// with the same prioriority as prevoiusly the \c i item.
  25.392 +    /// This function replaces item \c i with item \c j.
  25.393 +    /// Item \c i must be in the heap, while \c j must be out of the heap.
  25.394 +    /// After calling this method, item \c i will be out of the
  25.395 +    /// heap and \c j will be in the heap with the same prioriority
  25.396 +    /// as item \c i had before.
  25.397      void replace(const Item& i, const Item& j) {
  25.398        int idx = _iim[i];
  25.399        _iim.set(i, _iim[j]);
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/lemon/binomial_heap.h	Sun Aug 11 15:28:12 2013 +0200
    26.3 @@ -0,0 +1,445 @@
    26.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    26.5 + *
    26.6 + * This file is a part of LEMON, a generic C++ optimization library.
    26.7 + *
    26.8 + * Copyright (C) 2003-2010
    26.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   26.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   26.11 + *
   26.12 + * Permission to use, modify and distribute this software is granted
   26.13 + * provided that this copyright notice appears in all copies. For
   26.14 + * precise terms see the accompanying LICENSE file.
   26.15 + *
   26.16 + * This software is provided "AS IS" with no warranty of any kind,
   26.17 + * express or implied, and with no claim as to its suitability for any
   26.18 + * purpose.
   26.19 + *
   26.20 + */
   26.21 +
   26.22 +#ifndef LEMON_BINOMIAL_HEAP_H
   26.23 +#define LEMON_BINOMIAL_HEAP_H
   26.24 +
   26.25 +///\file
   26.26 +///\ingroup heaps
   26.27 +///\brief Binomial Heap implementation.
   26.28 +
   26.29 +#include <vector>
   26.30 +#include <utility>
   26.31 +#include <functional>
   26.32 +#include <lemon/math.h>
   26.33 +#include <lemon/counter.h>
   26.34 +
   26.35 +namespace lemon {
   26.36 +
   26.37 +  /// \ingroup heaps
   26.38 +  ///
   26.39 +  ///\brief Binomial heap data structure.
   26.40 +  ///
   26.41 +  /// This class implements the \e binomial \e heap data structure.
   26.42 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   26.43 +  ///
   26.44 +  /// The methods \ref increase() and \ref erase() are not efficient
   26.45 +  /// in a binomial heap. In case of many calls of these operations,
   26.46 +  /// it is better to use other heap structure, e.g. \ref BinHeap
   26.47 +  /// "binary heap".
   26.48 +  ///
   26.49 +  /// \tparam PR Type of the priorities of the items.
   26.50 +  /// \tparam IM A read-writable item map with \c int values, used
   26.51 +  /// internally to handle the cross references.
   26.52 +  /// \tparam CMP A functor class for comparing the priorities.
   26.53 +  /// The default is \c std::less<PR>.
   26.54 +#ifdef DOXYGEN
   26.55 +  template <typename PR, typename IM, typename CMP>
   26.56 +#else
   26.57 +  template <typename PR, typename IM, typename CMP = std::less<PR> >
   26.58 +#endif
   26.59 +  class BinomialHeap {
   26.60 +  public:
   26.61 +    /// Type of the item-int map.
   26.62 +    typedef IM ItemIntMap;
   26.63 +    /// Type of the priorities.
   26.64 +    typedef PR Prio;
   26.65 +    /// Type of the items stored in the heap.
   26.66 +    typedef typename ItemIntMap::Key Item;
   26.67 +    /// Functor type for comparing the priorities.
   26.68 +    typedef CMP Compare;
   26.69 +
   26.70 +    /// \brief Type to represent the states of the items.
   26.71 +    ///
   26.72 +    /// Each item has a state associated to it. It can be "in heap",
   26.73 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   26.74 +    /// heap's point of view, but may be useful to the user.
   26.75 +    ///
   26.76 +    /// The item-int map must be initialized in such way that it assigns
   26.77 +    /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap.
   26.78 +    enum State {
   26.79 +      IN_HEAP = 0,    ///< = 0.
   26.80 +      PRE_HEAP = -1,  ///< = -1.
   26.81 +      POST_HEAP = -2  ///< = -2.
   26.82 +    };
   26.83 +
   26.84 +  private:
   26.85 +    class Store;
   26.86 +
   26.87 +    std::vector<Store> _data;
   26.88 +    int _min, _head;
   26.89 +    ItemIntMap &_iim;
   26.90 +    Compare _comp;
   26.91 +    int _num_items;
   26.92 +
   26.93 +  public:
   26.94 +    /// \brief Constructor.
   26.95 +    ///
   26.96 +    /// Constructor.
   26.97 +    /// \param map A map that assigns \c int values to the items.
   26.98 +    /// It is used internally to handle the cross references.
   26.99 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  26.100 +    explicit BinomialHeap(ItemIntMap &map)
  26.101 +      : _min(0), _head(-1), _iim(map), _num_items(0) {}
  26.102 +
  26.103 +    /// \brief Constructor.
  26.104 +    ///
  26.105 +    /// Constructor.
  26.106 +    /// \param map A map that assigns \c int values to the items.
  26.107 +    /// It is used internally to handle the cross references.
  26.108 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  26.109 +    /// \param comp The function object used for comparing the priorities.
  26.110 +    BinomialHeap(ItemIntMap &map, const Compare &comp)
  26.111 +      : _min(0), _head(-1), _iim(map), _comp(comp), _num_items(0) {}
  26.112 +
  26.113 +    /// \brief The number of items stored in the heap.
  26.114 +    ///
  26.115 +    /// This function returns the number of items stored in the heap.
  26.116 +    int size() const { return _num_items; }
  26.117 +
  26.118 +    /// \brief Check if the heap is empty.
  26.119 +    ///
  26.120 +    /// This function returns \c true if the heap is empty.
  26.121 +    bool empty() const { return _num_items==0; }
  26.122 +
  26.123 +    /// \brief Make the heap empty.
  26.124 +    ///
  26.125 +    /// This functon makes the heap empty.
  26.126 +    /// It does not change the cross reference map. If you want to reuse
  26.127 +    /// a heap that is not surely empty, you should first clear it and
  26.128 +    /// then you should set the cross reference map to \c PRE_HEAP
  26.129 +    /// for each item.
  26.130 +    void clear() {
  26.131 +      _data.clear(); _min=0; _num_items=0; _head=-1;
  26.132 +    }
  26.133 +
  26.134 +    /// \brief Set the priority of an item or insert it, if it is
  26.135 +    /// not stored in the heap.
  26.136 +    ///
  26.137 +    /// This method sets the priority of the given item if it is
  26.138 +    /// already stored in the heap. Otherwise it inserts the given
  26.139 +    /// item into the heap with the given priority.
  26.140 +    /// \param item The item.
  26.141 +    /// \param value The priority.
  26.142 +    void set (const Item& item, const Prio& value) {
  26.143 +      int i=_iim[item];
  26.144 +      if ( i >= 0 && _data[i].in ) {
  26.145 +        if ( _comp(value, _data[i].prio) ) decrease(item, value);
  26.146 +        if ( _comp(_data[i].prio, value) ) increase(item, value);
  26.147 +      } else push(item, value);
  26.148 +    }
  26.149 +
  26.150 +    /// \brief Insert an item into the heap with the given priority.
  26.151 +    ///
  26.152 +    /// This function inserts the given item into the heap with the
  26.153 +    /// given priority.
  26.154 +    /// \param item The item to insert.
  26.155 +    /// \param value The priority of the item.
  26.156 +    /// \pre \e item must not be stored in the heap.
  26.157 +    void push (const Item& item, const Prio& value) {
  26.158 +      int i=_iim[item];
  26.159 +      if ( i<0 ) {
  26.160 +        int s=_data.size();
  26.161 +        _iim.set( item,s );
  26.162 +        Store st;
  26.163 +        st.name=item;
  26.164 +        st.prio=value;
  26.165 +        _data.push_back(st);
  26.166 +        i=s;
  26.167 +      }
  26.168 +      else {
  26.169 +        _data[i].parent=_data[i].right_neighbor=_data[i].child=-1;
  26.170 +        _data[i].degree=0;
  26.171 +        _data[i].in=true;
  26.172 +        _data[i].prio=value;
  26.173 +      }
  26.174 +
  26.175 +      if( 0==_num_items ) {
  26.176 +        _head=i;
  26.177 +        _min=i;
  26.178 +      } else {
  26.179 +        merge(i);
  26.180 +        if( _comp(_data[i].prio, _data[_min].prio) ) _min=i;
  26.181 +      }
  26.182 +      ++_num_items;
  26.183 +    }
  26.184 +
  26.185 +    /// \brief Return the item having minimum priority.
  26.186 +    ///
  26.187 +    /// This function returns the item having minimum priority.
  26.188 +    /// \pre The heap must be non-empty.
  26.189 +    Item top() const { return _data[_min].name; }
  26.190 +
  26.191 +    /// \brief The minimum priority.
  26.192 +    ///
  26.193 +    /// This function returns the minimum priority.
  26.194 +    /// \pre The heap must be non-empty.
  26.195 +    Prio prio() const { return _data[_min].prio; }
  26.196 +
  26.197 +    /// \brief The priority of the given item.
  26.198 +    ///
  26.199 +    /// This function returns the priority of the given item.
  26.200 +    /// \param item The item.
  26.201 +    /// \pre \e item must be in the heap.
  26.202 +    const Prio& operator[](const Item& item) const {
  26.203 +      return _data[_iim[item]].prio;
  26.204 +    }
  26.205 +
  26.206 +    /// \brief Remove the item having minimum priority.
  26.207 +    ///
  26.208 +    /// This function removes the item having minimum priority.
  26.209 +    /// \pre The heap must be non-empty.
  26.210 +    void pop() {
  26.211 +      _data[_min].in=false;
  26.212 +
  26.213 +      int head_child=-1;
  26.214 +      if ( _data[_min].child!=-1 ) {
  26.215 +        int child=_data[_min].child;
  26.216 +        int neighb;
  26.217 +        while( child!=-1 ) {
  26.218 +          neighb=_data[child].right_neighbor;
  26.219 +          _data[child].parent=-1;
  26.220 +          _data[child].right_neighbor=head_child;
  26.221 +          head_child=child;
  26.222 +          child=neighb;
  26.223 +        }
  26.224 +      }
  26.225 +
  26.226 +      if ( _data[_head].right_neighbor==-1 ) {
  26.227 +        // there was only one root
  26.228 +        _head=head_child;
  26.229 +      }
  26.230 +      else {
  26.231 +        // there were more roots
  26.232 +        if( _head!=_min )  { unlace(_min); }
  26.233 +        else { _head=_data[_head].right_neighbor; }
  26.234 +        merge(head_child);
  26.235 +      }
  26.236 +      _min=findMin();
  26.237 +      --_num_items;
  26.238 +    }
  26.239 +
  26.240 +    /// \brief Remove the given item from the heap.
  26.241 +    ///
  26.242 +    /// This function removes the given item from the heap if it is
  26.243 +    /// already stored.
  26.244 +    /// \param item The item to delete.
  26.245 +    /// \pre \e item must be in the heap.
  26.246 +    void erase (const Item& item) {
  26.247 +      int i=_iim[item];
  26.248 +      if ( i >= 0 && _data[i].in ) {
  26.249 +        decrease( item, _data[_min].prio-1 );
  26.250 +        pop();
  26.251 +      }
  26.252 +    }
  26.253 +
  26.254 +    /// \brief Decrease the priority of an item to the given value.
  26.255 +    ///
  26.256 +    /// This function decreases the priority of an item to the given value.
  26.257 +    /// \param item The item.
  26.258 +    /// \param value The priority.
  26.259 +    /// \pre \e item must be stored in the heap with priority at least \e value.
  26.260 +    void decrease (Item item, const Prio& value) {
  26.261 +      int i=_iim[item];
  26.262 +      int p=_data[i].parent;
  26.263 +      _data[i].prio=value;
  26.264 +
  26.265 +      while( p!=-1 && _comp(value, _data[p].prio) ) {
  26.266 +        _data[i].name=_data[p].name;
  26.267 +        _data[i].prio=_data[p].prio;
  26.268 +        _data[p].name=item;
  26.269 +        _data[p].prio=value;
  26.270 +        _iim[_data[i].name]=i;
  26.271 +        i=p;
  26.272 +        p=_data[p].parent;
  26.273 +      }
  26.274 +      _iim[item]=i;
  26.275 +      if ( _comp(value, _data[_min].prio) ) _min=i;
  26.276 +    }
  26.277 +
  26.278 +    /// \brief Increase the priority of an item to the given value.
  26.279 +    ///
  26.280 +    /// This function increases the priority of an item to the given value.
  26.281 +    /// \param item The item.
  26.282 +    /// \param value The priority.
  26.283 +    /// \pre \e item must be stored in the heap with priority at most \e value.
  26.284 +    void increase (Item item, const Prio& value) {
  26.285 +      erase(item);
  26.286 +      push(item, value);
  26.287 +    }
  26.288 +
  26.289 +    /// \brief Return the state of an item.
  26.290 +    ///
  26.291 +    /// This method returns \c PRE_HEAP if the given item has never
  26.292 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  26.293 +    /// and \c POST_HEAP otherwise.
  26.294 +    /// In the latter case it is possible that the item will get back
  26.295 +    /// to the heap again.
  26.296 +    /// \param item The item.
  26.297 +    State state(const Item &item) const {
  26.298 +      int i=_iim[item];
  26.299 +      if( i>=0 ) {
  26.300 +        if ( _data[i].in ) i=0;
  26.301 +        else i=-2;
  26.302 +      }
  26.303 +      return State(i);
  26.304 +    }
  26.305 +
  26.306 +    /// \brief Set the state of an item in the heap.
  26.307 +    ///
  26.308 +    /// This function sets the state of the given item in the heap.
  26.309 +    /// It can be used to manually clear the heap when it is important
  26.310 +    /// to achive better time complexity.
  26.311 +    /// \param i The item.
  26.312 +    /// \param st The state. It should not be \c IN_HEAP.
  26.313 +    void state(const Item& i, State st) {
  26.314 +      switch (st) {
  26.315 +      case POST_HEAP:
  26.316 +      case PRE_HEAP:
  26.317 +        if (state(i) == IN_HEAP) {
  26.318 +          erase(i);
  26.319 +        }
  26.320 +        _iim[i] = st;
  26.321 +        break;
  26.322 +      case IN_HEAP:
  26.323 +        break;
  26.324 +      }
  26.325 +    }
  26.326 +
  26.327 +  private:
  26.328 +
  26.329 +    // Find the minimum of the roots
  26.330 +    int findMin() {
  26.331 +      if( _head!=-1 ) {
  26.332 +        int min_loc=_head, min_val=_data[_head].prio;
  26.333 +        for( int x=_data[_head].right_neighbor; x!=-1;
  26.334 +             x=_data[x].right_neighbor ) {
  26.335 +          if( _comp( _data[x].prio,min_val ) ) {
  26.336 +            min_val=_data[x].prio;
  26.337 +            min_loc=x;
  26.338 +          }
  26.339 +        }
  26.340 +        return min_loc;
  26.341 +      }
  26.342 +      else return -1;
  26.343 +    }
  26.344 +
  26.345 +    // Merge the heap with another heap starting at the given position
  26.346 +    void merge(int a) {
  26.347 +      if( _head==-1 || a==-1 ) return;
  26.348 +      if( _data[a].right_neighbor==-1 &&
  26.349 +          _data[a].degree<=_data[_head].degree ) {
  26.350 +        _data[a].right_neighbor=_head;
  26.351 +        _head=a;
  26.352 +      } else {
  26.353 +        interleave(a);
  26.354 +      }
  26.355 +      if( _data[_head].right_neighbor==-1 ) return;
  26.356 +
  26.357 +      int x=_head;
  26.358 +      int x_prev=-1, x_next=_data[x].right_neighbor;
  26.359 +      while( x_next!=-1 ) {
  26.360 +        if( _data[x].degree!=_data[x_next].degree ||
  26.361 +            ( _data[x_next].right_neighbor!=-1 &&
  26.362 +              _data[_data[x_next].right_neighbor].degree==_data[x].degree ) ) {
  26.363 +          x_prev=x;
  26.364 +          x=x_next;
  26.365 +        }
  26.366 +        else {
  26.367 +          if( _comp(_data[x_next].prio,_data[x].prio) ) {
  26.368 +            if( x_prev==-1 ) {
  26.369 +              _head=x_next;
  26.370 +            } else {
  26.371 +              _data[x_prev].right_neighbor=x_next;
  26.372 +            }
  26.373 +            fuse(x,x_next);
  26.374 +            x=x_next;
  26.375 +          }
  26.376 +          else {
  26.377 +            _data[x].right_neighbor=_data[x_next].right_neighbor;
  26.378 +            fuse(x_next,x);
  26.379 +          }
  26.380 +        }
  26.381 +        x_next=_data[x].right_neighbor;
  26.382 +      }
  26.383 +    }
  26.384 +
  26.385 +    // Interleave the elements of the given list into the list of the roots
  26.386 +    void interleave(int a) {
  26.387 +      int p=_head, q=a;
  26.388 +      int curr=_data.size();
  26.389 +      _data.push_back(Store());
  26.390 +
  26.391 +      while( p!=-1 || q!=-1 ) {
  26.392 +        if( q==-1 || ( p!=-1 && _data[p].degree<_data[q].degree ) ) {
  26.393 +          _data[curr].right_neighbor=p;
  26.394 +          curr=p;
  26.395 +          p=_data[p].right_neighbor;
  26.396 +        }
  26.397 +        else {
  26.398 +          _data[curr].right_neighbor=q;
  26.399 +          curr=q;
  26.400 +          q=_data[q].right_neighbor;
  26.401 +        }
  26.402 +      }
  26.403 +
  26.404 +      _head=_data.back().right_neighbor;
  26.405 +      _data.pop_back();
  26.406 +    }
  26.407 +
  26.408 +    // Lace node a under node b
  26.409 +    void fuse(int a, int b) {
  26.410 +      _data[a].parent=b;
  26.411 +      _data[a].right_neighbor=_data[b].child;
  26.412 +      _data[b].child=a;
  26.413 +
  26.414 +      ++_data[b].degree;
  26.415 +    }
  26.416 +
  26.417 +    // Unlace node a (if it has siblings)
  26.418 +    void unlace(int a) {
  26.419 +      int neighb=_data[a].right_neighbor;
  26.420 +      int other=_head;
  26.421 +
  26.422 +      while( _data[other].right_neighbor!=a )
  26.423 +        other=_data[other].right_neighbor;
  26.424 +      _data[other].right_neighbor=neighb;
  26.425 +    }
  26.426 +
  26.427 +  private:
  26.428 +
  26.429 +    class Store {
  26.430 +      friend class BinomialHeap;
  26.431 +
  26.432 +      Item name;
  26.433 +      int parent;
  26.434 +      int right_neighbor;
  26.435 +      int child;
  26.436 +      int degree;
  26.437 +      bool in;
  26.438 +      Prio prio;
  26.439 +
  26.440 +      Store() : parent(-1), right_neighbor(-1), child(-1), degree(0),
  26.441 +        in(true) {}
  26.442 +    };
  26.443 +  };
  26.444 +
  26.445 +} //namespace lemon
  26.446 +
  26.447 +#endif //LEMON_BINOMIAL_HEAP_H
  26.448 +
    27.1 --- a/lemon/bits/array_map.h	Fri Aug 09 11:07:27 2013 +0200
    27.2 +++ b/lemon/bits/array_map.h	Sun Aug 11 15:28:12 2013 +0200
    27.3 @@ -2,7 +2,7 @@
    27.4   *
    27.5   * This file is a part of LEMON, a generic C++ optimization library.
    27.6   *
    27.7 - * Copyright (C) 2003-2009
    27.8 + * Copyright (C) 2003-2010
    27.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   27.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   27.11   *
   27.12 @@ -70,7 +70,7 @@
   27.13      typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
   27.14  
   27.15    private:
   27.16 -  
   27.17 +
   27.18      // The MapBase of the Map which imlements the core regisitry function.
   27.19      typedef typename Notifier::ObserverBase Parent;
   27.20  
    28.1 --- a/lemon/bits/default_map.h	Fri Aug 09 11:07:27 2013 +0200
    28.2 +++ b/lemon/bits/default_map.h	Sun Aug 11 15:28:12 2013 +0200
    28.3 @@ -2,7 +2,7 @@
    28.4   *
    28.5   * This file is a part of LEMON, a generic C++ optimization library.
    28.6   *
    28.7 - * Copyright (C) 2003-2009
    28.8 + * Copyright (C) 2003-2010
    28.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   28.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   28.11   *
   28.12 @@ -157,7 +157,7 @@
   28.13  
   28.14    public:
   28.15      typedef DefaultMap<_Graph, _Item, _Value> Map;
   28.16 -    
   28.17 +
   28.18      typedef typename Parent::GraphType GraphType;
   28.19      typedef typename Parent::Value Value;
   28.20  
    29.1 --- a/lemon/bits/edge_set_extender.h	Fri Aug 09 11:07:27 2013 +0200
    29.2 +++ b/lemon/bits/edge_set_extender.h	Sun Aug 11 15:28:12 2013 +0200
    29.3 @@ -1,8 +1,8 @@
    29.4 -/* -*- C++ -*-
    29.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    29.6   *
    29.7 - * This file is a part of LEMON, a generic C++ optimization library
    29.8 + * This file is a part of LEMON, a generic C++ optimization library.
    29.9   *
   29.10 - * Copyright (C) 2003-2008
   29.11 + * Copyright (C) 2003-2010
   29.12   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   29.13   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   29.14   *
   29.15 @@ -63,11 +63,11 @@
   29.16  
   29.17      Node oppositeNode(const Node &n, const Arc &e) const {
   29.18        if (n == Parent::source(e))
   29.19 -	return Parent::target(e);
   29.20 +        return Parent::target(e);
   29.21        else if(n==Parent::target(e))
   29.22 -	return Parent::source(e);
   29.23 +        return Parent::source(e);
   29.24        else
   29.25 -	return INVALID;
   29.26 +        return INVALID;
   29.27      }
   29.28  
   29.29  
   29.30 @@ -91,7 +91,7 @@
   29.31  
   29.32      // Iterable extensions
   29.33  
   29.34 -    class NodeIt : public Node { 
   29.35 +    class NodeIt : public Node {
   29.36        const Digraph* digraph;
   29.37      public:
   29.38  
   29.39 @@ -100,21 +100,21 @@
   29.40        NodeIt(Invalid i) : Node(i) { }
   29.41  
   29.42        explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
   29.43 -	_graph.first(static_cast<Node&>(*this));
   29.44 +        _graph.first(static_cast<Node&>(*this));
   29.45        }
   29.46  
   29.47 -      NodeIt(const Digraph& _graph, const Node& node) 
   29.48 -	: Node(node), digraph(&_graph) {}
   29.49 +      NodeIt(const Digraph& _graph, const Node& node)
   29.50 +        : Node(node), digraph(&_graph) {}
   29.51  
   29.52 -      NodeIt& operator++() { 
   29.53 -	digraph->next(*this);
   29.54 -	return *this; 
   29.55 +      NodeIt& operator++() {
   29.56 +        digraph->next(*this);
   29.57 +        return *this;
   29.58        }
   29.59  
   29.60      };
   29.61  
   29.62  
   29.63 -    class ArcIt : public Arc { 
   29.64 +    class ArcIt : public Arc {
   29.65        const Digraph* digraph;
   29.66      public:
   29.67  
   29.68 @@ -123,21 +123,21 @@
   29.69        ArcIt(Invalid i) : Arc(i) { }
   29.70  
   29.71        explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
   29.72 -	_graph.first(static_cast<Arc&>(*this));
   29.73 +        _graph.first(static_cast<Arc&>(*this));
   29.74        }
   29.75  
   29.76 -      ArcIt(const Digraph& _graph, const Arc& e) : 
   29.77 -	Arc(e), digraph(&_graph) { }
   29.78 +      ArcIt(const Digraph& _graph, const Arc& e) :
   29.79 +        Arc(e), digraph(&_graph) { }
   29.80  
   29.81 -      ArcIt& operator++() { 
   29.82 -	digraph->next(*this);
   29.83 -	return *this; 
   29.84 +      ArcIt& operator++() {
   29.85 +        digraph->next(*this);
   29.86 +        return *this;
   29.87        }
   29.88  
   29.89      };
   29.90  
   29.91  
   29.92 -    class OutArcIt : public Arc { 
   29.93 +    class OutArcIt : public Arc {
   29.94        const Digraph* digraph;
   29.95      public:
   29.96  
   29.97 @@ -145,23 +145,23 @@
   29.98  
   29.99        OutArcIt(Invalid i) : Arc(i) { }
  29.100  
  29.101 -      OutArcIt(const Digraph& _graph, const Node& node) 
  29.102 -	: digraph(&_graph) {
  29.103 -	_graph.firstOut(*this, node);
  29.104 +      OutArcIt(const Digraph& _graph, const Node& node)
  29.105 +        : digraph(&_graph) {
  29.106 +        _graph.firstOut(*this, node);
  29.107        }
  29.108  
  29.109 -      OutArcIt(const Digraph& _graph, const Arc& arc) 
  29.110 -	: Arc(arc), digraph(&_graph) {}
  29.111 +      OutArcIt(const Digraph& _graph, const Arc& arc)
  29.112 +        : Arc(arc), digraph(&_graph) {}
  29.113  
  29.114 -      OutArcIt& operator++() { 
  29.115 -	digraph->nextOut(*this);
  29.116 -	return *this; 
  29.117 +      OutArcIt& operator++() {
  29.118 +        digraph->nextOut(*this);
  29.119 +        return *this;
  29.120        }
  29.121  
  29.122      };
  29.123  
  29.124  
  29.125 -    class InArcIt : public Arc { 
  29.126 +    class InArcIt : public Arc {
  29.127        const Digraph* digraph;
  29.128      public:
  29.129  
  29.130 @@ -169,17 +169,17 @@
  29.131  
  29.132        InArcIt(Invalid i) : Arc(i) { }
  29.133  
  29.134 -      InArcIt(const Digraph& _graph, const Node& node) 
  29.135 -	: digraph(&_graph) {
  29.136 -	_graph.firstIn(*this, node);
  29.137 +      InArcIt(const Digraph& _graph, const Node& node)
  29.138 +        : digraph(&_graph) {
  29.139 +        _graph.firstIn(*this, node);
  29.140        }
  29.141  
  29.142 -      InArcIt(const Digraph& _graph, const Arc& arc) : 
  29.143 -	Arc(arc), digraph(&_graph) {}
  29.144 +      InArcIt(const Digraph& _graph, const Arc& arc) :
  29.145 +        Arc(arc), digraph(&_graph) {}
  29.146  
  29.147 -      InArcIt& operator++() { 
  29.148 -	digraph->nextIn(*this);
  29.149 -	return *this; 
  29.150 +      InArcIt& operator++() {
  29.151 +        digraph->nextIn(*this);
  29.152 +        return *this;
  29.153        }
  29.154  
  29.155      };
  29.156 @@ -215,26 +215,26 @@
  29.157      using Parent::first;
  29.158  
  29.159      // Mappable extension
  29.160 -    
  29.161 +
  29.162      template <typename _Value>
  29.163 -    class ArcMap 
  29.164 +    class ArcMap
  29.165        : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
  29.166        typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
  29.167  
  29.168      public:
  29.169 -      explicit ArcMap(const Digraph& _g) 
  29.170 -	: Parent(_g) {}
  29.171 -      ArcMap(const Digraph& _g, const _Value& _v) 
  29.172 -	: Parent(_g, _v) {}
  29.173 +      explicit ArcMap(const Digraph& _g)
  29.174 +        : Parent(_g) {}
  29.175 +      ArcMap(const Digraph& _g, const _Value& _v)
  29.176 +        : Parent(_g, _v) {}
  29.177  
  29.178        ArcMap& operator=(const ArcMap& cmap) {
  29.179 -	return operator=<ArcMap>(cmap);
  29.180 +        return operator=<ArcMap>(cmap);
  29.181        }
  29.182  
  29.183        template <typename CMap>
  29.184        ArcMap& operator=(const CMap& cmap) {
  29.185          Parent::operator=(cmap);
  29.186 -	return *this;
  29.187 +        return *this;
  29.188        }
  29.189  
  29.190      };
  29.191 @@ -247,7 +247,7 @@
  29.192        notifier(Arc()).add(arc);
  29.193        return arc;
  29.194      }
  29.195 -    
  29.196 +
  29.197      void clear() {
  29.198        notifier(Arc()).clear();
  29.199        Parent::clear();
  29.200 @@ -312,11 +312,11 @@
  29.201  
  29.202      Node oppositeNode(const Node &n, const Edge &e) const {
  29.203        if( n == Parent::u(e))
  29.204 -	return Parent::v(e);
  29.205 +        return Parent::v(e);
  29.206        else if( n == Parent::v(e))
  29.207 -	return Parent::u(e);
  29.208 +        return Parent::u(e);
  29.209        else
  29.210 -	return INVALID;
  29.211 +        return INVALID;
  29.212      }
  29.213  
  29.214      Arc oppositeArc(const Arc &e) const {
  29.215 @@ -340,7 +340,7 @@
  29.216    public:
  29.217  
  29.218      using Parent::notifier;
  29.219 -    
  29.220 +
  29.221      ArcNotifier& notifier(Arc) const {
  29.222        return arc_notifier;
  29.223      }
  29.224 @@ -350,7 +350,7 @@
  29.225      }
  29.226  
  29.227  
  29.228 -    class NodeIt : public Node { 
  29.229 +    class NodeIt : public Node {
  29.230        const Graph* graph;
  29.231      public:
  29.232  
  29.233 @@ -359,21 +359,21 @@
  29.234        NodeIt(Invalid i) : Node(i) { }
  29.235  
  29.236        explicit NodeIt(const Graph& _graph) : graph(&_graph) {
  29.237 -	_graph.first(static_cast<Node&>(*this));
  29.238 +        _graph.first(static_cast<Node&>(*this));
  29.239        }
  29.240  
  29.241 -      NodeIt(const Graph& _graph, const Node& node) 
  29.242 -	: Node(node), graph(&_graph) {}
  29.243 +      NodeIt(const Graph& _graph, const Node& node)
  29.244 +        : Node(node), graph(&_graph) {}
  29.245  
  29.246 -      NodeIt& operator++() { 
  29.247 -	graph->next(*this);
  29.248 -	return *this; 
  29.249 +      NodeIt& operator++() {
  29.250 +        graph->next(*this);
  29.251 +        return *this;
  29.252        }
  29.253  
  29.254      };
  29.255  
  29.256  
  29.257 -    class ArcIt : public Arc { 
  29.258 +    class ArcIt : public Arc {
  29.259        const Graph* graph;
  29.260      public:
  29.261  
  29.262 @@ -382,21 +382,21 @@
  29.263        ArcIt(Invalid i) : Arc(i) { }
  29.264  
  29.265        explicit ArcIt(const Graph& _graph) : graph(&_graph) {
  29.266 -	_graph.first(static_cast<Arc&>(*this));
  29.267 +        _graph.first(static_cast<Arc&>(*this));
  29.268        }
  29.269  
  29.270 -      ArcIt(const Graph& _graph, const Arc& e) : 
  29.271 -	Arc(e), graph(&_graph) { }
  29.272 +      ArcIt(const Graph& _graph, const Arc& e) :
  29.273 +        Arc(e), graph(&_graph) { }
  29.274  
  29.275 -      ArcIt& operator++() { 
  29.276 -	graph->next(*this);
  29.277 -	return *this; 
  29.278 +      ArcIt& operator++() {
  29.279 +        graph->next(*this);
  29.280 +        return *this;
  29.281        }
  29.282  
  29.283      };
  29.284  
  29.285  
  29.286 -    class OutArcIt : public Arc { 
  29.287 +    class OutArcIt : public Arc {
  29.288        const Graph* graph;
  29.289      public:
  29.290  
  29.291 @@ -404,23 +404,23 @@
  29.292  
  29.293        OutArcIt(Invalid i) : Arc(i) { }
  29.294  
  29.295 -      OutArcIt(const Graph& _graph, const Node& node) 
  29.296 -	: graph(&_graph) {
  29.297 -	_graph.firstOut(*this, node);
  29.298 +      OutArcIt(const Graph& _graph, const Node& node)
  29.299 +        : graph(&_graph) {
  29.300 +        _graph.firstOut(*this, node);
  29.301        }
  29.302  
  29.303 -      OutArcIt(const Graph& _graph, const Arc& arc) 
  29.304 -	: Arc(arc), graph(&_graph) {}
  29.305 +      OutArcIt(const Graph& _graph, const Arc& arc)
  29.306 +        : Arc(arc), graph(&_graph) {}
  29.307  
  29.308 -      OutArcIt& operator++() { 
  29.309 -	graph->nextOut(*this);
  29.310 -	return *this; 
  29.311 +      OutArcIt& operator++() {
  29.312 +        graph->nextOut(*this);
  29.313 +        return *this;
  29.314        }
  29.315  
  29.316      };
  29.317  
  29.318  
  29.319 -    class InArcIt : public Arc { 
  29.320 +    class InArcIt : public Arc {
  29.321        const Graph* graph;
  29.322      public:
  29.323  
  29.324 @@ -428,23 +428,23 @@
  29.325  
  29.326        InArcIt(Invalid i) : Arc(i) { }
  29.327  
  29.328 -      InArcIt(const Graph& _graph, const Node& node) 
  29.329 -	: graph(&_graph) {
  29.330 -	_graph.firstIn(*this, node);
  29.331 +      InArcIt(const Graph& _graph, const Node& node)
  29.332 +        : graph(&_graph) {
  29.333 +        _graph.firstIn(*this, node);
  29.334        }
  29.335  
  29.336 -      InArcIt(const Graph& _graph, const Arc& arc) : 
  29.337 -	Arc(arc), graph(&_graph) {}
  29.338 +      InArcIt(const Graph& _graph, const Arc& arc) :
  29.339 +        Arc(arc), graph(&_graph) {}
  29.340  
  29.341 -      InArcIt& operator++() { 
  29.342 -	graph->nextIn(*this);
  29.343 -	return *this; 
  29.344 +      InArcIt& operator++() {
  29.345 +        graph->nextIn(*this);
  29.346 +        return *this;
  29.347        }
  29.348  
  29.349      };
  29.350  
  29.351  
  29.352 -    class EdgeIt : public Parent::Edge { 
  29.353 +    class EdgeIt : public Parent::Edge {
  29.354        const Graph* graph;
  29.355      public:
  29.356  
  29.357 @@ -453,15 +453,15 @@
  29.358        EdgeIt(Invalid i) : Edge(i) { }
  29.359  
  29.360        explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
  29.361 -	_graph.first(static_cast<Edge&>(*this));
  29.362 +        _graph.first(static_cast<Edge&>(*this));
  29.363        }
  29.364  
  29.365 -      EdgeIt(const Graph& _graph, const Edge& e) : 
  29.366 -	Edge(e), graph(&_graph) { }
  29.367 +      EdgeIt(const Graph& _graph, const Edge& e) :
  29.368 +        Edge(e), graph(&_graph) { }
  29.369  
  29.370 -      EdgeIt& operator++() { 
  29.371 -	graph->next(*this);
  29.372 -	return *this; 
  29.373 +      EdgeIt& operator++() {
  29.374 +        graph->next(*this);
  29.375 +        return *this;
  29.376        }
  29.377  
  29.378      };
  29.379 @@ -477,17 +477,17 @@
  29.380        IncEdgeIt(Invalid i) : Edge(i), direction(false) { }
  29.381  
  29.382        IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
  29.383 -	_graph.firstInc(*this, direction, n);
  29.384 +        _graph.firstInc(*this, direction, n);
  29.385        }
  29.386  
  29.387        IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n)
  29.388 -	: graph(&_graph), Edge(ue) {
  29.389 -	direction = (_graph.source(ue) == n);
  29.390 +        : graph(&_graph), Edge(ue) {
  29.391 +        direction = (_graph.source(ue) == n);
  29.392        }
  29.393  
  29.394        IncEdgeIt& operator++() {
  29.395 -	graph->nextInc(*this, direction);
  29.396 -	return *this; 
  29.397 +        graph->nextInc(*this, direction);
  29.398 +        return *this;
  29.399        }
  29.400      };
  29.401  
  29.402 @@ -534,49 +534,49 @@
  29.403  
  29.404  
  29.405      template <typename _Value>
  29.406 -    class ArcMap 
  29.407 +    class ArcMap
  29.408        : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
  29.409        typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
  29.410  
  29.411      public:
  29.412 -      explicit ArcMap(const Graph& _g) 
  29.413 -	: Parent(_g) {}
  29.414 -      ArcMap(const Graph& _g, const _Value& _v) 
  29.415 -	: Parent(_g, _v) {}
  29.416 +      explicit ArcMap(const Graph& _g)
  29.417 +        : Parent(_g) {}
  29.418 +      ArcMap(const Graph& _g, const _Value& _v)
  29.419 +        : Parent(_g, _v) {}
  29.420  
  29.421        ArcMap& operator=(const ArcMap& cmap) {
  29.422 -	return operator=<ArcMap>(cmap);
  29.423 +        return operator=<ArcMap>(cmap);
  29.424        }
  29.425  
  29.426        template <typename CMap>
  29.427        ArcMap& operator=(const CMap& cmap) {
  29.428          Parent::operator=(cmap);
  29.429 -	return *this;
  29.430 +        return *this;
  29.431        }
  29.432  
  29.433      };
  29.434  
  29.435  
  29.436      template <typename _Value>
  29.437 -    class EdgeMap 
  29.438 +    class EdgeMap
  29.439        : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
  29.440        typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
  29.441  
  29.442      public:
  29.443 -      explicit EdgeMap(const Graph& _g) 
  29.444 -	: Parent(_g) {}
  29.445 +      explicit EdgeMap(const Graph& _g)
  29.446 +        : Parent(_g) {}
  29.447  
  29.448 -      EdgeMap(const Graph& _g, const _Value& _v) 
  29.449 -	: Parent(_g, _v) {}
  29.450 +      EdgeMap(const Graph& _g, const _Value& _v)
  29.451 +        : Parent(_g, _v) {}
  29.452  
  29.453        EdgeMap& operator=(const EdgeMap& cmap) {
  29.454 -	return operator=<EdgeMap>(cmap);
  29.455 +        return operator=<EdgeMap>(cmap);
  29.456        }
  29.457  
  29.458        template <typename CMap>
  29.459        EdgeMap& operator=(const CMap& cmap) {
  29.460          Parent::operator=(cmap);
  29.461 -	return *this;
  29.462 +        return *this;
  29.463        }
  29.464  
  29.465      };
  29.466 @@ -593,7 +593,7 @@
  29.467        notifier(Arc()).add(arcs);
  29.468        return edge;
  29.469      }
  29.470 -    
  29.471 +
  29.472      void clear() {
  29.473        notifier(Arc()).clear();
  29.474        notifier(Edge()).clear();
  29.475 @@ -619,7 +619,7 @@
  29.476        edge_notifier.clear();
  29.477        arc_notifier.clear();
  29.478      }
  29.479 -    
  29.480 +
  29.481    };
  29.482  
  29.483  }
    30.1 --- a/lemon/bits/graph_extender.h	Fri Aug 09 11:07:27 2013 +0200
    30.2 +++ b/lemon/bits/graph_extender.h	Sun Aug 11 15:28:12 2013 +0200
    30.3 @@ -56,11 +56,11 @@
    30.4        return Parent::maxArcId();
    30.5      }
    30.6  
    30.7 -    Node fromId(int id, Node) const {
    30.8 +    static Node fromId(int id, Node) {
    30.9        return Parent::nodeFromId(id);
   30.10      }
   30.11  
   30.12 -    Arc fromId(int id, Arc) const {
   30.13 +    static Arc fromId(int id, Arc) {
   30.14        return Parent::arcFromId(id);
   30.15      }
   30.16  
   30.17 @@ -355,15 +355,15 @@
   30.18        return Parent::maxEdgeId();
   30.19      }
   30.20  
   30.21 -    Node fromId(int id, Node) const {
   30.22 +    static Node fromId(int id, Node) {
   30.23        return Parent::nodeFromId(id);
   30.24      }
   30.25  
   30.26 -    Arc fromId(int id, Arc) const {
   30.27 +    static Arc fromId(int id, Arc) {
   30.28        return Parent::arcFromId(id);
   30.29      }
   30.30  
   30.31 -    Edge fromId(int id, Edge) const {
   30.32 +    static Edge fromId(int id, Edge) {
   30.33        return Parent::edgeFromId(id);
   30.34      }
   30.35  
    31.1 --- a/lemon/bits/solver_bits.h	Fri Aug 09 11:07:27 2013 +0200
    31.2 +++ b/lemon/bits/solver_bits.h	Sun Aug 11 15:28:12 2013 +0200
    31.3 @@ -2,7 +2,7 @@
    31.4   *
    31.5   * This file is a part of LEMON, a generic C++ optimization library.
    31.6   *
    31.7 - * Copyright (C) 2003-2008
    31.8 + * Copyright (C) 2003-2010
    31.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   31.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   31.11   *
    32.1 --- a/lemon/bits/windows.cc	Fri Aug 09 11:07:27 2013 +0200
    32.2 +++ b/lemon/bits/windows.cc	Sun Aug 11 15:28:12 2013 +0200
    32.3 @@ -2,7 +2,7 @@
    32.4   *
    32.5   * This file is a part of LEMON, a generic C++ optimization library.
    32.6   *
    32.7 - * Copyright (C) 2003-2009
    32.8 + * Copyright (C) 2003-2010
    32.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   32.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   32.11   *
   32.12 @@ -98,7 +98,7 @@
   32.13        SYSTEMTIME time;
   32.14        GetSystemTime(&time);
   32.15        char buf1[11], buf2[9], buf3[5];
   32.16 -	  if (GetDateFormat(MY_LOCALE, 0, &time,
   32.17 +          if (GetDateFormat(MY_LOCALE, 0, &time,
   32.18                          ("ddd MMM dd"), buf1, 11) &&
   32.19            GetTimeFormat(MY_LOCALE, 0, &time,
   32.20                          ("HH':'mm':'ss"), buf2, 9) &&
    33.1 --- a/lemon/bucket_heap.h	Fri Aug 09 11:07:27 2013 +0200
    33.2 +++ b/lemon/bucket_heap.h	Sun Aug 11 15:28:12 2013 +0200
    33.3 @@ -2,7 +2,7 @@
    33.4   *
    33.5   * This file is a part of LEMON, a generic C++ optimization library.
    33.6   *
    33.7 - * Copyright (C) 2003-2009
    33.8 + * Copyright (C) 2003-2010
    33.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   33.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   33.11   *
   33.12 @@ -19,9 +19,9 @@
   33.13  #ifndef LEMON_BUCKET_HEAP_H
   33.14  #define LEMON_BUCKET_HEAP_H
   33.15  
   33.16 -///\ingroup auxdat
   33.17 +///\ingroup heaps
   33.18  ///\file
   33.19 -///\brief Bucket Heap implementation.
   33.20 +///\brief Bucket heap implementation.
   33.21  
   33.22  #include <vector>
   33.23  #include <utility>
   33.24 @@ -53,35 +53,41 @@
   33.25  
   33.26    }
   33.27  
   33.28 -  /// \ingroup auxdat
   33.29 +  /// \ingroup heaps
   33.30    ///
   33.31 -  /// \brief A Bucket Heap implementation.
   33.32 +  /// \brief Bucket heap data structure.
   33.33    ///
   33.34 -  /// This class implements the \e bucket \e heap data structure. A \e heap
   33.35 -  /// is a data structure for storing items with specified values called \e
   33.36 -  /// priorities in such a way that finding the item with minimum priority is
   33.37 -  /// efficient. The bucket heap is very simple implementation, it can store
   33.38 -  /// only integer priorities and it stores for each priority in the
   33.39 -  /// \f$ [0..C) \f$ range a list of items. So it should be used only when
   33.40 -  /// the priorities are small. It is not intended to use as dijkstra heap.
   33.41 +  /// This class implements the \e bucket \e heap data structure.
   33.42 +  /// It practically conforms to the \ref concepts::Heap "heap concept",
   33.43 +  /// but it has some limitations.
   33.44    ///
   33.45 -  /// \param IM A read and write Item int map, used internally
   33.46 -  /// to handle the cross references.
   33.47 -  /// \param MIN If the given parameter is false then instead of the
   33.48 -  /// minimum value the maximum can be retrivied with the top() and
   33.49 -  /// prio() member functions.
   33.50 +  /// The bucket heap is a very simple structure. It can store only
   33.51 +  /// \c int priorities and it maintains a list of items for each priority
   33.52 +  /// in the range <tt>[0..C)</tt>. So it should only be used when the
   33.53 +  /// priorities are small. It is not intended to use as a Dijkstra heap.
   33.54 +  ///
   33.55 +  /// \tparam IM A read-writable item map with \c int values, used
   33.56 +  /// internally to handle the cross references.
   33.57 +  /// \tparam MIN Indicate if the heap is a \e min-heap or a \e max-heap.
   33.58 +  /// The default is \e min-heap. If this parameter is set to \c false,
   33.59 +  /// then the comparison is reversed, so the top(), prio() and pop()
   33.60 +  /// functions deal with the item having maximum priority instead of the
   33.61 +  /// minimum.
   33.62 +  ///
   33.63 +  /// \sa SimpleBucketHeap
   33.64    template <typename IM, bool MIN = true>
   33.65    class BucketHeap {
   33.66  
   33.67    public:
   33.68 -    /// \e
   33.69 -    typedef typename IM::Key Item;
   33.70 -    /// \e
   33.71 +
   33.72 +    /// Type of the item-int map.
   33.73 +    typedef IM ItemIntMap;
   33.74 +    /// Type of the priorities.
   33.75      typedef int Prio;
   33.76 -    /// \e
   33.77 -    typedef std::pair<Item, Prio> Pair;
   33.78 -    /// \e
   33.79 -    typedef IM ItemIntMap;
   33.80 +    /// Type of the items stored in the heap.
   33.81 +    typedef typename ItemIntMap::Key Item;
   33.82 +    /// Type of the item-priority pairs.
   33.83 +    typedef std::pair<Item,Prio> Pair;
   33.84  
   33.85    private:
   33.86  
   33.87 @@ -89,10 +95,10 @@
   33.88  
   33.89    public:
   33.90  
   33.91 -    /// \brief Type to represent the items states.
   33.92 +    /// \brief Type to represent the states of the items.
   33.93      ///
   33.94 -    /// Each Item element have a state associated to it. It may be "in heap",
   33.95 -    /// "pre heap" or "post heap". The latter two are indifferent from the
   33.96 +    /// Each item has a state associated to it. It can be "in heap",
   33.97 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   33.98      /// heap's point of view, but may be useful to the user.
   33.99      ///
  33.100      /// The item-int map must be initialized in such way that it assigns
  33.101 @@ -104,37 +110,39 @@
  33.102      };
  33.103  
  33.104    public:
  33.105 -    /// \brief The constructor.
  33.106 +
  33.107 +    /// \brief Constructor.
  33.108      ///
  33.109 -    /// The constructor.
  33.110 -    /// \param map should be given to the constructor, since it is used
  33.111 -    /// internally to handle the cross references. The value of the map
  33.112 -    /// should be PRE_HEAP (-1) for each element.
  33.113 +    /// Constructor.
  33.114 +    /// \param map A map that assigns \c int values to the items.
  33.115 +    /// It is used internally to handle the cross references.
  33.116 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  33.117      explicit BucketHeap(ItemIntMap &map) : _iim(map), _minimum(0) {}
  33.118  
  33.119 -    /// The number of items stored in the heap.
  33.120 +    /// \brief The number of items stored in the heap.
  33.121      ///
  33.122 -    /// \brief Returns the number of items stored in the heap.
  33.123 +    /// This function returns the number of items stored in the heap.
  33.124      int size() const { return _data.size(); }
  33.125  
  33.126 -    /// \brief Checks if the heap stores no items.
  33.127 +    /// \brief Check if the heap is empty.
  33.128      ///
  33.129 -    /// Returns \c true if and only if the heap stores no items.
  33.130 +    /// This function returns \c true if the heap is empty.
  33.131      bool empty() const { return _data.empty(); }
  33.132  
  33.133 -    /// \brief Make empty this heap.
  33.134 +    /// \brief Make the heap empty.
  33.135      ///
  33.136 -    /// Make empty this heap. It does not change the cross reference
  33.137 -    /// map.  If you want to reuse a heap what is not surely empty you
  33.138 -    /// should first clear the heap and after that you should set the
  33.139 -    /// cross reference map for each item to \c PRE_HEAP.
  33.140 +    /// This functon makes the heap empty.
  33.141 +    /// It does not change the cross reference map. If you want to reuse
  33.142 +    /// a heap that is not surely empty, you should first clear it and
  33.143 +    /// then you should set the cross reference map to \c PRE_HEAP
  33.144 +    /// for each item.
  33.145      void clear() {
  33.146        _data.clear(); _first.clear(); _minimum = 0;
  33.147      }
  33.148  
  33.149    private:
  33.150  
  33.151 -    void relocate_last(int idx) {
  33.152 +    void relocateLast(int idx) {
  33.153        if (idx + 1 < int(_data.size())) {
  33.154          _data[idx] = _data.back();
  33.155          if (_data[idx].prev != -1) {
  33.156 @@ -174,19 +182,24 @@
  33.157      }
  33.158  
  33.159    public:
  33.160 +
  33.161      /// \brief Insert a pair of item and priority into the heap.
  33.162      ///
  33.163 -    /// Adds \c p.first to the heap with priority \c p.second.
  33.164 +    /// This function inserts \c p.first to the heap with priority
  33.165 +    /// \c p.second.
  33.166      /// \param p The pair to insert.
  33.167 +    /// \pre \c p.first must not be stored in the heap.
  33.168      void push(const Pair& p) {
  33.169        push(p.first, p.second);
  33.170      }
  33.171  
  33.172      /// \brief Insert an item into the heap with the given priority.
  33.173      ///
  33.174 -    /// Adds \c i to the heap with priority \c p.
  33.175 +    /// This function inserts the given item into the heap with the
  33.176 +    /// given priority.
  33.177      /// \param i The item to insert.
  33.178      /// \param p The priority of the item.
  33.179 +    /// \pre \e i must not be stored in the heap.
  33.180      void push(const Item &i, const Prio &p) {
  33.181        int idx = _data.size();
  33.182        _iim[i] = idx;
  33.183 @@ -197,10 +210,10 @@
  33.184        }
  33.185      }
  33.186  
  33.187 -    /// \brief Returns the item with minimum priority.
  33.188 +    /// \brief Return the item having minimum priority.
  33.189      ///
  33.190 -    /// This method returns the item with minimum priority.
  33.191 -    /// \pre The heap must be nonempty.
  33.192 +    /// This function returns the item having minimum priority.
  33.193 +    /// \pre The heap must be non-empty.
  33.194      Item top() const {
  33.195        while (_first[_minimum] == -1) {
  33.196          Direction::increase(_minimum);
  33.197 @@ -208,10 +221,10 @@
  33.198        return _data[_first[_minimum]].item;
  33.199      }
  33.200  
  33.201 -    /// \brief Returns the minimum priority.
  33.202 +    /// \brief The minimum priority.
  33.203      ///
  33.204 -    /// It returns the minimum priority.
  33.205 -    /// \pre The heap must be nonempty.
  33.206 +    /// This function returns the minimum priority.
  33.207 +    /// \pre The heap must be non-empty.
  33.208      Prio prio() const {
  33.209        while (_first[_minimum] == -1) {
  33.210          Direction::increase(_minimum);
  33.211 @@ -219,9 +232,9 @@
  33.212        return _minimum;
  33.213      }
  33.214  
  33.215 -    /// \brief Deletes the item with minimum priority.
  33.216 +    /// \brief Remove the item having minimum priority.
  33.217      ///
  33.218 -    /// This method deletes the item with minimum priority from the heap.
  33.219 +    /// This function removes the item having minimum priority.
  33.220      /// \pre The heap must be non-empty.
  33.221      void pop() {
  33.222        while (_first[_minimum] == -1) {
  33.223 @@ -230,37 +243,38 @@
  33.224        int idx = _first[_minimum];
  33.225        _iim[_data[idx].item] = -2;
  33.226        unlace(idx);
  33.227 -      relocate_last(idx);
  33.228 +      relocateLast(idx);
  33.229      }
  33.230  
  33.231 -    /// \brief Deletes \c i from the heap.
  33.232 +    /// \brief Remove the given item from the heap.
  33.233      ///
  33.234 -    /// This method deletes item \c i from the heap, if \c i was
  33.235 -    /// already stored in the heap.
  33.236 -    /// \param i The item to erase.
  33.237 +    /// This function removes the given item from the heap if it is
  33.238 +    /// already stored.
  33.239 +    /// \param i The item to delete.
  33.240 +    /// \pre \e i must be in the heap.
  33.241      void erase(const Item &i) {
  33.242        int idx = _iim[i];
  33.243        _iim[_data[idx].item] = -2;
  33.244        unlace(idx);
  33.245 -      relocate_last(idx);
  33.246 +      relocateLast(idx);
  33.247      }
  33.248  
  33.249 -
  33.250 -    /// \brief Returns the priority of \c i.
  33.251 +    /// \brief The priority of the given item.
  33.252      ///
  33.253 -    /// This function returns the priority of item \c i.
  33.254 -    /// \pre \c i must be in the heap.
  33.255 +    /// This function returns the priority of the given item.
  33.256      /// \param i The item.
  33.257 +    /// \pre \e i must be in the heap.
  33.258      Prio operator[](const Item &i) const {
  33.259        int idx = _iim[i];
  33.260        return _data[idx].value;
  33.261      }
  33.262  
  33.263 -    /// \brief \c i gets to the heap with priority \c p independently
  33.264 -    /// if \c i was already there.
  33.265 +    /// \brief Set the priority of an item or insert it, if it is
  33.266 +    /// not stored in the heap.
  33.267      ///
  33.268 -    /// This method calls \ref push(\c i, \c p) if \c i is not stored
  33.269 -    /// in the heap and sets the priority of \c i to \c p otherwise.
  33.270 +    /// This method sets the priority of the given item if it is
  33.271 +    /// already stored in the heap. Otherwise it inserts the given
  33.272 +    /// item into the heap with the given priority.
  33.273      /// \param i The item.
  33.274      /// \param p The priority.
  33.275      void set(const Item &i, const Prio &p) {
  33.276 @@ -274,13 +288,12 @@
  33.277        }
  33.278      }
  33.279  
  33.280 -    /// \brief Decreases the priority of \c i to \c p.
  33.281 +    /// \brief Decrease the priority of an item to the given value.
  33.282      ///
  33.283 -    /// This method decreases the priority of item \c i to \c p.
  33.284 -    /// \pre \c i must be stored in the heap with priority at least \c
  33.285 -    /// p relative to \c Compare.
  33.286 +    /// This function decreases the priority of an item to the given value.
  33.287      /// \param i The item.
  33.288      /// \param p The priority.
  33.289 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  33.290      void decrease(const Item &i, const Prio &p) {
  33.291        int idx = _iim[i];
  33.292        unlace(idx);
  33.293 @@ -291,13 +304,12 @@
  33.294        lace(idx);
  33.295      }
  33.296  
  33.297 -    /// \brief Increases the priority of \c i to \c p.
  33.298 +    /// \brief Increase the priority of an item to the given value.
  33.299      ///
  33.300 -    /// This method sets the priority of item \c i to \c p.
  33.301 -    /// \pre \c i must be stored in the heap with priority at most \c
  33.302 -    /// p relative to \c Compare.
  33.303 +    /// This function increases the priority of an item to the given value.
  33.304      /// \param i The item.
  33.305      /// \param p The priority.
  33.306 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  33.307      void increase(const Item &i, const Prio &p) {
  33.308        int idx = _iim[i];
  33.309        unlace(idx);
  33.310 @@ -305,13 +317,13 @@
  33.311        lace(idx);
  33.312      }
  33.313  
  33.314 -    /// \brief Returns if \c item is in, has already been in, or has
  33.315 -    /// never been in the heap.
  33.316 +    /// \brief Return the state of an item.
  33.317      ///
  33.318 -    /// This method returns PRE_HEAP if \c item has never been in the
  33.319 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  33.320 -    /// otherwise. In the latter case it is possible that \c item will
  33.321 -    /// get back to the heap again.
  33.322 +    /// This method returns \c PRE_HEAP if the given item has never
  33.323 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  33.324 +    /// and \c POST_HEAP otherwise.
  33.325 +    /// In the latter case it is possible that the item will get back
  33.326 +    /// to the heap again.
  33.327      /// \param i The item.
  33.328      State state(const Item &i) const {
  33.329        int idx = _iim[i];
  33.330 @@ -319,11 +331,11 @@
  33.331        return State(idx);
  33.332      }
  33.333  
  33.334 -    /// \brief Sets the state of the \c item in the heap.
  33.335 +    /// \brief Set the state of an item in the heap.
  33.336      ///
  33.337 -    /// Sets the state of the \c item in the heap. It can be used to
  33.338 -    /// manually clear the heap when it is important to achive the
  33.339 -    /// better time complexity.
  33.340 +    /// This function sets the state of the given item in the heap.
  33.341 +    /// It can be used to manually clear the heap when it is important
  33.342 +    /// to achive better time complexity.
  33.343      /// \param i The item.
  33.344      /// \param st The state. It should not be \c IN_HEAP.
  33.345      void state(const Item& i, State st) {
  33.346 @@ -359,33 +371,44 @@
  33.347  
  33.348    }; // class BucketHeap
  33.349  
  33.350 -  /// \ingroup auxdat
  33.351 +  /// \ingroup heaps
  33.352    ///
  33.353 -  /// \brief A Simplified Bucket Heap implementation.
  33.354 +  /// \brief Simplified bucket heap data structure.
  33.355    ///
  33.356    /// This class implements a simplified \e bucket \e heap data
  33.357 -  /// structure.  It does not provide some functionality but it faster
  33.358 -  /// and simplier data structure than the BucketHeap. The main
  33.359 -  /// difference is that the BucketHeap stores for every key a double
  33.360 -  /// linked list while this class stores just simple lists. In the
  33.361 -  /// other way it does not support erasing each elements just the
  33.362 -  /// minimal and it does not supports key increasing, decreasing.
  33.363 +  /// structure. It does not provide some functionality, but it is
  33.364 +  /// faster and simpler than BucketHeap. The main difference is
  33.365 +  /// that BucketHeap stores a doubly-linked list for each key while
  33.366 +  /// this class stores only simply-linked lists. It supports erasing
  33.367 +  /// only for the item having minimum priority and it does not support
  33.368 +  /// key increasing and decreasing.
  33.369    ///
  33.370 -  /// \param IM A read and write Item int map, used internally
  33.371 -  /// to handle the cross references.
  33.372 -  /// \param MIN If the given parameter is false then instead of the
  33.373 -  /// minimum value the maximum can be retrivied with the top() and
  33.374 -  /// prio() member functions.
  33.375 +  /// Note that this implementation does not conform to the
  33.376 +  /// \ref concepts::Heap "heap concept" due to the lack of some
  33.377 +  /// functionality.
  33.378 +  ///
  33.379 +  /// \tparam IM A read-writable item map with \c int values, used
  33.380 +  /// internally to handle the cross references.
  33.381 +  /// \tparam MIN Indicate if the heap is a \e min-heap or a \e max-heap.
  33.382 +  /// The default is \e min-heap. If this parameter is set to \c false,
  33.383 +  /// then the comparison is reversed, so the top(), prio() and pop()
  33.384 +  /// functions deal with the item having maximum priority instead of the
  33.385 +  /// minimum.
  33.386    ///
  33.387    /// \sa BucketHeap
  33.388    template <typename IM, bool MIN = true >
  33.389    class SimpleBucketHeap {
  33.390  
  33.391    public:
  33.392 -    typedef typename IM::Key Item;
  33.393 +
  33.394 +    /// Type of the item-int map.
  33.395 +    typedef IM ItemIntMap;
  33.396 +    /// Type of the priorities.
  33.397      typedef int Prio;
  33.398 -    typedef std::pair<Item, Prio> Pair;
  33.399 -    typedef IM ItemIntMap;
  33.400 +    /// Type of the items stored in the heap.
  33.401 +    typedef typename ItemIntMap::Key Item;
  33.402 +    /// Type of the item-priority pairs.
  33.403 +    typedef std::pair<Item,Prio> Pair;
  33.404  
  33.405    private:
  33.406  
  33.407 @@ -393,10 +416,10 @@
  33.408  
  33.409    public:
  33.410  
  33.411 -    /// \brief Type to represent the items states.
  33.412 +    /// \brief Type to represent the states of the items.
  33.413      ///
  33.414 -    /// Each Item element have a state associated to it. It may be "in heap",
  33.415 -    /// "pre heap" or "post heap". The latter two are indifferent from the
  33.416 +    /// Each item has a state associated to it. It can be "in heap",
  33.417 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
  33.418      /// heap's point of view, but may be useful to the user.
  33.419      ///
  33.420      /// The item-int map must be initialized in such way that it assigns
  33.421 @@ -409,48 +432,53 @@
  33.422  
  33.423    public:
  33.424  
  33.425 -    /// \brief The constructor.
  33.426 +    /// \brief Constructor.
  33.427      ///
  33.428 -    /// The constructor.
  33.429 -    /// \param map should be given to the constructor, since it is used
  33.430 -    /// internally to handle the cross references. The value of the map
  33.431 -    /// should be PRE_HEAP (-1) for each element.
  33.432 +    /// Constructor.
  33.433 +    /// \param map A map that assigns \c int values to the items.
  33.434 +    /// It is used internally to handle the cross references.
  33.435 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  33.436      explicit SimpleBucketHeap(ItemIntMap &map)
  33.437        : _iim(map), _free(-1), _num(0), _minimum(0) {}
  33.438  
  33.439 -    /// \brief Returns the number of items stored in the heap.
  33.440 +    /// \brief The number of items stored in the heap.
  33.441      ///
  33.442 -    /// The number of items stored in the heap.
  33.443 +    /// This function returns the number of items stored in the heap.
  33.444      int size() const { return _num; }
  33.445  
  33.446 -    /// \brief Checks if the heap stores no items.
  33.447 +    /// \brief Check if the heap is empty.
  33.448      ///
  33.449 -    /// Returns \c true if and only if the heap stores no items.
  33.450 +    /// This function returns \c true if the heap is empty.
  33.451      bool empty() const { return _num == 0; }
  33.452  
  33.453 -    /// \brief Make empty this heap.
  33.454 +    /// \brief Make the heap empty.
  33.455      ///
  33.456 -    /// Make empty this heap. It does not change the cross reference
  33.457 -    /// map.  If you want to reuse a heap what is not surely empty you
  33.458 -    /// should first clear the heap and after that you should set the
  33.459 -    /// cross reference map for each item to \c PRE_HEAP.
  33.460 +    /// This functon makes the heap empty.
  33.461 +    /// It does not change the cross reference map. If you want to reuse
  33.462 +    /// a heap that is not surely empty, you should first clear it and
  33.463 +    /// then you should set the cross reference map to \c PRE_HEAP
  33.464 +    /// for each item.
  33.465      void clear() {
  33.466        _data.clear(); _first.clear(); _free = -1; _num = 0; _minimum = 0;
  33.467      }
  33.468  
  33.469      /// \brief Insert a pair of item and priority into the heap.
  33.470      ///
  33.471 -    /// Adds \c p.first to the heap with priority \c p.second.
  33.472 +    /// This function inserts \c p.first to the heap with priority
  33.473 +    /// \c p.second.
  33.474      /// \param p The pair to insert.
  33.475 +    /// \pre \c p.first must not be stored in the heap.
  33.476      void push(const Pair& p) {
  33.477        push(p.first, p.second);
  33.478      }
  33.479  
  33.480      /// \brief Insert an item into the heap with the given priority.
  33.481      ///
  33.482 -    /// Adds \c i to the heap with priority \c p.
  33.483 +    /// This function inserts the given item into the heap with the
  33.484 +    /// given priority.
  33.485      /// \param i The item to insert.
  33.486      /// \param p The priority of the item.
  33.487 +    /// \pre \e i must not be stored in the heap.
  33.488      void push(const Item &i, const Prio &p) {
  33.489        int idx;
  33.490        if (_free == -1) {
  33.491 @@ -471,10 +499,10 @@
  33.492        ++_num;
  33.493      }
  33.494  
  33.495 -    /// \brief Returns the item with minimum priority.
  33.496 +    /// \brief Return the item having minimum priority.
  33.497      ///
  33.498 -    /// This method returns the item with minimum priority.
  33.499 -    /// \pre The heap must be nonempty.
  33.500 +    /// This function returns the item having minimum priority.
  33.501 +    /// \pre The heap must be non-empty.
  33.502      Item top() const {
  33.503        while (_first[_minimum] == -1) {
  33.504          Direction::increase(_minimum);
  33.505 @@ -482,10 +510,10 @@
  33.506        return _data[_first[_minimum]].item;
  33.507      }
  33.508  
  33.509 -    /// \brief Returns the minimum priority.
  33.510 +    /// \brief The minimum priority.
  33.511      ///
  33.512 -    /// It returns the minimum priority.
  33.513 -    /// \pre The heap must be nonempty.
  33.514 +    /// This function returns the minimum priority.
  33.515 +    /// \pre The heap must be non-empty.
  33.516      Prio prio() const {
  33.517        while (_first[_minimum] == -1) {
  33.518          Direction::increase(_minimum);
  33.519 @@ -493,9 +521,9 @@
  33.520        return _minimum;
  33.521      }
  33.522  
  33.523 -    /// \brief Deletes the item with minimum priority.
  33.524 +    /// \brief Remove the item having minimum priority.
  33.525      ///
  33.526 -    /// This method deletes the item with minimum priority from the heap.
  33.527 +    /// This function removes the item having minimum priority.
  33.528      /// \pre The heap must be non-empty.
  33.529      void pop() {
  33.530        while (_first[_minimum] == -1) {
  33.531 @@ -509,16 +537,15 @@
  33.532        --_num;
  33.533      }
  33.534  
  33.535 -    /// \brief Returns the priority of \c i.
  33.536 +    /// \brief The priority of the given item.
  33.537      ///
  33.538 -    /// This function returns the priority of item \c i.
  33.539 -    /// \warning This operator is not a constant time function
  33.540 -    /// because it scans the whole data structure to find the proper
  33.541 -    /// value.
  33.542 -    /// \pre \c i must be in the heap.
  33.543 +    /// This function returns the priority of the given item.
  33.544      /// \param i The item.
  33.545 +    /// \pre \e i must be in the heap.
  33.546 +    /// \warning This operator is not a constant time function because
  33.547 +    /// it scans the whole data structure to find the proper value.
  33.548      Prio operator[](const Item &i) const {
  33.549 -      for (int k = 0; k < _first.size(); ++k) {
  33.550 +      for (int k = 0; k < int(_first.size()); ++k) {
  33.551          int idx = _first[k];
  33.552          while (idx != -1) {
  33.553            if (_data[idx].item == i) {
  33.554 @@ -530,13 +557,13 @@
  33.555        return -1;
  33.556      }
  33.557  
  33.558 -    /// \brief Returns if \c item is in, has already been in, or has
  33.559 -    /// never been in the heap.
  33.560 +    /// \brief Return the state of an item.
  33.561      ///
  33.562 -    /// This method returns PRE_HEAP if \c item has never been in the
  33.563 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  33.564 -    /// otherwise. In the latter case it is possible that \c item will
  33.565 -    /// get back to the heap again.
  33.566 +    /// This method returns \c PRE_HEAP if the given item has never
  33.567 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  33.568 +    /// and \c POST_HEAP otherwise.
  33.569 +    /// In the latter case it is possible that the item will get back
  33.570 +    /// to the heap again.
  33.571      /// \param i The item.
  33.572      State state(const Item &i) const {
  33.573        int idx = _iim[i];
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/lemon/capacity_scaling.h	Sun Aug 11 15:28:12 2013 +0200
    34.3 @@ -0,0 +1,990 @@
    34.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    34.5 + *
    34.6 + * This file is a part of LEMON, a generic C++ optimization library.
    34.7 + *
    34.8 + * Copyright (C) 2003-2010
    34.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   34.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   34.11 + *
   34.12 + * Permission to use, modify and distribute this software is granted
   34.13 + * provided that this copyright notice appears in all copies. For
   34.14 + * precise terms see the accompanying LICENSE file.
   34.15 + *
   34.16 + * This software is provided "AS IS" with no warranty of any kind,
   34.17 + * express or implied, and with no claim as to its suitability for any
   34.18 + * purpose.
   34.19 + *
   34.20 + */
   34.21 +
   34.22 +#ifndef LEMON_CAPACITY_SCALING_H
   34.23 +#define LEMON_CAPACITY_SCALING_H
   34.24 +
   34.25 +/// \ingroup min_cost_flow_algs
   34.26 +///
   34.27 +/// \file
   34.28 +/// \brief Capacity Scaling algorithm for finding a minimum cost flow.
   34.29 +
   34.30 +#include <vector>
   34.31 +#include <limits>
   34.32 +#include <lemon/core.h>
   34.33 +#include <lemon/bin_heap.h>
   34.34 +
   34.35 +namespace lemon {
   34.36 +
   34.37 +  /// \brief Default traits class of CapacityScaling algorithm.
   34.38 +  ///
   34.39 +  /// Default traits class of CapacityScaling algorithm.
   34.40 +  /// \tparam GR Digraph type.
   34.41 +  /// \tparam V The number type used for flow amounts, capacity bounds
   34.42 +  /// and supply values. By default it is \c int.
   34.43 +  /// \tparam C The number type used for costs and potentials.
   34.44 +  /// By default it is the same as \c V.
   34.45 +  template <typename GR, typename V = int, typename C = V>
   34.46 +  struct CapacityScalingDefaultTraits
   34.47 +  {
   34.48 +    /// The type of the digraph
   34.49 +    typedef GR Digraph;
   34.50 +    /// The type of the flow amounts, capacity bounds and supply values
   34.51 +    typedef V Value;
   34.52 +    /// The type of the arc costs
   34.53 +    typedef C Cost;
   34.54 +
   34.55 +    /// \brief The type of the heap used for internal Dijkstra computations.
   34.56 +    ///
   34.57 +    /// The type of the heap used for internal Dijkstra computations.
   34.58 +    /// It must conform to the \ref lemon::concepts::Heap "Heap" concept,
   34.59 +    /// its priority type must be \c Cost and its cross reference type
   34.60 +    /// must be \ref RangeMap "RangeMap<int>".
   34.61 +    typedef BinHeap<Cost, RangeMap<int> > Heap;
   34.62 +  };
   34.63 +
   34.64 +  /// \addtogroup min_cost_flow_algs
   34.65 +  /// @{
   34.66 +
   34.67 +  /// \brief Implementation of the Capacity Scaling algorithm for
   34.68 +  /// finding a \ref min_cost_flow "minimum cost flow".
   34.69 +  ///
   34.70 +  /// \ref CapacityScaling implements the capacity scaling version
   34.71 +  /// of the successive shortest path algorithm for finding a
   34.72 +  /// \ref min_cost_flow "minimum cost flow" \ref amo93networkflows,
   34.73 +  /// \ref edmondskarp72theoretical. It is an efficient dual
   34.74 +  /// solution method.
   34.75 +  ///
   34.76 +  /// Most of the parameters of the problem (except for the digraph)
   34.77 +  /// can be given using separate functions, and the algorithm can be
   34.78 +  /// executed using the \ref run() function. If some parameters are not
   34.79 +  /// specified, then default values will be used.
   34.80 +  ///
   34.81 +  /// \tparam GR The digraph type the algorithm runs on.
   34.82 +  /// \tparam V The number type used for flow amounts, capacity bounds
   34.83 +  /// and supply values in the algorithm. By default, it is \c int.
   34.84 +  /// \tparam C The number type used for costs and potentials in the
   34.85 +  /// algorithm. By default, it is the same as \c V.
   34.86 +  /// \tparam TR The traits class that defines various types used by the
   34.87 +  /// algorithm. By default, it is \ref CapacityScalingDefaultTraits
   34.88 +  /// "CapacityScalingDefaultTraits<GR, V, C>".
   34.89 +  /// In most cases, this parameter should not be set directly,
   34.90 +  /// consider to use the named template parameters instead.
   34.91 +  ///
   34.92 +  /// \warning Both number types must be signed and all input data must
   34.93 +  /// be integer.
   34.94 +  /// \warning This algorithm does not support negative costs for such
   34.95 +  /// arcs that have infinite upper bound.
   34.96 +#ifdef DOXYGEN
   34.97 +  template <typename GR, typename V, typename C, typename TR>
   34.98 +#else
   34.99 +  template < typename GR, typename V = int, typename C = V,
  34.100 +             typename TR = CapacityScalingDefaultTraits<GR, V, C> >
  34.101 +#endif
  34.102 +  class CapacityScaling
  34.103 +  {
  34.104 +  public:
  34.105 +
  34.106 +    /// The type of the digraph
  34.107 +    typedef typename TR::Digraph Digraph;
  34.108 +    /// The type of the flow amounts, capacity bounds and supply values
  34.109 +    typedef typename TR::Value Value;
  34.110 +    /// The type of the arc costs
  34.111 +    typedef typename TR::Cost Cost;
  34.112 +
  34.113 +    /// The type of the heap used for internal Dijkstra computations
  34.114 +    typedef typename TR::Heap Heap;
  34.115 +
  34.116 +    /// The \ref CapacityScalingDefaultTraits "traits class" of the algorithm
  34.117 +    typedef TR Traits;
  34.118 +
  34.119 +  public:
  34.120 +
  34.121 +    /// \brief Problem type constants for the \c run() function.
  34.122 +    ///
  34.123 +    /// Enum type containing the problem type constants that can be
  34.124 +    /// returned by the \ref run() function of the algorithm.
  34.125 +    enum ProblemType {
  34.126 +      /// The problem has no feasible solution (flow).
  34.127 +      INFEASIBLE,
  34.128 +      /// The problem has optimal solution (i.e. it is feasible and
  34.129 +      /// bounded), and the algorithm has found optimal flow and node
  34.130 +      /// potentials (primal and dual solutions).
  34.131 +      OPTIMAL,
  34.132 +      /// The digraph contains an arc of negative cost and infinite
  34.133 +      /// upper bound. It means that the objective function is unbounded
  34.134 +      /// on that arc, however, note that it could actually be bounded
  34.135 +      /// over the feasible flows, but this algroithm cannot handle
  34.136 +      /// these cases.
  34.137 +      UNBOUNDED
  34.138 +    };
  34.139 +
  34.140 +  private:
  34.141 +
  34.142 +    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
  34.143 +
  34.144 +    typedef std::vector<int> IntVector;
  34.145 +    typedef std::vector<Value> ValueVector;
  34.146 +    typedef std::vector<Cost> CostVector;
  34.147 +    typedef std::vector<char> BoolVector;
  34.148 +    // Note: vector<char> is used instead of vector<bool> for efficiency reasons
  34.149 +
  34.150 +  private:
  34.151 +
  34.152 +    // Data related to the underlying digraph
  34.153 +    const GR &_graph;
  34.154 +    int _node_num;
  34.155 +    int _arc_num;
  34.156 +    int _res_arc_num;
  34.157 +    int _root;
  34.158 +
  34.159 +    // Parameters of the problem
  34.160 +    bool _have_lower;
  34.161 +    Value _sum_supply;
  34.162 +
  34.163 +    // Data structures for storing the digraph
  34.164 +    IntNodeMap _node_id;
  34.165 +    IntArcMap _arc_idf;
  34.166 +    IntArcMap _arc_idb;
  34.167 +    IntVector _first_out;
  34.168 +    BoolVector _forward;
  34.169 +    IntVector _source;
  34.170 +    IntVector _target;
  34.171 +    IntVector _reverse;
  34.172 +
  34.173 +    // Node and arc data
  34.174 +    ValueVector _lower;
  34.175 +    ValueVector _upper;
  34.176 +    CostVector _cost;
  34.177 +    ValueVector _supply;
  34.178 +
  34.179 +    ValueVector _res_cap;
  34.180 +    CostVector _pi;
  34.181 +    ValueVector _excess;
  34.182 +    IntVector _excess_nodes;
  34.183 +    IntVector _deficit_nodes;
  34.184 +
  34.185 +    Value _delta;
  34.186 +    int _factor;
  34.187 +    IntVector _pred;
  34.188 +
  34.189 +  public:
  34.190 +
  34.191 +    /// \brief Constant for infinite upper bounds (capacities).
  34.192 +    ///
  34.193 +    /// Constant for infinite upper bounds (capacities).
  34.194 +    /// It is \c std::numeric_limits<Value>::infinity() if available,
  34.195 +    /// \c std::numeric_limits<Value>::max() otherwise.
  34.196 +    const Value INF;
  34.197 +
  34.198 +  private:
  34.199 +
  34.200 +    // Special implementation of the Dijkstra algorithm for finding
  34.201 +    // shortest paths in the residual network of the digraph with
  34.202 +    // respect to the reduced arc costs and modifying the node
  34.203 +    // potentials according to the found distance labels.
  34.204 +    class ResidualDijkstra
  34.205 +    {
  34.206 +    private:
  34.207 +
  34.208 +      int _node_num;
  34.209 +      bool _geq;
  34.210 +      const IntVector &_first_out;
  34.211 +      const IntVector &_target;
  34.212 +      const CostVector &_cost;
  34.213 +      const ValueVector &_res_cap;
  34.214 +      const ValueVector &_excess;
  34.215 +      CostVector &_pi;
  34.216 +      IntVector &_pred;
  34.217 +
  34.218 +      IntVector _proc_nodes;
  34.219 +      CostVector _dist;
  34.220 +
  34.221 +    public:
  34.222 +
  34.223 +      ResidualDijkstra(CapacityScaling& cs) :
  34.224 +        _node_num(cs._node_num), _geq(cs._sum_supply < 0),
  34.225 +        _first_out(cs._first_out), _target(cs._target), _cost(cs._cost),
  34.226 +        _res_cap(cs._res_cap), _excess(cs._excess), _pi(cs._pi),
  34.227 +        _pred(cs._pred), _dist(cs._node_num)
  34.228 +      {}
  34.229 +
  34.230 +      int run(int s, Value delta = 1) {
  34.231 +        RangeMap<int> heap_cross_ref(_node_num, Heap::PRE_HEAP);
  34.232 +        Heap heap(heap_cross_ref);
  34.233 +        heap.push(s, 0);
  34.234 +        _pred[s] = -1;
  34.235 +        _proc_nodes.clear();
  34.236 +
  34.237 +        // Process nodes
  34.238 +        while (!heap.empty() && _excess[heap.top()] > -delta) {
  34.239 +          int u = heap.top(), v;
  34.240 +          Cost d = heap.prio() + _pi[u], dn;
  34.241 +          _dist[u] = heap.prio();
  34.242 +          _proc_nodes.push_back(u);
  34.243 +          heap.pop();
  34.244 +
  34.245 +          // Traverse outgoing residual arcs
  34.246 +          int last_out = _geq ? _first_out[u+1] : _first_out[u+1] - 1;
  34.247 +          for (int a = _first_out[u]; a != last_out; ++a) {
  34.248 +            if (_res_cap[a] < delta) continue;
  34.249 +            v = _target[a];
  34.250 +            switch (heap.state(v)) {
  34.251 +              case Heap::PRE_HEAP:
  34.252 +                heap.push(v, d + _cost[a] - _pi[v]);
  34.253 +                _pred[v] = a;
  34.254 +                break;
  34.255 +              case Heap::IN_HEAP:
  34.256 +                dn = d + _cost[a] - _pi[v];
  34.257 +                if (dn < heap[v]) {
  34.258 +                  heap.decrease(v, dn);
  34.259 +                  _pred[v] = a;
  34.260 +                }
  34.261 +                break;
  34.262 +              case Heap::POST_HEAP:
  34.263 +                break;
  34.264 +            }
  34.265 +          }
  34.266 +        }
  34.267 +        if (heap.empty()) return -1;
  34.268 +
  34.269 +        // Update potentials of processed nodes
  34.270 +        int t = heap.top();
  34.271 +        Cost dt = heap.prio();
  34.272 +        for (int i = 0; i < int(_proc_nodes.size()); ++i) {
  34.273 +          _pi[_proc_nodes[i]] += _dist[_proc_nodes[i]] - dt;
  34.274 +        }
  34.275 +
  34.276 +        return t;
  34.277 +      }
  34.278 +
  34.279 +    }; //class ResidualDijkstra
  34.280 +
  34.281 +  public:
  34.282 +
  34.283 +    /// \name Named Template Parameters
  34.284 +    /// @{
  34.285 +
  34.286 +    template <typename T>
  34.287 +    struct SetHeapTraits : public Traits {
  34.288 +      typedef T Heap;
  34.289 +    };
  34.290 +
  34.291 +    /// \brief \ref named-templ-param "Named parameter" for setting
  34.292 +    /// \c Heap type.
  34.293 +    ///
  34.294 +    /// \ref named-templ-param "Named parameter" for setting \c Heap
  34.295 +    /// type, which is used for internal Dijkstra computations.
  34.296 +    /// It must conform to the \ref lemon::concepts::Heap "Heap" concept,
  34.297 +    /// its priority type must be \c Cost and its cross reference type
  34.298 +    /// must be \ref RangeMap "RangeMap<int>".
  34.299 +    template <typename T>
  34.300 +    struct SetHeap
  34.301 +      : public CapacityScaling<GR, V, C, SetHeapTraits<T> > {
  34.302 +      typedef  CapacityScaling<GR, V, C, SetHeapTraits<T> > Create;
  34.303 +    };
  34.304 +
  34.305 +    /// @}
  34.306 +
  34.307 +  protected:
  34.308 +
  34.309 +    CapacityScaling() {}
  34.310 +
  34.311 +  public:
  34.312 +
  34.313 +    /// \brief Constructor.
  34.314 +    ///
  34.315 +    /// The constructor of the class.
  34.316 +    ///
  34.317 +    /// \param graph The digraph the algorithm runs on.
  34.318 +    CapacityScaling(const GR& graph) :
  34.319 +      _graph(graph), _node_id(graph), _arc_idf(graph), _arc_idb(graph),
  34.320 +      INF(std::numeric_limits<Value>::has_infinity ?
  34.321 +          std::numeric_limits<Value>::infinity() :
  34.322 +          std::numeric_limits<Value>::max())
  34.323 +    {
  34.324 +      // Check the number types
  34.325 +      LEMON_ASSERT(std::numeric_limits<Value>::is_signed,
  34.326 +        "The flow type of CapacityScaling must be signed");
  34.327 +      LEMON_ASSERT(std::numeric_limits<Cost>::is_signed,
  34.328 +        "The cost type of CapacityScaling must be signed");
  34.329 +
  34.330 +      // Reset data structures
  34.331 +      reset();
  34.332 +    }
  34.333 +
  34.334 +    /// \name Parameters
  34.335 +    /// The parameters of the algorithm can be specified using these
  34.336 +    /// functions.
  34.337 +
  34.338 +    /// @{
  34.339 +
  34.340 +    /// \brief Set the lower bounds on the arcs.
  34.341 +    ///
  34.342 +    /// This function sets the lower bounds on the arcs.
  34.343 +    /// If it is not used before calling \ref run(), the lower bounds
  34.344 +    /// will be set to zero on all arcs.
  34.345 +    ///
  34.346 +    /// \param map An arc map storing the lower bounds.
  34.347 +    /// Its \c Value type must be convertible to the \c Value type
  34.348 +    /// of the algorithm.
  34.349 +    ///
  34.350 +    /// \return <tt>(*this)</tt>
  34.351 +    template <typename LowerMap>
  34.352 +    CapacityScaling& lowerMap(const LowerMap& map) {
  34.353 +      _have_lower = true;
  34.354 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  34.355 +        _lower[_arc_idf[a]] = map[a];
  34.356 +        _lower[_arc_idb[a]] = map[a];
  34.357 +      }
  34.358 +      return *this;
  34.359 +    }
  34.360 +
  34.361 +    /// \brief Set the upper bounds (capacities) on the arcs.
  34.362 +    ///
  34.363 +    /// This function sets the upper bounds (capacities) on the arcs.
  34.364 +    /// If it is not used before calling \ref run(), the upper bounds
  34.365 +    /// will be set to \ref INF on all arcs (i.e. the flow value will be
  34.366 +    /// unbounded from above).
  34.367 +    ///
  34.368 +    /// \param map An arc map storing the upper bounds.
  34.369 +    /// Its \c Value type must be convertible to the \c Value type
  34.370 +    /// of the algorithm.
  34.371 +    ///
  34.372 +    /// \return <tt>(*this)</tt>
  34.373 +    template<typename UpperMap>
  34.374 +    CapacityScaling& upperMap(const UpperMap& map) {
  34.375 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  34.376 +        _upper[_arc_idf[a]] = map[a];
  34.377 +      }
  34.378 +      return *this;
  34.379 +    }
  34.380 +
  34.381 +    /// \brief Set the costs of the arcs.
  34.382 +    ///
  34.383 +    /// This function sets the costs of the arcs.
  34.384 +    /// If it is not used before calling \ref run(), the costs
  34.385 +    /// will be set to \c 1 on all arcs.
  34.386 +    ///
  34.387 +    /// \param map An arc map storing the costs.
  34.388 +    /// Its \c Value type must be convertible to the \c Cost type
  34.389 +    /// of the algorithm.
  34.390 +    ///
  34.391 +    /// \return <tt>(*this)</tt>
  34.392 +    template<typename CostMap>
  34.393 +    CapacityScaling& costMap(const CostMap& map) {
  34.394 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  34.395 +        _cost[_arc_idf[a]] =  map[a];
  34.396 +        _cost[_arc_idb[a]] = -map[a];
  34.397 +      }
  34.398 +      return *this;
  34.399 +    }
  34.400 +
  34.401 +    /// \brief Set the supply values of the nodes.
  34.402 +    ///
  34.403 +    /// This function sets the supply values of the nodes.
  34.404 +    /// If neither this function nor \ref stSupply() is used before
  34.405 +    /// calling \ref run(), the supply of each node will be set to zero.
  34.406 +    ///
  34.407 +    /// \param map A node map storing the supply values.
  34.408 +    /// Its \c Value type must be convertible to the \c Value type
  34.409 +    /// of the algorithm.
  34.410 +    ///
  34.411 +    /// \return <tt>(*this)</tt>
  34.412 +    template<typename SupplyMap>
  34.413 +    CapacityScaling& supplyMap(const SupplyMap& map) {
  34.414 +      for (NodeIt n(_graph); n != INVALID; ++n) {
  34.415 +        _supply[_node_id[n]] = map[n];
  34.416 +      }
  34.417 +      return *this;
  34.418 +    }
  34.419 +
  34.420 +    /// \brief Set single source and target nodes and a supply value.
  34.421 +    ///
  34.422 +    /// This function sets a single source node and a single target node
  34.423 +    /// and the required flow value.
  34.424 +    /// If neither this function nor \ref supplyMap() is used before
  34.425 +    /// calling \ref run(), the supply of each node will be set to zero.
  34.426 +    ///
  34.427 +    /// Using this function has the same effect as using \ref supplyMap()
  34.428 +    /// with such a map in which \c k is assigned to \c s, \c -k is
  34.429 +    /// assigned to \c t and all other nodes have zero supply value.
  34.430 +    ///
  34.431 +    /// \param s The source node.
  34.432 +    /// \param t The target node.
  34.433 +    /// \param k The required amount of flow from node \c s to node \c t
  34.434 +    /// (i.e. the supply of \c s and the demand of \c t).
  34.435 +    ///
  34.436 +    /// \return <tt>(*this)</tt>
  34.437 +    CapacityScaling& stSupply(const Node& s, const Node& t, Value k) {
  34.438 +      for (int i = 0; i != _node_num; ++i) {
  34.439 +        _supply[i] = 0;
  34.440 +      }
  34.441 +      _supply[_node_id[s]] =  k;
  34.442 +      _supply[_node_id[t]] = -k;
  34.443 +      return *this;
  34.444 +    }
  34.445 +
  34.446 +    /// @}
  34.447 +
  34.448 +    /// \name Execution control
  34.449 +    /// The algorithm can be executed using \ref run().
  34.450 +
  34.451 +    /// @{
  34.452 +
  34.453 +    /// \brief Run the algorithm.
  34.454 +    ///
  34.455 +    /// This function runs the algorithm.
  34.456 +    /// The paramters can be specified using functions \ref lowerMap(),
  34.457 +    /// \ref upperMap(), \ref costMap(), \ref supplyMap(), \ref stSupply().
  34.458 +    /// For example,
  34.459 +    /// \code
  34.460 +    ///   CapacityScaling<ListDigraph> cs(graph);
  34.461 +    ///   cs.lowerMap(lower).upperMap(upper).costMap(cost)
  34.462 +    ///     .supplyMap(sup).run();
  34.463 +    /// \endcode
  34.464 +    ///
  34.465 +    /// This function can be called more than once. All the given parameters
  34.466 +    /// are kept for the next call, unless \ref resetParams() or \ref reset()
  34.467 +    /// is used, thus only the modified parameters have to be set again.
  34.468 +    /// If the underlying digraph was also modified after the construction
  34.469 +    /// of the class (or the last \ref reset() call), then the \ref reset()
  34.470 +    /// function must be called.
  34.471 +    ///
  34.472 +    /// \param factor The capacity scaling factor. It must be larger than
  34.473 +    /// one to use scaling. If it is less or equal to one, then scaling
  34.474 +    /// will be disabled.
  34.475 +    ///
  34.476 +    /// \return \c INFEASIBLE if no feasible flow exists,
  34.477 +    /// \n \c OPTIMAL if the problem has optimal solution
  34.478 +    /// (i.e. it is feasible and bounded), and the algorithm has found
  34.479 +    /// optimal flow and node potentials (primal and dual solutions),
  34.480 +    /// \n \c UNBOUNDED if the digraph contains an arc of negative cost
  34.481 +    /// and infinite upper bound. It means that the objective function
  34.482 +    /// is unbounded on that arc, however, note that it could actually be
  34.483 +    /// bounded over the feasible flows, but this algroithm cannot handle
  34.484 +    /// these cases.
  34.485 +    ///
  34.486 +    /// \see ProblemType
  34.487 +    /// \see resetParams(), reset()
  34.488 +    ProblemType run(int factor = 4) {
  34.489 +      _factor = factor;
  34.490 +      ProblemType pt = init();
  34.491 +      if (pt != OPTIMAL) return pt;
  34.492 +      return start();
  34.493 +    }
  34.494 +
  34.495 +    /// \brief Reset all the parameters that have been given before.
  34.496 +    ///
  34.497 +    /// This function resets all the paramaters that have been given
  34.498 +    /// before using functions \ref lowerMap(), \ref upperMap(),
  34.499 +    /// \ref costMap(), \ref supplyMap(), \ref stSupply().
  34.500 +    ///
  34.501 +    /// It is useful for multiple \ref run() calls. Basically, all the given
  34.502 +    /// parameters are kept for the next \ref run() call, unless
  34.503 +    /// \ref resetParams() or \ref reset() is used.
  34.504 +    /// If the underlying digraph was also modified after the construction
  34.505 +    /// of the class or the last \ref reset() call, then the \ref reset()
  34.506 +    /// function must be used, otherwise \ref resetParams() is sufficient.
  34.507 +    ///
  34.508 +    /// For example,
  34.509 +    /// \code
  34.510 +    ///   CapacityScaling<ListDigraph> cs(graph);
  34.511 +    ///
  34.512 +    ///   // First run
  34.513 +    ///   cs.lowerMap(lower).upperMap(upper).costMap(cost)
  34.514 +    ///     .supplyMap(sup).run();
  34.515 +    ///
  34.516 +    ///   // Run again with modified cost map (resetParams() is not called,
  34.517 +    ///   // so only the cost map have to be set again)
  34.518 +    ///   cost[e] += 100;
  34.519 +    ///   cs.costMap(cost).run();
  34.520 +    ///
  34.521 +    ///   // Run again from scratch using resetParams()
  34.522 +    ///   // (the lower bounds will be set to zero on all arcs)
  34.523 +    ///   cs.resetParams();
  34.524 +    ///   cs.upperMap(capacity).costMap(cost)
  34.525 +    ///     .supplyMap(sup).run();
  34.526 +    /// \endcode
  34.527 +    ///
  34.528 +    /// \return <tt>(*this)</tt>
  34.529 +    ///
  34.530 +    /// \see reset(), run()
  34.531 +    CapacityScaling& resetParams() {
  34.532 +      for (int i = 0; i != _node_num; ++i) {
  34.533 +        _supply[i] = 0;
  34.534 +      }
  34.535 +      for (int j = 0; j != _res_arc_num; ++j) {
  34.536 +        _lower[j] = 0;
  34.537 +        _upper[j] = INF;
  34.538 +        _cost[j] = _forward[j] ? 1 : -1;
  34.539 +      }
  34.540 +      _have_lower = false;
  34.541 +      return *this;
  34.542 +    }
  34.543 +
  34.544 +    /// \brief Reset the internal data structures and all the parameters
  34.545 +    /// that have been given before.
  34.546 +    ///
  34.547 +    /// This function resets the internal data structures and all the
  34.548 +    /// paramaters that have been given before using functions \ref lowerMap(),
  34.549 +    /// \ref upperMap(), \ref costMap(), \ref supplyMap(), \ref stSupply().
  34.550 +    ///
  34.551 +    /// It is useful for multiple \ref run() calls. Basically, all the given
  34.552 +    /// parameters are kept for the next \ref run() call, unless
  34.553 +    /// \ref resetParams() or \ref reset() is used.
  34.554 +    /// If the underlying digraph was also modified after the construction
  34.555 +    /// of the class or the last \ref reset() call, then the \ref reset()
  34.556 +    /// function must be used, otherwise \ref resetParams() is sufficient.
  34.557 +    ///
  34.558 +    /// See \ref resetParams() for examples.
  34.559 +    ///
  34.560 +    /// \return <tt>(*this)</tt>
  34.561 +    ///
  34.562 +    /// \see resetParams(), run()
  34.563 +    CapacityScaling& reset() {
  34.564 +      // Resize vectors
  34.565 +      _node_num = countNodes(_graph);
  34.566 +      _arc_num = countArcs(_graph);
  34.567 +      _res_arc_num = 2 * (_arc_num + _node_num);
  34.568 +      _root = _node_num;
  34.569 +      ++_node_num;
  34.570 +
  34.571 +      _first_out.resize(_node_num + 1);
  34.572 +      _forward.resize(_res_arc_num);
  34.573 +      _source.resize(_res_arc_num);
  34.574 +      _target.resize(_res_arc_num);
  34.575 +      _reverse.resize(_res_arc_num);
  34.576 +
  34.577 +      _lower.resize(_res_arc_num);
  34.578 +      _upper.resize(_res_arc_num);
  34.579 +      _cost.resize(_res_arc_num);
  34.580 +      _supply.resize(_node_num);
  34.581 +
  34.582 +      _res_cap.resize(_res_arc_num);
  34.583 +      _pi.resize(_node_num);
  34.584 +      _excess.resize(_node_num);
  34.585 +      _pred.resize(_node_num);
  34.586 +
  34.587 +      // Copy the graph
  34.588 +      int i = 0, j = 0, k = 2 * _arc_num + _node_num - 1;
  34.589 +      for (NodeIt n(_graph); n != INVALID; ++n, ++i) {
  34.590 +        _node_id[n] = i;
  34.591 +      }
  34.592 +      i = 0;
  34.593 +      for (NodeIt n(_graph); n != INVALID; ++n, ++i) {
  34.594 +        _first_out[i] = j;
  34.595 +        for (OutArcIt a(_graph, n); a != INVALID; ++a, ++j) {
  34.596 +          _arc_idf[a] = j;
  34.597 +          _forward[j] = true;
  34.598 +          _source[j] = i;
  34.599 +          _target[j] = _node_id[_graph.runningNode(a)];
  34.600 +        }
  34.601 +        for (InArcIt a(_graph, n); a != INVALID; ++a, ++j) {
  34.602 +          _arc_idb[a] = j;
  34.603 +          _forward[j] = false;
  34.604 +          _source[j] = i;
  34.605 +          _target[j] = _node_id[_graph.runningNode(a)];
  34.606 +        }
  34.607 +        _forward[j] = false;
  34.608 +        _source[j] = i;
  34.609 +        _target[j] = _root;
  34.610 +        _reverse[j] = k;
  34.611 +        _forward[k] = true;
  34.612 +        _source[k] = _root;
  34.613 +        _target[k] = i;
  34.614 +        _reverse[k] = j;
  34.615 +        ++j; ++k;
  34.616 +      }
  34.617 +      _first_out[i] = j;
  34.618 +      _first_out[_node_num] = k;
  34.619 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  34.620 +        int fi = _arc_idf[a];
  34.621 +        int bi = _arc_idb[a];
  34.622 +        _reverse[fi] = bi;
  34.623 +        _reverse[bi] = fi;
  34.624 +      }
  34.625 +
  34.626 +      // Reset parameters
  34.627 +      resetParams();
  34.628 +      return *this;
  34.629 +    }
  34.630 +
  34.631 +    /// @}
  34.632 +
  34.633 +    /// \name Query Functions
  34.634 +    /// The results of the algorithm can be obtained using these
  34.635 +    /// functions.\n
  34.636 +    /// The \ref run() function must be called before using them.
  34.637 +
  34.638 +    /// @{
  34.639 +
  34.640 +    /// \brief Return the total cost of the found flow.
  34.641 +    ///
  34.642 +    /// This function returns the total cost of the found flow.
  34.643 +    /// Its complexity is O(e).
  34.644 +    ///
  34.645 +    /// \note The return type of the function can be specified as a
  34.646 +    /// template parameter. For example,
  34.647 +    /// \code
  34.648 +    ///   cs.totalCost<double>();
  34.649 +    /// \endcode
  34.650 +    /// It is useful if the total cost cannot be stored in the \c Cost
  34.651 +    /// type of the algorithm, which is the default return type of the
  34.652 +    /// function.
  34.653 +    ///
  34.654 +    /// \pre \ref run() must be called before using this function.
  34.655 +    template <typename Number>
  34.656 +    Number totalCost() const {
  34.657 +      Number c = 0;
  34.658 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  34.659 +        int i = _arc_idb[a];
  34.660 +        c += static_cast<Number>(_res_cap[i]) *
  34.661 +             (-static_cast<Number>(_cost[i]));
  34.662 +      }
  34.663 +      return c;
  34.664 +    }
  34.665 +
  34.666 +#ifndef DOXYGEN
  34.667 +    Cost totalCost() const {
  34.668 +      return totalCost<Cost>();
  34.669 +    }
  34.670 +#endif
  34.671 +
  34.672 +    /// \brief Return the flow on the given arc.
  34.673 +    ///
  34.674 +    /// This function returns the flow on the given arc.
  34.675 +    ///
  34.676 +    /// \pre \ref run() must be called before using this function.
  34.677 +    Value flow(const Arc& a) const {
  34.678 +      return _res_cap[_arc_idb[a]];
  34.679 +    }
  34.680 +
  34.681 +    /// \brief Return the flow map (the primal solution).
  34.682 +    ///
  34.683 +    /// This function copies the flow value on each arc into the given
  34.684 +    /// map. The \c Value type of the algorithm must be convertible to
  34.685 +    /// the \c Value type of the map.
  34.686 +    ///
  34.687 +    /// \pre \ref run() must be called before using this function.
  34.688 +    template <typename FlowMap>
  34.689 +    void flowMap(FlowMap &map) const {
  34.690 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  34.691 +        map.set(a, _res_cap[_arc_idb[a]]);
  34.692 +      }
  34.693 +    }
  34.694 +
  34.695 +    /// \brief Return the potential (dual value) of the given node.
  34.696 +    ///
  34.697 +    /// This function returns the potential (dual value) of the
  34.698 +    /// given node.
  34.699 +    ///
  34.700 +    /// \pre \ref run() must be called before using this function.
  34.701 +    Cost potential(const Node& n) const {
  34.702 +      return _pi[_node_id[n]];
  34.703 +    }
  34.704 +
  34.705 +    /// \brief Return the potential map (the dual solution).
  34.706 +    ///
  34.707 +    /// This function copies the potential (dual value) of each node
  34.708 +    /// into the given map.
  34.709 +    /// The \c Cost type of the algorithm must be convertible to the
  34.710 +    /// \c Value type of the map.
  34.711 +    ///
  34.712 +    /// \pre \ref run() must be called before using this function.
  34.713 +    template <typename PotentialMap>
  34.714 +    void potentialMap(PotentialMap &map) const {
  34.715 +      for (NodeIt n(_graph); n != INVALID; ++n) {
  34.716 +        map.set(n, _pi[_node_id[n]]);
  34.717 +      }
  34.718 +    }
  34.719 +
  34.720 +    /// @}
  34.721 +
  34.722 +  private:
  34.723 +
  34.724 +    // Initialize the algorithm
  34.725 +    ProblemType init() {
  34.726 +      if (_node_num <= 1) return INFEASIBLE;
  34.727 +
  34.728 +      // Check the sum of supply values
  34.729 +      _sum_supply = 0;
  34.730 +      for (int i = 0; i != _root; ++i) {
  34.731 +        _sum_supply += _supply[i];
  34.732 +      }
  34.733 +      if (_sum_supply > 0) return INFEASIBLE;
  34.734 +
  34.735 +      // Initialize vectors
  34.736 +      for (int i = 0; i != _root; ++i) {
  34.737 +        _pi[i] = 0;
  34.738 +        _excess[i] = _supply[i];
  34.739 +      }
  34.740 +
  34.741 +      // Remove non-zero lower bounds
  34.742 +      const Value MAX = std::numeric_limits<Value>::max();
  34.743 +      int last_out;
  34.744 +      if (_have_lower) {
  34.745 +        for (int i = 0; i != _root; ++i) {
  34.746 +          last_out = _first_out[i+1];
  34.747 +          for (int j = _first_out[i]; j != last_out; ++j) {
  34.748 +            if (_forward[j]) {
  34.749 +              Value c = _lower[j];
  34.750 +              if (c >= 0) {
  34.751 +                _res_cap[j] = _upper[j] < MAX ? _upper[j] - c : INF;
  34.752 +              } else {
  34.753 +                _res_cap[j] = _upper[j] < MAX + c ? _upper[j] - c : INF;
  34.754 +              }
  34.755 +              _excess[i] -= c;
  34.756 +              _excess[_target[j]] += c;
  34.757 +            } else {
  34.758 +              _res_cap[j] = 0;
  34.759 +            }
  34.760 +          }
  34.761 +        }
  34.762 +      } else {
  34.763 +        for (int j = 0; j != _res_arc_num; ++j) {
  34.764 +          _res_cap[j] = _forward[j] ? _upper[j] : 0;
  34.765 +        }
  34.766 +      }
  34.767 +
  34.768 +      // Handle negative costs
  34.769 +      for (int i = 0; i != _root; ++i) {
  34.770 +        last_out = _first_out[i+1] - 1;
  34.771 +        for (int j = _first_out[i]; j != last_out; ++j) {
  34.772 +          Value rc = _res_cap[j];
  34.773 +          if (_cost[j] < 0 && rc > 0) {
  34.774 +            if (rc >= MAX) return UNBOUNDED;
  34.775 +            _excess[i] -= rc;
  34.776 +            _excess[_target[j]] += rc;
  34.777 +            _res_cap[j] = 0;
  34.778 +            _res_cap[_reverse[j]] += rc;
  34.779 +          }
  34.780 +        }
  34.781 +      }
  34.782 +
  34.783 +      // Handle GEQ supply type
  34.784 +      if (_sum_supply < 0) {
  34.785 +        _pi[_root] = 0;
  34.786 +        _excess[_root] = -_sum_supply;
  34.787 +        for (int a = _first_out[_root]; a != _res_arc_num; ++a) {
  34.788 +          int ra = _reverse[a];
  34.789 +          _res_cap[a] = -_sum_supply + 1;
  34.790 +          _res_cap[ra] = 0;
  34.791 +          _cost[a] = 0;
  34.792 +          _cost[ra] = 0;
  34.793 +        }
  34.794 +      } else {
  34.795 +        _pi[_root] = 0;
  34.796 +        _excess[_root] = 0;
  34.797 +        for (int a = _first_out[_root]; a != _res_arc_num; ++a) {
  34.798 +          int ra = _reverse[a];
  34.799 +          _res_cap[a] = 1;
  34.800 +          _res_cap[ra] = 0;
  34.801 +          _cost[a] = 0;
  34.802 +          _cost[ra] = 0;
  34.803 +        }
  34.804 +      }
  34.805 +
  34.806 +      // Initialize delta value
  34.807 +      if (_factor > 1) {
  34.808 +        // With scaling
  34.809 +        Value max_sup = 0, max_dem = 0, max_cap = 0;
  34.810 +        for (int i = 0; i != _root; ++i) {
  34.811 +          Value ex = _excess[i];
  34.812 +          if ( ex > max_sup) max_sup =  ex;
  34.813 +          if (-ex > max_dem) max_dem = -ex;
  34.814 +          int last_out = _first_out[i+1] - 1;
  34.815 +          for (int j = _first_out[i]; j != last_out; ++j) {
  34.816 +            if (_res_cap[j] > max_cap) max_cap = _res_cap[j];
  34.817 +          }
  34.818 +        }
  34.819 +        max_sup = std::min(std::min(max_sup, max_dem), max_cap);
  34.820 +        for (_delta = 1; 2 * _delta <= max_sup; _delta *= 2) ;
  34.821 +      } else {
  34.822 +        // Without scaling
  34.823 +        _delta = 1;
  34.824 +      }
  34.825 +
  34.826 +      return OPTIMAL;
  34.827 +    }
  34.828 +
  34.829 +    ProblemType start() {
  34.830 +      // Execute the algorithm
  34.831 +      ProblemType pt;
  34.832 +      if (_delta > 1)
  34.833 +        pt = startWithScaling();
  34.834 +      else
  34.835 +        pt = startWithoutScaling();
  34.836 +
  34.837 +      // Handle non-zero lower bounds
  34.838 +      if (_have_lower) {
  34.839 +        int limit = _first_out[_root];
  34.840 +        for (int j = 0; j != limit; ++j) {
  34.841 +          if (!_forward[j]) _res_cap[j] += _lower[j];
  34.842 +        }
  34.843 +      }
  34.844 +
  34.845 +      // Shift potentials if necessary
  34.846 +      Cost pr = _pi[_root];
  34.847 +      if (_sum_supply < 0 || pr > 0) {
  34.848 +        for (int i = 0; i != _node_num; ++i) {
  34.849 +          _pi[i] -= pr;
  34.850 +        }
  34.851 +      }
  34.852 +
  34.853 +      return pt;
  34.854 +    }
  34.855 +
  34.856 +    // Execute the capacity scaling algorithm
  34.857 +    ProblemType startWithScaling() {
  34.858 +      // Perform capacity scaling phases
  34.859 +      int s, t;
  34.860 +      ResidualDijkstra _dijkstra(*this);
  34.861 +      while (true) {
  34.862 +        // Saturate all arcs not satisfying the optimality condition
  34.863 +        int last_out;
  34.864 +        for (int u = 0; u != _node_num; ++u) {
  34.865 +          last_out = _sum_supply < 0 ?
  34.866 +            _first_out[u+1] : _first_out[u+1] - 1;
  34.867 +          for (int a = _first_out[u]; a != last_out; ++a) {
  34.868 +            int v = _target[a];
  34.869 +            Cost c = _cost[a] + _pi[u] - _pi[v];
  34.870 +            Value rc = _res_cap[a];
  34.871 +            if (c < 0 && rc >= _delta) {
  34.872 +              _excess[u] -= rc;
  34.873 +              _excess[v] += rc;
  34.874 +              _res_cap[a] = 0;
  34.875 +              _res_cap[_reverse[a]] += rc;
  34.876 +            }
  34.877 +          }
  34.878 +        }
  34.879 +
  34.880 +        // Find excess nodes and deficit nodes
  34.881 +        _excess_nodes.clear();
  34.882 +        _deficit_nodes.clear();
  34.883 +        for (int u = 0; u != _node_num; ++u) {
  34.884 +          Value ex = _excess[u];
  34.885 +          if (ex >=  _delta) _excess_nodes.push_back(u);
  34.886 +          if (ex <= -_delta) _deficit_nodes.push_back(u);
  34.887 +        }
  34.888 +        int next_node = 0, next_def_node = 0;
  34.889 +
  34.890 +        // Find augmenting shortest paths
  34.891 +        while (next_node < int(_excess_nodes.size())) {
  34.892 +          // Check deficit nodes
  34.893 +          if (_delta > 1) {
  34.894 +            bool delta_deficit = false;
  34.895 +            for ( ; next_def_node < int(_deficit_nodes.size());
  34.896 +                    ++next_def_node ) {
  34.897 +              if (_excess[_deficit_nodes[next_def_node]] <= -_delta) {
  34.898 +                delta_deficit = true;
  34.899 +                break;
  34.900 +              }
  34.901 +            }
  34.902 +            if (!delta_deficit) break;
  34.903 +          }
  34.904 +
  34.905 +          // Run Dijkstra in the residual network
  34.906 +          s = _excess_nodes[next_node];
  34.907 +          if ((t = _dijkstra.run(s, _delta)) == -1) {
  34.908 +            if (_delta > 1) {
  34.909 +              ++next_node;
  34.910 +              continue;
  34.911 +            }
  34.912 +            return INFEASIBLE;
  34.913 +          }
  34.914 +
  34.915 +          // Augment along a shortest path from s to t
  34.916 +          Value d = std::min(_excess[s], -_excess[t]);
  34.917 +          int u = t;
  34.918 +          int a;
  34.919 +          if (d > _delta) {
  34.920 +            while ((a = _pred[u]) != -1) {
  34.921 +              if (_res_cap[a] < d) d = _res_cap[a];
  34.922 +              u = _source[a];
  34.923 +            }
  34.924 +          }
  34.925 +          u = t;
  34.926 +          while ((a = _pred[u]) != -1) {
  34.927 +            _res_cap[a] -= d;
  34.928 +            _res_cap[_reverse[a]] += d;
  34.929 +            u = _source[a];
  34.930 +          }
  34.931 +          _excess[s] -= d;
  34.932 +          _excess[t] += d;
  34.933 +
  34.934 +          if (_excess[s] < _delta) ++next_node;
  34.935 +        }
  34.936 +
  34.937 +        if (_delta == 1) break;
  34.938 +        _delta = _delta <= _factor ? 1 : _delta / _factor;
  34.939 +      }
  34.940 +
  34.941 +      return OPTIMAL;
  34.942 +    }
  34.943 +
  34.944 +    // Execute the successive shortest path algorithm
  34.945 +    ProblemType startWithoutScaling() {
  34.946 +      // Find excess nodes
  34.947 +      _excess_nodes.clear();
  34.948 +      for (int i = 0; i != _node_num; ++i) {
  34.949 +        if (_excess[i] > 0) _excess_nodes.push_back(i);
  34.950 +      }
  34.951 +      if (_excess_nodes.size() == 0) return OPTIMAL;
  34.952 +      int next_node = 0;
  34.953 +
  34.954 +      // Find shortest paths
  34.955 +      int s, t;
  34.956 +      ResidualDijkstra _dijkstra(*this);
  34.957 +      while ( _excess[_excess_nodes[next_node]] > 0 ||
  34.958 +              ++next_node < int(_excess_nodes.size()) )
  34.959 +      {
  34.960 +        // Run Dijkstra in the residual network
  34.961 +        s = _excess_nodes[next_node];
  34.962 +        if ((t = _dijkstra.run(s)) == -1) return INFEASIBLE;
  34.963 +
  34.964 +        // Augment along a shortest path from s to t
  34.965 +        Value d = std::min(_excess[s], -_excess[t]);
  34.966 +        int u = t;
  34.967 +        int a;
  34.968 +        if (d > 1) {
  34.969 +          while ((a = _pred[u]) != -1) {
  34.970 +            if (_res_cap[a] < d) d = _res_cap[a];
  34.971 +            u = _source[a];
  34.972 +          }
  34.973 +        }
  34.974 +        u = t;
  34.975 +        while ((a = _pred[u]) != -1) {
  34.976 +          _res_cap[a] -= d;
  34.977 +          _res_cap[_reverse[a]] += d;
  34.978 +          u = _source[a];
  34.979 +        }
  34.980 +        _excess[s] -= d;
  34.981 +        _excess[t] += d;
  34.982 +      }
  34.983 +
  34.984 +      return OPTIMAL;
  34.985 +    }
  34.986 +
  34.987 +  }; //class CapacityScaling
  34.988 +
  34.989 +  ///@}
  34.990 +
  34.991 +} //namespace lemon
  34.992 +
  34.993 +#endif //LEMON_CAPACITY_SCALING_H
    35.1 --- a/lemon/cbc.cc	Fri Aug 09 11:07:27 2013 +0200
    35.2 +++ b/lemon/cbc.cc	Sun Aug 11 15:28:12 2013 +0200
    35.3 @@ -89,6 +89,18 @@
    35.4      return _prob->numberRows() - 1;
    35.5    }
    35.6  
    35.7 +  int CbcMip::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
    35.8 +    std::vector<int> indexes;
    35.9 +    std::vector<Value> values;
   35.10 +
   35.11 +    for(ExprIterator it = b; it != e; ++it) {
   35.12 +      indexes.push_back(it->first);
   35.13 +      values.push_back(it->second);
   35.14 +    }
   35.15 +
   35.16 +    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
   35.17 +    return _prob->numberRows() - 1;
   35.18 +  }
   35.19  
   35.20    void CbcMip::_eraseCol(int i) {
   35.21      _prob->deleteColumn(i);
    36.1 --- a/lemon/cbc.h	Fri Aug 09 11:07:27 2013 +0200
    36.2 +++ b/lemon/cbc.h	Sun Aug 11 15:28:12 2013 +0200
    36.3 @@ -2,7 +2,7 @@
    36.4   *
    36.5   * This file is a part of LEMON, a generic C++ optimization library.
    36.6   *
    36.7 - * Copyright (C) 2003-2009
    36.8 + * Copyright (C) 2003-2010
    36.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   36.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   36.11   *
   36.12 @@ -62,6 +62,7 @@
   36.13  
   36.14      virtual int _addCol();
   36.15      virtual int _addRow();
   36.16 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
   36.17  
   36.18      virtual void _eraseCol(int i);
   36.19      virtual void _eraseRow(int i);
   36.20 @@ -120,7 +121,7 @@
   36.21  
   36.22      int _message_level;
   36.23  
   36.24 -    
   36.25 +
   36.26  
   36.27    };
   36.28  
    37.1 --- a/lemon/circulation.h	Fri Aug 09 11:07:27 2013 +0200
    37.2 +++ b/lemon/circulation.h	Sun Aug 11 15:28:12 2013 +0200
    37.3 @@ -2,7 +2,7 @@
    37.4   *
    37.5   * This file is a part of LEMON, a generic C++ optimization library.
    37.6   *
    37.7 - * Copyright (C) 2003-2009
    37.8 + * Copyright (C) 2003-2010
    37.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   37.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   37.11   *
   37.12 @@ -59,8 +59,8 @@
   37.13  
   37.14      /// \brief The type of supply map.
   37.15      ///
   37.16 -    /// The type of the map that stores the signed supply values of the 
   37.17 -    /// nodes. 
   37.18 +    /// The type of the map that stores the signed supply values of the
   37.19 +    /// nodes.
   37.20      /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
   37.21      typedef SM SupplyMap;
   37.22  
   37.23 @@ -72,7 +72,11 @@
   37.24      /// The type of the map that stores the flow values.
   37.25      /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap"
   37.26      /// concept.
   37.27 +#ifdef DOXYGEN
   37.28 +    typedef GR::ArcMap<Value> FlowMap;
   37.29 +#else
   37.30      typedef typename Digraph::template ArcMap<Value> FlowMap;
   37.31 +#endif
   37.32  
   37.33      /// \brief Instantiates a FlowMap.
   37.34      ///
   37.35 @@ -87,9 +91,12 @@
   37.36      ///
   37.37      /// The elevator type used by the algorithm.
   37.38      ///
   37.39 -    /// \sa Elevator
   37.40 -    /// \sa LinkedElevator
   37.41 +    /// \sa Elevator, LinkedElevator
   37.42 +#ifdef DOXYGEN
   37.43 +    typedef lemon::Elevator<GR, GR::Node> Elevator;
   37.44 +#else
   37.45      typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator;
   37.46 +#endif
   37.47  
   37.48      /// \brief Instantiates an Elevator.
   37.49      ///
   37.50 @@ -134,7 +141,7 @@
   37.51       \f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu)
   37.52       \geq sup(u) \quad \forall u\in V, \f]
   37.53       \f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A. \f]
   37.54 -     
   37.55 +
   37.56       The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be
   37.57       zero or negative in order to have a feasible solution (since the sum
   37.58       of the expressions on the left-hand side of the inequalities is zero).
   37.59 @@ -144,7 +151,7 @@
   37.60       If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand
   37.61       constraints have to be satisfied with equality, i.e. all demands
   37.62       have to be satisfied and all supplies have to be used.
   37.63 -     
   37.64 +
   37.65       If you need the opposite inequalities in the supply/demand constraints
   37.66       (i.e. the total demand is less than the total supply and all the demands
   37.67       have to be satisfied while there could be supplies that are not used),
   37.68 @@ -166,6 +173,11 @@
   37.69       The default map type is \c LM.
   37.70       \tparam SM The type of the supply map. The default map type is
   37.71       \ref concepts::Digraph::NodeMap "GR::NodeMap<UM::Value>".
   37.72 +     \tparam TR The traits class that defines various types used by the
   37.73 +     algorithm. By default, it is \ref CirculationDefaultTraits
   37.74 +     "CirculationDefaultTraits<GR, LM, UM, SM>".
   37.75 +     In most cases, this parameter should not be set directly,
   37.76 +     consider to use the named template parameters instead.
   37.77    */
   37.78  #ifdef DOXYGEN
   37.79  template< typename GR,
   37.80 @@ -299,7 +311,7 @@
   37.81      /// The Elevator should have standard constructor interface to be
   37.82      /// able to automatically created by the algorithm (i.e. the
   37.83      /// digraph and the maximum level should be passed to it).
   37.84 -    /// However an external elevator object could also be passed to the
   37.85 +    /// However, an external elevator object could also be passed to the
   37.86      /// algorithm with the \ref elevator(Elevator&) "elevator()" function
   37.87      /// before calling \ref run() or \ref init().
   37.88      /// \sa SetElevator
   37.89 @@ -325,7 +337,7 @@
   37.90      ///
   37.91      /// \param graph The digraph the algorithm runs on.
   37.92      /// \param lower The lower bounds for the flow values on the arcs.
   37.93 -    /// \param upper The upper bounds (capacities) for the flow values 
   37.94 +    /// \param upper The upper bounds (capacities) for the flow values
   37.95      /// on the arcs.
   37.96      /// \param supply The signed supply values of the nodes.
   37.97      Circulation(const Digraph &graph, const LowerMap &lower,
   37.98 @@ -450,9 +462,10 @@
   37.99        return *_level;
  37.100      }
  37.101  
  37.102 -    /// \brief Sets the tolerance used by algorithm.
  37.103 +    /// \brief Sets the tolerance used by the algorithm.
  37.104      ///
  37.105 -    /// Sets the tolerance used by algorithm.
  37.106 +    /// Sets the tolerance object used by the algorithm.
  37.107 +    /// \return <tt>(*this)</tt>
  37.108      Circulation& tolerance(const Tolerance& tolerance) {
  37.109        _tol = tolerance;
  37.110        return *this;
  37.111 @@ -460,15 +473,16 @@
  37.112  
  37.113      /// \brief Returns a const reference to the tolerance.
  37.114      ///
  37.115 -    /// Returns a const reference to the tolerance.
  37.116 +    /// Returns a const reference to the tolerance object used by
  37.117 +    /// the algorithm.
  37.118      const Tolerance& tolerance() const {
  37.119        return _tol;
  37.120      }
  37.121  
  37.122      /// \name Execution Control
  37.123      /// The simplest way to execute the algorithm is to call \ref run().\n
  37.124 -    /// If you need more control on the initial solution or the execution,
  37.125 -    /// first you have to call one of the \ref init() functions, then
  37.126 +    /// If you need better control on the initial solution or the execution,
  37.127 +    /// you have to call one of the \ref init() functions first, then
  37.128      /// the \ref start() function.
  37.129  
  37.130      ///@{
    38.1 --- a/lemon/clp.cc	Fri Aug 09 11:07:27 2013 +0200
    38.2 +++ b/lemon/clp.cc	Sun Aug 11 15:28:12 2013 +0200
    38.3 @@ -2,7 +2,7 @@
    38.4   *
    38.5   * This file is a part of LEMON, a generic C++ optimization library.
    38.6   *
    38.7 - * Copyright (C) 2003-2008
    38.8 + * Copyright (C) 2003-2010
    38.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   38.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   38.11   *
   38.12 @@ -78,6 +78,19 @@
   38.13      return _prob->numberRows() - 1;
   38.14    }
   38.15  
   38.16 +  int ClpLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
   38.17 +    std::vector<int> indexes;
   38.18 +    std::vector<Value> values;
   38.19 +
   38.20 +    for(ExprIterator it = b; it != e; ++it) {
   38.21 +      indexes.push_back(it->first);
   38.22 +      values.push_back(it->second);
   38.23 +    }
   38.24 +
   38.25 +    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
   38.26 +    return _prob->numberRows() - 1;
   38.27 +  }
   38.28 +
   38.29  
   38.30    void ClpLp::_eraseCol(int c) {
   38.31      _col_names_ref.erase(_prob->getColumnName(c));
    39.1 --- a/lemon/clp.h	Fri Aug 09 11:07:27 2013 +0200
    39.2 +++ b/lemon/clp.h	Sun Aug 11 15:28:12 2013 +0200
    39.3 @@ -2,7 +2,7 @@
    39.4   *
    39.5   * This file is a part of LEMON, a generic C++ optimization library.
    39.6   *
    39.7 - * Copyright (C) 2003-2008
    39.8 + * Copyright (C) 2003-2010
    39.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   39.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   39.11   *
   39.12 @@ -75,6 +75,7 @@
   39.13  
   39.14      virtual int _addCol();
   39.15      virtual int _addRow();
   39.16 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
   39.17  
   39.18      virtual void _eraseCol(int i);
   39.19      virtual void _eraseRow(int i);
   39.20 @@ -137,7 +138,7 @@
   39.21      virtual void _clear();
   39.22  
   39.23      virtual void _messageLevel(MessageLevel);
   39.24 -    
   39.25 +
   39.26    public:
   39.27  
   39.28      ///Solves LP with primal simplex method.
    40.1 --- a/lemon/concepts/digraph.h	Fri Aug 09 11:07:27 2013 +0200
    40.2 +++ b/lemon/concepts/digraph.h	Sun Aug 11 15:28:12 2013 +0200
    40.3 @@ -2,7 +2,7 @@
    40.4   *
    40.5   * This file is a part of LEMON, a generic C++ optimization library.
    40.6   *
    40.7 - * Copyright (C) 2003-2009
    40.8 + * Copyright (C) 2003-2010
    40.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   40.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   40.11   *
   40.12 @@ -35,46 +35,40 @@
   40.13      ///
   40.14      /// \brief Class describing the concept of directed graphs.
   40.15      ///
   40.16 -    /// This class describes the \ref concept "concept" of the
   40.17 -    /// immutable directed digraphs.
   40.18 +    /// This class describes the common interface of all directed
   40.19 +    /// graphs (digraphs).
   40.20      ///
   40.21 -    /// Note that actual digraph implementation like @ref ListDigraph or
   40.22 -    /// @ref SmartDigraph may have several additional functionality.
   40.23 +    /// Like all concept classes, it only provides an interface
   40.24 +    /// without any sensible implementation. So any general algorithm for
   40.25 +    /// directed graphs should compile with this class, but it will not
   40.26 +    /// run properly, of course.
   40.27 +    /// An actual digraph implementation like \ref ListDigraph or
   40.28 +    /// \ref SmartDigraph may have additional functionality.
   40.29      ///
   40.30 -    /// \sa concept
   40.31 +    /// \sa Graph
   40.32      class Digraph {
   40.33      private:
   40.34 -      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
   40.35 +      /// Diraphs are \e not copy constructible. Use DigraphCopy instead.
   40.36 +      Digraph(const Digraph &) {}
   40.37 +      /// \brief Assignment of a digraph to another one is \e not allowed.
   40.38 +      /// Use DigraphCopy instead.
   40.39 +      void operator=(const Digraph &) {}
   40.40  
   40.41 -      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
   40.42 -      ///
   40.43 -      Digraph(const Digraph &) {};
   40.44 -      ///\brief Assignment of \ref Digraph "Digraph"s to another ones are
   40.45 -      ///\e not allowed. Use DigraphCopy() instead.
   40.46 +    public:
   40.47 +      /// Default constructor.
   40.48 +      Digraph() { }
   40.49  
   40.50 -      ///Assignment of \ref Digraph "Digraph"s to another ones are
   40.51 -      ///\e not allowed.  Use DigraphCopy() instead.
   40.52 -
   40.53 -      void operator=(const Digraph &) {}
   40.54 -    public:
   40.55 -      ///\e
   40.56 -
   40.57 -      /// Defalult constructor.
   40.58 -
   40.59 -      /// Defalult constructor.
   40.60 -      ///
   40.61 -      Digraph() { }
   40.62 -      /// Class for identifying a node of the digraph
   40.63 +      /// The node type of the digraph
   40.64  
   40.65        /// This class identifies a node of the digraph. It also serves
   40.66        /// as a base class of the node iterators,
   40.67 -      /// thus they will convert to this type.
   40.68 +      /// thus they convert to this type.
   40.69        class Node {
   40.70        public:
   40.71          /// Default constructor
   40.72  
   40.73 -        /// @warning The default constructor sets the iterator
   40.74 -        /// to an undefined value.
   40.75 +        /// Default constructor.
   40.76 +        /// \warning It sets the object to an undefined value.
   40.77          Node() { }
   40.78          /// Copy constructor.
   40.79  
   40.80 @@ -82,40 +76,39 @@
   40.81          ///
   40.82          Node(const Node&) { }
   40.83  
   40.84 -        /// Invalid constructor \& conversion.
   40.85 +        /// %Invalid constructor \& conversion.
   40.86  
   40.87 -        /// This constructor initializes the iterator to be invalid.
   40.88 +        /// Initializes the object to be invalid.
   40.89          /// \sa Invalid for more details.
   40.90          Node(Invalid) { }
   40.91          /// Equality operator
   40.92  
   40.93 +        /// Equality operator.
   40.94 +        ///
   40.95          /// Two iterators are equal if and only if they point to the
   40.96 -        /// same object or both are invalid.
   40.97 +        /// same object or both are \c INVALID.
   40.98          bool operator==(Node) const { return true; }
   40.99  
  40.100          /// Inequality operator
  40.101  
  40.102 -        /// \sa operator==(Node n)
  40.103 -        ///
  40.104 +        /// Inequality operator.
  40.105          bool operator!=(Node) const { return true; }
  40.106  
  40.107          /// Artificial ordering operator.
  40.108  
  40.109 -        /// To allow the use of digraph descriptors as key type in std::map or
  40.110 -        /// similar associative container we require this.
  40.111 +        /// Artificial ordering operator.
  40.112          ///
  40.113 -        /// \note This operator only have to define some strict ordering of
  40.114 -        /// the items; this order has nothing to do with the iteration
  40.115 -        /// ordering of the items.
  40.116 +        /// \note This operator only has to define some strict ordering of
  40.117 +        /// the nodes; this order has nothing to do with the iteration
  40.118 +        /// ordering of the nodes.
  40.119          bool operator<(Node) const { return false; }
  40.120 -
  40.121        };
  40.122  
  40.123 -      /// This iterator goes through each node.
  40.124 +      /// Iterator class for the nodes.
  40.125  
  40.126 -      /// This iterator goes through each node.
  40.127 -      /// Its usage is quite simple, for example you can count the number
  40.128 -      /// of nodes in digraph \c g of type \c Digraph like this:
  40.129 +      /// This iterator goes through each node of the digraph.
  40.130 +      /// Its usage is quite simple, for example, you can count the number
  40.131 +      /// of nodes in a digraph \c g of type \c %Digraph like this:
  40.132        ///\code
  40.133        /// int count=0;
  40.134        /// for (Digraph::NodeIt n(g); n!=INVALID; ++n) ++count;
  40.135 @@ -124,30 +117,28 @@
  40.136        public:
  40.137          /// Default constructor
  40.138  
  40.139 -        /// @warning The default constructor sets the iterator
  40.140 -        /// to an undefined value.
  40.141 +        /// Default constructor.
  40.142 +        /// \warning It sets the iterator to an undefined value.
  40.143          NodeIt() { }
  40.144          /// Copy constructor.
  40.145  
  40.146          /// Copy constructor.
  40.147          ///
  40.148          NodeIt(const NodeIt& n) : Node(n) { }
  40.149 -        /// Invalid constructor \& conversion.
  40.150 +        /// %Invalid constructor \& conversion.
  40.151  
  40.152 -        /// Initialize the iterator to be invalid.
  40.153 +        /// Initializes the iterator to be invalid.
  40.154          /// \sa Invalid for more details.
  40.155          NodeIt(Invalid) { }
  40.156          /// Sets the iterator to the first node.
  40.157  
  40.158 -        /// Sets the iterator to the first node of \c g.
  40.159 +        /// Sets the iterator to the first node of the given digraph.
  40.160          ///
  40.161 -        NodeIt(const Digraph&) { }
  40.162 -        /// Node -> NodeIt conversion.
  40.163 +        explicit NodeIt(const Digraph&) { }
  40.164 +        /// Sets the iterator to the given node.
  40.165  
  40.166 -        /// Sets the iterator to the node of \c the digraph pointed by
  40.167 -        /// the trivial iterator.
  40.168 -        /// This feature necessitates that each time we
  40.169 -        /// iterate the arc-set, the iteration order is the same.
  40.170 +        /// Sets the iterator to the given node of the given digraph.
  40.171 +        ///
  40.172          NodeIt(const Digraph&, const Node&) { }
  40.173          /// Next node.
  40.174  
  40.175 @@ -157,7 +148,7 @@
  40.176        };
  40.177  
  40.178  
  40.179 -      /// Class for identifying an arc of the digraph
  40.180 +      /// The arc type of the digraph
  40.181  
  40.182        /// This class identifies an arc of the digraph. It also serves
  40.183        /// as a base class of the arc iterators,
  40.184 @@ -166,207 +157,214 @@
  40.185        public:
  40.186          /// Default constructor
  40.187  
  40.188 -        /// @warning The default constructor sets the iterator
  40.189 -        /// to an undefined value.
  40.190 +        /// Default constructor.
  40.191 +        /// \warning It sets the object to an undefined value.
  40.192          Arc() { }
  40.193          /// Copy constructor.
  40.194  
  40.195          /// Copy constructor.
  40.196          ///
  40.197          Arc(const Arc&) { }
  40.198 -        /// Initialize the iterator to be invalid.
  40.199 +        /// %Invalid constructor \& conversion.
  40.200  
  40.201 -        /// Initialize the iterator to be invalid.
  40.202 -        ///
  40.203 +        /// Initializes the object to be invalid.
  40.204 +        /// \sa Invalid for more details.
  40.205          Arc(Invalid) { }
  40.206          /// Equality operator
  40.207  
  40.208 +        /// Equality operator.
  40.209 +        ///
  40.210          /// Two iterators are equal if and only if they point to the
  40.211 -        /// same object or both are invalid.
  40.212 +        /// same object or both are \c INVALID.
  40.213          bool operator==(Arc) const { return true; }
  40.214          /// Inequality operator
  40.215  
  40.216 -        /// \sa operator==(Arc n)
  40.217 -        ///
  40.218 +        /// Inequality operator.
  40.219          bool operator!=(Arc) const { return true; }
  40.220  
  40.221          /// Artificial ordering operator.
  40.222  
  40.223 -        /// To allow the use of digraph descriptors as key type in std::map or
  40.224 -        /// similar associative container we require this.
  40.225 +        /// Artificial ordering operator.
  40.226          ///
  40.227 -        /// \note This operator only have to define some strict ordering of
  40.228 -        /// the items; this order has nothing to do with the iteration
  40.229 -        /// ordering of the items.
  40.230 +        /// \note This operator only has to define some strict ordering of
  40.231 +        /// the arcs; this order has nothing to do with the iteration
  40.232 +        /// ordering of the arcs.
  40.233          bool operator<(Arc) const { return false; }
  40.234        };
  40.235  
  40.236 -      /// This iterator goes trough the outgoing arcs of a node.
  40.237 +      /// Iterator class for the outgoing arcs of a node.
  40.238  
  40.239        /// This iterator goes trough the \e outgoing arcs of a certain node
  40.240        /// of a digraph.
  40.241 -      /// Its usage is quite simple, for example you can count the number
  40.242 +      /// Its usage is quite simple, for example, you can count the number
  40.243        /// of outgoing arcs of a node \c n
  40.244 -      /// in digraph \c g of type \c Digraph as follows.
  40.245 +      /// in a digraph \c g of type \c %Digraph as follows.
  40.246        ///\code
  40.247        /// int count=0;
  40.248 -      /// for (Digraph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
  40.249 +      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
  40.250        ///\endcode
  40.251 -
  40.252        class OutArcIt : public Arc {
  40.253        public:
  40.254          /// Default constructor
  40.255  
  40.256 -        /// @warning The default constructor sets the iterator
  40.257 -        /// to an undefined value.
  40.258 +        /// Default constructor.
  40.259 +        /// \warning It sets the iterator to an undefined value.
  40.260          OutArcIt() { }
  40.261          /// Copy constructor.
  40.262  
  40.263          /// Copy constructor.
  40.264          ///
  40.265          OutArcIt(const OutArcIt& e) : Arc(e) { }
  40.266 -        /// Initialize the iterator to be invalid.
  40.267 +        /// %Invalid constructor \& conversion.
  40.268  
  40.269 -        /// Initialize the iterator to be invalid.
  40.270 +        /// Initializes the iterator to be invalid.
  40.271 +        /// \sa Invalid for more details.
  40.272 +        OutArcIt(Invalid) { }
  40.273 +        /// Sets the iterator to the first outgoing arc.
  40.274 +
  40.275 +        /// Sets the iterator to the first outgoing arc of the given node.
  40.276          ///
  40.277 -        OutArcIt(Invalid) { }
  40.278 -        /// This constructor sets the iterator to the first outgoing arc.
  40.279 +        OutArcIt(const Digraph&, const Node&) { }
  40.280 +        /// Sets the iterator to the given arc.
  40.281  
  40.282 -        /// This constructor sets the iterator to the first outgoing arc of
  40.283 -        /// the node.
  40.284 -        OutArcIt(const Digraph&, const Node&) { }
  40.285 -        /// Arc -> OutArcIt conversion
  40.286 -
  40.287 -        /// Sets the iterator to the value of the trivial iterator.
  40.288 -        /// This feature necessitates that each time we
  40.289 -        /// iterate the arc-set, the iteration order is the same.
  40.290 +        /// Sets the iterator to the given arc of the given digraph.
  40.291 +        ///
  40.292          OutArcIt(const Digraph&, const Arc&) { }
  40.293 -        ///Next outgoing arc
  40.294 +        /// Next outgoing arc
  40.295  
  40.296          /// Assign the iterator to the next
  40.297          /// outgoing arc of the corresponding node.
  40.298          OutArcIt& operator++() { return *this; }
  40.299        };
  40.300  
  40.301 -      /// This iterator goes trough the incoming arcs of a node.
  40.302 +      /// Iterator class for the incoming arcs of a node.
  40.303  
  40.304        /// This iterator goes trough the \e incoming arcs of a certain node
  40.305        /// of a digraph.
  40.306 -      /// Its usage is quite simple, for example you can count the number
  40.307 -      /// of outgoing arcs of a node \c n
  40.308 -      /// in digraph \c g of type \c Digraph as follows.
  40.309 +      /// Its usage is quite simple, for example, you can count the number
  40.310 +      /// of incoming arcs of a node \c n
  40.311 +      /// in a digraph \c g of type \c %Digraph as follows.
  40.312        ///\code
  40.313        /// int count=0;
  40.314 -      /// for(Digraph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
  40.315 +      /// for(Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
  40.316        ///\endcode
  40.317 -
  40.318        class InArcIt : public Arc {
  40.319        public:
  40.320          /// Default constructor
  40.321  
  40.322 -        /// @warning The default constructor sets the iterator
  40.323 -        /// to an undefined value.
  40.324 +        /// Default constructor.
  40.325 +        /// \warning It sets the iterator to an undefined value.
  40.326          InArcIt() { }
  40.327          /// Copy constructor.
  40.328  
  40.329          /// Copy constructor.
  40.330          ///
  40.331          InArcIt(const InArcIt& e) : Arc(e) { }
  40.332 -        /// Initialize the iterator to be invalid.
  40.333 +        /// %Invalid constructor \& conversion.
  40.334  
  40.335 -        /// Initialize the iterator to be invalid.
  40.336 +        /// Initializes the iterator to be invalid.
  40.337 +        /// \sa Invalid for more details.
  40.338 +        InArcIt(Invalid) { }
  40.339 +        /// Sets the iterator to the first incoming arc.
  40.340 +
  40.341 +        /// Sets the iterator to the first incoming arc of the given node.
  40.342          ///
  40.343 -        InArcIt(Invalid) { }
  40.344 -        /// This constructor sets the iterator to first incoming arc.
  40.345 +        InArcIt(const Digraph&, const Node&) { }
  40.346 +        /// Sets the iterator to the given arc.
  40.347  
  40.348 -        /// This constructor set the iterator to the first incoming arc of
  40.349 -        /// the node.
  40.350 -        InArcIt(const Digraph&, const Node&) { }
  40.351 -        /// Arc -> InArcIt conversion
  40.352 -
  40.353 -        /// Sets the iterator to the value of the trivial iterator \c e.
  40.354 -        /// This feature necessitates that each time we
  40.355 -        /// iterate the arc-set, the iteration order is the same.
  40.356 +        /// Sets the iterator to the given arc of the given digraph.
  40.357 +        ///
  40.358          InArcIt(const Digraph&, const Arc&) { }
  40.359          /// Next incoming arc
  40.360  
  40.361 -        /// Assign the iterator to the next inarc of the corresponding node.
  40.362 -        ///
  40.363 +        /// Assign the iterator to the next
  40.364 +        /// incoming arc of the corresponding node.
  40.365          InArcIt& operator++() { return *this; }
  40.366        };
  40.367 -      /// This iterator goes through each arc.
  40.368  
  40.369 -      /// This iterator goes through each arc of a digraph.
  40.370 -      /// Its usage is quite simple, for example you can count the number
  40.371 -      /// of arcs in a digraph \c g of type \c Digraph as follows:
  40.372 +      /// Iterator class for the arcs.
  40.373 +
  40.374 +      /// This iterator goes through each arc of the digraph.
  40.375 +      /// Its usage is quite simple, for example, you can count the number
  40.376 +      /// of arcs in a digraph \c g of type \c %Digraph as follows:
  40.377        ///\code
  40.378        /// int count=0;
  40.379 -      /// for(Digraph::ArcIt e(g); e!=INVALID; ++e) ++count;
  40.380 +      /// for(Digraph::ArcIt a(g); a!=INVALID; ++a) ++count;
  40.381        ///\endcode
  40.382        class ArcIt : public Arc {
  40.383        public:
  40.384          /// Default constructor
  40.385  
  40.386 -        /// @warning The default constructor sets the iterator
  40.387 -        /// to an undefined value.
  40.388 +        /// Default constructor.
  40.389 +        /// \warning It sets the iterator to an undefined value.
  40.390          ArcIt() { }
  40.391          /// Copy constructor.
  40.392  
  40.393          /// Copy constructor.
  40.394          ///
  40.395          ArcIt(const ArcIt& e) : Arc(e) { }
  40.396 -        /// Initialize the iterator to be invalid.
  40.397 +        /// %Invalid constructor \& conversion.
  40.398  
  40.399 -        /// Initialize the iterator to be invalid.
  40.400 +        /// Initializes the iterator to be invalid.
  40.401 +        /// \sa Invalid for more details.
  40.402 +        ArcIt(Invalid) { }
  40.403 +        /// Sets the iterator to the first arc.
  40.404 +
  40.405 +        /// Sets the iterator to the first arc of the given digraph.
  40.406          ///
  40.407 -        ArcIt(Invalid) { }
  40.408 -        /// This constructor sets the iterator to the first arc.
  40.409 +        explicit ArcIt(const Digraph& g) { ::lemon::ignore_unused_variable_warning(g); }
  40.410 +        /// Sets the iterator to the given arc.
  40.411  
  40.412 -        /// This constructor sets the iterator to the first arc of \c g.
  40.413 -        ///@param g the digraph
  40.414 -        ArcIt(const Digraph& g) { ::lemon::ignore_unused_variable_warning(g); }
  40.415 -        /// Arc -> ArcIt conversion
  40.416 -
  40.417 -        /// Sets the iterator to the value of the trivial iterator \c e.
  40.418 -        /// This feature necessitates that each time we
  40.419 -        /// iterate the arc-set, the iteration order is the same.
  40.420 +        /// Sets the iterator to the given arc of the given digraph.
  40.421 +        ///
  40.422          ArcIt(const Digraph&, const Arc&) { }
  40.423 -        ///Next arc
  40.424 +        /// Next arc
  40.425  
  40.426          /// Assign the iterator to the next arc.
  40.427 +        ///
  40.428          ArcIt& operator++() { return *this; }
  40.429        };
  40.430 -      ///Gives back the target node of an arc.
  40.431  
  40.432 -      ///Gives back the target node of an arc.
  40.433 +      /// \brief The source node of the arc.
  40.434        ///
  40.435 -      Node target(Arc) const { return INVALID; }
  40.436 -      ///Gives back the source node of an arc.
  40.437 -
  40.438 -      ///Gives back the source node of an arc.
  40.439 -      ///
  40.440 +      /// Returns the source node of the given arc.
  40.441        Node source(Arc) const { return INVALID; }
  40.442  
  40.443 -      /// \brief Returns the ID of the node.
  40.444 +      /// \brief The target node of the arc.
  40.445 +      ///
  40.446 +      /// Returns the target node of the given arc.
  40.447 +      Node target(Arc) const { return INVALID; }
  40.448 +
  40.449 +      /// \brief The ID of the node.
  40.450 +      ///
  40.451 +      /// Returns the ID of the given node.
  40.452        int id(Node) const { return -1; }
  40.453  
  40.454 -      /// \brief Returns the ID of the arc.
  40.455 +      /// \brief The ID of the arc.
  40.456 +      ///
  40.457 +      /// Returns the ID of the given arc.
  40.458        int id(Arc) const { return -1; }
  40.459  
  40.460 -      /// \brief Returns the node with the given ID.
  40.461 +      /// \brief The node with the given ID.
  40.462        ///
  40.463 -      /// \pre The argument should be a valid node ID in the graph.
  40.464 +      /// Returns the node with the given ID.
  40.465 +      /// \pre The argument should be a valid node ID in the digraph.
  40.466        Node nodeFromId(int) const { return INVALID; }
  40.467  
  40.468 -      /// \brief Returns the arc with the given ID.
  40.469 +      /// \brief The arc with the given ID.
  40.470        ///
  40.471 -      /// \pre The argument should be a valid arc ID in the graph.
  40.472 +      /// Returns the arc with the given ID.
  40.473 +      /// \pre The argument should be a valid arc ID in the digraph.
  40.474        Arc arcFromId(int) const { return INVALID; }
  40.475  
  40.476 -      /// \brief Returns an upper bound on the node IDs.
  40.477 +      /// \brief An upper bound on the node IDs.
  40.478 +      ///
  40.479 +      /// Returns an upper bound on the node IDs.
  40.480        int maxNodeId() const { return -1; }
  40.481  
  40.482 -      /// \brief Returns an upper bound on the arc IDs.
  40.483 +      /// \brief An upper bound on the arc IDs.
  40.484 +      ///
  40.485 +      /// Returns an upper bound on the arc IDs.
  40.486        int maxArcId() const { return -1; }
  40.487  
  40.488        void first(Node&) const {}
  40.489 @@ -392,50 +390,51 @@
  40.490        // Dummy parameter.
  40.491        int maxId(Arc) const { return -1; }
  40.492  
  40.493 +      /// \brief The opposite node on the arc.
  40.494 +      ///
  40.495 +      /// Returns the opposite node on the given arc.
  40.496 +      Node oppositeNode(Node, Arc) const { return INVALID; }
  40.497 +
  40.498        /// \brief The base node of the iterator.
  40.499        ///
  40.500 -      /// Gives back the base node of the iterator.
  40.501 -      /// It is always the target of the pointed arc.
  40.502 -      Node baseNode(const InArcIt&) const { return INVALID; }
  40.503 +      /// Returns the base node of the given outgoing arc iterator
  40.504 +      /// (i.e. the source node of the corresponding arc).
  40.505 +      Node baseNode(OutArcIt) const { return INVALID; }
  40.506  
  40.507        /// \brief The running node of the iterator.
  40.508        ///
  40.509 -      /// Gives back the running node of the iterator.
  40.510 -      /// It is always the source of the pointed arc.
  40.511 -      Node runningNode(const InArcIt&) const { return INVALID; }
  40.512 +      /// Returns the running node of the given outgoing arc iterator
  40.513 +      /// (i.e. the target node of the corresponding arc).
  40.514 +      Node runningNode(OutArcIt) const { return INVALID; }
  40.515  
  40.516        /// \brief The base node of the iterator.
  40.517        ///
  40.518 -      /// Gives back the base node of the iterator.
  40.519 -      /// It is always the source of the pointed arc.
  40.520 -      Node baseNode(const OutArcIt&) const { return INVALID; }
  40.521 +      /// Returns the base node of the given incomming arc iterator
  40.522 +      /// (i.e. the target node of the corresponding arc).
  40.523 +      Node baseNode(InArcIt) const { return INVALID; }
  40.524  
  40.525        /// \brief The running node of the iterator.
  40.526        ///
  40.527 -      /// Gives back the running node of the iterator.
  40.528 -      /// It is always the target of the pointed arc.
  40.529 -      Node runningNode(const OutArcIt&) const { return INVALID; }
  40.530 +      /// Returns the running node of the given incomming arc iterator
  40.531 +      /// (i.e. the source node of the corresponding arc).
  40.532 +      Node runningNode(InArcIt) const { return INVALID; }
  40.533  
  40.534 -      /// \brief The opposite node on the given arc.
  40.535 +      /// \brief Standard graph map type for the nodes.
  40.536        ///
  40.537 -      /// Gives back the opposite node on the given arc.
  40.538 -      Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
  40.539 -
  40.540 -      /// \brief Reference map of the nodes to type \c T.
  40.541 -      ///
  40.542 -      /// Reference map of the nodes to type \c T.
  40.543 +      /// Standard graph map type for the nodes.
  40.544 +      /// It conforms to the ReferenceMap concept.
  40.545        template<class T>
  40.546        class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
  40.547        public:
  40.548  
  40.549 -        ///\e
  40.550 -        NodeMap(const Digraph&) { }
  40.551 -        ///\e
  40.552 +        /// Constructor
  40.553 +        explicit NodeMap(const Digraph&) { }
  40.554 +        /// Constructor with given initial value
  40.555          NodeMap(const Digraph&, T) { }
  40.556  
  40.557        private:
  40.558          ///Copy constructor
  40.559 -        NodeMap(const NodeMap& nm) : 
  40.560 +        NodeMap(const NodeMap& nm) :
  40.561            ReferenceMap<Node, T, T&, const T&>(nm) { }
  40.562          ///Assignment operator
  40.563          template <typename CMap>
  40.564 @@ -445,17 +444,19 @@
  40.565          }
  40.566        };
  40.567  
  40.568 -      /// \brief Reference map of the arcs to type \c T.
  40.569 +      /// \brief Standard graph map type for the arcs.
  40.570        ///
  40.571 -      /// Reference map of the arcs to type \c T.
  40.572 +      /// Standard graph map type for the arcs.
  40.573 +      /// It conforms to the ReferenceMap concept.
  40.574        template<class T>
  40.575        class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
  40.576        public:
  40.577  
  40.578 -        ///\e
  40.579 -        ArcMap(const Digraph&) { }
  40.580 -        ///\e
  40.581 +        /// Constructor
  40.582 +        explicit ArcMap(const Digraph&) { }
  40.583 +        /// Constructor with given initial value
  40.584          ArcMap(const Digraph&, T) { }
  40.585 +
  40.586        private:
  40.587          ///Copy constructor
  40.588          ArcMap(const ArcMap& em) :
    41.1 --- a/lemon/concepts/graph.h	Fri Aug 09 11:07:27 2013 +0200
    41.2 +++ b/lemon/concepts/graph.h	Sun Aug 11 15:28:12 2013 +0200
    41.3 @@ -2,7 +2,7 @@
    41.4   *
    41.5   * This file is a part of LEMON, a generic C++ optimization library.
    41.6   *
    41.7 - * Copyright (C) 2003-2009
    41.8 + * Copyright (C) 2003-2010
    41.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   41.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   41.11   *
   41.12 @@ -18,12 +18,14 @@
   41.13  
   41.14  ///\ingroup graph_concepts
   41.15  ///\file
   41.16 -///\brief The concept of Undirected Graphs.
   41.17 +///\brief The concept of undirected graphs.
   41.18  
   41.19  #ifndef LEMON_CONCEPTS_GRAPH_H
   41.20  #define LEMON_CONCEPTS_GRAPH_H
   41.21  
   41.22  #include <lemon/concepts/graph_components.h>
   41.23 +#include <lemon/concepts/maps.h>
   41.24 +#include <lemon/concept_check.h>
   41.25  #include <lemon/core.h>
   41.26  
   41.27  namespace lemon {
   41.28 @@ -31,63 +33,74 @@
   41.29  
   41.30      /// \ingroup graph_concepts
   41.31      ///
   41.32 -    /// \brief Class describing the concept of Undirected Graphs.
   41.33 +    /// \brief Class describing the concept of undirected graphs.
   41.34      ///
   41.35 -    /// This class describes the common interface of all Undirected
   41.36 -    /// Graphs.
   41.37 +    /// This class describes the common interface of all undirected
   41.38 +    /// graphs.
   41.39      ///
   41.40 -    /// As all concept describing classes it provides only interface
   41.41 -    /// without any sensible implementation. So any algorithm for
   41.42 -    /// undirected graph should compile with this class, but it will not
   41.43 +    /// Like all concept classes, it only provides an interface
   41.44 +    /// without any sensible implementation. So any general algorithm for
   41.45 +    /// undirected graphs should compile with this class, but it will not
   41.46      /// run properly, of course.
   41.47 +    /// An actual graph implementation like \ref ListGraph or
   41.48 +    /// \ref SmartGraph may have additional functionality.
   41.49      ///
   41.50 -    /// The LEMON undirected graphs also fulfill the concept of
   41.51 -    /// directed graphs (\ref lemon::concepts::Digraph "Digraph
   41.52 -    /// Concept"). Each edges can be seen as two opposite
   41.53 -    /// directed arc and consequently the undirected graph can be
   41.54 -    /// seen as the direceted graph of these directed arcs. The
   41.55 -    /// Graph has the Edge inner class for the edges and
   41.56 -    /// the Arc type for the directed arcs. The Arc type is
   41.57 -    /// convertible to Edge or inherited from it so from a directed
   41.58 -    /// arc we can get the represented edge.
   41.59 +    /// The undirected graphs also fulfill the concept of \ref Digraph
   41.60 +    /// "directed graphs", since each edge can also be regarded as two
   41.61 +    /// oppositely directed arcs.
   41.62 +    /// Undirected graphs provide an Edge type for the undirected edges and
   41.63 +    /// an Arc type for the directed arcs. The Arc type is convertible to
   41.64 +    /// Edge or inherited from it, i.e. the corresponding edge can be
   41.65 +    /// obtained from an arc.
   41.66 +    /// EdgeIt and EdgeMap classes can be used for the edges, while ArcIt
   41.67 +    /// and ArcMap classes can be used for the arcs (just like in digraphs).
   41.68 +    /// Both InArcIt and OutArcIt iterates on the same edges but with
   41.69 +    /// opposite direction. IncEdgeIt also iterates on the same edges
   41.70 +    /// as OutArcIt and InArcIt, but it is not convertible to Arc,
   41.71 +    /// only to Edge.
   41.72      ///
   41.73 -    /// In the sense of the LEMON each edge has a default
   41.74 -    /// direction (it should be in every computer implementation,
   41.75 -    /// because the order of edge's nodes defines an
   41.76 -    /// orientation). With the default orientation we can define that
   41.77 -    /// the directed arc is forward or backward directed. With the \c
   41.78 -    /// direction() and \c direct() function we can get the direction
   41.79 -    /// of the directed arc and we can direct an edge.
   41.80 +    /// In LEMON, each undirected edge has an inherent orientation.
   41.81 +    /// Thus it can defined if an arc is forward or backward oriented in
   41.82 +    /// an undirected graph with respect to this default oriantation of
   41.83 +    /// the represented edge.
   41.84 +    /// With the direction() and direct() functions the direction
   41.85 +    /// of an arc can be obtained and set, respectively.
   41.86      ///
   41.87 -    /// The EdgeIt is an iterator for the edges. We can use
   41.88 -    /// the EdgeMap to map values for the edges. The InArcIt and
   41.89 -    /// OutArcIt iterates on the same edges but with opposite
   41.90 -    /// direction. The IncEdgeIt iterates also on the same edges
   41.91 -    /// as the OutArcIt and InArcIt but it is not convertible to Arc just
   41.92 -    /// to Edge.
   41.93 +    /// Only nodes and edges can be added to or removed from an undirected
   41.94 +    /// graph and the corresponding arcs are added or removed automatically.
   41.95 +    ///
   41.96 +    /// \sa Digraph
   41.97      class Graph {
   41.98 +    private:
   41.99 +      /// Graphs are \e not copy constructible. Use DigraphCopy instead.
  41.100 +      Graph(const Graph&) {}
  41.101 +      /// \brief Assignment of a graph to another one is \e not allowed.
  41.102 +      /// Use DigraphCopy instead.
  41.103 +      void operator=(const Graph&) {}
  41.104 +
  41.105      public:
  41.106 -      /// \brief The undirected graph should be tagged by the
  41.107 -      /// UndirectedTag.
  41.108 +      /// Default constructor.
  41.109 +      Graph() {}
  41.110 +
  41.111 +      /// \brief Undirected graphs should be tagged with \c UndirectedTag.
  41.112        ///
  41.113 -      /// The undirected graph should be tagged by the UndirectedTag. This
  41.114 -      /// tag helps the enable_if technics to make compile time
  41.115 +      /// Undirected graphs should be tagged with \c UndirectedTag.
  41.116 +      ///
  41.117 +      /// This tag helps the \c enable_if technics to make compile time
  41.118        /// specializations for undirected graphs.
  41.119        typedef True UndirectedTag;
  41.120  
  41.121 -      /// \brief The base type of node iterators,
  41.122 -      /// or in other words, the trivial node iterator.
  41.123 -      ///
  41.124 -      /// This is the base type of each node iterator,
  41.125 -      /// thus each kind of node iterator converts to this.
  41.126 -      /// More precisely each kind of node iterator should be inherited
  41.127 -      /// from the trivial node iterator.
  41.128 +      /// The node type of the graph
  41.129 +
  41.130 +      /// This class identifies a node of the graph. It also serves
  41.131 +      /// as a base class of the node iterators,
  41.132 +      /// thus they convert to this type.
  41.133        class Node {
  41.134        public:
  41.135          /// Default constructor
  41.136  
  41.137 -        /// @warning The default constructor sets the iterator
  41.138 -        /// to an undefined value.
  41.139 +        /// Default constructor.
  41.140 +        /// \warning It sets the object to an undefined value.
  41.141          Node() { }
  41.142          /// Copy constructor.
  41.143  
  41.144 @@ -95,40 +108,40 @@
  41.145          ///
  41.146          Node(const Node&) { }
  41.147  
  41.148 -        /// Invalid constructor \& conversion.
  41.149 +        /// %Invalid constructor \& conversion.
  41.150  
  41.151 -        /// This constructor initializes the iterator to be invalid.
  41.152 +        /// Initializes the object to be invalid.
  41.153          /// \sa Invalid for more details.
  41.154          Node(Invalid) { }
  41.155          /// Equality operator
  41.156  
  41.157 +        /// Equality operator.
  41.158 +        ///
  41.159          /// Two iterators are equal if and only if they point to the
  41.160 -        /// same object or both are invalid.
  41.161 +        /// same object or both are \c INVALID.
  41.162          bool operator==(Node) const { return true; }
  41.163  
  41.164          /// Inequality operator
  41.165  
  41.166 -        /// \sa operator==(Node n)
  41.167 -        ///
  41.168 +        /// Inequality operator.
  41.169          bool operator!=(Node) const { return true; }
  41.170  
  41.171          /// Artificial ordering operator.
  41.172  
  41.173 -        /// To allow the use of graph descriptors as key type in std::map or
  41.174 -        /// similar associative container we require this.
  41.175 +        /// Artificial ordering operator.
  41.176          ///
  41.177 -        /// \note This operator only have to define some strict ordering of
  41.178 +        /// \note This operator only has to define some strict ordering of
  41.179          /// the items; this order has nothing to do with the iteration
  41.180          /// ordering of the items.
  41.181          bool operator<(Node) const { return false; }
  41.182  
  41.183        };
  41.184  
  41.185 -      /// This iterator goes through each node.
  41.186 +      /// Iterator class for the nodes.
  41.187  
  41.188 -      /// This iterator goes through each node.
  41.189 -      /// Its usage is quite simple, for example you can count the number
  41.190 -      /// of nodes in graph \c g of type \c Graph like this:
  41.191 +      /// This iterator goes through each node of the graph.
  41.192 +      /// Its usage is quite simple, for example, you can count the number
  41.193 +      /// of nodes in a graph \c g of type \c %Graph like this:
  41.194        ///\code
  41.195        /// int count=0;
  41.196        /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
  41.197 @@ -137,30 +150,28 @@
  41.198        public:
  41.199          /// Default constructor
  41.200  
  41.201 -        /// @warning The default constructor sets the iterator
  41.202 -        /// to an undefined value.
  41.203 +        /// Default constructor.
  41.204 +        /// \warning It sets the iterator to an undefined value.
  41.205          NodeIt() { }
  41.206          /// Copy constructor.
  41.207  
  41.208          /// Copy constructor.
  41.209          ///
  41.210          NodeIt(const NodeIt& n) : Node(n) { }
  41.211 -        /// Invalid constructor \& conversion.
  41.212 +        /// %Invalid constructor \& conversion.
  41.213  
  41.214 -        /// Initialize the iterator to be invalid.
  41.215 +        /// Initializes the iterator to be invalid.
  41.216          /// \sa Invalid for more details.
  41.217          NodeIt(Invalid) { }
  41.218          /// Sets the iterator to the first node.
  41.219  
  41.220 -        /// Sets the iterator to the first node of \c g.
  41.221 +        /// Sets the iterator to the first node of the given digraph.
  41.222          ///
  41.223 -        NodeIt(const Graph&) { }
  41.224 -        /// Node -> NodeIt conversion.
  41.225 +        explicit NodeIt(const Graph&) { }
  41.226 +        /// Sets the iterator to the given node.
  41.227  
  41.228 -        /// Sets the iterator to the node of \c the graph pointed by
  41.229 -        /// the trivial iterator.
  41.230 -        /// This feature necessitates that each time we
  41.231 -        /// iterate the arc-set, the iteration order is the same.
  41.232 +        /// Sets the iterator to the given node of the given digraph.
  41.233 +        ///
  41.234          NodeIt(const Graph&, const Node&) { }
  41.235          /// Next node.
  41.236  
  41.237 @@ -170,54 +181,55 @@
  41.238        };
  41.239  
  41.240  
  41.241 -      /// The base type of the edge iterators.
  41.242 +      /// The edge type of the graph
  41.243  
  41.244 -      /// The base type of the edge iterators.
  41.245 -      ///
  41.246 +      /// This class identifies an edge of the graph. It also serves
  41.247 +      /// as a base class of the edge iterators,
  41.248 +      /// thus they will convert to this type.
  41.249        class Edge {
  41.250        public:
  41.251          /// Default constructor
  41.252  
  41.253 -        /// @warning The default constructor sets the iterator
  41.254 -        /// to an undefined value.
  41.255 +        /// Default constructor.
  41.256 +        /// \warning It sets the object to an undefined value.
  41.257          Edge() { }
  41.258          /// Copy constructor.
  41.259  
  41.260          /// Copy constructor.
  41.261          ///
  41.262          Edge(const Edge&) { }
  41.263 -        /// Initialize the iterator to be invalid.
  41.264 +        /// %Invalid constructor \& conversion.
  41.265  
  41.266 -        /// Initialize the iterator to be invalid.
  41.267 -        ///
  41.268 +        /// Initializes the object to be invalid.
  41.269 +        /// \sa Invalid for more details.
  41.270          Edge(Invalid) { }
  41.271          /// Equality operator
  41.272  
  41.273 +        /// Equality operator.
  41.274 +        ///
  41.275          /// Two iterators are equal if and only if they point to the
  41.276 -        /// same object or both are invalid.
  41.277 +        /// same object or both are \c INVALID.
  41.278          bool operator==(Edge) const { return true; }
  41.279          /// Inequality operator
  41.280  
  41.281 -        /// \sa operator==(Edge n)
  41.282 -        ///
  41.283 +        /// Inequality operator.
  41.284          bool operator!=(Edge) const { return true; }
  41.285  
  41.286          /// Artificial ordering operator.
  41.287  
  41.288 -        /// To allow the use of graph descriptors as key type in std::map or
  41.289 -        /// similar associative container we require this.
  41.290 +        /// Artificial ordering operator.
  41.291          ///
  41.292 -        /// \note This operator only have to define some strict ordering of
  41.293 -        /// the items; this order has nothing to do with the iteration
  41.294 -        /// ordering of the items.
  41.295 +        /// \note This operator only has to define some strict ordering of
  41.296 +        /// the edges; this order has nothing to do with the iteration
  41.297 +        /// ordering of the edges.
  41.298          bool operator<(Edge) const { return false; }
  41.299        };
  41.300  
  41.301 -      /// This iterator goes through each edge.
  41.302 +      /// Iterator class for the edges.
  41.303  
  41.304 -      /// This iterator goes through each edge of a graph.
  41.305 -      /// Its usage is quite simple, for example you can count the number
  41.306 -      /// of edges in a graph \c g of type \c Graph as follows:
  41.307 +      /// This iterator goes through each edge of the graph.
  41.308 +      /// Its usage is quite simple, for example, you can count the number
  41.309 +      /// of edges in a graph \c g of type \c %Graph as follows:
  41.310        ///\code
  41.311        /// int count=0;
  41.312        /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
  41.313 @@ -226,290 +238,285 @@
  41.314        public:
  41.315          /// Default constructor
  41.316  
  41.317 -        /// @warning The default constructor sets the iterator
  41.318 -        /// to an undefined value.
  41.319 +        /// Default constructor.
  41.320 +        /// \warning It sets the iterator to an undefined value.
  41.321          EdgeIt() { }
  41.322          /// Copy constructor.
  41.323  
  41.324          /// Copy constructor.
  41.325          ///
  41.326          EdgeIt(const EdgeIt& e) : Edge(e) { }
  41.327 -        /// Initialize the iterator to be invalid.
  41.328 +        /// %Invalid constructor \& conversion.
  41.329  
  41.330 -        /// Initialize the iterator to be invalid.
  41.331 +        /// Initializes the iterator to be invalid.
  41.332 +        /// \sa Invalid for more details.
  41.333 +        EdgeIt(Invalid) { }
  41.334 +        /// Sets the iterator to the first edge.
  41.335 +
  41.336 +        /// Sets the iterator to the first edge of the given graph.
  41.337          ///
  41.338 -        EdgeIt(Invalid) { }
  41.339 -        /// This constructor sets the iterator to the first edge.
  41.340 +        explicit EdgeIt(const Graph&) { }
  41.341 +        /// Sets the iterator to the given edge.
  41.342  
  41.343 -        /// This constructor sets the iterator to the first edge.
  41.344 -        EdgeIt(const Graph&) { }
  41.345 -        /// Edge -> EdgeIt conversion
  41.346 -
  41.347 -        /// Sets the iterator to the value of the trivial iterator.
  41.348 -        /// This feature necessitates that each time we
  41.349 -        /// iterate the edge-set, the iteration order is the
  41.350 -        /// same.
  41.351 +        /// Sets the iterator to the given edge of the given graph.
  41.352 +        ///
  41.353          EdgeIt(const Graph&, const Edge&) { }
  41.354          /// Next edge
  41.355  
  41.356          /// Assign the iterator to the next edge.
  41.357 +        ///
  41.358          EdgeIt& operator++() { return *this; }
  41.359        };
  41.360  
  41.361 -      /// \brief This iterator goes trough the incident undirected
  41.362 -      /// arcs of a node.
  41.363 -      ///
  41.364 -      /// This iterator goes trough the incident edges
  41.365 -      /// of a certain node of a graph. You should assume that the
  41.366 -      /// loop arcs will be iterated twice.
  41.367 -      ///
  41.368 -      /// Its usage is quite simple, for example you can compute the
  41.369 -      /// degree (i.e. count the number of incident arcs of a node \c n
  41.370 -      /// in graph \c g of type \c Graph as follows.
  41.371 +      /// Iterator class for the incident edges of a node.
  41.372 +
  41.373 +      /// This iterator goes trough the incident undirected edges
  41.374 +      /// of a certain node of a graph.
  41.375 +      /// Its usage is quite simple, for example, you can compute the
  41.376 +      /// degree (i.e. the number of incident edges) of a node \c n
  41.377 +      /// in a graph \c g of type \c %Graph as follows.
  41.378        ///
  41.379        ///\code
  41.380        /// int count=0;
  41.381        /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
  41.382        ///\endcode
  41.383 +      ///
  41.384 +      /// \warning Loop edges will be iterated twice.
  41.385        class IncEdgeIt : public Edge {
  41.386        public:
  41.387          /// Default constructor
  41.388  
  41.389 -        /// @warning The default constructor sets the iterator
  41.390 -        /// to an undefined value.
  41.391 +        /// Default constructor.
  41.392 +        /// \warning It sets the iterator to an undefined value.
  41.393          IncEdgeIt() { }
  41.394          /// Copy constructor.
  41.395  
  41.396          /// Copy constructor.
  41.397          ///
  41.398          IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
  41.399 -        /// Initialize the iterator to be invalid.
  41.400 +        /// %Invalid constructor \& conversion.
  41.401  
  41.402 -        /// Initialize the iterator to be invalid.
  41.403 +        /// Initializes the iterator to be invalid.
  41.404 +        /// \sa Invalid for more details.
  41.405 +        IncEdgeIt(Invalid) { }
  41.406 +        /// Sets the iterator to the first incident edge.
  41.407 +
  41.408 +        /// Sets the iterator to the first incident edge of the given node.
  41.409          ///
  41.410 -        IncEdgeIt(Invalid) { }
  41.411 -        /// This constructor sets the iterator to first incident arc.
  41.412 +        IncEdgeIt(const Graph&, const Node&) { }
  41.413 +        /// Sets the iterator to the given edge.
  41.414  
  41.415 -        /// This constructor set the iterator to the first incident arc of
  41.416 -        /// the node.
  41.417 -        IncEdgeIt(const Graph&, const Node&) { }
  41.418 -        /// Edge -> IncEdgeIt conversion
  41.419 +        /// Sets the iterator to the given edge of the given graph.
  41.420 +        ///
  41.421 +        IncEdgeIt(const Graph&, const Edge&) { }
  41.422 +        /// Next incident edge
  41.423  
  41.424 -        /// Sets the iterator to the value of the trivial iterator \c e.
  41.425 -        /// This feature necessitates that each time we
  41.426 -        /// iterate the arc-set, the iteration order is the same.
  41.427 -        IncEdgeIt(const Graph&, const Edge&) { }
  41.428 -        /// Next incident arc
  41.429 -
  41.430 -        /// Assign the iterator to the next incident arc
  41.431 +        /// Assign the iterator to the next incident edge
  41.432          /// of the corresponding node.
  41.433          IncEdgeIt& operator++() { return *this; }
  41.434        };
  41.435  
  41.436 -      /// The directed arc type.
  41.437 +      /// The arc type of the graph
  41.438  
  41.439 -      /// The directed arc type. It can be converted to the
  41.440 -      /// edge or it should be inherited from the undirected
  41.441 -      /// edge.
  41.442 +      /// This class identifies a directed arc of the graph. It also serves
  41.443 +      /// as a base class of the arc iterators,
  41.444 +      /// thus they will convert to this type.
  41.445        class Arc {
  41.446        public:
  41.447          /// Default constructor
  41.448  
  41.449 -        /// @warning The default constructor sets the iterator
  41.450 -        /// to an undefined value.
  41.451 +        /// Default constructor.
  41.452 +        /// \warning It sets the object to an undefined value.
  41.453          Arc() { }
  41.454          /// Copy constructor.
  41.455  
  41.456          /// Copy constructor.
  41.457          ///
  41.458          Arc(const Arc&) { }
  41.459 -        /// Initialize the iterator to be invalid.
  41.460 +        /// %Invalid constructor \& conversion.
  41.461  
  41.462 -        /// Initialize the iterator to be invalid.
  41.463 -        ///
  41.464 +        /// Initializes the object to be invalid.
  41.465 +        /// \sa Invalid for more details.
  41.466          Arc(Invalid) { }
  41.467          /// Equality operator
  41.468  
  41.469 +        /// Equality operator.
  41.470 +        ///
  41.471          /// Two iterators are equal if and only if they point to the
  41.472 -        /// same object or both are invalid.
  41.473 +        /// same object or both are \c INVALID.
  41.474          bool operator==(Arc) const { return true; }
  41.475          /// Inequality operator
  41.476  
  41.477 -        /// \sa operator==(Arc n)
  41.478 -        ///
  41.479 +        /// Inequality operator.
  41.480          bool operator!=(Arc) const { return true; }
  41.481  
  41.482          /// Artificial ordering operator.
  41.483  
  41.484 -        /// To allow the use of graph descriptors as key type in std::map or
  41.485 -        /// similar associative container we require this.
  41.486 +        /// Artificial ordering operator.
  41.487          ///
  41.488 -        /// \note This operator only have to define some strict ordering of
  41.489 -        /// the items; this order has nothing to do with the iteration
  41.490 -        /// ordering of the items.
  41.491 +        /// \note This operator only has to define some strict ordering of
  41.492 +        /// the arcs; this order has nothing to do with the iteration
  41.493 +        /// ordering of the arcs.
  41.494          bool operator<(Arc) const { return false; }
  41.495  
  41.496 -        /// Converison to Edge
  41.497 +        /// Converison to \c Edge
  41.498 +
  41.499 +        /// Converison to \c Edge.
  41.500 +        ///
  41.501          operator Edge() const { return Edge(); }
  41.502        };
  41.503 -      /// This iterator goes through each directed arc.
  41.504  
  41.505 -      /// This iterator goes through each arc of a graph.
  41.506 -      /// Its usage is quite simple, for example you can count the number
  41.507 -      /// of arcs in a graph \c g of type \c Graph as follows:
  41.508 +      /// Iterator class for the arcs.
  41.509 +
  41.510 +      /// This iterator goes through each directed arc of the graph.
  41.511 +      /// Its usage is quite simple, for example, you can count the number
  41.512 +      /// of arcs in a graph \c g of type \c %Graph as follows:
  41.513        ///\code
  41.514        /// int count=0;
  41.515 -      /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
  41.516 +      /// for(Graph::ArcIt a(g); a!=INVALID; ++a) ++count;
  41.517        ///\endcode
  41.518        class ArcIt : public Arc {
  41.519        public:
  41.520          /// Default constructor
  41.521  
  41.522 -        /// @warning The default constructor sets the iterator
  41.523 -        /// to an undefined value.
  41.524 +        /// Default constructor.
  41.525 +        /// \warning It sets the iterator to an undefined value.
  41.526          ArcIt() { }
  41.527          /// Copy constructor.
  41.528  
  41.529          /// Copy constructor.
  41.530          ///
  41.531          ArcIt(const ArcIt& e) : Arc(e) { }
  41.532 -        /// Initialize the iterator to be invalid.
  41.533 +        /// %Invalid constructor \& conversion.
  41.534  
  41.535 -        /// Initialize the iterator to be invalid.
  41.536 +        /// Initializes the iterator to be invalid.
  41.537 +        /// \sa Invalid for more details.
  41.538 +        ArcIt(Invalid) { }
  41.539 +        /// Sets the iterator to the first arc.
  41.540 +
  41.541 +        /// Sets the iterator to the first arc of the given graph.
  41.542          ///
  41.543 -        ArcIt(Invalid) { }
  41.544 -        /// This constructor sets the iterator to the first arc.
  41.545 +        explicit ArcIt(const Graph &g) { ::lemon::ignore_unused_variable_warning(g); }
  41.546 +        /// Sets the iterator to the given arc.
  41.547  
  41.548 -        /// This constructor sets the iterator to the first arc of \c g.
  41.549 -        ///@param g the graph
  41.550 -        ArcIt(const Graph &g) { ::lemon::ignore_unused_variable_warning(g); }
  41.551 -        /// Arc -> ArcIt conversion
  41.552 -
  41.553 -        /// Sets the iterator to the value of the trivial iterator \c e.
  41.554 -        /// This feature necessitates that each time we
  41.555 -        /// iterate the arc-set, the iteration order is the same.
  41.556 +        /// Sets the iterator to the given arc of the given graph.
  41.557 +        ///
  41.558          ArcIt(const Graph&, const Arc&) { }
  41.559 -        ///Next arc
  41.560 +        /// Next arc
  41.561  
  41.562          /// Assign the iterator to the next arc.
  41.563 +        ///
  41.564          ArcIt& operator++() { return *this; }
  41.565        };
  41.566  
  41.567 -      /// This iterator goes trough the outgoing directed arcs of a node.
  41.568 +      /// Iterator class for the outgoing arcs of a node.
  41.569  
  41.570 -      /// This iterator goes trough the \e outgoing arcs of a certain node
  41.571 -      /// of a graph.
  41.572 -      /// Its usage is quite simple, for example you can count the number
  41.573 +      /// This iterator goes trough the \e outgoing directed arcs of a
  41.574 +      /// certain node of a graph.
  41.575 +      /// Its usage is quite simple, for example, you can count the number
  41.576        /// of outgoing arcs of a node \c n
  41.577 -      /// in graph \c g of type \c Graph as follows.
  41.578 +      /// in a graph \c g of type \c %Graph as follows.
  41.579        ///\code
  41.580        /// int count=0;
  41.581 -      /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
  41.582 +      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
  41.583        ///\endcode
  41.584 -
  41.585        class OutArcIt : public Arc {
  41.586        public:
  41.587          /// Default constructor
  41.588  
  41.589 -        /// @warning The default constructor sets the iterator
  41.590 -        /// to an undefined value.
  41.591 +        /// Default constructor.
  41.592 +        /// \warning It sets the iterator to an undefined value.
  41.593          OutArcIt() { }
  41.594          /// Copy constructor.
  41.595  
  41.596          /// Copy constructor.
  41.597          ///
  41.598          OutArcIt(const OutArcIt& e) : Arc(e) { }
  41.599 -        /// Initialize the iterator to be invalid.
  41.600 +        /// %Invalid constructor \& conversion.
  41.601  
  41.602 -        /// Initialize the iterator to be invalid.
  41.603 +        /// Initializes the iterator to be invalid.
  41.604 +        /// \sa Invalid for more details.
  41.605 +        OutArcIt(Invalid) { }
  41.606 +        /// Sets the iterator to the first outgoing arc.
  41.607 +
  41.608 +        /// Sets the iterator to the first outgoing arc of the given node.
  41.609          ///
  41.610 -        OutArcIt(Invalid) { }
  41.611 -        /// This constructor sets the iterator to the first outgoing arc.
  41.612 -
  41.613 -        /// This constructor sets the iterator to the first outgoing arc of
  41.614 -        /// the node.
  41.615 -        ///@param n the node
  41.616 -        ///@param g the graph
  41.617          OutArcIt(const Graph& n, const Node& g) {
  41.618            ::lemon::ignore_unused_variable_warning(n);
  41.619            ::lemon::ignore_unused_variable_warning(g);
  41.620          }
  41.621 -        /// Arc -> OutArcIt conversion
  41.622 +        /// Sets the iterator to the given arc.
  41.623  
  41.624 -        /// Sets the iterator to the value of the trivial iterator.
  41.625 -        /// This feature necessitates that each time we
  41.626 -        /// iterate the arc-set, the iteration order is the same.
  41.627 +        /// Sets the iterator to the given arc of the given graph.
  41.628 +        ///
  41.629          OutArcIt(const Graph&, const Arc&) { }
  41.630 -        ///Next outgoing arc
  41.631 +        /// Next outgoing arc
  41.632  
  41.633          /// Assign the iterator to the next
  41.634          /// outgoing arc of the corresponding node.
  41.635          OutArcIt& operator++() { return *this; }
  41.636        };
  41.637  
  41.638 -      /// This iterator goes trough the incoming directed arcs of a node.
  41.639 +      /// Iterator class for the incoming arcs of a node.
  41.640  
  41.641 -      /// This iterator goes trough the \e incoming arcs of a certain node
  41.642 -      /// of a graph.
  41.643 -      /// Its usage is quite simple, for example you can count the number
  41.644 -      /// of outgoing arcs of a node \c n
  41.645 -      /// in graph \c g of type \c Graph as follows.
  41.646 +      /// This iterator goes trough the \e incoming directed arcs of a
  41.647 +      /// certain node of a graph.
  41.648 +      /// Its usage is quite simple, for example, you can count the number
  41.649 +      /// of incoming arcs of a node \c n
  41.650 +      /// in a graph \c g of type \c %Graph as follows.
  41.651        ///\code
  41.652        /// int count=0;
  41.653 -      /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
  41.654 +      /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
  41.655        ///\endcode
  41.656 -
  41.657        class InArcIt : public Arc {
  41.658        public:
  41.659          /// Default constructor
  41.660  
  41.661 -        /// @warning The default constructor sets the iterator
  41.662 -        /// to an undefined value.
  41.663 +        /// Default constructor.
  41.664 +        /// \warning It sets the iterator to an undefined value.
  41.665          InArcIt() { }
  41.666          /// Copy constructor.
  41.667  
  41.668          /// Copy constructor.
  41.669          ///
  41.670          InArcIt(const InArcIt& e) : Arc(e) { }
  41.671 -        /// Initialize the iterator to be invalid.
  41.672 +        /// %Invalid constructor \& conversion.
  41.673  
  41.674 -        /// Initialize the iterator to be invalid.
  41.675 +        /// Initializes the iterator to be invalid.
  41.676 +        /// \sa Invalid for more details.
  41.677 +        InArcIt(Invalid) { }
  41.678 +        /// Sets the iterator to the first incoming arc.
  41.679 +
  41.680 +        /// Sets the iterator to the first incoming arc of the given node.
  41.681          ///
  41.682 -        InArcIt(Invalid) { }
  41.683 -        /// This constructor sets the iterator to first incoming arc.
  41.684 -
  41.685 -        /// This constructor set the iterator to the first incoming arc of
  41.686 -        /// the node.
  41.687 -        ///@param n the node
  41.688 -        ///@param g the graph
  41.689          InArcIt(const Graph& g, const Node& n) {
  41.690            ::lemon::ignore_unused_variable_warning(n);
  41.691            ::lemon::ignore_unused_variable_warning(g);
  41.692          }
  41.693 -        /// Arc -> InArcIt conversion
  41.694 +        /// Sets the iterator to the given arc.
  41.695  
  41.696 -        /// Sets the iterator to the value of the trivial iterator \c e.
  41.697 -        /// This feature necessitates that each time we
  41.698 -        /// iterate the arc-set, the iteration order is the same.
  41.699 +        /// Sets the iterator to the given arc of the given graph.
  41.700 +        ///
  41.701          InArcIt(const Graph&, const Arc&) { }
  41.702          /// Next incoming arc
  41.703  
  41.704 -        /// Assign the iterator to the next inarc of the corresponding node.
  41.705 -        ///
  41.706 +        /// Assign the iterator to the next
  41.707 +        /// incoming arc of the corresponding node.
  41.708          InArcIt& operator++() { return *this; }
  41.709        };
  41.710  
  41.711 -      /// \brief Reference map of the nodes to type \c T.
  41.712 +      /// \brief Standard graph map type for the nodes.
  41.713        ///
  41.714 -      /// Reference map of the nodes to type \c T.
  41.715 +      /// Standard graph map type for the nodes.
  41.716 +      /// It conforms to the ReferenceMap concept.
  41.717        template<class T>
  41.718        class NodeMap : public ReferenceMap<Node, T, T&, const T&>
  41.719        {
  41.720        public:
  41.721  
  41.722 -        ///\e
  41.723 -        NodeMap(const Graph&) { }
  41.724 -        ///\e
  41.725 +        /// Constructor
  41.726 +        explicit NodeMap(const Graph&) { }
  41.727 +        /// Constructor with given initial value
  41.728          NodeMap(const Graph&, T) { }
  41.729  
  41.730        private:
  41.731 @@ -524,18 +531,20 @@
  41.732          }
  41.733        };
  41.734  
  41.735 -      /// \brief Reference map of the arcs to type \c T.
  41.736 +      /// \brief Standard graph map type for the arcs.
  41.737        ///
  41.738 -      /// Reference map of the arcs to type \c T.
  41.739 +      /// Standard graph map type for the arcs.
  41.740 +      /// It conforms to the ReferenceMap concept.
  41.741        template<class T>
  41.742        class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
  41.743        {
  41.744        public:
  41.745  
  41.746 -        ///\e
  41.747 -        ArcMap(const Graph&) { }
  41.748 -        ///\e
  41.749 +        /// Constructor
  41.750 +        explicit ArcMap(const Graph&) { }
  41.751 +        /// Constructor with given initial value
  41.752          ArcMap(const Graph&, T) { }
  41.753 +
  41.754        private:
  41.755          ///Copy constructor
  41.756          ArcMap(const ArcMap& em) :
  41.757 @@ -548,18 +557,20 @@
  41.758          }
  41.759        };
  41.760  
  41.761 -      /// Reference map of the edges to type \c T.
  41.762 -
  41.763 -      /// Reference map of the edges to type \c T.
  41.764 +      /// \brief Standard graph map type for the edges.
  41.765 +      ///
  41.766 +      /// Standard graph map type for the edges.
  41.767 +      /// It conforms to the ReferenceMap concept.
  41.768        template<class T>
  41.769        class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
  41.770        {
  41.771        public:
  41.772  
  41.773 -        ///\e
  41.774 -        EdgeMap(const Graph&) { }
  41.775 -        ///\e
  41.776 +        /// Constructor
  41.777 +        explicit EdgeMap(const Graph&) { }
  41.778 +        /// Constructor with given initial value
  41.779          EdgeMap(const Graph&, T) { }
  41.780