Merge
authorAlpar Juttner <alpar@cs.elte.hu>
Tue, 20 Dec 2011 18:15:14 +0100
changeset 11072b6bffe0e7e8
parent 1106 7c4ba7daaf5f
parent 1057 633956ca9421
child 1108 a1fd7008a052
Merge
CMakeLists.txt
configure.ac
doc/CMakeLists.txt
doc/Doxyfile.in
doc/mainpage.dox.in
lemon/Makefile.am
lemon/bits/edge_set_extender.h
lemon/bits/windows.cc
lemon/core.h
lemon/dfs.h
lemon/graph_to_eps.h
lemon/lgf_reader.h
lemon/lp_base.h
lemon/network_simplex.h
lemon/preflow.h
test/CMakeLists.txt
test/Makefile.am
test/dfs_test.cc
test/heap_test.cc
test/preflow_test.cc
     1.1 --- a/.hgignore	Tue Dec 20 17:44:38 2011 +0100
     1.2 +++ b/.hgignore	Tue Dec 20 18:15:14 2011 +0100
     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	Tue Dec 20 17:44:38 2011 +0100
     2.2 +++ b/CMakeLists.txt	Tue Dec 20 18:15:14 2011 +0100
     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	Tue Dec 20 17:44:38 2011 +0100
     3.2 +++ b/INSTALL	Tue Dec 20 18:15:14 2011 +0100
     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/Makefile.am	Tue Dec 20 17:44:38 2011 +0100
     4.2 +++ b/Makefile.am	Tue Dec 20 18:15:14 2011 +0100
     4.3 @@ -44,6 +44,7 @@
     4.4  include test/Makefile.am
     4.5  include doc/Makefile.am
     4.6  include tools/Makefile.am
     4.7 +include scripts/Makefile.am
     4.8  
     4.9  DIST_SUBDIRS = demo
    4.10  
     5.1 --- a/README	Tue Dec 20 17:44:38 2011 +0100
     5.2 +++ b/README	Tue Dec 20 18:15:14 2011 +0100
     5.3 @@ -17,6 +17,10 @@
     5.4  
     5.5     Copying, distribution and modification conditions and terms.
     5.6  
     5.7 +NEWS
     5.8 +
     5.9 +   News and version history.
    5.10 +
    5.11  INSTALL
    5.12  
    5.13     General building and installation instructions.
    5.14 @@ -33,6 +37,10 @@
    5.15  
    5.16     Some example programs to make you easier to get familiar with LEMON.
    5.17  
    5.18 +scripts/
    5.19 +
    5.20 +   Scripts that make it easier to develop LEMON.
    5.21 +
    5.22  test/
    5.23  
    5.24     Programs to check the integrity and correctness of LEMON.
     6.1 --- a/configure.ac	Tue Dec 20 17:44:38 2011 +0100
     6.2 +++ b/configure.ac	Tue Dec 20 18:15:14 2011 +0100
     6.3 @@ -41,6 +41,7 @@
     6.4  AC_PROG_LIBTOOL
     6.5  
     6.6  AC_CHECK_PROG([doxygen_found],[doxygen],[yes],[no])
     6.7 +AC_CHECK_PROG([python_found],[python],[yes],[no])
     6.8  AC_CHECK_PROG([gs_found],[gs],[yes],[no])
     6.9  
    6.10  dnl Detect Intel compiler.
    6.11 @@ -82,6 +83,21 @@
    6.12  fi
    6.13  AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"])
    6.14  
    6.15 +dnl Support for running test cases using valgrind.
    6.16 +use_valgrind=no
    6.17 +AC_ARG_ENABLE([valgrind],
    6.18 +AS_HELP_STRING([--enable-valgrind], [use valgrind when running tests]),
    6.19 +              [use_valgrind=yes])
    6.20 +
    6.21 +if [[ "$use_valgrind" = "yes" ]]; then
    6.22 +  AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
    6.23 +
    6.24 +  if [[ "$HAVE_VALGRIND" = "no" ]]; then
    6.25 +    AC_MSG_ERROR([Valgrind not found in PATH.])
    6.26 +  fi
    6.27 +fi
    6.28 +AM_CONDITIONAL(USE_VALGRIND, [test "$use_valgrind" = "yes"])
    6.29 +
    6.30  dnl Checks for header files.
    6.31  AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h unistd.h)
    6.32  
    6.33 @@ -128,6 +144,7 @@
    6.34  echo CBC support................... : $lx_cbc_found
    6.35  echo
    6.36  echo Build additional tools........ : $enable_tools
    6.37 +echo Use valgrind for tests........ : $use_valgrind
    6.38  echo
    6.39  echo The packace will be installed in
    6.40  echo -n '  '
     7.1 --- a/demo/arg_parser_demo.cc	Tue Dec 20 17:44:38 2011 +0100
     7.2 +++ b/demo/arg_parser_demo.cc	Tue Dec 20 18:15:14 2011 +0100
     7.3 @@ -2,7 +2,7 @@
     7.4   *
     7.5   * This file is a part of LEMON, a generic C++ optimization library.
     7.6   *
     7.7 - * Copyright (C) 2003-2009
     7.8 + * Copyright (C) 2003-2010
     7.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    7.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    7.11   *
    7.12 @@ -65,9 +65,18 @@
    7.13    ap.other("infile", "The input file.")
    7.14      .other("...");
    7.15  
    7.16 +  // Throw an exception when problems occurs. The default behavior is to
    7.17 +  // exit(1) on these cases, but this makes Valgrind falsely warn
    7.18 +  // about memory leaks.
    7.19 +  ap.throwOnProblems();
    7.20 +
    7.21    // Perform the parsing process
    7.22    // (in case of any error it terminates the program)
    7.23 -  ap.parse();
    7.24 +  // The try {} construct is necessary only if the ap.trowOnProblems()
    7.25 +  // setting is in use.
    7.26 +  try {
    7.27 +    ap.parse();
    7.28 +  } catch (ArgParserException &) { return 1; }
    7.29  
    7.30    // Check each option if it has been given and print its value
    7.31    std::cout << "Parameters of '" << ap.commandName() << "':\n";
     8.1 --- a/doc/CMakeLists.txt	Tue Dec 20 17:44:38 2011 +0100
     8.2 +++ b/doc/CMakeLists.txt	Tue Dec 20 18:15:14 2011 +0100
     8.3 @@ -17,7 +17,7 @@
     8.4    @ONLY
     8.5  )
     8.6  
     8.7 -IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
     8.8 +IF(DOXYGEN_EXECUTABLE AND PYTHONINTERP_FOUND AND GHOSTSCRIPT_EXECUTABLE)
     8.9    FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
    8.10    SET(GHOSTSCRIPT_OPTIONS -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha)
    8.11    ADD_CUSTOM_TARGET(html
    8.12 @@ -28,14 +28,17 @@
    8.13      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
    8.14      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
    8.15      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
    8.16 +    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/matching.eps
    8.17      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
    8.18      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
    8.19      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
    8.20      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
    8.21      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
    8.22      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
    8.23 +    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/planar.png ${CMAKE_CURRENT_SOURCE_DIR}/images/planar.eps
    8.24      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
    8.25      COMMAND ${CMAKE_COMMAND} -E remove_directory html
    8.26 +    COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/bib2dox.py ${CMAKE_CURRENT_SOURCE_DIR}/references.bib >references.dox
    8.27      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
    8.28      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    8.29    )
     9.1 --- a/doc/Doxyfile.in	Tue Dec 20 17:44:38 2011 +0100
     9.2 +++ b/doc/Doxyfile.in	Tue Dec 20 18:15:14 2011 +0100
     9.3 @@ -97,7 +97,8 @@
     9.4                           "@abs_top_srcdir@/demo" \
     9.5                           "@abs_top_srcdir@/tools" \
     9.6                           "@abs_top_srcdir@/test/test_tools.h" \
     9.7 -                         "@abs_top_builddir@/doc/mainpage.dox"
     9.8 +                         "@abs_top_builddir@/doc/mainpage.dox" \
     9.9 +                         "@abs_top_builddir@/doc/references.dox"
    9.10  INPUT_ENCODING         = UTF-8
    9.11  FILE_PATTERNS          = *.h \
    9.12                           *.cc \
    10.1 --- a/doc/Makefile.am	Tue Dec 20 17:44:38 2011 +0100
    10.2 +++ b/doc/Makefile.am	Tue Dec 20 18:15:14 2011 +0100
    10.3 @@ -27,7 +27,9 @@
    10.4  	bipartite_partitions.eps \
    10.5  	connected_components.eps \
    10.6  	edge_biconnected_components.eps \
    10.7 +	matching.eps \
    10.8  	node_biconnected_components.eps \
    10.9 +	planar.eps \
   10.10  	strongly_connected_components.eps
   10.11  
   10.12  DOC_EPS_IMAGES = \
   10.13 @@ -66,7 +68,19 @@
   10.14  	  exit 1; \
   10.15  	fi
   10.16  
   10.17 -html-local: $(DOC_PNG_IMAGES)
   10.18 +references.dox: doc/references.bib
   10.19 +	if test ${python_found} = yes; then \
   10.20 +	  cd doc; \
   10.21 +	  python @abs_top_srcdir@/scripts/bib2dox.py @abs_top_builddir@/$< >$@; \
   10.22 +	  cd ..; \
   10.23 +	else \
   10.24 +	  echo; \
   10.25 +	  echo "Python not found."; \
   10.26 +	  echo; \
   10.27 +	  exit 1; \
   10.28 +	fi
   10.29 +
   10.30 +html-local: $(DOC_PNG_IMAGES) references.dox
   10.31  	if test ${doxygen_found} = yes; then \
   10.32  	  cd doc; \
   10.33  	  doxygen Doxyfile; \
    11.1 --- a/doc/groups.dox	Tue Dec 20 17:44:38 2011 +0100
    11.2 +++ b/doc/groups.dox	Tue Dec 20 18:15:14 2011 +0100
    11.3 @@ -2,7 +2,7 @@
    11.4   *
    11.5   * This file is a part of LEMON, a generic C++ optimization library.
    11.6   *
    11.7 - * Copyright (C) 2003-2009
    11.8 + * Copyright (C) 2003-2010
    11.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   11.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   11.11   *
   11.12 @@ -226,14 +226,6 @@
   11.13  */
   11.14  
   11.15  /**
   11.16 -@defgroup matrices Matrices
   11.17 -@ingroup datas
   11.18 -\brief Two dimensional data storages implemented in LEMON.
   11.19 -
   11.20 -This group contains two dimensional data storages implemented in LEMON.
   11.21 -*/
   11.22 -
   11.23 -/**
   11.24  @defgroup paths Path Structures
   11.25  @ingroup datas
   11.26  \brief %Path structures implemented in LEMON.
   11.27 @@ -246,7 +238,36 @@
   11.28  efficient to have e.g. the Dijkstra algorithm to store its result in
   11.29  any kind of path structure.
   11.30  
   11.31 -\sa lemon::concepts::Path
   11.32 +\sa \ref concepts::Path "Path concept"
   11.33 +*/
   11.34 +
   11.35 +/**
   11.36 +@defgroup heaps Heap Structures
   11.37 +@ingroup datas
   11.38 +\brief %Heap structures implemented in LEMON.
   11.39 +
   11.40 +This group contains the heap structures implemented in LEMON.
   11.41 +
   11.42 +LEMON provides several heap classes. They are efficient implementations
   11.43 +of the abstract data type \e priority \e queue. They store items with
   11.44 +specified values called \e priorities in such a way that finding and
   11.45 +removing the item with minimum priority are efficient.
   11.46 +The basic operations are adding and erasing items, changing the priority
   11.47 +of an item, etc.
   11.48 +
   11.49 +Heaps are crucial in several algorithms, such as Dijkstra and Prim.
   11.50 +The heap implementations have the same interface, thus any of them can be
   11.51 +used easily in such algorithms.
   11.52 +
   11.53 +\sa \ref concepts::Heap "Heap concept"
   11.54 +*/
   11.55 +
   11.56 +/**
   11.57 +@defgroup matrices Matrices
   11.58 +@ingroup datas
   11.59 +\brief Two dimensional data storages implemented in LEMON.
   11.60 +
   11.61 +This group contains two dimensional data storages implemented in LEMON.
   11.62  */
   11.63  
   11.64  /**
   11.65 @@ -259,6 +280,28 @@
   11.66  */
   11.67  
   11.68  /**
   11.69 +@defgroup geomdat Geometric Data Structures
   11.70 +@ingroup auxdat
   11.71 +\brief Geometric data structures implemented in LEMON.
   11.72 +
   11.73 +This group contains geometric data structures implemented in LEMON.
   11.74 +
   11.75 + - \ref lemon::dim2::Point "dim2::Point" implements a two dimensional
   11.76 +   vector with the usual operations.
   11.77 + - \ref lemon::dim2::Box "dim2::Box" can be used to determine the
   11.78 +   rectangular bounding box of a set of \ref lemon::dim2::Point
   11.79 +   "dim2::Point"'s.
   11.80 +*/
   11.81 +
   11.82 +/**
   11.83 +@defgroup matrices Matrices
   11.84 +@ingroup auxdat
   11.85 +\brief Two dimensional data storages implemented in LEMON.
   11.86 +
   11.87 +This group contains two dimensional data storages implemented in LEMON.
   11.88 +*/
   11.89 +
   11.90 +/**
   11.91  @defgroup algs Algorithms
   11.92  \brief This group contains the several algorithms
   11.93  implemented in LEMON.
   11.94 @@ -273,7 +316,8 @@
   11.95  \brief Common graph search algorithms.
   11.96  
   11.97  This group contains the common graph search algorithms, namely
   11.98 -\e breadth-first \e search (BFS) and \e depth-first \e search (DFS).
   11.99 +\e breadth-first \e search (BFS) and \e depth-first \e search (DFS)
  11.100 +\ref clrs01algorithms.
  11.101  */
  11.102  
  11.103  /**
  11.104 @@ -281,7 +325,8 @@
  11.105  @ingroup algs
  11.106  \brief Algorithms for finding shortest paths.
  11.107  
  11.108 -This group contains the algorithms for finding shortest paths in digraphs.
  11.109 +This group contains the algorithms for finding shortest paths in digraphs
  11.110 +\ref clrs01algorithms.
  11.111  
  11.112   - \ref Dijkstra algorithm for finding shortest paths from a source node
  11.113     when all arc lengths are non-negative.
  11.114 @@ -298,12 +343,21 @@
  11.115  */
  11.116  
  11.117  /**
  11.118 +@defgroup spantree Minimum Spanning Tree Algorithms
  11.119 +@ingroup algs
  11.120 +\brief Algorithms for finding minimum cost spanning trees and arborescences.
  11.121 +
  11.122 +This group contains the algorithms for finding minimum cost spanning
  11.123 +trees and arborescences \ref clrs01algorithms.
  11.124 +*/
  11.125 +
  11.126 +/**
  11.127  @defgroup max_flow Maximum Flow Algorithms
  11.128  @ingroup algs
  11.129  \brief Algorithms for finding maximum flows.
  11.130  
  11.131  This group contains the algorithms for finding maximum flows and
  11.132 -feasible circulations.
  11.133 +feasible circulations \ref clrs01algorithms, \ref amo93networkflows.
  11.134  
  11.135  The \e maximum \e flow \e problem is to find a flow of maximum value between
  11.136  a single source and a single target. Formally, there is a \f$G=(V,A)\f$
  11.137 @@ -318,17 +372,21 @@
  11.138  \f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f]
  11.139  
  11.140  LEMON contains several algorithms for solving maximum flow problems:
  11.141 -- \ref EdmondsKarp Edmonds-Karp algorithm.
  11.142 -- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm.
  11.143 -- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees.
  11.144 -- \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees.
  11.145 +- \ref EdmondsKarp Edmonds-Karp algorithm
  11.146 +  \ref edmondskarp72theoretical.
  11.147 +- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm
  11.148 +  \ref goldberg88newapproach.
  11.149 +- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees
  11.150 +  \ref dinic70algorithm, \ref sleator83dynamic.
  11.151 +- \ref GoldbergTarjan !Preflow push-relabel algorithm with dynamic trees
  11.152 +  \ref goldberg88newapproach, \ref sleator83dynamic.
  11.153  
  11.154 -In most cases the \ref Preflow "Preflow" algorithm provides the
  11.155 +In most cases the \ref Preflow algorithm provides the
  11.156  fastest method for computing a maximum flow. All implementations
  11.157  also provide functions to query the minimum cut, which is the dual
  11.158  problem of maximum flow.
  11.159  
  11.160 -\ref Circulation is a preflow push-relabel algorithm implemented directly 
  11.161 +\ref Circulation is a preflow push-relabel algorithm implemented directly
  11.162  for finding feasible circulations, which is a somewhat different problem,
  11.163  but it is strongly related to maximum flow.
  11.164  For more information, see \ref Circulation.
  11.165 @@ -341,18 +399,20 @@
  11.166  \brief Algorithms for finding minimum cost flows and circulations.
  11.167  
  11.168  This group contains the algorithms for finding minimum cost flows and
  11.169 -circulations. For more information about this problem and its dual
  11.170 -solution see \ref min_cost_flow "Minimum Cost Flow Problem".
  11.171 +circulations \ref amo93networkflows. For more information about this
  11.172 +problem and its dual solution, see \ref min_cost_flow
  11.173 +"Minimum Cost Flow Problem".
  11.174  
  11.175  LEMON contains several algorithms for this problem.
  11.176   - \ref NetworkSimplex Primal Network Simplex algorithm with various
  11.177 -   pivot strategies.
  11.178 - - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on
  11.179 -   cost scaling.
  11.180 - - \ref CapacityScaling Successive Shortest %Path algorithm with optional
  11.181 -   capacity scaling.
  11.182 - - \ref CancelAndTighten The Cancel and Tighten algorithm.
  11.183 - - \ref CycleCanceling Cycle-Canceling algorithms.
  11.184 +   pivot strategies \ref dantzig63linearprog, \ref kellyoneill91netsimplex.
  11.185 + - \ref CostScaling Cost Scaling algorithm based on push/augment and
  11.186 +   relabel operations \ref goldberg90approximation, \ref goldberg97efficient,
  11.187 +   \ref bunnagel98efficient.
  11.188 + - \ref CapacityScaling Capacity Scaling algorithm based on the successive
  11.189 +   shortest path method \ref edmondskarp72theoretical.
  11.190 + - \ref CycleCanceling Cycle-Canceling algorithms, two of which are
  11.191 +   strongly polynomial \ref klein67primal, \ref goldberg89cyclecanceling.
  11.192  
  11.193  In general NetworkSimplex is the most efficient implementation,
  11.194  but in special cases other algorithms could be faster.
  11.195 @@ -375,7 +435,7 @@
  11.196  cut is the \f$X\f$ solution of the next optimization problem:
  11.197  
  11.198  \f[ \min_{X \subset V, X\not\in \{\emptyset, V\}}
  11.199 -    \sum_{uv\in A, u\in X, v\not\in X}cap(uv) \f]
  11.200 +    \sum_{uv\in A: u\in X, v\not\in X}cap(uv) \f]
  11.201  
  11.202  LEMON contains several algorithms related to minimum cut problems:
  11.203  
  11.204 @@ -391,27 +451,40 @@
  11.205  */
  11.206  
  11.207  /**
  11.208 -@defgroup graph_properties Connectivity and Other Graph Properties
  11.209 +@defgroup min_mean_cycle Minimum Mean Cycle Algorithms
  11.210  @ingroup algs
  11.211 -\brief Algorithms for discovering the graph properties
  11.212 +\brief Algorithms for finding minimum mean cycles.
  11.213  
  11.214 -This group contains the algorithms for discovering the graph properties
  11.215 -like connectivity, bipartiteness, euler property, simplicity etc.
  11.216 +This group contains the algorithms for finding minimum mean cycles
  11.217 +\ref clrs01algorithms, \ref amo93networkflows.
  11.218  
  11.219 -\image html edge_biconnected_components.png
  11.220 -\image latex edge_biconnected_components.eps "bi-edge-connected components" width=\textwidth
  11.221 -*/
  11.222 +The \e minimum \e mean \e cycle \e problem is to find a directed cycle
  11.223 +of minimum mean length (cost) in a digraph.
  11.224 +The mean length of a cycle is the average length of its arcs, i.e. the
  11.225 +ratio between the total length of the cycle and the number of arcs on it.
  11.226  
  11.227 -/**
  11.228 -@defgroup planar Planarity Embedding and Drawing
  11.229 -@ingroup algs
  11.230 -\brief Algorithms for planarity checking, embedding and drawing
  11.231 +This problem has an important connection to \e conservative \e length
  11.232 +\e functions, too. A length function on the arcs of a digraph is called
  11.233 +conservative if and only if there is no directed cycle of negative total
  11.234 +length. For an arbitrary length function, the negative of the minimum
  11.235 +cycle mean is the smallest \f$\epsilon\f$ value so that increasing the
  11.236 +arc lengths uniformly by \f$\epsilon\f$ results in a conservative length
  11.237 +function.
  11.238  
  11.239 -This group contains the algorithms for planarity checking,
  11.240 -embedding and drawing.
  11.241 +LEMON contains three algorithms for solving the minimum mean cycle problem:
  11.242 +- \ref Karp "Karp"'s original algorithm \ref amo93networkflows,
  11.243 +  \ref dasdan98minmeancycle.
  11.244 +- \ref HartmannOrlin "Hartmann-Orlin"'s algorithm, which is an improved
  11.245 +  version of Karp's algorithm \ref dasdan98minmeancycle.
  11.246 +- \ref Howard "Howard"'s policy iteration algorithm
  11.247 +  \ref dasdan98minmeancycle.
  11.248  
  11.249 -\image html planar.png
  11.250 -\image latex planar.eps "Plane graph" width=\textwidth
  11.251 +In practice, the Howard algorithm proved to be by far the most efficient
  11.252 +one, though the best known theoretical bound on its running time is
  11.253 +exponential.
  11.254 +Both Karp and HartmannOrlin algorithms run in time O(ne) and use space
  11.255 +O(n<sup>2</sup>+e), but the latter one is typically faster due to the
  11.256 +applied early termination scheme.
  11.257  */
  11.258  
  11.259  /**
  11.260 @@ -449,18 +522,49 @@
  11.261  - \ref MaxWeightedPerfectMatching
  11.262    Edmond's blossom shrinking algorithm for calculating maximum weighted
  11.263    perfect matching in general graphs.
  11.264 +- \ref MaxFractionalMatching Push-relabel algorithm for calculating
  11.265 +  maximum cardinality fractional matching in general graphs.
  11.266 +- \ref MaxWeightedFractionalMatching Augmenting path algorithm for calculating
  11.267 +  maximum weighted fractional matching in general graphs.
  11.268 +- \ref MaxWeightedPerfectFractionalMatching
  11.269 +  Augmenting path algorithm for calculating maximum weighted
  11.270 +  perfect fractional matching in general graphs.
  11.271  
  11.272 -\image html bipartite_matching.png
  11.273 -\image latex bipartite_matching.eps "Bipartite Matching" width=\textwidth
  11.274 +\image html matching.png
  11.275 +\image latex matching.eps "Min Cost Perfect Matching" width=\textwidth
  11.276  */
  11.277  
  11.278  /**
  11.279 -@defgroup spantree Minimum Spanning Tree Algorithms
  11.280 +@defgroup graph_properties Connectivity and Other Graph Properties
  11.281  @ingroup algs
  11.282 -\brief Algorithms for finding minimum cost spanning trees and arborescences.
  11.283 +\brief Algorithms for discovering the graph properties
  11.284  
  11.285 -This group contains the algorithms for finding minimum cost spanning
  11.286 -trees and arborescences.
  11.287 +This group contains the algorithms for discovering the graph properties
  11.288 +like connectivity, bipartiteness, euler property, simplicity etc.
  11.289 +
  11.290 +\image html connected_components.png
  11.291 +\image latex connected_components.eps "Connected components" width=\textwidth
  11.292 +*/
  11.293 +
  11.294 +/**
  11.295 +@defgroup planar Planarity Embedding and Drawing
  11.296 +@ingroup algs
  11.297 +\brief Algorithms for planarity checking, embedding and drawing
  11.298 +
  11.299 +This group contains the algorithms for planarity checking,
  11.300 +embedding and drawing.
  11.301 +
  11.302 +\image html planar.png
  11.303 +\image latex planar.eps "Plane graph" width=\textwidth
  11.304 +*/
  11.305 +
  11.306 +/**
  11.307 +@defgroup approx Approximation Algorithms
  11.308 +@ingroup algs
  11.309 +\brief Approximation algorithms.
  11.310 +
  11.311 +This group contains the approximation and heuristic algorithms
  11.312 +implemented in LEMON.
  11.313  */
  11.314  
  11.315  /**
  11.316 @@ -473,15 +577,6 @@
  11.317  */
  11.318  
  11.319  /**
  11.320 -@defgroup approx Approximation Algorithms
  11.321 -@ingroup algs
  11.322 -\brief Approximation algorithms.
  11.323 -
  11.324 -This group contains the approximation and heuristic algorithms
  11.325 -implemented in LEMON.
  11.326 -*/
  11.327 -
  11.328 -/**
  11.329  @defgroup gen_opt_group General Optimization Tools
  11.330  \brief This group contains some general optimization frameworks
  11.331  implemented in LEMON.
  11.332 @@ -491,13 +586,16 @@
  11.333  */
  11.334  
  11.335  /**
  11.336 -@defgroup lp_group Lp and Mip Solvers
  11.337 +@defgroup lp_group LP and MIP Solvers
  11.338  @ingroup gen_opt_group
  11.339 -\brief Lp and Mip solver interfaces for LEMON.
  11.340 +\brief LP and MIP solver interfaces for LEMON.
  11.341  
  11.342 -This group contains Lp and Mip solver interfaces for LEMON. The
  11.343 -various LP solvers could be used in the same manner with this
  11.344 -interface.
  11.345 +This group contains LP and MIP solver interfaces for LEMON.
  11.346 +Various LP solvers could be used in the same manner with this
  11.347 +high-level interface.
  11.348 +
  11.349 +The currently supported solvers are \ref glpk, \ref clp, \ref cbc,
  11.350 +\ref cplex, \ref soplex.
  11.351  */
  11.352  
  11.353  /**
  11.354 @@ -587,7 +685,7 @@
  11.355  */
  11.356  
  11.357  /**
  11.358 -@defgroup dimacs_group DIMACS format
  11.359 +@defgroup dimacs_group DIMACS Format
  11.360  @ingroup io_group
  11.361  \brief Read and write files in DIMACS format
  11.362  
  11.363 @@ -636,8 +734,8 @@
  11.364  @ingroup concept
  11.365  \brief Skeleton and concept checking classes for graph structures
  11.366  
  11.367 -This group contains the skeletons and concept checking classes of LEMON's
  11.368 -graph structures and helper classes used to implement these.
  11.369 +This group contains the skeletons and concept checking classes of
  11.370 +graph structures.
  11.371  */
  11.372  
  11.373  /**
  11.374 @@ -649,6 +747,15 @@
  11.375  */
  11.376  
  11.377  /**
  11.378 +@defgroup tools Standalone Utility Applications
  11.379 +
  11.380 +Some utility applications are listed here.
  11.381 +
  11.382 +The standard compilation procedure (<tt>./configure;make</tt>) will compile
  11.383 +them, as well.
  11.384 +*/
  11.385 +
  11.386 +/**
  11.387  \anchor demoprograms
  11.388  
  11.389  @defgroup demos Demo Programs
  11.390 @@ -660,13 +767,4 @@
  11.391  <tt>make check</tt> commands.
  11.392  */
  11.393  
  11.394 -/**
  11.395 -@defgroup tools Standalone Utility Applications
  11.396 -
  11.397 -Some utility applications are listed here.
  11.398 -
  11.399 -The standard compilation procedure (<tt>./configure;make</tt>) will compile
  11.400 -them, as well.
  11.401 -*/
  11.402 -
  11.403  }
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/doc/images/matching.eps	Tue Dec 20 18:15:14 2011 +0100
    12.3 @@ -0,0 +1,130 @@
    12.4 +%!PS-Adobe-2.0 EPSF-2.0
    12.5 +%%Creator: LEMON, graphToEps()
    12.6 +%%CreationDate: Sun Mar 14 09:08:34 2010
    12.7 +%%BoundingBox: -353 -264 559 292
    12.8 +%%EndComments
    12.9 +/lb { setlinewidth setrgbcolor newpath moveto
   12.10 +      4 2 roll 1 index 1 index curveto stroke } bind def
   12.11 +/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def
   12.12 +/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def
   12.13 +/sq { newpath 2 index 1 index add 2 index 2 index add moveto
   12.14 +      2 index 1 index sub 2 index 2 index add lineto
   12.15 +      2 index 1 index sub 2 index 2 index sub lineto
   12.16 +      2 index 1 index add 2 index 2 index sub lineto
   12.17 +      closepath pop pop pop} bind def
   12.18 +/di { newpath 2 index 1 index add 2 index moveto
   12.19 +      2 index             2 index 2 index add lineto
   12.20 +      2 index 1 index sub 2 index             lineto
   12.21 +      2 index             2 index 2 index sub lineto
   12.22 +      closepath pop pop pop} bind def
   12.23 +/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill
   12.24 +     setrgbcolor 1.1 div c fill
   12.25 +   } bind def
   12.26 +/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill
   12.27 +     setrgbcolor 1.1 div sq fill
   12.28 +   } bind def
   12.29 +/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill
   12.30 +     setrgbcolor 1.1 div di fill
   12.31 +   } bind def
   12.32 +/nfemale { 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   12.33 +  newpath 5 index 5 index moveto 5 index 5 index 5 index 3.01 mul sub
   12.34 +  lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto
   12.35 +  5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke
   12.36 +  5 index 5 index 5 index c fill
   12.37 +  setrgbcolor 1.1 div c fill
   12.38 +  } bind def
   12.39 +/nmale {
   12.40 +  0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   12.41 +  newpath 5 index 5 index moveto
   12.42 +  5 index 4 index 1 mul 1.5 mul add
   12.43 +  5 index 5 index 3 sqrt 1.5 mul mul add
   12.44 +  1 index 1 index lineto
   12.45 +  1 index 1 index 7 index sub moveto
   12.46 +  1 index 1 index lineto
   12.47 +  exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto
   12.48 +  stroke
   12.49 +  5 index 5 index 5 index c fill
   12.50 +  setrgbcolor 1.1 div c fill
   12.51 +  } bind def
   12.52 +/arrl 1 def
   12.53 +/arrw 0.3 def
   12.54 +/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def
   12.55 +/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def
   12.56 +       /w exch def /len exch def
   12.57 +       newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto
   12.58 +       len w sub arrl sub dx dy lrl
   12.59 +       arrw dy dx neg lrl
   12.60 +       dx arrl w add mul dy w 2 div arrw add mul sub
   12.61 +       dy arrl w add mul dx w 2 div arrw add mul add rlineto
   12.62 +       dx arrl w add mul neg dy w 2 div arrw add mul sub
   12.63 +       dy arrl w add mul neg dx w 2 div arrw add mul add rlineto
   12.64 +       arrw dy dx neg lrl
   12.65 +       len w sub arrl sub neg dx dy lrl
   12.66 +       closepath fill } bind def
   12.67 +/cshow { 2 index 2 index moveto dup stringwidth pop
   12.68 +         neg 2 div fosi .35 mul neg rmoveto show pop pop} def
   12.69 +
   12.70 +gsave
   12.71 +%Arcs:
   12.72 +gsave
   12.73 +140.321 266.249 -327.729 150.06 0 0 0 4.99223 l
   12.74 +82.1207 -238.726 -245.288 -110.743 0 0 0 4.99223 l
   12.75 +336.635 -229.036 533.603 13.109 0 0 0 4.99223 l
   12.76 +53.8598 -45.8071 -245.288 -110.743 0 0 0 4.99223 l
   12.77 +-75.5617 118.579 -327.729 150.06 0 0 0 4.99223 l
   12.78 +-327.729 150.06 -245.288 -110.743 1 0 0 11.9813 l
   12.79 +533.603 13.109 218.184 -84.2955 0 0 0 4.99223 l
   12.80 +39.87 175.035 141.163 67.2575 0 0 0 4.99223 l
   12.81 +53.8598 -45.8071 -75.5617 118.579 0 0 0 4.99223 l
   12.82 +-102.406 -141.267 82.1207 -238.726 0 0 0 4.99223 l
   12.83 +399.144 166.894 533.603 13.109 1 0 0 11.9813 l
   12.84 +39.87 175.035 140.321 266.249 1 0 0 11.9813 l
   12.85 +399.144 166.894 140.321 266.249 0 0 0 4.99223 l
   12.86 +399.144 166.894 141.163 67.2575 0 0 0 4.99223 l
   12.87 +53.8598 -45.8071 204.765 -173.77 0 0 0 4.99223 l
   12.88 +82.1207 -238.726 204.765 -173.77 0 0 0 4.99223 l
   12.89 +258.227 61.658 399.144 166.894 0 0 0 4.99223 l
   12.90 +53.8598 -45.8071 -102.406 -141.267 1 0 0 11.9813 l
   12.91 +175.073 -37.4477 141.163 67.2575 0 0 0 4.99223 l
   12.92 +258.227 61.658 380 0 0 0 0 4.99223 l
   12.93 +34.6739 40.8267 -75.5617 118.579 1 0 0 11.9813 l
   12.94 +380 0 533.603 13.109 0 0 0 4.99223 l
   12.95 +175.073 -37.4477 380 0 0 0 0 4.99223 l
   12.96 +218.184 -84.2955 204.765 -173.77 0 0 0 4.99223 l
   12.97 +53.8598 -45.8071 34.6739 40.8267 0 0 0 4.99223 l
   12.98 +167.905 -213.988 82.1207 -238.726 1 0 0 11.9813 l
   12.99 +336.635 -229.036 204.765 -173.77 1 0 0 11.9813 l
  12.100 +336.635 -229.036 167.905 -213.988 0 0 0 4.99223 l
  12.101 +329.08 -26.3098 218.184 -84.2955 0 0 0 4.99223 l
  12.102 +39.87 175.035 -75.5617 118.579 0 0 0 4.99223 l
  12.103 +53.8598 -45.8071 175.073 -37.4477 0 0 0 4.99223 l
  12.104 +34.6739 40.8267 141.163 67.2575 0 0 0 4.99223 l
  12.105 +258.227 61.658 141.163 67.2575 1 0 0 11.9813 l
  12.106 +175.073 -37.4477 218.184 -84.2955 1 0 0 11.9813 l
  12.107 +380 0 329.08 -26.3098 1 0 0 11.9813 l
  12.108 +grestore
  12.109 +%Nodes:
  12.110 +gsave
  12.111 +-245.288 -110.743 14.9767 1 1 1 nc
  12.112 +204.765 -173.77 14.9767 1 1 1 nc
  12.113 +-327.729 150.06 14.9767 1 1 1 nc
  12.114 +-75.5617 118.579 14.9767 1 1 1 nc
  12.115 +218.184 -84.2955 14.9767 1 1 1 nc
  12.116 +140.321 266.249 14.9767 1 1 1 nc
  12.117 +141.163 67.2575 14.9767 1 1 1 nc
  12.118 +82.1207 -238.726 14.9767 1 1 1 nc
  12.119 +329.08 -26.3098 14.9767 1 1 1 nc
  12.120 +-102.406 -141.267 14.9767 1 1 1 nc
  12.121 +533.603 13.109 14.9767 1 1 1 nc
  12.122 +167.905 -213.988 14.9767 1 1 1 nc
  12.123 +336.635 -229.036 14.9767 1 1 1 nc
  12.124 +380 0 14.9767 1 1 1 nc
  12.125 +399.144 166.894 14.9767 1 1 1 nc
  12.126 +34.6739 40.8267 14.9767 1 1 1 nc
  12.127 +39.87 175.035 14.9767 1 1 1 nc
  12.128 +175.073 -37.4477 14.9767 1 1 1 nc
  12.129 +53.8598 -45.8071 14.9767 1 1 1 nc
  12.130 +258.227 61.658 14.9767 1 1 1 nc
  12.131 +grestore
  12.132 +grestore
  12.133 +showpage
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/doc/images/planar.eps	Tue Dec 20 18:15:14 2011 +0100
    13.3 @@ -0,0 +1,181 @@
    13.4 +%!PS-Adobe-2.0 EPSF-2.0
    13.5 +%%Creator: LEMON, graphToEps()
    13.6 +%%CreationDate: Fri Oct 19 18:32:32 2007
    13.7 +%%BoundingBox: 0 0 596 842
    13.8 +%%DocumentPaperSizes: a4
    13.9 +%%EndComments
   13.10 +/lb { setlinewidth setrgbcolor newpath moveto
   13.11 +      4 2 roll 1 index 1 index curveto stroke } bind def
   13.12 +/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def
   13.13 +/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def
   13.14 +/sq { newpath 2 index 1 index add 2 index 2 index add moveto
   13.15 +      2 index 1 index sub 2 index 2 index add lineto
   13.16 +      2 index 1 index sub 2 index 2 index sub lineto
   13.17 +      2 index 1 index add 2 index 2 index sub lineto
   13.18 +      closepath pop pop pop} bind def
   13.19 +/di { newpath 2 index 1 index add 2 index moveto
   13.20 +      2 index             2 index 2 index add lineto
   13.21 +      2 index 1 index sub 2 index             lineto
   13.22 +      2 index             2 index 2 index sub lineto
   13.23 +      closepath pop pop pop} bind def
   13.24 +/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill
   13.25 +     setrgbcolor 1.1 div c fill
   13.26 +   } bind def
   13.27 +/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill
   13.28 +     setrgbcolor 1.1 div sq fill
   13.29 +   } bind def
   13.30 +/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill
   13.31 +     setrgbcolor 1.1 div di fill
   13.32 +   } bind def
   13.33 +/nfemale { 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   13.34 +  newpath 5 index 5 index moveto 5 index 5 index 5 index 3.01 mul sub
   13.35 +  lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto
   13.36 +  5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke
   13.37 +  5 index 5 index 5 index c fill
   13.38 +  setrgbcolor 1.1 div c fill
   13.39 +  } bind def
   13.40 +/nmale {
   13.41 +  0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
   13.42 +  newpath 5 index 5 index moveto
   13.43 +  5 index 4 index 1 mul 1.5 mul add
   13.44 +  5 index 5 index 3 sqrt 1.5 mul mul add
   13.45 +  1 index 1 index lineto
   13.46 +  1 index 1 index 7 index sub moveto
   13.47 +  1 index 1 index lineto
   13.48 +  exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto
   13.49 +  stroke
   13.50 +  5 index 5 index 5 index c fill
   13.51 +  setrgbcolor 1.1 div c fill
   13.52 +  } bind def
   13.53 +/arrl 1 def
   13.54 +/arrw 0.3 def
   13.55 +/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def
   13.56 +/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def
   13.57 +       /w exch def /len exch def
   13.58 +       newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto
   13.59 +       len w sub arrl sub dx dy lrl
   13.60 +       arrw dy dx neg lrl
   13.61 +       dx arrl w add mul dy w 2 div arrw add mul sub
   13.62 +       dy arrl w add mul dx w 2 div arrw add mul add rlineto
   13.63 +       dx arrl w add mul neg dy w 2 div arrw add mul sub
   13.64 +       dy arrl w add mul neg dx w 2 div arrw add mul add rlineto
   13.65 +       arrw dy dx neg lrl
   13.66 +       len w sub arrl sub neg dx dy lrl
   13.67 +       closepath fill } bind def
   13.68 +/cshow { 2 index 2 index moveto dup stringwidth pop
   13.69 +         neg 2 div fosi .35 mul neg rmoveto show pop pop} def
   13.70 +
   13.71 +gsave
   13.72 +15 138.307 translate
   13.73 +12.7843 dup scale
   13.74 +90 rotate
   13.75 +0.608112 -43.6081 translate
   13.76 +%Edges:
   13.77 +gsave
   13.78 +9 31 9.5 30.5 10 30 0 0 0 0.091217 lb
   13.79 +9 31 5.5 34.5 2 38 0 0 0 0.091217 lb
   13.80 +9 31 25.5 16 42 1 0 0 0 0.091217 lb
   13.81 +3 40 23 20.5 43 1 0 0 0 0.091217 lb
   13.82 +3 40 22.5 20.5 42 1 0 0 0 0.091217 lb
   13.83 +3 40 2.5 40.5 2 41 0 0 0 0.091217 lb
   13.84 +13 25 10.5 24.5 8 24 0 0 0 0.091217 lb
   13.85 +13 25 12 27 11 29 0 0 0 0.091217 lb
   13.86 +3 4 2.5 3 2 2 0 0 0 0.091217 lb
   13.87 +3 4 4.5 3 6 2 0 0 0 0.091217 lb
   13.88 +6 25 7 24.5 8 24 0 0 0 0.091217 lb
   13.89 +6 25 6 24.5 6 24 0 0 0 0.091217 lb
   13.90 +34 2 33.5 2 33 2 0 0 0 0.091217 lb
   13.91 +34 2 35 2 36 2 0 0 0 0.091217 lb
   13.92 +6 8 16 9 26 10 0 0 0 0.091217 lb
   13.93 +6 8 6 10.5 6 13 0 0 0 0.091217 lb
   13.94 +6 8 6 7.5 6 7 0 0 0 0.091217 lb
   13.95 +26 10 27.5 8.5 29 7 0 0 0 0.091217 lb
   13.96 +26 10 27.5 9 29 8 0 0 0 0.091217 lb
   13.97 +10 30 10.5 29.5 11 29 0 0 0 0.091217 lb
   13.98 +8 24 7 23.5 6 23 0 0 0 0.091217 lb
   13.99 +8 24 8 24.5 8 25 0 0 0 0.091217 lb
  13.100 +33 2 32.5 2 32 2 0 0 0 0.091217 lb
  13.101 +29 7 17.5 7 6 7 0 0 0 0.091217 lb
  13.102 +2 2 1.5 22 1 42 0 0 0 0.091217 lb
  13.103 +2 2 3.5 2 5 2 0 0 0 0.091217 lb
  13.104 +21 15 13.5 14.5 6 14 0 0 0 0.091217 lb
  13.105 +21 15 21 15.5 21 16 0 0 0 0.091217 lb
  13.106 +1 42 0.5 42.5 0 43 0 0 0 0.091217 lb
  13.107 +1 42 1.5 41.5 2 41 0 0 0 0.091217 lb
  13.108 +6 15 6 15.5 6 16 0 0 0 0.091217 lb
  13.109 +6 15 6 14.5 6 14 0 0 0 0.091217 lb
  13.110 +43 1 22 0.5 1 0 0 0 0 0.091217 lb
  13.111 +31 2 18.5 2 6 2 0 0 0 0.091217 lb
  13.112 +31 2 31.5 2 32 2 0 0 0 0.091217 lb
  13.113 +6 24 6 23.5 6 23 0 0 0 0.091217 lb
  13.114 +6 16 6 16.5 6 17 0 0 0 0.091217 lb
  13.115 +6 23 6 20 6 17 0 0 0 0.091217 lb
  13.116 +6 2 5.5 2 5 2 0 0 0 0.091217 lb
  13.117 +6 2 6 4.5 6 7 0 0 0 0.091217 lb
  13.118 +0 43 0.5 21.5 1 0 0 0 0 0.091217 lb
  13.119 +1 1 19.5 1.5 38 2 0 0 0 0.091217 lb
  13.120 +1 1 1 0.5 1 0 0 0 0 0.091217 lb
  13.121 +2 38 5.5 31.5 9 25 0 0 0 0.091217 lb
  13.122 +25 13 15.5 13 6 13 0 0 0 0.091217 lb
  13.123 +25 13 15.5 13.5 6 14 0 0 0 0.091217 lb
  13.124 +8 25 8.5 25 9 25 0 0 0 0.091217 lb
  13.125 +11 29 24.5 15.5 38 2 0 0 0 0.091217 lb
  13.126 +6 17 11.5 18 17 19 0 0 0 0.091217 lb
  13.127 +16 23 26.5 12.5 37 2 0 0 0 0.091217 lb
  13.128 +16 23 18.5 19.5 21 16 0 0 0 0.091217 lb
  13.129 +36 2 36.5 2 37 2 0 0 0 0.091217 lb
  13.130 +36 2 32.5 5 29 8 0 0 0 0.091217 lb
  13.131 +6 13 6 13.5 6 14 0 0 0 0.091217 lb
  13.132 +37 2 37.5 2 38 2 0 0 0 0.091217 lb
  13.133 +21 16 19 17.5 17 19 0 0 0 0.091217 lb
  13.134 +grestore
  13.135 +%Nodes:
  13.136 +gsave
  13.137 +29 8 0.304556 1 1 1 nc
  13.138 +2 41 0.304556 1 1 1 nc
  13.139 +6 7 0.304556 1 1 1 nc
  13.140 +5 2 0.304556 1 1 1 nc
  13.141 +17 19 0.304556 1 1 1 nc
  13.142 +21 16 0.304556 1 1 1 nc
  13.143 +1 0 0.304556 1 1 1 nc
  13.144 +9 25 0.304556 1 1 1 nc
  13.145 +6 14 0.304556 1 1 1 nc
  13.146 +42 1 0.304556 1 1 1 nc
  13.147 +38 2 0.304556 1 1 1 nc
  13.148 +37 2 0.304556 1 1 1 nc
  13.149 +6 13 0.304556 1 1 1 nc
  13.150 +36 2 0.304556 1 1 1 nc
  13.151 +16 23 0.304556 1 1 1 nc
  13.152 +6 17 0.304556 1 1 1 nc
  13.153 +11 29 0.304556 1 1 1 nc
  13.154 +8 25 0.304556 1 1 1 nc
  13.155 +32 2 0.304556 1 1 1 nc
  13.156 +25 13 0.304556 1 1 1 nc
  13.157 +2 38 0.304556 1 1 1 nc
  13.158 +1 1 0.304556 1 1 1 nc
  13.159 +0 43 0.304556 1 1 1 nc
  13.160 +6 2 0.304556 1 1 1 nc
  13.161 +6 23 0.304556 1 1 1 nc
  13.162 +6 16 0.304556 1 1 1 nc
  13.163 +6 24 0.304556 1 1 1 nc
  13.164 +31 2 0.304556 1 1 1 nc
  13.165 +43 1 0.304556 1 1 1 nc
  13.166 +6 15 0.304556 1 1 1 nc
  13.167 +1 42 0.304556 1 1 1 nc
  13.168 +21 15 0.304556 1 1 1 nc
  13.169 +2 2 0.304556 1 1 1 nc
  13.170 +29 7 0.304556 1 1 1 nc
  13.171 +33 2 0.304556 1 1 1 nc
  13.172 +8 24 0.304556 1 1 1 nc
  13.173 +10 30 0.304556 1 1 1 nc
  13.174 +26 10 0.304556 1 1 1 nc
  13.175 +6 8 0.304556 1 1 1 nc
  13.176 +34 2 0.304556 1 1 1 nc
  13.177 +6 25 0.304556 1 1 1 nc
  13.178 +3 4 0.304556 1 1 1 nc
  13.179 +13 25 0.304556 1 1 1 nc
  13.180 +3 40 0.304556 1 1 1 nc
  13.181 +9 31 0.304556 1 1 1 nc
  13.182 +grestore
  13.183 +grestore
  13.184 +showpage
    14.1 --- a/doc/mainpage.dox.in	Tue Dec 20 17:44:38 2011 +0100
    14.2 +++ b/doc/mainpage.dox.in	Tue Dec 20 18:15:14 2011 +0100
    14.3 @@ -2,7 +2,7 @@
    14.4   *
    14.5   * This file is a part of LEMON, a generic C++ optimization library.
    14.6   *
    14.7 - * Copyright (C) 2003-2009
    14.8 + * Copyright (C) 2003-2010
    14.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   14.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   14.11   *
   14.12 @@ -21,14 +21,11 @@
   14.13  
   14.14  \section intro Introduction
   14.15  
   14.16 -\subsection whatis What is LEMON
   14.17 -
   14.18 -LEMON stands for <b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
   14.19 -and <b>O</b>ptimization in <b>N</b>etworks.
   14.20 -It is a C++ template
   14.21 -library aimed at combinatorial optimization tasks which
   14.22 -often involve in working
   14.23 -with graphs.
   14.24 +<b>LEMON</b> stands for <i><b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
   14.25 +and <b>O</b>ptimization in <b>N</b>etworks</i>.
   14.26 +It is a C++ template library providing efficient implementations of common
   14.27 +data structures and algorithms with focus on combinatorial optimization
   14.28 +tasks connected mainly with graphs and networks.
   14.29  
   14.30  <b>
   14.31  LEMON is an <a class="el" href="http://opensource.org/">open&nbsp;source</a>
   14.32 @@ -38,11 +35,24 @@
   14.33  \ref license "license terms".
   14.34  </b>
   14.35  
   14.36 -\subsection howtoread How to read the documentation
   14.37 +The project is maintained by the
   14.38 +<a href="http://www.cs.elte.hu/egres/">Egerv&aacute;ry Research Group on
   14.39 +Combinatorial Optimization</a> \ref egres
   14.40 +at the Operations Research Department of the
   14.41 +<a href="http://www.elte.hu/en/">E&ouml;tv&ouml;s Lor&aacute;nd University</a>,
   14.42 +Budapest, Hungary.
   14.43 +LEMON is also a member of the <a href="http://www.coin-or.org/">COIN-OR</a>
   14.44 +initiative \ref coinor.
   14.45 +
   14.46 +\section howtoread How to Read the Documentation
   14.47  
   14.48  If you would like to get to know the library, see
   14.49  <a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>.
   14.50  
   14.51 +If you are interested in starting to use the library, see the <a class="el"
   14.52 +href="http://lemon.cs.elte.hu/trac/lemon/wiki/InstallGuide/">Installation
   14.53 +Guide</a>.
   14.54 +
   14.55  If you know what you are looking for, then try to find it under the
   14.56  <a class="el" href="modules.html">Modules</a> section.
   14.57  
    15.1 --- a/doc/min_cost_flow.dox	Tue Dec 20 17:44:38 2011 +0100
    15.2 +++ b/doc/min_cost_flow.dox	Tue Dec 20 18:15:14 2011 +0100
    15.3 @@ -2,7 +2,7 @@
    15.4   *
    15.5   * This file is a part of LEMON, a generic C++ optimization library.
    15.6   *
    15.7 - * Copyright (C) 2003-2009
    15.8 + * Copyright (C) 2003-2010
    15.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   15.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   15.11   *
   15.12 @@ -26,7 +26,7 @@
   15.13  The \e minimum \e cost \e flow \e problem is to find a feasible flow of
   15.14  minimum total cost from a set of supply nodes to a set of demand nodes
   15.15  in a network with capacity constraints (lower and upper bounds)
   15.16 -and arc costs.
   15.17 +and arc costs \ref amo93networkflows.
   15.18  
   15.19  Formally, let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$,
   15.20  \f$upper: A\rightarrow\mathbf{R}\cup\{+\infty\}\f$ denote the lower and
   15.21 @@ -78,10 +78,10 @@
   15.22     - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$;
   15.23     - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$.
   15.24   - For all \f$u\in V\f$ nodes:
   15.25 -   - \f$\pi(u)<=0\f$;
   15.26 +   - \f$\pi(u)\leq 0\f$;
   15.27     - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$,
   15.28       then \f$\pi(u)=0\f$.
   15.29 - 
   15.30 +
   15.31  Here \f$cost^\pi(uv)\f$ denotes the \e reduced \e cost of the arc
   15.32  \f$uv\in A\f$ with respect to the potential function \f$\pi\f$, i.e.
   15.33  \f[ cost^\pi(uv) = cost(uv) + \pi(u) - \pi(v).\f]
   15.34 @@ -119,7 +119,7 @@
   15.35      sup(u) \quad \forall u\in V \f]
   15.36  \f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f]
   15.37  
   15.38 -It means that the total demand must be less or equal to the 
   15.39 +It means that the total demand must be less or equal to the
   15.40  total supply (i.e. \f$\sum_{u\in V} sup(u)\f$ must be zero or
   15.41  positive) and all the demands have to be satisfied, but there
   15.42  could be supplies that are not carried out from the supply
   15.43 @@ -145,7 +145,7 @@
   15.44     - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$;
   15.45     - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$.
   15.46   - For all \f$u\in V\f$ nodes:
   15.47 -   - \f$\pi(u)>=0\f$;
   15.48 +   - \f$\pi(u)\geq 0\f$;
   15.49     - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$,
   15.50       then \f$\pi(u)=0\f$.
   15.51  
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/doc/references.bib	Tue Dec 20 18:15:14 2011 +0100
    16.3 @@ -0,0 +1,301 @@
    16.4 +%%%%% Defining LEMON %%%%%
    16.5 +
    16.6 +@misc{lemon,
    16.7 +  key =          {LEMON},
    16.8 +  title =        {{LEMON} -- {L}ibrary for {E}fficient {M}odeling and
    16.9 +                  {O}ptimization in {N}etworks},
   16.10 +  howpublished = {\url{http://lemon.cs.elte.hu/}},
   16.11 +  year =         2009
   16.12 +}
   16.13 +
   16.14 +@misc{egres,
   16.15 +  key =          {EGRES},
   16.16 +  title =        {{EGRES} -- {E}gerv{\'a}ry {R}esearch {G}roup on
   16.17 +                  {C}ombinatorial {O}ptimization},
   16.18 +  url =          {http://www.cs.elte.hu/egres/}
   16.19 +}
   16.20 +
   16.21 +@misc{coinor,
   16.22 +  key =          {COIN-OR},
   16.23 +  title =        {{COIN-OR} -- {C}omputational {I}nfrastructure for
   16.24 +                  {O}perations {R}esearch},
   16.25 +  url =          {http://www.coin-or.org/}
   16.26 +}
   16.27 +
   16.28 +
   16.29 +%%%%% Other libraries %%%%%%
   16.30 +
   16.31 +@misc{boost,
   16.32 +  key =          {Boost},
   16.33 +  title =        {{B}oost {C++} {L}ibraries},
   16.34 +  url =          {http://www.boost.org/}
   16.35 +}
   16.36 +
   16.37 +@book{bglbook,
   16.38 +  author =       {Jeremy G. Siek and Lee-Quan Lee and Andrew
   16.39 +                  Lumsdaine},
   16.40 +  title =        {The Boost Graph Library: User Guide and Reference
   16.41 +                  Manual},
   16.42 +  publisher =    {Addison-Wesley},
   16.43 +  year =         2002
   16.44 +}
   16.45 +
   16.46 +@misc{leda,
   16.47 +  key =          {LEDA},
   16.48 +  title =        {{LEDA} -- {L}ibrary of {E}fficient {D}ata {T}ypes and
   16.49 +                  {A}lgorithms},
   16.50 +  url =          {http://www.algorithmic-solutions.com/}
   16.51 +}
   16.52 +
   16.53 +@book{ledabook,
   16.54 +  author =       {Kurt Mehlhorn and Stefan N{\"a}her},
   16.55 +  title =        {{LEDA}: {A} platform for combinatorial and geometric
   16.56 +                  computing},
   16.57 +  isbn =         {0-521-56329-1},
   16.58 +  publisher =    {Cambridge University Press},
   16.59 +  address =      {New York, NY, USA},
   16.60 +  year =         1999
   16.61 +}
   16.62 +
   16.63 +
   16.64 +%%%%% Tools that LEMON depends on %%%%%
   16.65 +
   16.66 +@misc{cmake,
   16.67 +  key =          {CMake},
   16.68 +  title =        {{CMake} -- {C}ross {P}latform {M}ake},
   16.69 +  url =          {http://www.cmake.org/}
   16.70 +}
   16.71 +
   16.72 +@misc{doxygen,
   16.73 +  key =          {Doxygen},
   16.74 +  title =        {{Doxygen} -- {S}ource code documentation generator
   16.75 +                  tool},
   16.76 +  url =          {http://www.doxygen.org/}
   16.77 +}
   16.78 +
   16.79 +
   16.80 +%%%%% LP/MIP libraries %%%%%
   16.81 +
   16.82 +@misc{glpk,
   16.83 +  key =          {GLPK},
   16.84 +  title =        {{GLPK} -- {GNU} {L}inear {P}rogramming {K}it},
   16.85 +  url =          {http://www.gnu.org/software/glpk/}
   16.86 +}
   16.87 +
   16.88 +@misc{clp,
   16.89 +  key =          {Clp},
   16.90 +  title =        {{Clp} -- {Coin-Or} {L}inear {P}rogramming},
   16.91 +  url =          {http://projects.coin-or.org/Clp/}
   16.92 +}
   16.93 +
   16.94 +@misc{cbc,
   16.95 +  key =          {Cbc},
   16.96 +  title =        {{Cbc} -- {Coin-Or} {B}ranch and {C}ut},
   16.97 +  url =          {http://projects.coin-or.org/Cbc/}
   16.98 +}
   16.99 +
  16.100 +@misc{cplex,
  16.101 +  key =          {CPLEX},
  16.102 +  title =        {{ILOG} {CPLEX}},
  16.103 +  url =          {http://www.ilog.com/}
  16.104 +}
  16.105 +
  16.106 +@misc{soplex,
  16.107 +  key =          {SoPlex},
  16.108 +  title =        {{SoPlex} -- {T}he {S}equential {O}bject-{O}riented
  16.109 +                  {S}implex},
  16.110 +  url =          {http://soplex.zib.de/}
  16.111 +}
  16.112 +
  16.113 +
  16.114 +%%%%% General books %%%%%
  16.115 +
  16.116 +@book{amo93networkflows,
  16.117 +  author =       {Ravindra K. Ahuja and Thomas L. Magnanti and James
  16.118 +                  B. Orlin},
  16.119 +  title =        {Network Flows: Theory, Algorithms, and Applications},
  16.120 +  publisher =    {Prentice-Hall, Inc.},
  16.121 +  year =         1993,
  16.122 +  month =        feb,
  16.123 +  isbn =         {978-0136175490}
  16.124 +}
  16.125 +
  16.126 +@book{schrijver03combinatorial,
  16.127 +  author =       {Alexander Schrijver},
  16.128 +  title =        {Combinatorial Optimization: Polyhedra and Efficiency},
  16.129 +  publisher =    {Springer-Verlag},
  16.130 +  year =         2003,
  16.131 +  isbn =         {978-3540443896}
  16.132 +}
  16.133 +
  16.134 +@book{clrs01algorithms,
  16.135 +  author =       {Thomas H. Cormen and Charles E. Leiserson and Ronald
  16.136 +                  L. Rivest and Clifford Stein},
  16.137 +  title =        {Introduction to Algorithms},
  16.138 +  publisher =    {The MIT Press},
  16.139 +  year =         2001,
  16.140 +  edition =      {2nd}
  16.141 +}
  16.142 +
  16.143 +@book{stroustrup00cpp,
  16.144 +  author =       {Bjarne Stroustrup},
  16.145 +  title =        {The C++ Programming Language},
  16.146 +  edition =      {3rd},
  16.147 +  publisher =    {Addison-Wesley Professional},
  16.148 +  isbn =         0201700735,
  16.149 +  month =        {February},
  16.150 +  year =         2000
  16.151 +}
  16.152 +
  16.153 +
  16.154 +%%%%% Maximum flow algorithms %%%%%
  16.155 +
  16.156 +@article{edmondskarp72theoretical,
  16.157 +  author =       {Jack Edmonds and Richard M. Karp},
  16.158 +  title =        {Theoretical improvements in algorithmic efficiency
  16.159 +                  for network flow problems},
  16.160 +  journal =      {Journal of the ACM},
  16.161 +  year =         1972,
  16.162 +  volume =       19,
  16.163 +  number =       2,
  16.164 +  pages =        {248-264}
  16.165 +}
  16.166 +
  16.167 +@article{goldberg88newapproach,
  16.168 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  16.169 +  title =        {A new approach to the maximum flow problem},
  16.170 +  journal =      {Journal of the ACM},
  16.171 +  year =         1988,
  16.172 +  volume =       35,
  16.173 +  number =       4,
  16.174 +  pages =        {921-940}
  16.175 +}
  16.176 +
  16.177 +@article{dinic70algorithm,
  16.178 +  author =       {E. A. Dinic},
  16.179 +  title =        {Algorithm for solution of a problem of maximum flow
  16.180 +                  in a network with power estimation},
  16.181 +  journal =      {Soviet Math. Doklady},
  16.182 +  year =         1970,
  16.183 +  volume =       11,
  16.184 +  pages =        {1277-1280}
  16.185 +}
  16.186 +
  16.187 +@article{goldberg08partial,
  16.188 +  author =       {Andrew V. Goldberg},
  16.189 +  title =        {The Partial Augment-Relabel Algorithm for the
  16.190 +                  Maximum Flow Problem},
  16.191 +  journal =      {16th Annual European Symposium on Algorithms},
  16.192 +  year =         2008,
  16.193 +  pages =        {466-477}
  16.194 +}
  16.195 +
  16.196 +@article{sleator83dynamic,
  16.197 +  author =       {Daniel D. Sleator and Robert E. Tarjan},
  16.198 +  title =        {A data structure for dynamic trees},
  16.199 +  journal =      {Journal of Computer and System Sciences},
  16.200 +  year =         1983,
  16.201 +  volume =       26,
  16.202 +  number =       3,
  16.203 +  pages =        {362-391}
  16.204 +}
  16.205 +
  16.206 +
  16.207 +%%%%% Minimum mean cycle algorithms %%%%%
  16.208 +
  16.209 +@article{karp78characterization,
  16.210 +  author =       {Richard M. Karp},
  16.211 +  title =        {A characterization of the minimum cycle mean in a
  16.212 +                  digraph},
  16.213 +  journal =      {Discrete Math.},
  16.214 +  year =         1978,
  16.215 +  volume =       23,
  16.216 +  pages =        {309-311}
  16.217 +}
  16.218 +
  16.219 +@article{dasdan98minmeancycle,
  16.220 +  author =       {Ali Dasdan and Rajesh K. Gupta},
  16.221 +  title =        {Faster Maximum and Minimum Mean Cycle Alogrithms for
  16.222 +                  System Performance Analysis},
  16.223 +  journal =      {IEEE Transactions on Computer-Aided Design of
  16.224 +                  Integrated Circuits and Systems},
  16.225 +  year =         1998,
  16.226 +  volume =       17,
  16.227 +  number =       10,
  16.228 +  pages =        {889-899}
  16.229 +}
  16.230 +
  16.231 +
  16.232 +%%%%% Minimum cost flow algorithms %%%%%
  16.233 +
  16.234 +@article{klein67primal,
  16.235 +  author =       {Morton Klein},
  16.236 +  title =        {A primal method for minimal cost flows with
  16.237 +                  applications to the assignment and transportation
  16.238 +                  problems},
  16.239 +  journal =      {Management Science},
  16.240 +  year =         1967,
  16.241 +  volume =       14,
  16.242 +  pages =        {205-220}
  16.243 +}
  16.244 +
  16.245 +@article{goldberg89cyclecanceling,
  16.246 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  16.247 +  title =        {Finding minimum-cost circulations by canceling
  16.248 +                  negative cycles},
  16.249 +  journal =      {Journal of the ACM},
  16.250 +  year =         1989,
  16.251 +  volume =       36,
  16.252 +  number =       4,
  16.253 +  pages =        {873-886}
  16.254 +}
  16.255 +
  16.256 +@article{goldberg90approximation,
  16.257 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  16.258 +  title =        {Finding Minimum-Cost Circulations by Successive
  16.259 +                  Approximation},
  16.260 +  journal =      {Mathematics of Operations Research},
  16.261 +  year =         1990,
  16.262 +  volume =       15,
  16.263 +  number =       3,
  16.264 +  pages =        {430-466}
  16.265 +}
  16.266 +
  16.267 +@article{goldberg97efficient,
  16.268 +  author =       {Andrew V. Goldberg},
  16.269 +  title =        {An Efficient Implementation of a Scaling
  16.270 +                  Minimum-Cost Flow Algorithm},
  16.271 +  journal =      {Journal of Algorithms},
  16.272 +  year =         1997,
  16.273 +  volume =       22,
  16.274 +  number =       1,
  16.275 +  pages =        {1-29}
  16.276 +}
  16.277 +
  16.278 +@article{bunnagel98efficient,
  16.279 +  author =       {Ursula B{\"u}nnagel and Bernhard Korte and Jens
  16.280 +                  Vygen},
  16.281 +  title =        {Efficient implementation of the {G}oldberg-{T}arjan
  16.282 +                  minimum-cost flow algorithm},
  16.283 +  journal =      {Optimization Methods and Software},
  16.284 +  year =         1998,
  16.285 +  volume =       10,
  16.286 +  pages =        {157-174}
  16.287 +}
  16.288 +
  16.289 +@book{dantzig63linearprog,
  16.290 +  author =       {George B. Dantzig},
  16.291 +  title =        {Linear Programming and Extensions},
  16.292 +  publisher =    {Princeton University Press},
  16.293 +  year =         1963
  16.294 +}
  16.295 +
  16.296 +@mastersthesis{kellyoneill91netsimplex,
  16.297 +  author =       {Damian J. Kelly and Garrett M. O'Neill},
  16.298 +  title =        {The Minimum Cost Flow Problem and The Network
  16.299 +                  Simplex Method},
  16.300 +  school =       {University College},
  16.301 +  address =      {Dublin, Ireland},
  16.302 +  year =         1991,
  16.303 +  month =        sep,
  16.304 +}
    17.1 --- a/lemon/Makefile.am	Tue Dec 20 17:44:38 2011 +0100
    17.2 +++ b/lemon/Makefile.am	Tue Dec 20 18:15:14 2011 +0100
    17.3 @@ -58,19 +58,25 @@
    17.4  	lemon/adaptors.h \
    17.5  	lemon/arg_parser.h \
    17.6  	lemon/assert.h \
    17.7 +	lemon/bellman_ford.h \
    17.8  	lemon/bfs.h \
    17.9  	lemon/bin_heap.h \
   17.10 +	lemon/binomial_heap.h \
   17.11  	lemon/bucket_heap.h \
   17.12 +	lemon/capacity_scaling.h \
   17.13  	lemon/cbc.h \
   17.14  	lemon/circulation.h \
   17.15  	lemon/clp.h \
   17.16  	lemon/color.h \
   17.17  	lemon/concept_check.h \
   17.18  	lemon/connectivity.h \
   17.19 +	lemon/core.h \
   17.20 +	lemon/cost_scaling.h \
   17.21  	lemon/counter.h \
   17.22 -	lemon/core.h \
   17.23  	lemon/cplex.h \
   17.24 +	lemon/cycle_canceling.h \
   17.25  	lemon/dfs.h \
   17.26 +	lemon/dheap.h \
   17.27  	lemon/dijkstra.h \
   17.28  	lemon/dim2.h \
   17.29  	lemon/dimacs.h \
   17.30 @@ -79,12 +85,16 @@
   17.31  	lemon/error.h \
   17.32  	lemon/euler.h \
   17.33  	lemon/fib_heap.h \
   17.34 +	lemon/fractional_matching.h \
   17.35  	lemon/full_graph.h \
   17.36  	lemon/glpk.h \
   17.37  	lemon/gomory_hu.h \
   17.38  	lemon/graph_to_eps.h \
   17.39  	lemon/grid_graph.h \
   17.40 +	lemon/hartmann_orlin_mmc.h \
   17.41 +	lemon/howard_mmc.h \
   17.42  	lemon/hypercube_graph.h \
   17.43 +	lemon/karp_mmc.h \
   17.44  	lemon/kruskal.h \
   17.45  	lemon/hao_orlin.h \
   17.46  	lemon/lgf_reader.h \
   17.47 @@ -99,13 +109,17 @@
   17.48  	lemon/min_cost_arborescence.h \
   17.49  	lemon/nauty_reader.h \
   17.50  	lemon/network_simplex.h \
   17.51 +	lemon/pairing_heap.h \
   17.52  	lemon/path.h \
   17.53 +	lemon/planarity.h \
   17.54  	lemon/preflow.h \
   17.55 +	lemon/quad_heap.h \
   17.56  	lemon/radix_heap.h \
   17.57  	lemon/radix_sort.h \
   17.58  	lemon/random.h \
   17.59  	lemon/smart_graph.h \
   17.60  	lemon/soplex.h \
   17.61 +	lemon/static_graph.h \
   17.62  	lemon/suurballe.h \
   17.63  	lemon/time_measure.h \
   17.64  	lemon/tolerance.h \
    18.1 --- a/lemon/adaptors.h	Tue Dec 20 17:44:38 2011 +0100
    18.2 +++ b/lemon/adaptors.h	Tue Dec 20 18:15:14 2011 +0100
    18.3 @@ -2,7 +2,7 @@
    18.4   *
    18.5   * This file is a part of LEMON, a generic C++ optimization library.
    18.6   *
    18.7 - * Copyright (C) 2003-2009
    18.8 + * Copyright (C) 2003-2010
    18.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   18.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   18.11   *
   18.12 @@ -360,6 +360,9 @@
   18.13    /// by adding or removing nodes or arcs, unless the \c GR template
   18.14    /// parameter is set to be \c const.
   18.15    ///
   18.16 +  /// This class provides item counting in the same time as the adapted
   18.17 +  /// digraph structure.
   18.18 +  ///
   18.19    /// \tparam DGR The type of the adapted digraph.
   18.20    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
   18.21    /// It can also be specified to be \c const.
   18.22 @@ -418,7 +421,7 @@
   18.23      void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
   18.24        Parent::initialize(digraph);
   18.25        _node_filter = &node_filter;
   18.26 -      _arc_filter = &arc_filter;      
   18.27 +      _arc_filter = &arc_filter;
   18.28      }
   18.29  
   18.30    public:
   18.31 @@ -505,11 +508,11 @@
   18.32    public:
   18.33  
   18.34      template <typename V>
   18.35 -    class NodeMap 
   18.36 -      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 
   18.37 -	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
   18.38 +    class NodeMap
   18.39 +      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   18.40 +              LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
   18.41        typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   18.42 -	LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
   18.43 +        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
   18.44  
   18.45      public:
   18.46        typedef V Value;
   18.47 @@ -532,9 +535,9 @@
   18.48      };
   18.49  
   18.50      template <typename V>
   18.51 -    class ArcMap 
   18.52 +    class ArcMap
   18.53        : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   18.54 -	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
   18.55 +              LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
   18.56        typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
   18.57          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
   18.58  
   18.59 @@ -579,7 +582,7 @@
   18.60      void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
   18.61        Parent::initialize(digraph);
   18.62        _node_filter = &node_filter;
   18.63 -      _arc_filter = &arc_filter;      
   18.64 +      _arc_filter = &arc_filter;
   18.65      }
   18.66  
   18.67    public:
   18.68 @@ -648,10 +651,10 @@
   18.69      }
   18.70  
   18.71      template <typename V>
   18.72 -    class NodeMap 
   18.73 +    class NodeMap
   18.74        : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   18.75            LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
   18.76 -      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 
   18.77 +      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   18.78          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
   18.79  
   18.80      public:
   18.81 @@ -675,7 +678,7 @@
   18.82      };
   18.83  
   18.84      template <typename V>
   18.85 -    class ArcMap 
   18.86 +    class ArcMap
   18.87        : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   18.88            LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
   18.89        typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
   18.90 @@ -719,6 +722,8 @@
   18.91    /// by adding or removing nodes or arcs, unless the \c GR template
   18.92    /// parameter is set to be \c const.
   18.93    ///
   18.94 +  /// This class provides only linear time counting for nodes and arcs.
   18.95 +  ///
   18.96    /// \tparam DGR The type of the adapted digraph.
   18.97    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
   18.98    /// It can also be specified to be \c const.
   18.99 @@ -1016,10 +1021,10 @@
  18.100      }
  18.101  
  18.102      template <typename V>
  18.103 -    class NodeMap 
  18.104 +    class NodeMap
  18.105        : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  18.106            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
  18.107 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
  18.108 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  18.109          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
  18.110  
  18.111      public:
  18.112 @@ -1043,10 +1048,10 @@
  18.113      };
  18.114  
  18.115      template <typename V>
  18.116 -    class ArcMap 
  18.117 +    class ArcMap
  18.118        : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  18.119            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
  18.120 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
  18.121 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  18.122          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
  18.123  
  18.124      public:
  18.125 @@ -1070,10 +1075,10 @@
  18.126      };
  18.127  
  18.128      template <typename V>
  18.129 -    class EdgeMap 
  18.130 +    class EdgeMap
  18.131        : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  18.132          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
  18.133 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
  18.134 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
  18.135          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
  18.136  
  18.137      public:
  18.138 @@ -1112,8 +1117,8 @@
  18.139    protected:
  18.140      NF* _node_filter;
  18.141      EF* _edge_filter;
  18.142 -    SubGraphBase() 
  18.143 -	  : Parent(), _node_filter(0), _edge_filter(0) { }
  18.144 +    SubGraphBase()
  18.145 +          : Parent(), _node_filter(0), _edge_filter(0) { }
  18.146  
  18.147      void initialize(GR& graph, NF& node_filter, EF& edge_filter) {
  18.148        Parent::initialize(graph);
  18.149 @@ -1214,10 +1219,10 @@
  18.150      }
  18.151  
  18.152      template <typename V>
  18.153 -    class NodeMap 
  18.154 +    class NodeMap
  18.155        : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  18.156            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
  18.157 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
  18.158 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  18.159          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
  18.160  
  18.161      public:
  18.162 @@ -1241,10 +1246,10 @@
  18.163      };
  18.164  
  18.165      template <typename V>
  18.166 -    class ArcMap 
  18.167 +    class ArcMap
  18.168        : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  18.169            LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
  18.170 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
  18.171 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  18.172          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
  18.173  
  18.174      public:
  18.175 @@ -1268,11 +1273,11 @@
  18.176      };
  18.177  
  18.178      template <typename V>
  18.179 -    class EdgeMap 
  18.180 +    class EdgeMap
  18.181        : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  18.182          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
  18.183 -      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
  18.184 -	LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
  18.185 +      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
  18.186 +        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
  18.187  
  18.188      public:
  18.189        typedef V Value;
  18.190 @@ -1314,6 +1319,8 @@
  18.191    /// by adding or removing nodes or edges, unless the \c GR template
  18.192    /// parameter is set to be \c const.
  18.193    ///
  18.194 +  /// This class provides only linear time counting for nodes, edges and arcs.
  18.195 +  ///
  18.196    /// \tparam GR The type of the adapted graph.
  18.197    /// It must conform to the \ref concepts::Graph "Graph" concept.
  18.198    /// It can also be specified to be \c const.
  18.199 @@ -1471,6 +1478,8 @@
  18.200    /// by adding or removing nodes or arcs/edges, unless the \c GR template
  18.201    /// parameter is set to be \c const.
  18.202    ///
  18.203 +  /// This class provides only linear time item counting.
  18.204 +  ///
  18.205    /// \tparam GR The type of the adapted digraph or graph.
  18.206    /// It must conform to the \ref concepts::Digraph "Digraph" concept
  18.207    /// or the \ref concepts::Graph "Graph" concept.
  18.208 @@ -1495,7 +1504,7 @@
  18.209                       true> > {
  18.210  #endif
  18.211      typedef DigraphAdaptorExtender<
  18.212 -      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 
  18.213 +      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >,
  18.214                       true> > Parent;
  18.215  
  18.216    public:
  18.217 @@ -1516,7 +1525,7 @@
  18.218      ///
  18.219      /// Creates a subgraph for the given digraph or graph with the
  18.220      /// given node filter map.
  18.221 -    FilterNodes(GR& graph, NF& node_filter) 
  18.222 +    FilterNodes(GR& graph, NF& node_filter)
  18.223        : Parent(), const_true_map()
  18.224      {
  18.225        Parent::initialize(graph, node_filter, const_true_map);
  18.226 @@ -1554,11 +1563,11 @@
  18.227    class FilterNodes<GR, NF,
  18.228                      typename enable_if<UndirectedTagIndicator<GR> >::type> :
  18.229      public GraphAdaptorExtender<
  18.230 -      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
  18.231 +      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >,
  18.232                     true> > {
  18.233  
  18.234      typedef GraphAdaptorExtender<
  18.235 -      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
  18.236 +      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >,
  18.237                     true> > Parent;
  18.238  
  18.239    public:
  18.240 @@ -1619,6 +1628,8 @@
  18.241    /// by adding or removing nodes or arcs, unless the \c GR template
  18.242    /// parameter is set to be \c const.
  18.243    ///
  18.244 +  /// This class provides only linear time counting for nodes and arcs.
  18.245 +  ///
  18.246    /// \tparam DGR The type of the adapted digraph.
  18.247    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  18.248    /// It can also be specified to be \c const.
  18.249 @@ -1642,7 +1653,7 @@
  18.250                       AF, false> > {
  18.251  #endif
  18.252      typedef DigraphAdaptorExtender<
  18.253 -      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 
  18.254 +      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >,
  18.255                       AF, false> > Parent;
  18.256  
  18.257    public:
  18.258 @@ -1729,6 +1740,8 @@
  18.259    /// by adding or removing nodes or edges, unless the \c GR template
  18.260    /// parameter is set to be \c const.
  18.261    ///
  18.262 +  /// This class provides only linear time counting for nodes, edges and arcs.
  18.263 +  ///
  18.264    /// \tparam GR The type of the adapted graph.
  18.265    /// It must conform to the \ref concepts::Graph "Graph" concept.
  18.266    /// It can also be specified to be \c const.
  18.267 @@ -1748,11 +1761,11 @@
  18.268             typename EF = typename GR::template EdgeMap<bool> >
  18.269    class FilterEdges :
  18.270      public GraphAdaptorExtender<
  18.271 -      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, 
  18.272 +      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >,
  18.273                     EF, false> > {
  18.274  #endif
  18.275      typedef GraphAdaptorExtender<
  18.276 -      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 
  18.277 +      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >,
  18.278                     EF, false> > Parent;
  18.279  
  18.280    public:
  18.281 @@ -1777,7 +1790,7 @@
  18.282      ///
  18.283      /// Creates a subgraph for the given graph with the given edge
  18.284      /// filter map.
  18.285 -    FilterEdges(GR& graph, EF& edge_filter) 
  18.286 +    FilterEdges(GR& graph, EF& edge_filter)
  18.287        : Parent(), const_true_map() {
  18.288        Parent::initialize(graph, const_true_map, edge_filter);
  18.289      }
  18.290 @@ -1845,7 +1858,7 @@
  18.291        Edge _edge;
  18.292        bool _forward;
  18.293  
  18.294 -      Arc(const Edge& edge, bool forward) 
  18.295 +      Arc(const Edge& edge, bool forward)
  18.296          : _edge(edge), _forward(forward) {}
  18.297  
  18.298      public:
  18.299 @@ -2085,7 +2098,7 @@
  18.300          _forward(*adaptor._digraph), _backward(*adaptor._digraph) {}
  18.301  
  18.302        ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value)
  18.303 -        : _forward(*adaptor._digraph, value), 
  18.304 +        : _forward(*adaptor._digraph, value),
  18.305            _backward(*adaptor._digraph, value) {}
  18.306  
  18.307        void set(const Arc& a, const V& value) {
  18.308 @@ -2203,7 +2216,7 @@
  18.309  
  18.310      typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier;
  18.311      EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
  18.312 -    
  18.313 +
  18.314      typedef EdgeNotifier ArcNotifier;
  18.315      ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); }
  18.316  
  18.317 @@ -2232,6 +2245,9 @@
  18.318    /// by adding or removing nodes or edges, unless the \c GR template
  18.319    /// parameter is set to be \c const.
  18.320    ///
  18.321 +  /// This class provides item counting in the same time as the adapted
  18.322 +  /// digraph structure.
  18.323 +  ///
  18.324    /// \tparam DGR The type of the adapted digraph.
  18.325    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  18.326    /// It can also be specified to be \c const.
  18.327 @@ -2535,6 +2551,9 @@
  18.328    /// by adding or removing nodes or arcs, unless the \c GR template
  18.329    /// parameter is set to be \c const.
  18.330    ///
  18.331 +  /// This class provides item counting in the same time as the adapted
  18.332 +  /// graph structure.
  18.333 +  ///
  18.334    /// \tparam GR The type of the adapted graph.
  18.335    /// It must conform to the \ref concepts::Graph "Graph" concept.
  18.336    /// It can also be specified to be \c const.
  18.337 @@ -2678,6 +2697,8 @@
  18.338    /// arcs).
  18.339    /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
  18.340    ///
  18.341 +  /// This class provides only linear time counting for nodes and arcs.
  18.342 +  ///
  18.343    /// \tparam DGR The type of the adapted digraph.
  18.344    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  18.345    /// It is implicitly \c const.
  18.346 @@ -2707,7 +2728,7 @@
  18.347             typename CM = typename DGR::template ArcMap<int>,
  18.348             typename FM = CM,
  18.349             typename TL = Tolerance<typename CM::Value> >
  18.350 -  class ResidualDigraph 
  18.351 +  class ResidualDigraph
  18.352      : public SubDigraph<
  18.353          Undirector<const DGR>,
  18.354          ConstMap<typename DGR::Node, Const<bool, true> >,
  18.355 @@ -2764,7 +2785,7 @@
  18.356      /// digraph, the capacity map, the flow map, and a tolerance object.
  18.357      ResidualDigraph(const DGR& digraph, const CM& capacity,
  18.358                      FM& flow, const TL& tolerance = Tolerance())
  18.359 -      : Parent(), _capacity(&capacity), _flow(&flow), 
  18.360 +      : Parent(), _capacity(&capacity), _flow(&flow),
  18.361          _graph(digraph), _node_filter(),
  18.362          _forward_filter(capacity, flow, tolerance),
  18.363          _backward_filter(capacity, flow, tolerance),
  18.364 @@ -2846,7 +2867,7 @@
  18.365        typedef typename CapacityMap::Value Value;
  18.366  
  18.367        /// Constructor
  18.368 -      ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) 
  18.369 +      ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor)
  18.370          : _adaptor(&adaptor) {}
  18.371  
  18.372        /// Returns the value associated with the given residual arc
  18.373 @@ -3325,6 +3346,9 @@
  18.374    /// costs/capacities of the original digraph to the \e bind \e arcs
  18.375    /// in the adaptor.
  18.376    ///
  18.377 +  /// This class provides item counting in the same time as the adapted
  18.378 +  /// digraph structure.
  18.379 +  ///
  18.380    /// \tparam DGR The type of the adapted digraph.
  18.381    /// It must conform to the \ref concepts::Digraph "Digraph" concept.
  18.382    /// It is implicitly \c const.
  18.383 @@ -3423,7 +3447,7 @@
  18.384      /// This map adaptor class adapts two node maps of the original digraph
  18.385      /// to get a node map of the split digraph.
  18.386      /// Its value type is inherited from the first node map type (\c IN).
  18.387 -    /// \tparam IN The type of the node map for the in-nodes. 
  18.388 +    /// \tparam IN The type of the node map for the in-nodes.
  18.389      /// \tparam OUT The type of the node map for the out-nodes.
  18.390      template <typename IN, typename OUT>
  18.391      class CombinedNodeMap {
    19.1 --- a/lemon/arg_parser.cc	Tue Dec 20 17:44:38 2011 +0100
    19.2 +++ b/lemon/arg_parser.cc	Tue Dec 20 18:15:14 2011 +0100
    19.3 @@ -2,7 +2,7 @@
    19.4   *
    19.5   * This file is a part of LEMON, a generic C++ optimization library.
    19.6   *
    19.7 - * Copyright (C) 2003-2009
    19.8 + * Copyright (C) 2003-2010
    19.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   19.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   19.11   *
   19.12 @@ -20,14 +20,23 @@
   19.13  
   19.14  namespace lemon {
   19.15  
   19.16 +  void ArgParser::_terminate(ArgParserException::Reason reason) const
   19.17 +  {
   19.18 +    if(_exit_on_problems)
   19.19 +      exit(1);
   19.20 +    else throw(ArgParserException(reason));
   19.21 +  }
   19.22 +
   19.23 +
   19.24    void ArgParser::_showHelp(void *p)
   19.25    {
   19.26      (static_cast<ArgParser*>(p))->showHelp();
   19.27 -    exit(1);
   19.28 +    (static_cast<ArgParser*>(p))->_terminate(ArgParserException::HELP);
   19.29    }
   19.30  
   19.31    ArgParser::ArgParser(int argc, const char * const *argv)
   19.32 -    :_argc(argc), _argv(argv), _command_name(argv[0]) {
   19.33 +    :_argc(argc), _argv(argv), _command_name(argv[0]),
   19.34 +    _exit_on_problems(true) {
   19.35      funcOption("-help","Print a short help message",_showHelp,this);
   19.36      synonym("help","-help");
   19.37      synonym("h","-help");
   19.38 @@ -342,7 +351,7 @@
   19.39      for(std::vector<OtherArg>::const_iterator i=_others_help.begin();
   19.40          i!=_others_help.end();++i) showHelp(i);
   19.41      for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i) showHelp(i);
   19.42 -    exit(1);
   19.43 +    _terminate(ArgParserException::HELP);
   19.44    }
   19.45  
   19.46  
   19.47 @@ -351,7 +360,7 @@
   19.48      std::cerr << "\nUnknown option: " << arg << "\n";
   19.49      std::cerr << "\nType '" << _command_name <<
   19.50        " --help' to obtain a short summary on the usage.\n\n";
   19.51 -    exit(1);
   19.52 +    _terminate(ArgParserException::UNKNOWN_OPT);
   19.53    }
   19.54  
   19.55    void ArgParser::requiresValue(std::string arg, OptType t) const
   19.56 @@ -414,7 +423,7 @@
   19.57      if(!ok) {
   19.58        std::cerr << "\nType '" << _command_name <<
   19.59          " --help' to obtain a short summary on the usage.\n\n";
   19.60 -      exit(1);
   19.61 +      _terminate(ArgParserException::INVALID_OPT);
   19.62      }
   19.63    }
   19.64  
    20.1 --- a/lemon/arg_parser.h	Tue Dec 20 17:44:38 2011 +0100
    20.2 +++ b/lemon/arg_parser.h	Tue Dec 20 18:15:14 2011 +0100
    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 @@ -34,6 +34,44 @@
   20.13  
   20.14  namespace lemon {
   20.15  
   20.16 +  ///Exception used by ArgParser
   20.17 +  class ArgParserException : public Exception {
   20.18 +  public:
   20.19 +    enum Reason {
   20.20 +      HELP,         /// <tt>--help</tt> option was given
   20.21 +      UNKNOWN_OPT,  /// Unknown option was given
   20.22 +      INVALID_OPT   /// Invalid combination of options
   20.23 +    };
   20.24 +
   20.25 +  private:
   20.26 +    Reason _reason;
   20.27 +
   20.28 +  public:
   20.29 +    ///Constructor
   20.30 +    ArgParserException(Reason r) throw() : _reason(r) {}
   20.31 +    ///Virtual destructor
   20.32 +    virtual ~ArgParserException() throw() {}
   20.33 +    ///A short description of the exception
   20.34 +    virtual const char* what() const throw() {
   20.35 +      switch(_reason)
   20.36 +        {
   20.37 +        case HELP:
   20.38 +          return "lemon::ArgParseException: ask for help";
   20.39 +          break;
   20.40 +        case UNKNOWN_OPT:
   20.41 +          return "lemon::ArgParseException: unknown option";
   20.42 +          break;
   20.43 +        case INVALID_OPT:
   20.44 +          return "lemon::ArgParseException: invalid combination of options";
   20.45 +          break;
   20.46 +        }
   20.47 +      return "";
   20.48 +    }
   20.49 +    ///Return the reason for the failure
   20.50 +    Reason reason() const {return _reason; }
   20.51 +  };
   20.52 +
   20.53 +
   20.54    ///Command line arguments parser
   20.55  
   20.56    ///\ingroup misc
   20.57 @@ -116,6 +154,10 @@
   20.58                      const std::string &help,
   20.59                      void (*func)(void *),void *data);
   20.60  
   20.61 +    bool _exit_on_problems;
   20.62 +
   20.63 +    void _terminate(ArgParserException::Reason reason) const;
   20.64 +
   20.65    public:
   20.66  
   20.67      ///Constructor
   20.68 @@ -380,6 +422,11 @@
   20.69      ///not starting with a '-' character.
   20.70      const std::vector<std::string> &files() const { return _file_args; }
   20.71  
   20.72 +    ///Throw instead of exit in case of problems
   20.73 +    void throwOnProblems()
   20.74 +    {
   20.75 +      _exit_on_problems=false;
   20.76 +    }
   20.77    };
   20.78  }
   20.79  
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/lemon/bellman_ford.h	Tue Dec 20 18:15:14 2011 +0100
    21.3 @@ -0,0 +1,1165 @@
    21.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    21.5 + *
    21.6 + * This file is a part of LEMON, a generic C++ optimization library.
    21.7 + *
    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 + * Permission to use, modify and distribute this software is granted
   21.13 + * provided that this copyright notice appears in all copies. For
   21.14 + * precise terms see the accompanying LICENSE file.
   21.15 + *
   21.16 + * This software is provided "AS IS" with no warranty of any kind,
   21.17 + * express or implied, and with no claim as to its suitability for any
   21.18 + * purpose.
   21.19 + *
   21.20 + */
   21.21 +
   21.22 +#ifndef LEMON_BELLMAN_FORD_H
   21.23 +#define LEMON_BELLMAN_FORD_H
   21.24 +
   21.25 +/// \ingroup shortest_path
   21.26 +/// \file
   21.27 +/// \brief Bellman-Ford algorithm.
   21.28 +
   21.29 +#include <lemon/list_graph.h>
   21.30 +#include <lemon/bits/path_dump.h>
   21.31 +#include <lemon/core.h>
   21.32 +#include <lemon/error.h>
   21.33 +#include <lemon/maps.h>
   21.34 +#include <lemon/tolerance.h>
   21.35 +#include <lemon/path.h>
   21.36 +
   21.37 +#include <limits>
   21.38 +
   21.39 +namespace lemon {
   21.40 +
   21.41 +  /// \brief Default operation traits for the BellmanFord algorithm class.
   21.42 +  ///
   21.43 +  /// This operation traits class defines all computational operations
   21.44 +  /// and constants that are used in the Bellman-Ford algorithm.
   21.45 +  /// The default implementation is based on the \c numeric_limits class.
   21.46 +  /// If the numeric type does not have infinity value, then the maximum
   21.47 +  /// value is used as extremal infinity value.
   21.48 +  ///
   21.49 +  /// \see BellmanFordToleranceOperationTraits
   21.50 +  template <
   21.51 +    typename V,
   21.52 +    bool has_inf = std::numeric_limits<V>::has_infinity>
   21.53 +  struct BellmanFordDefaultOperationTraits {
   21.54 +    /// \brief Value type for the algorithm.
   21.55 +    typedef V Value;
   21.56 +    /// \brief Gives back the zero value of the type.
   21.57 +    static Value zero() {
   21.58 +      return static_cast<Value>(0);
   21.59 +    }
   21.60 +    /// \brief Gives back the positive infinity value of the type.
   21.61 +    static Value infinity() {
   21.62 +      return std::numeric_limits<Value>::infinity();
   21.63 +    }
   21.64 +    /// \brief Gives back the sum of the given two elements.
   21.65 +    static Value plus(const Value& left, const Value& right) {
   21.66 +      return left + right;
   21.67 +    }
   21.68 +    /// \brief Gives back \c true only if the first value is less than
   21.69 +    /// the second.
   21.70 +    static bool less(const Value& left, const Value& right) {
   21.71 +      return left < right;
   21.72 +    }
   21.73 +  };
   21.74 +
   21.75 +  template <typename V>
   21.76 +  struct BellmanFordDefaultOperationTraits<V, false> {
   21.77 +    typedef V Value;
   21.78 +    static Value zero() {
   21.79 +      return static_cast<Value>(0);
   21.80 +    }
   21.81 +    static Value infinity() {
   21.82 +      return std::numeric_limits<Value>::max();
   21.83 +    }
   21.84 +    static Value plus(const Value& left, const Value& right) {
   21.85 +      if (left == infinity() || right == infinity()) return infinity();
   21.86 +      return left + right;
   21.87 +    }
   21.88 +    static bool less(const Value& left, const Value& right) {
   21.89 +      return left < right;
   21.90 +    }
   21.91 +  };
   21.92 +
   21.93 +  /// \brief Operation traits for the BellmanFord algorithm class
   21.94 +  /// using tolerance.
   21.95 +  ///
   21.96 +  /// This operation traits class defines all computational operations
   21.97 +  /// and constants that are used in the Bellman-Ford algorithm.
   21.98 +  /// The only difference between this implementation and
   21.99 +  /// \ref BellmanFordDefaultOperationTraits is that this class uses
  21.100 +  /// the \ref Tolerance "tolerance technique" in its \ref less()
  21.101 +  /// function.
  21.102 +  ///
  21.103 +  /// \tparam V The value type.
  21.104 +  /// \tparam eps The epsilon value for the \ref less() function.
  21.105 +  /// By default, it is the epsilon value used by \ref Tolerance
  21.106 +  /// "Tolerance<V>".
  21.107 +  ///
  21.108 +  /// \see BellmanFordDefaultOperationTraits
  21.109 +#ifdef DOXYGEN
  21.110 +  template <typename V, V eps>
  21.111 +#else
  21.112 +  template <
  21.113 +    typename V,
  21.114 +    V eps = Tolerance<V>::def_epsilon>
  21.115 +#endif
  21.116 +  struct BellmanFordToleranceOperationTraits {
  21.117 +    /// \brief Value type for the algorithm.
  21.118 +    typedef V Value;
  21.119 +    /// \brief Gives back the zero value of the type.
  21.120 +    static Value zero() {
  21.121 +      return static_cast<Value>(0);
  21.122 +    }
  21.123 +    /// \brief Gives back the positive infinity value of the type.
  21.124 +    static Value infinity() {
  21.125 +      return std::numeric_limits<Value>::infinity();
  21.126 +    }
  21.127 +    /// \brief Gives back the sum of the given two elements.
  21.128 +    static Value plus(const Value& left, const Value& right) {
  21.129 +      return left + right;
  21.130 +    }
  21.131 +    /// \brief Gives back \c true only if the first value is less than
  21.132 +    /// the second.
  21.133 +    static bool less(const Value& left, const Value& right) {
  21.134 +      return left + eps < right;
  21.135 +    }
  21.136 +  };
  21.137 +
  21.138 +  /// \brief Default traits class of BellmanFord class.
  21.139 +  ///
  21.140 +  /// Default traits class of BellmanFord class.
  21.141 +  /// \param GR The type of the digraph.
  21.142 +  /// \param LEN The type of the length map.
  21.143 +  template<typename GR, typename LEN>
  21.144 +  struct BellmanFordDefaultTraits {
  21.145 +    /// The type of the digraph the algorithm runs on.
  21.146 +    typedef GR Digraph;
  21.147 +
  21.148 +    /// \brief The type of the map that stores the arc lengths.
  21.149 +    ///
  21.150 +    /// The type of the map that stores the arc lengths.
  21.151 +    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
  21.152 +    typedef LEN LengthMap;
  21.153 +
  21.154 +    /// The type of the arc lengths.
  21.155 +    typedef typename LEN::Value Value;
  21.156 +
  21.157 +    /// \brief Operation traits for Bellman-Ford algorithm.
  21.158 +    ///
  21.159 +    /// It defines the used operations and the infinity value for the
  21.160 +    /// given \c Value type.
  21.161 +    /// \see BellmanFordDefaultOperationTraits,
  21.162 +    /// BellmanFordToleranceOperationTraits
  21.163 +    typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
  21.164 +
  21.165 +    /// \brief The type of the map that stores the last arcs of the
  21.166 +    /// shortest paths.
  21.167 +    ///
  21.168 +    /// The type of the map that stores the last
  21.169 +    /// arcs of the shortest paths.
  21.170 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  21.171 +    typedef typename GR::template NodeMap<typename GR::Arc> PredMap;
  21.172 +
  21.173 +    /// \brief Instantiates a \c PredMap.
  21.174 +    ///
  21.175 +    /// This function instantiates a \ref PredMap.
  21.176 +    /// \param g is the digraph to which we would like to define the
  21.177 +    /// \ref PredMap.
  21.178 +    static PredMap *createPredMap(const GR& g) {
  21.179 +      return new PredMap(g);
  21.180 +    }
  21.181 +
  21.182 +    /// \brief The type of the map that stores the distances of the nodes.
  21.183 +    ///
  21.184 +    /// The type of the map that stores the distances of the nodes.
  21.185 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  21.186 +    typedef typename GR::template NodeMap<typename LEN::Value> DistMap;
  21.187 +
  21.188 +    /// \brief Instantiates a \c DistMap.
  21.189 +    ///
  21.190 +    /// This function instantiates a \ref DistMap.
  21.191 +    /// \param g is the digraph to which we would like to define the
  21.192 +    /// \ref DistMap.
  21.193 +    static DistMap *createDistMap(const GR& g) {
  21.194 +      return new DistMap(g);
  21.195 +    }
  21.196 +
  21.197 +  };
  21.198 +
  21.199 +  /// \brief %BellmanFord algorithm class.
  21.200 +  ///
  21.201 +  /// \ingroup shortest_path
  21.202 +  /// This class provides an efficient implementation of the Bellman-Ford
  21.203 +  /// algorithm. The maximum time complexity of the algorithm is
  21.204 +  /// <tt>O(ne)</tt>.
  21.205 +  ///
  21.206 +  /// The Bellman-Ford algorithm solves the single-source shortest path
  21.207 +  /// problem when the arcs can have negative lengths, but the digraph
  21.208 +  /// should not contain directed cycles with negative total length.
  21.209 +  /// If all arc costs are non-negative, consider to use the Dijkstra
  21.210 +  /// algorithm instead, since it is more efficient.
  21.211 +  ///
  21.212 +  /// The arc lengths are passed to the algorithm using a
  21.213 +  /// \ref concepts::ReadMap "ReadMap", so it is easy to change it to any
  21.214 +  /// kind of length. The type of the length values is determined by the
  21.215 +  /// \ref concepts::ReadMap::Value "Value" type of the length map.
  21.216 +  ///
  21.217 +  /// There is also a \ref bellmanFord() "function-type interface" for the
  21.218 +  /// Bellman-Ford algorithm, which is convenient in the simplier cases and
  21.219 +  /// it can be used easier.
  21.220 +  ///
  21.221 +  /// \tparam GR The type of the digraph the algorithm runs on.
  21.222 +  /// The default type is \ref ListDigraph.
  21.223 +  /// \tparam LEN A \ref concepts::ReadMap "readable" arc map that specifies
  21.224 +  /// the lengths of the arcs. The default map type is
  21.225 +  /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
  21.226 +  /// \tparam TR The traits class that defines various types used by the
  21.227 +  /// algorithm. By default, it is \ref BellmanFordDefaultTraits
  21.228 +  /// "BellmanFordDefaultTraits<GR, LEN>".
  21.229 +  /// In most cases, this parameter should not be set directly,
  21.230 +  /// consider to use the named template parameters instead.
  21.231 +#ifdef DOXYGEN
  21.232 +  template <typename GR, typename LEN, typename TR>
  21.233 +#else
  21.234 +  template <typename GR=ListDigraph,
  21.235 +            typename LEN=typename GR::template ArcMap<int>,
  21.236 +            typename TR=BellmanFordDefaultTraits<GR,LEN> >
  21.237 +#endif
  21.238 +  class BellmanFord {
  21.239 +  public:
  21.240 +
  21.241 +    ///The type of the underlying digraph.
  21.242 +    typedef typename TR::Digraph Digraph;
  21.243 +
  21.244 +    /// \brief The type of the arc lengths.
  21.245 +    typedef typename TR::LengthMap::Value Value;
  21.246 +    /// \brief The type of the map that stores the arc lengths.
  21.247 +    typedef typename TR::LengthMap LengthMap;
  21.248 +    /// \brief The type of the map that stores the last
  21.249 +    /// arcs of the shortest paths.
  21.250 +    typedef typename TR::PredMap PredMap;
  21.251 +    /// \brief The type of the map that stores the distances of the nodes.
  21.252 +    typedef typename TR::DistMap DistMap;
  21.253 +    /// The type of the paths.
  21.254 +    typedef PredMapPath<Digraph, PredMap> Path;
  21.255 +    ///\brief The \ref BellmanFordDefaultOperationTraits
  21.256 +    /// "operation traits class" of the algorithm.
  21.257 +    typedef typename TR::OperationTraits OperationTraits;
  21.258 +
  21.259 +    ///The \ref BellmanFordDefaultTraits "traits class" of the algorithm.
  21.260 +    typedef TR Traits;
  21.261 +
  21.262 +  private:
  21.263 +
  21.264 +    typedef typename Digraph::Node Node;
  21.265 +    typedef typename Digraph::NodeIt NodeIt;
  21.266 +    typedef typename Digraph::Arc Arc;
  21.267 +    typedef typename Digraph::OutArcIt OutArcIt;
  21.268 +
  21.269 +    // Pointer to the underlying digraph.
  21.270 +    const Digraph *_gr;
  21.271 +    // Pointer to the length map
  21.272 +    const LengthMap *_length;
  21.273 +    // Pointer to the map of predecessors arcs.
  21.274 +    PredMap *_pred;
  21.275 +    // Indicates if _pred is locally allocated (true) or not.
  21.276 +    bool _local_pred;
  21.277 +    // Pointer to the map of distances.
  21.278 +    DistMap *_dist;
  21.279 +    // Indicates if _dist is locally allocated (true) or not.
  21.280 +    bool _local_dist;
  21.281 +
  21.282 +    typedef typename Digraph::template NodeMap<bool> MaskMap;
  21.283 +    MaskMap *_mask;
  21.284 +
  21.285 +    std::vector<Node> _process;
  21.286 +
  21.287 +    // Creates the maps if necessary.
  21.288 +    void create_maps() {
  21.289 +      if(!_pred) {
  21.290 +        _local_pred = true;
  21.291 +        _pred = Traits::createPredMap(*_gr);
  21.292 +      }
  21.293 +      if(!_dist) {
  21.294 +        _local_dist = true;
  21.295 +        _dist = Traits::createDistMap(*_gr);
  21.296 +      }
  21.297 +      if(!_mask) {
  21.298 +        _mask = new MaskMap(*_gr);
  21.299 +      }
  21.300 +    }
  21.301 +
  21.302 +  public :
  21.303 +
  21.304 +    typedef BellmanFord Create;
  21.305 +
  21.306 +    /// \name Named Template Parameters
  21.307 +
  21.308 +    ///@{
  21.309 +
  21.310 +    template <class T>
  21.311 +    struct SetPredMapTraits : public Traits {
  21.312 +      typedef T PredMap;
  21.313 +      static PredMap *createPredMap(const Digraph&) {
  21.314 +        LEMON_ASSERT(false, "PredMap is not initialized");
  21.315 +        return 0; // ignore warnings
  21.316 +      }
  21.317 +    };
  21.318 +
  21.319 +    /// \brief \ref named-templ-param "Named parameter" for setting
  21.320 +    /// \c PredMap type.
  21.321 +    ///
  21.322 +    /// \ref named-templ-param "Named parameter" for setting
  21.323 +    /// \c PredMap type.
  21.324 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  21.325 +    template <class T>
  21.326 +    struct SetPredMap
  21.327 +      : public BellmanFord< Digraph, LengthMap, SetPredMapTraits<T> > {
  21.328 +      typedef BellmanFord< Digraph, LengthMap, SetPredMapTraits<T> > Create;
  21.329 +    };
  21.330 +
  21.331 +    template <class T>
  21.332 +    struct SetDistMapTraits : public Traits {
  21.333 +      typedef T DistMap;
  21.334 +      static DistMap *createDistMap(const Digraph&) {
  21.335 +        LEMON_ASSERT(false, "DistMap is not initialized");
  21.336 +        return 0; // ignore warnings
  21.337 +      }
  21.338 +    };
  21.339 +
  21.340 +    /// \brief \ref named-templ-param "Named parameter" for setting
  21.341 +    /// \c DistMap type.
  21.342 +    ///
  21.343 +    /// \ref named-templ-param "Named parameter" for setting
  21.344 +    /// \c DistMap type.
  21.345 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  21.346 +    template <class T>
  21.347 +    struct SetDistMap
  21.348 +      : public BellmanFord< Digraph, LengthMap, SetDistMapTraits<T> > {
  21.349 +      typedef BellmanFord< Digraph, LengthMap, SetDistMapTraits<T> > Create;
  21.350 +    };
  21.351 +
  21.352 +    template <class T>
  21.353 +    struct SetOperationTraitsTraits : public Traits {
  21.354 +      typedef T OperationTraits;
  21.355 +    };
  21.356 +
  21.357 +    /// \brief \ref named-templ-param "Named parameter" for setting
  21.358 +    /// \c OperationTraits type.
  21.359 +    ///
  21.360 +    /// \ref named-templ-param "Named parameter" for setting
  21.361 +    /// \c OperationTraits type.
  21.362 +    /// For more information, see \ref BellmanFordDefaultOperationTraits.
  21.363 +    template <class T>
  21.364 +    struct SetOperationTraits
  21.365 +      : public BellmanFord< Digraph, LengthMap, SetOperationTraitsTraits<T> > {
  21.366 +      typedef BellmanFord< Digraph, LengthMap, SetOperationTraitsTraits<T> >
  21.367 +      Create;
  21.368 +    };
  21.369 +
  21.370 +    ///@}
  21.371 +
  21.372 +  protected:
  21.373 +
  21.374 +    BellmanFord() {}
  21.375 +
  21.376 +  public:
  21.377 +
  21.378 +    /// \brief Constructor.
  21.379 +    ///
  21.380 +    /// Constructor.
  21.381 +    /// \param g The digraph the algorithm runs on.
  21.382 +    /// \param length The length map used by the algorithm.
  21.383 +    BellmanFord(const Digraph& g, const LengthMap& length) :
  21.384 +      _gr(&g), _length(&length),
  21.385 +      _pred(0), _local_pred(false),
  21.386 +      _dist(0), _local_dist(false), _mask(0) {}
  21.387 +
  21.388 +    ///Destructor.
  21.389 +    ~BellmanFord() {
  21.390 +      if(_local_pred) delete _pred;
  21.391 +      if(_local_dist) delete _dist;
  21.392 +      if(_mask) delete _mask;
  21.393 +    }
  21.394 +
  21.395 +    /// \brief Sets the length map.
  21.396 +    ///
  21.397 +    /// Sets the length map.
  21.398 +    /// \return <tt>(*this)</tt>
  21.399 +    BellmanFord &lengthMap(const LengthMap &map) {
  21.400 +      _length = &map;
  21.401 +      return *this;
  21.402 +    }
  21.403 +
  21.404 +    /// \brief Sets the map that stores the predecessor arcs.
  21.405 +    ///
  21.406 +    /// Sets the map that stores the predecessor arcs.
  21.407 +    /// If you don't use this function before calling \ref run()
  21.408 +    /// or \ref init(), an instance will be allocated automatically.
  21.409 +    /// The destructor deallocates this automatically allocated map,
  21.410 +    /// of course.
  21.411 +    /// \return <tt>(*this)</tt>
  21.412 +    BellmanFord &predMap(PredMap &map) {
  21.413 +      if(_local_pred) {
  21.414 +        delete _pred;
  21.415 +        _local_pred=false;
  21.416 +      }
  21.417 +      _pred = &map;
  21.418 +      return *this;
  21.419 +    }
  21.420 +
  21.421 +    /// \brief Sets the map that stores the distances of the nodes.
  21.422 +    ///
  21.423 +    /// Sets the map that stores the distances of the nodes calculated
  21.424 +    /// by the algorithm.
  21.425 +    /// If you don't use this function before calling \ref run()
  21.426 +    /// or \ref init(), an instance will be allocated automatically.
  21.427 +    /// The destructor deallocates this automatically allocated map,
  21.428 +    /// of course.
  21.429 +    /// \return <tt>(*this)</tt>
  21.430 +    BellmanFord &distMap(DistMap &map) {
  21.431 +      if(_local_dist) {
  21.432 +        delete _dist;
  21.433 +        _local_dist=false;
  21.434 +      }
  21.435 +      _dist = &map;
  21.436 +      return *this;
  21.437 +    }
  21.438 +
  21.439 +    /// \name Execution Control
  21.440 +    /// The simplest way to execute the Bellman-Ford algorithm is to use
  21.441 +    /// one of the member functions called \ref run().\n
  21.442 +    /// If you need better control on the execution, you have to call
  21.443 +    /// \ref init() first, then you can add several source nodes
  21.444 +    /// with \ref addSource(). Finally the actual path computation can be
  21.445 +    /// performed with \ref start(), \ref checkedStart() or
  21.446 +    /// \ref limitedStart().
  21.447 +
  21.448 +    ///@{
  21.449 +
  21.450 +    /// \brief Initializes the internal data structures.
  21.451 +    ///
  21.452 +    /// Initializes the internal data structures. The optional parameter
  21.453 +    /// is the initial distance of each node.
  21.454 +    void init(const Value value = OperationTraits::infinity()) {
  21.455 +      create_maps();
  21.456 +      for (NodeIt it(*_gr); it != INVALID; ++it) {
  21.457 +        _pred->set(it, INVALID);
  21.458 +        _dist->set(it, value);
  21.459 +      }
  21.460 +      _process.clear();
  21.461 +      if (OperationTraits::less(value, OperationTraits::infinity())) {
  21.462 +        for (NodeIt it(*_gr); it != INVALID; ++it) {
  21.463 +          _process.push_back(it);
  21.464 +          _mask->set(it, true);
  21.465 +        }
  21.466 +      } else {
  21.467 +        for (NodeIt it(*_gr); it != INVALID; ++it) {
  21.468 +          _mask->set(it, false);
  21.469 +        }
  21.470 +      }
  21.471 +    }
  21.472 +
  21.473 +    /// \brief Adds a new source node.
  21.474 +    ///
  21.475 +    /// This function adds a new source node. The optional second parameter
  21.476 +    /// is the initial distance of the node.
  21.477 +    void addSource(Node source, Value dst = OperationTraits::zero()) {
  21.478 +      _dist->set(source, dst);
  21.479 +      if (!(*_mask)[source]) {
  21.480 +        _process.push_back(source);
  21.481 +        _mask->set(source, true);
  21.482 +      }
  21.483 +    }
  21.484 +
  21.485 +    /// \brief Executes one round from the Bellman-Ford algorithm.
  21.486 +    ///
  21.487 +    /// If the algoritm calculated the distances in the previous round
  21.488 +    /// exactly for the paths of at most \c k arcs, then this function
  21.489 +    /// will calculate the distances exactly for the paths of at most
  21.490 +    /// <tt>k+1</tt> arcs. Performing \c k iterations using this function
  21.491 +    /// calculates the shortest path distances exactly for the paths
  21.492 +    /// consisting of at most \c k arcs.
  21.493 +    ///
  21.494 +    /// \warning The paths with limited arc number cannot be retrieved
  21.495 +    /// easily with \ref path() or \ref predArc() functions. If you also
  21.496 +    /// need the shortest paths and not only the distances, you should
  21.497 +    /// store the \ref predMap() "predecessor map" after each iteration
  21.498 +    /// and build the path manually.
  21.499 +    ///
  21.500 +    /// \return \c true when the algorithm have not found more shorter
  21.501 +    /// paths.
  21.502 +    ///
  21.503 +    /// \see ActiveIt
  21.504 +    bool processNextRound() {
  21.505 +      for (int i = 0; i < int(_process.size()); ++i) {
  21.506 +        _mask->set(_process[i], false);
  21.507 +      }
  21.508 +      std::vector<Node> nextProcess;
  21.509 +      std::vector<Value> values(_process.size());
  21.510 +      for (int i = 0; i < int(_process.size()); ++i) {
  21.511 +        values[i] = (*_dist)[_process[i]];
  21.512 +      }
  21.513 +      for (int i = 0; i < int(_process.size()); ++i) {
  21.514 +        for (OutArcIt it(*_gr, _process[i]); it != INVALID; ++it) {
  21.515 +          Node target = _gr->target(it);
  21.516 +          Value relaxed = OperationTraits::plus(values[i], (*_length)[it]);
  21.517 +          if (OperationTraits::less(relaxed, (*_dist)[target])) {
  21.518 +            _pred->set(target, it);
  21.519 +            _dist->set(target, relaxed);
  21.520 +            if (!(*_mask)[target]) {
  21.521 +              _mask->set(target, true);
  21.522 +              nextProcess.push_back(target);
  21.523 +            }
  21.524 +          }
  21.525 +        }
  21.526 +      }
  21.527 +      _process.swap(nextProcess);
  21.528 +      return _process.empty();
  21.529 +    }
  21.530 +
  21.531 +    /// \brief Executes one weak round from the Bellman-Ford algorithm.
  21.532 +    ///
  21.533 +    /// If the algorithm calculated the distances in the previous round
  21.534 +    /// at least for the paths of at most \c k arcs, then this function
  21.535 +    /// will calculate the distances at least for the paths of at most
  21.536 +    /// <tt>k+1</tt> arcs.
  21.537 +    /// This function does not make it possible to calculate the shortest
  21.538 +    /// path distances exactly for paths consisting of at most \c k arcs,
  21.539 +    /// this is why it is called weak round.
  21.540 +    ///
  21.541 +    /// \return \c true when the algorithm have not found more shorter
  21.542 +    /// paths.
  21.543 +    ///
  21.544 +    /// \see ActiveIt
  21.545 +    bool processNextWeakRound() {
  21.546 +      for (int i = 0; i < int(_process.size()); ++i) {
  21.547 +        _mask->set(_process[i], false);
  21.548 +      }
  21.549 +      std::vector<Node> nextProcess;
  21.550 +      for (int i = 0; i < int(_process.size()); ++i) {
  21.551 +        for (OutArcIt it(*_gr, _process[i]); it != INVALID; ++it) {
  21.552 +          Node target = _gr->target(it);
  21.553 +          Value relaxed =
  21.554 +            OperationTraits::plus((*_dist)[_process[i]], (*_length)[it]);
  21.555 +          if (OperationTraits::less(relaxed, (*_dist)[target])) {
  21.556 +            _pred->set(target, it);
  21.557 +            _dist->set(target, relaxed);
  21.558 +            if (!(*_mask)[target]) {
  21.559 +              _mask->set(target, true);
  21.560 +              nextProcess.push_back(target);
  21.561 +            }
  21.562 +          }
  21.563 +        }
  21.564 +      }
  21.565 +      _process.swap(nextProcess);
  21.566 +      return _process.empty();
  21.567 +    }
  21.568 +
  21.569 +    /// \brief Executes the algorithm.
  21.570 +    ///
  21.571 +    /// Executes the algorithm.
  21.572 +    ///
  21.573 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  21.574 +    /// in order to compute the shortest path to each node.
  21.575 +    ///
  21.576 +    /// The algorithm computes
  21.577 +    /// - the shortest path tree (forest),
  21.578 +    /// - the distance of each node from the root(s).
  21.579 +    ///
  21.580 +    /// \pre init() must be called and at least one root node should be
  21.581 +    /// added with addSource() before using this function.
  21.582 +    void start() {
  21.583 +      int num = countNodes(*_gr) - 1;
  21.584 +      for (int i = 0; i < num; ++i) {
  21.585 +        if (processNextWeakRound()) break;
  21.586 +      }
  21.587 +    }
  21.588 +
  21.589 +    /// \brief Executes the algorithm and checks the negative cycles.
  21.590 +    ///
  21.591 +    /// Executes the algorithm and checks the negative cycles.
  21.592 +    ///
  21.593 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  21.594 +    /// in order to compute the shortest path to each node and also checks
  21.595 +    /// if the digraph contains cycles with negative total length.
  21.596 +    ///
  21.597 +    /// The algorithm computes
  21.598 +    /// - the shortest path tree (forest),
  21.599 +    /// - the distance of each node from the root(s).
  21.600 +    ///
  21.601 +    /// \return \c false if there is a negative cycle in the digraph.
  21.602 +    ///
  21.603 +    /// \pre init() must be called and at least one root node should be
  21.604 +    /// added with addSource() before using this function.
  21.605 +    bool checkedStart() {
  21.606 +      int num = countNodes(*_gr);
  21.607 +      for (int i = 0; i < num; ++i) {
  21.608 +        if (processNextWeakRound()) return true;
  21.609 +      }
  21.610 +      return _process.empty();
  21.611 +    }
  21.612 +
  21.613 +    /// \brief Executes the algorithm with arc number limit.
  21.614 +    ///
  21.615 +    /// Executes the algorithm with arc number limit.
  21.616 +    ///
  21.617 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  21.618 +    /// in order to compute the shortest path distance for each node
  21.619 +    /// using only the paths consisting of at most \c num arcs.
  21.620 +    ///
  21.621 +    /// The algorithm computes
  21.622 +    /// - the limited distance of each node from the root(s),
  21.623 +    /// - the predecessor arc for each node.
  21.624 +    ///
  21.625 +    /// \warning The paths with limited arc number cannot be retrieved
  21.626 +    /// easily with \ref path() or \ref predArc() functions. If you also
  21.627 +    /// need the shortest paths and not only the distances, you should
  21.628 +    /// store the \ref predMap() "predecessor map" after each iteration
  21.629 +    /// and build the path manually.
  21.630 +    ///
  21.631 +    /// \pre init() must be called and at least one root node should be
  21.632 +    /// added with addSource() before using this function.
  21.633 +    void limitedStart(int num) {
  21.634 +      for (int i = 0; i < num; ++i) {
  21.635 +        if (processNextRound()) break;
  21.636 +      }
  21.637 +    }
  21.638 +
  21.639 +    /// \brief Runs the algorithm from the given root node.
  21.640 +    ///
  21.641 +    /// This method runs the Bellman-Ford algorithm from the given root
  21.642 +    /// node \c s in order to compute the shortest path to each node.
  21.643 +    ///
  21.644 +    /// The algorithm computes
  21.645 +    /// - the shortest path tree (forest),
  21.646 +    /// - the distance of each node from the root(s).
  21.647 +    ///
  21.648 +    /// \note bf.run(s) is just a shortcut of the following code.
  21.649 +    /// \code
  21.650 +    ///   bf.init();
  21.651 +    ///   bf.addSource(s);
  21.652 +    ///   bf.start();
  21.653 +    /// \endcode
  21.654 +    void run(Node s) {
  21.655 +      init();
  21.656 +      addSource(s);
  21.657 +      start();
  21.658 +    }
  21.659 +
  21.660 +    /// \brief Runs the algorithm from the given root node with arc
  21.661 +    /// number limit.
  21.662 +    ///
  21.663 +    /// This method runs the Bellman-Ford algorithm from the given root
  21.664 +    /// node \c s in order to compute the shortest path distance for each
  21.665 +    /// node using only the paths consisting of at most \c num arcs.
  21.666 +    ///
  21.667 +    /// The algorithm computes
  21.668 +    /// - the limited distance of each node from the root(s),
  21.669 +    /// - the predecessor arc for each node.
  21.670 +    ///
  21.671 +    /// \warning The paths with limited arc number cannot be retrieved
  21.672 +    /// easily with \ref path() or \ref predArc() functions. If you also
  21.673 +    /// need the shortest paths and not only the distances, you should
  21.674 +    /// store the \ref predMap() "predecessor map" after each iteration
  21.675 +    /// and build the path manually.
  21.676 +    ///
  21.677 +    /// \note bf.run(s, num) is just a shortcut of the following code.
  21.678 +    /// \code
  21.679 +    ///   bf.init();
  21.680 +    ///   bf.addSource(s);
  21.681 +    ///   bf.limitedStart(num);
  21.682 +    /// \endcode
  21.683 +    void run(Node s, int num) {
  21.684 +      init();
  21.685 +      addSource(s);
  21.686 +      limitedStart(num);
  21.687 +    }
  21.688 +
  21.689 +    ///@}
  21.690 +
  21.691 +    /// \brief LEMON iterator for getting the active nodes.
  21.692 +    ///
  21.693 +    /// This class provides a common style LEMON iterator that traverses
  21.694 +    /// the active nodes of the Bellman-Ford algorithm after the last
  21.695 +    /// phase. These nodes should be checked in the next phase to
  21.696 +    /// find augmenting arcs outgoing from them.
  21.697 +    class ActiveIt {
  21.698 +    public:
  21.699 +
  21.700 +      /// \brief Constructor.
  21.701 +      ///
  21.702 +      /// Constructor for getting the active nodes of the given BellmanFord
  21.703 +      /// instance.
  21.704 +      ActiveIt(const BellmanFord& algorithm) : _algorithm(&algorithm)
  21.705 +      {
  21.706 +        _index = _algorithm->_process.size() - 1;
  21.707 +      }
  21.708 +
  21.709 +      /// \brief Invalid constructor.
  21.710 +      ///
  21.711 +      /// Invalid constructor.
  21.712 +      ActiveIt(Invalid) : _algorithm(0), _index(-1) {}
  21.713 +
  21.714 +      /// \brief Conversion to \c Node.
  21.715 +      ///
  21.716 +      /// Conversion to \c Node.
  21.717 +      operator Node() const {
  21.718 +        return _index >= 0 ? _algorithm->_process[_index] : INVALID;
  21.719 +      }
  21.720 +
  21.721 +      /// \brief Increment operator.
  21.722 +      ///
  21.723 +      /// Increment operator.
  21.724 +      ActiveIt& operator++() {
  21.725 +        --_index;
  21.726 +        return *this;
  21.727 +      }
  21.728 +
  21.729 +      bool operator==(const ActiveIt& it) const {
  21.730 +        return static_cast<Node>(*this) == static_cast<Node>(it);
  21.731 +      }
  21.732 +      bool operator!=(const ActiveIt& it) const {
  21.733 +        return static_cast<Node>(*this) != static_cast<Node>(it);
  21.734 +      }
  21.735 +      bool operator<(const ActiveIt& it) const {
  21.736 +        return static_cast<Node>(*this) < static_cast<Node>(it);
  21.737 +      }
  21.738 +
  21.739 +    private:
  21.740 +      const BellmanFord* _algorithm;
  21.741 +      int _index;
  21.742 +    };
  21.743 +
  21.744 +    /// \name Query Functions
  21.745 +    /// The result of the Bellman-Ford algorithm can be obtained using these
  21.746 +    /// functions.\n
  21.747 +    /// Either \ref run() or \ref init() should be called before using them.
  21.748 +
  21.749 +    ///@{
  21.750 +
  21.751 +    /// \brief The shortest path to the given node.
  21.752 +    ///
  21.753 +    /// Gives back the shortest path to the given node from the root(s).
  21.754 +    ///
  21.755 +    /// \warning \c t should be reached from the root(s).
  21.756 +    ///
  21.757 +    /// \pre Either \ref run() or \ref init() must be called before
  21.758 +    /// using this function.
  21.759 +    Path path(Node t) const
  21.760 +    {
  21.761 +      return Path(*_gr, *_pred, t);
  21.762 +    }
  21.763 +
  21.764 +    /// \brief The distance of the given node from the root(s).
  21.765 +    ///
  21.766 +    /// Returns the distance of the given node from the root(s).
  21.767 +    ///
  21.768 +    /// \warning If node \c v is not reached from the root(s), then
  21.769 +    /// the return value of this function is undefined.
  21.770 +    ///
  21.771 +    /// \pre Either \ref run() or \ref init() must be called before
  21.772 +    /// using this function.
  21.773 +    Value dist(Node v) const { return (*_dist)[v]; }
  21.774 +
  21.775 +    /// \brief Returns the 'previous arc' of the shortest path tree for
  21.776 +    /// the given node.
  21.777 +    ///
  21.778 +    /// This function returns the 'previous arc' of the shortest path
  21.779 +    /// tree for node \c v, i.e. it returns the last arc of a
  21.780 +    /// shortest path from a root to \c v. It is \c INVALID if \c v
  21.781 +    /// is not reached from the root(s) or if \c v is a root.
  21.782 +    ///
  21.783 +    /// The shortest path tree used here is equal to the shortest path
  21.784 +    /// tree used in \ref predNode() and \ref predMap().
  21.785 +    ///
  21.786 +    /// \pre Either \ref run() or \ref init() must be called before
  21.787 +    /// using this function.
  21.788 +    Arc predArc(Node v) const { return (*_pred)[v]; }
  21.789 +
  21.790 +    /// \brief Returns the 'previous node' of the shortest path tree for
  21.791 +    /// the given node.
  21.792 +    ///
  21.793 +    /// This function returns the 'previous node' of the shortest path
  21.794 +    /// tree for node \c v, i.e. it returns the last but one node of
  21.795 +    /// a shortest path from a root to \c v. It is \c INVALID if \c v
  21.796 +    /// is not reached from the root(s) or if \c v is a root.
  21.797 +    ///
  21.798 +    /// The shortest path tree used here is equal to the shortest path
  21.799 +    /// tree used in \ref predArc() and \ref predMap().
  21.800 +    ///
  21.801 +    /// \pre Either \ref run() or \ref init() must be called before
  21.802 +    /// using this function.
  21.803 +    Node predNode(Node v) const {
  21.804 +      return (*_pred)[v] == INVALID ? INVALID : _gr->source((*_pred)[v]);
  21.805 +    }
  21.806 +
  21.807 +    /// \brief Returns a const reference to the node map that stores the
  21.808 +    /// distances of the nodes.
  21.809 +    ///
  21.810 +    /// Returns a const reference to the node map that stores the distances
  21.811 +    /// of the nodes calculated by the algorithm.
  21.812 +    ///
  21.813 +    /// \pre Either \ref run() or \ref init() must be called before
  21.814 +    /// using this function.
  21.815 +    const DistMap &distMap() const { return *_dist;}
  21.816 +
  21.817 +    /// \brief Returns a const reference to the node map that stores the
  21.818 +    /// predecessor arcs.
  21.819 +    ///
  21.820 +    /// Returns a const reference to the node map that stores the predecessor
  21.821 +    /// arcs, which form the shortest path tree (forest).
  21.822 +    ///
  21.823 +    /// \pre Either \ref run() or \ref init() must be called before
  21.824 +    /// using this function.
  21.825 +    const PredMap &predMap() const { return *_pred; }
  21.826 +
  21.827 +    /// \brief Checks if a node is reached from the root(s).
  21.828 +    ///
  21.829 +    /// Returns \c true if \c v is reached from the root(s).
  21.830 +    ///
  21.831 +    /// \pre Either \ref run() or \ref init() must be called before
  21.832 +    /// using this function.
  21.833 +    bool reached(Node v) const {
  21.834 +      return (*_dist)[v] != OperationTraits::infinity();
  21.835 +    }
  21.836 +
  21.837 +    /// \brief Gives back a negative cycle.
  21.838 +    ///
  21.839 +    /// This function gives back a directed cycle with negative total
  21.840 +    /// length if the algorithm has already found one.
  21.841 +    /// Otherwise it gives back an empty path.
  21.842 +    lemon::Path<Digraph> negativeCycle() const {
  21.843 +      typename Digraph::template NodeMap<int> state(*_gr, -1);
  21.844 +      lemon::Path<Digraph> cycle;
  21.845 +      for (int i = 0; i < int(_process.size()); ++i) {
  21.846 +        if (state[_process[i]] != -1) continue;
  21.847 +        for (Node v = _process[i]; (*_pred)[v] != INVALID;
  21.848 +             v = _gr->source((*_pred)[v])) {
  21.849 +          if (state[v] == i) {
  21.850 +            cycle.addFront((*_pred)[v]);
  21.851 +            for (Node u = _gr->source((*_pred)[v]); u != v;
  21.852 +                 u = _gr->source((*_pred)[u])) {
  21.853 +              cycle.addFront((*_pred)[u]);
  21.854 +            }
  21.855 +            return cycle;
  21.856 +          }
  21.857 +          else if (state[v] >= 0) {
  21.858 +            break;
  21.859 +          }
  21.860 +          state[v] = i;
  21.861 +        }
  21.862 +      }
  21.863 +      return cycle;
  21.864 +    }
  21.865 +
  21.866 +    ///@}
  21.867 +  };
  21.868 +
  21.869 +  /// \brief Default traits class of bellmanFord() function.
  21.870 +  ///
  21.871 +  /// Default traits class of bellmanFord() function.
  21.872 +  /// \tparam GR The type of the digraph.
  21.873 +  /// \tparam LEN The type of the length map.
  21.874 +  template <typename GR, typename LEN>
  21.875 +  struct BellmanFordWizardDefaultTraits {
  21.876 +    /// The type of the digraph the algorithm runs on.
  21.877 +    typedef GR Digraph;
  21.878 +
  21.879 +    /// \brief The type of the map that stores the arc lengths.
  21.880 +    ///
  21.881 +    /// The type of the map that stores the arc lengths.
  21.882 +    /// It must meet the \ref concepts::ReadMap "ReadMap" concept.
  21.883 +    typedef LEN LengthMap;
  21.884 +
  21.885 +    /// The type of the arc lengths.
  21.886 +    typedef typename LEN::Value Value;
  21.887 +
  21.888 +    /// \brief Operation traits for Bellman-Ford algorithm.
  21.889 +    ///
  21.890 +    /// It defines the used operations and the infinity value for the
  21.891 +    /// given \c Value type.
  21.892 +    /// \see BellmanFordDefaultOperationTraits,
  21.893 +    /// BellmanFordToleranceOperationTraits
  21.894 +    typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
  21.895 +
  21.896 +    /// \brief The type of the map that stores the last
  21.897 +    /// arcs of the shortest paths.
  21.898 +    ///
  21.899 +    /// The type of the map that stores the last arcs of the shortest paths.
  21.900 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  21.901 +    typedef typename GR::template NodeMap<typename GR::Arc> PredMap;
  21.902 +
  21.903 +    /// \brief Instantiates a \c PredMap.
  21.904 +    ///
  21.905 +    /// This function instantiates a \ref PredMap.
  21.906 +    /// \param g is the digraph to which we would like to define the
  21.907 +    /// \ref PredMap.
  21.908 +    static PredMap *createPredMap(const GR &g) {
  21.909 +      return new PredMap(g);
  21.910 +    }
  21.911 +
  21.912 +    /// \brief The type of the map that stores the distances of the nodes.
  21.913 +    ///
  21.914 +    /// The type of the map that stores the distances of the nodes.
  21.915 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  21.916 +    typedef typename GR::template NodeMap<Value> DistMap;
  21.917 +
  21.918 +    /// \brief Instantiates a \c DistMap.
  21.919 +    ///
  21.920 +    /// This function instantiates a \ref DistMap.
  21.921 +    /// \param g is the digraph to which we would like to define the
  21.922 +    /// \ref DistMap.
  21.923 +    static DistMap *createDistMap(const GR &g) {
  21.924 +      return new DistMap(g);
  21.925 +    }
  21.926 +
  21.927 +    ///The type of the shortest paths.
  21.928 +
  21.929 +    ///The type of the shortest paths.
  21.930 +    ///It must meet the \ref concepts::Path "Path" concept.
  21.931 +    typedef lemon::Path<Digraph> Path;
  21.932 +  };
  21.933 +
  21.934 +  /// \brief Default traits class used by BellmanFordWizard.
  21.935 +  ///
  21.936 +  /// Default traits class used by BellmanFordWizard.
  21.937 +  /// \tparam GR The type of the digraph.
  21.938 +  /// \tparam LEN The type of the length map.
  21.939 +  template <typename GR, typename LEN>
  21.940 +  class BellmanFordWizardBase
  21.941 +    : public BellmanFordWizardDefaultTraits<GR, LEN> {
  21.942 +
  21.943 +    typedef BellmanFordWizardDefaultTraits<GR, LEN> Base;
  21.944 +  protected:
  21.945 +    // Type of the nodes in the digraph.
  21.946 +    typedef typename Base::Digraph::Node Node;
  21.947 +
  21.948 +    // Pointer to the underlying digraph.
  21.949 +    void *_graph;
  21.950 +    // Pointer to the length map
  21.951 +    void *_length;
  21.952 +    // Pointer to the map of predecessors arcs.
  21.953 +    void *_pred;
  21.954 +    // Pointer to the map of distances.
  21.955 +    void *_dist;
  21.956 +    //Pointer to the shortest path to the target node.
  21.957 +    void *_path;
  21.958 +    //Pointer to the distance of the target node.
  21.959 +    void *_di;
  21.960 +
  21.961 +    public:
  21.962 +    /// Constructor.
  21.963 +
  21.964 +    /// This constructor does not require parameters, it initiates
  21.965 +    /// all of the attributes to default values \c 0.
  21.966 +    BellmanFordWizardBase() :
  21.967 +      _graph(0), _length(0), _pred(0), _dist(0), _path(0), _di(0) {}
  21.968 +
  21.969 +    /// Constructor.
  21.970 +
  21.971 +    /// This constructor requires two parameters,
  21.972 +    /// others are initiated to \c 0.
  21.973 +    /// \param gr The digraph the algorithm runs on.
  21.974 +    /// \param len The length map.
  21.975 +    BellmanFordWizardBase(const GR& gr,
  21.976 +                          const LEN& len) :
  21.977 +      _graph(reinterpret_cast<void*>(const_cast<GR*>(&gr))),
  21.978 +      _length(reinterpret_cast<void*>(const_cast<LEN*>(&len))),
  21.979 +      _pred(0), _dist(0), _path(0), _di(0) {}
  21.980 +
  21.981 +  };
  21.982 +
  21.983 +  /// \brief Auxiliary class for the function-type interface of the
  21.984 +  /// \ref BellmanFord "Bellman-Ford" algorithm.
  21.985 +  ///
  21.986 +  /// This auxiliary class is created to implement the
  21.987 +  /// \ref bellmanFord() "function-type interface" of the
  21.988 +  /// \ref BellmanFord "Bellman-Ford" algorithm.
  21.989 +  /// It does not have own \ref run() method, it uses the
  21.990 +  /// functions and features of the plain \ref BellmanFord.
  21.991 +  ///
  21.992 +  /// This class should only be used through the \ref bellmanFord()
  21.993 +  /// function, which makes it easier to use the algorithm.
  21.994 +  ///
  21.995 +  /// \tparam TR The traits class that defines various types used by the
  21.996 +  /// algorithm.
  21.997 +  template<class TR>
  21.998 +  class BellmanFordWizard : public TR {
  21.999 +    typedef TR Base;
 21.1000 +
 21.1001 +    typedef typename TR::Digraph Digraph;
 21.1002 +
 21.1003 +    typedef typename Digraph::Node Node;
 21.1004 +    typedef typename Digraph::NodeIt NodeIt;
 21.1005 +    typedef typename Digraph::Arc Arc;
 21.1006 +    typedef typename Digraph::OutArcIt ArcIt;
 21.1007 +
 21.1008 +    typedef typename TR::LengthMap LengthMap;
 21.1009 +    typedef typename LengthMap::Value Value;
 21.1010 +    typedef typename TR::PredMap PredMap;
 21.1011 +    typedef typename TR::DistMap DistMap;
 21.1012 +    typedef typename TR::Path Path;
 21.1013 +
 21.1014 +  public:
 21.1015 +    /// Constructor.
 21.1016 +    BellmanFordWizard() : TR() {}
 21.1017 +
 21.1018 +    /// \brief Constructor that requires parameters.
 21.1019 +    ///
 21.1020 +    /// Constructor that requires parameters.
 21.1021 +    /// These parameters will be the default values for the traits class.
 21.1022 +    /// \param gr The digraph the algorithm runs on.
 21.1023 +    /// \param len The length map.
 21.1024 +    BellmanFordWizard(const Digraph& gr, const LengthMap& len)
 21.1025 +      : TR(gr, len) {}
 21.1026 +
 21.1027 +    /// \brief Copy constructor
 21.1028 +    BellmanFordWizard(const TR &b) : TR(b) {}
 21.1029 +
 21.1030 +    ~BellmanFordWizard() {}
 21.1031 +
 21.1032 +    /// \brief Runs the Bellman-Ford algorithm from the given source node.
 21.1033 +    ///
 21.1034 +    /// This method runs the Bellman-Ford algorithm from the given source
 21.1035 +    /// node in order to compute the shortest path to each node.
 21.1036 +    void run(Node s) {
 21.1037 +      BellmanFord<Digraph,LengthMap,TR>
 21.1038 +        bf(*reinterpret_cast<const Digraph*>(Base::_graph),
 21.1039 +           *reinterpret_cast<const LengthMap*>(Base::_length));
 21.1040 +      if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
 21.1041 +      if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
 21.1042 +      bf.run(s);
 21.1043 +    }
 21.1044 +
 21.1045 +    /// \brief Runs the Bellman-Ford algorithm to find the shortest path
 21.1046 +    /// between \c s and \c t.
 21.1047 +    ///
 21.1048 +    /// This method runs the Bellman-Ford algorithm from node \c s
 21.1049 +    /// in order to compute the shortest path to node \c t.
 21.1050 +    /// Actually, it computes the shortest path to each node, but using
 21.1051 +    /// this function you can retrieve the distance and the shortest path
 21.1052 +    /// for a single target node easier.
 21.1053 +    ///
 21.1054 +    /// \return \c true if \c t is reachable form \c s.
 21.1055 +    bool run(Node s, Node t) {
 21.1056 +      BellmanFord<Digraph,LengthMap,TR>
 21.1057 +        bf(*reinterpret_cast<const Digraph*>(Base::_graph),
 21.1058 +           *reinterpret_cast<const LengthMap*>(Base::_length));
 21.1059 +      if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
 21.1060 +      if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
 21.1061 +      bf.run(s);
 21.1062 +      if (Base::_path) *reinterpret_cast<Path*>(Base::_path) = bf.path(t);
 21.1063 +      if (Base::_di) *reinterpret_cast<Value*>(Base::_di) = bf.dist(t);
 21.1064 +      return bf.reached(t);
 21.1065 +    }
 21.1066 +
 21.1067 +    template<class T>
 21.1068 +    struct SetPredMapBase : public Base {
 21.1069 +      typedef T PredMap;
 21.1070 +      static PredMap *createPredMap(const Digraph &) { return 0; };
 21.1071 +      SetPredMapBase(const TR &b) : TR(b) {}
 21.1072 +    };
 21.1073 +
 21.1074 +    /// \brief \ref named-templ-param "Named parameter" for setting
 21.1075 +    /// the predecessor map.
 21.1076 +    ///
 21.1077 +    /// \ref named-templ-param "Named parameter" for setting
 21.1078 +    /// the map that stores the predecessor arcs of the nodes.
 21.1079 +    template<class T>
 21.1080 +    BellmanFordWizard<SetPredMapBase<T> > predMap(const T &t) {
 21.1081 +      Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
 21.1082 +      return BellmanFordWizard<SetPredMapBase<T> >(*this);
 21.1083 +    }
 21.1084 +
 21.1085 +    template<class T>
 21.1086 +    struct SetDistMapBase : public Base {
 21.1087 +      typedef T DistMap;
 21.1088 +      static DistMap *createDistMap(const Digraph &) { return 0; };
 21.1089 +      SetDistMapBase(const TR &b) : TR(b) {}
 21.1090 +    };
 21.1091 +
 21.1092 +    /// \brief \ref named-templ-param "Named parameter" for setting
 21.1093 +    /// the distance map.
 21.1094 +    ///
 21.1095 +    /// \ref named-templ-param "Named parameter" for setting
 21.1096 +    /// the map that stores the distances of the nodes calculated
 21.1097 +    /// by the algorithm.
 21.1098 +    template<class T>
 21.1099 +    BellmanFordWizard<SetDistMapBase<T> > distMap(const T &t) {
 21.1100 +      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
 21.1101 +      return BellmanFordWizard<SetDistMapBase<T> >(*this);
 21.1102 +    }
 21.1103 +
 21.1104 +    template<class T>
 21.1105 +    struct SetPathBase : public Base {
 21.1106 +      typedef T Path;
 21.1107 +      SetPathBase(const TR &b) : TR(b) {}
 21.1108 +    };
 21.1109 +
 21.1110 +    /// \brief \ref named-func-param "Named parameter" for getting
 21.1111 +    /// the shortest path to the target node.
 21.1112 +    ///
 21.1113 +    /// \ref named-func-param "Named parameter" for getting
 21.1114 +    /// the shortest path to the target node.
 21.1115 +    template<class T>
 21.1116 +    BellmanFordWizard<SetPathBase<T> > path(const T &t)
 21.1117 +    {
 21.1118 +      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
 21.1119 +      return BellmanFordWizard<SetPathBase<T> >(*this);
 21.1120 +    }
 21.1121 +
 21.1122 +    /// \brief \ref named-func-param "Named parameter" for getting
 21.1123 +    /// the distance of the target node.
 21.1124 +    ///
 21.1125 +    /// \ref named-func-param "Named parameter" for getting
 21.1126 +    /// the distance of the target node.
 21.1127 +    BellmanFordWizard dist(const Value &d)
 21.1128 +    {
 21.1129 +      Base::_di=reinterpret_cast<void*>(const_cast<Value*>(&d));
 21.1130 +      return *this;
 21.1131 +    }
 21.1132 +
 21.1133 +  };
 21.1134 +
 21.1135 +  /// \brief Function type interface for the \ref BellmanFord "Bellman-Ford"
 21.1136 +  /// algorithm.
 21.1137 +  ///
 21.1138 +  /// \ingroup shortest_path
 21.1139 +  /// Function type interface for the \ref BellmanFord "Bellman-Ford"
 21.1140 +  /// algorithm.
 21.1141 +  ///
 21.1142 +  /// This function also has several \ref named-templ-func-param
 21.1143 +  /// "named parameters", they are declared as the members of class
 21.1144 +  /// \ref BellmanFordWizard.
 21.1145 +  /// The following examples show how to use these parameters.
 21.1146 +  /// \code
 21.1147 +  ///   // Compute shortest path from node s to each node
 21.1148 +  ///   bellmanFord(g,length).predMap(preds).distMap(dists).run(s);
 21.1149 +  ///
 21.1150 +  ///   // Compute shortest path from s to t
 21.1151 +  ///   bool reached = bellmanFord(g,length).path(p).dist(d).run(s,t);
 21.1152 +  /// \endcode
 21.1153 +  /// \warning Don't forget to put the \ref BellmanFordWizard::run() "run()"
 21.1154 +  /// to the end of the parameter list.
 21.1155 +  /// \sa BellmanFordWizard
 21.1156 +  /// \sa BellmanFord
 21.1157 +  template<typename GR, typename LEN>
 21.1158 +  BellmanFordWizard<BellmanFordWizardBase<GR,LEN> >
 21.1159 +  bellmanFord(const GR& digraph,
 21.1160 +              const LEN& length)
 21.1161 +  {
 21.1162 +    return BellmanFordWizard<BellmanFordWizardBase<GR,LEN> >(digraph, length);
 21.1163 +  }
 21.1164 +
 21.1165 +} //END OF NAMESPACE LEMON
 21.1166 +
 21.1167 +#endif
 21.1168 +
    22.1 --- a/lemon/bfs.h	Tue Dec 20 17:44:38 2011 +0100
    22.2 +++ b/lemon/bfs.h	Tue Dec 20 18:15:14 2011 +0100
    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 @@ -47,7 +47,7 @@
   22.13      ///
   22.14      ///The type of the map that stores the predecessor
   22.15      ///arcs of the shortest paths.
   22.16 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   22.17 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   22.18      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
   22.19      ///Instantiates a \c PredMap.
   22.20  
   22.21 @@ -62,7 +62,8 @@
   22.22      ///The type of the map that indicates which nodes are processed.
   22.23  
   22.24      ///The type of the map that indicates which nodes are processed.
   22.25 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   22.26 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   22.27 +    ///By default, it is a NullMap.
   22.28      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   22.29      ///Instantiates a \c ProcessedMap.
   22.30  
   22.31 @@ -81,7 +82,8 @@
   22.32      ///The type of the map that indicates which nodes are reached.
   22.33  
   22.34      ///The type of the map that indicates which nodes are reached.
   22.35 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   22.36 +    ///It must conform to
   22.37 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   22.38      typedef typename Digraph::template NodeMap<bool> ReachedMap;
   22.39      ///Instantiates a \c ReachedMap.
   22.40  
   22.41 @@ -96,7 +98,7 @@
   22.42      ///The type of the map that stores the distances of the nodes.
   22.43  
   22.44      ///The type of the map that stores the distances of the nodes.
   22.45 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   22.46 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   22.47      typedef typename Digraph::template NodeMap<int> DistMap;
   22.48      ///Instantiates a \c DistMap.
   22.49  
   22.50 @@ -120,6 +122,11 @@
   22.51    ///
   22.52    ///\tparam GR The type of the digraph the algorithm runs on.
   22.53    ///The default type is \ref ListDigraph.
   22.54 +  ///\tparam TR The traits class that defines various types used by the
   22.55 +  ///algorithm. By default, it is \ref BfsDefaultTraits
   22.56 +  ///"BfsDefaultTraits<GR>".
   22.57 +  ///In most cases, this parameter should not be set directly,
   22.58 +  ///consider to use the named template parameters instead.
   22.59  #ifdef DOXYGEN
   22.60    template <typename GR,
   22.61              typename TR>
   22.62 @@ -225,7 +232,7 @@
   22.63      ///
   22.64      ///\ref named-templ-param "Named parameter" for setting
   22.65      ///\c PredMap type.
   22.66 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   22.67 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   22.68      template <class T>
   22.69      struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
   22.70        typedef Bfs< Digraph, SetPredMapTraits<T> > Create;
   22.71 @@ -245,7 +252,7 @@
   22.72      ///
   22.73      ///\ref named-templ-param "Named parameter" for setting
   22.74      ///\c DistMap type.
   22.75 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   22.76 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   22.77      template <class T>
   22.78      struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
   22.79        typedef Bfs< Digraph, SetDistMapTraits<T> > Create;
   22.80 @@ -265,7 +272,8 @@
   22.81      ///
   22.82      ///\ref named-templ-param "Named parameter" for setting
   22.83      ///\c ReachedMap type.
   22.84 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   22.85 +    ///It must conform to
   22.86 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   22.87      template <class T>
   22.88      struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
   22.89        typedef Bfs< Digraph, SetReachedMapTraits<T> > Create;
   22.90 @@ -285,7 +293,7 @@
   22.91      ///
   22.92      ///\ref named-templ-param "Named parameter" for setting
   22.93      ///\c ProcessedMap type.
   22.94 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   22.95 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   22.96      template <class T>
   22.97      struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
   22.98        typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create;
   22.99 @@ -413,8 +421,8 @@
  22.100      ///\name Execution Control
  22.101      ///The simplest way to execute the BFS algorithm is to use one of the
  22.102      ///member functions called \ref run(Node) "run()".\n
  22.103 -    ///If you need more control on the execution, first you have to call
  22.104 -    ///\ref init(), then you can add several source nodes with
  22.105 +    ///If you need better control on the execution, you have to call
  22.106 +    ///\ref init() first, then you can add several source nodes with
  22.107      ///\ref addSource(). Finally the actual path computation can be
  22.108      ///performed with one of the \ref start() functions.
  22.109  
  22.110 @@ -700,12 +708,8 @@
  22.111  
  22.112      ///Runs the algorithm to visit all nodes in the digraph.
  22.113  
  22.114 -    ///This method runs the %BFS algorithm in order to
  22.115 -    ///compute the shortest path to each node.
  22.116 -    ///
  22.117 -    ///The algorithm computes
  22.118 -    ///- the shortest path tree (forest),
  22.119 -    ///- the distance of each node from the root(s).
  22.120 +    ///This method runs the %BFS algorithm in order to visit all nodes
  22.121 +    ///in the digraph.
  22.122      ///
  22.123      ///\note <tt>b.run(s)</tt> is just a shortcut of the following code.
  22.124      ///\code
  22.125 @@ -737,9 +741,9 @@
  22.126  
  22.127      ///@{
  22.128  
  22.129 -    ///The shortest path to a node.
  22.130 +    ///The shortest path to the given node.
  22.131  
  22.132 -    ///Returns the shortest path to a node.
  22.133 +    ///Returns the shortest path to the given node from the root(s).
  22.134      ///
  22.135      ///\warning \c t should be reached from the root(s).
  22.136      ///
  22.137 @@ -747,9 +751,9 @@
  22.138      ///must be called before using this function.
  22.139      Path path(Node t) const { return Path(*G, *_pred, t); }
  22.140  
  22.141 -    ///The distance of a node from the root(s).
  22.142 +    ///The distance of the given node from the root(s).
  22.143  
  22.144 -    ///Returns the distance of a node from the root(s).
  22.145 +    ///Returns the distance of the given node from the root(s).
  22.146      ///
  22.147      ///\warning If node \c v is not reached from the root(s), then
  22.148      ///the return value of this function is undefined.
  22.149 @@ -758,29 +762,31 @@
  22.150      ///must be called before using this function.
  22.151      int dist(Node v) const { return (*_dist)[v]; }
  22.152  
  22.153 -    ///Returns the 'previous arc' of the shortest path tree for a node.
  22.154 -
  22.155 +    ///\brief Returns the 'previous arc' of the shortest path tree for
  22.156 +    ///the given node.
  22.157 +    ///
  22.158      ///This function returns the 'previous arc' of the shortest path
  22.159      ///tree for the node \c v, i.e. it returns the last arc of a
  22.160      ///shortest path from a root to \c v. It is \c INVALID if \c v
  22.161      ///is not reached from the root(s) or if \c v is a root.
  22.162      ///
  22.163      ///The shortest path tree used here is equal to the shortest path
  22.164 -    ///tree used in \ref predNode().
  22.165 +    ///tree used in \ref predNode() and \ref predMap().
  22.166      ///
  22.167      ///\pre Either \ref run(Node) "run()" or \ref init()
  22.168      ///must be called before using this function.
  22.169      Arc predArc(Node v) const { return (*_pred)[v];}
  22.170  
  22.171 -    ///Returns the 'previous node' of the shortest path tree for a node.
  22.172 -
  22.173 +    ///\brief Returns the 'previous node' of the shortest path tree for
  22.174 +    ///the given node.
  22.175 +    ///
  22.176      ///This function returns the 'previous node' of the shortest path
  22.177      ///tree for the node \c v, i.e. it returns the last but one node
  22.178 -    ///from a shortest path from a root to \c v. It is \c INVALID
  22.179 +    ///of a shortest path from a root to \c v. It is \c INVALID
  22.180      ///if \c v is not reached from the root(s) or if \c v is a root.
  22.181      ///
  22.182      ///The shortest path tree used here is equal to the shortest path
  22.183 -    ///tree used in \ref predArc().
  22.184 +    ///tree used in \ref predArc() and \ref predMap().
  22.185      ///
  22.186      ///\pre Either \ref run(Node) "run()" or \ref init()
  22.187      ///must be called before using this function.
  22.188 @@ -801,13 +807,13 @@
  22.189      ///predecessor arcs.
  22.190      ///
  22.191      ///Returns a const reference to the node map that stores the predecessor
  22.192 -    ///arcs, which form the shortest path tree.
  22.193 +    ///arcs, which form the shortest path tree (forest).
  22.194      ///
  22.195      ///\pre Either \ref run(Node) "run()" or \ref init()
  22.196      ///must be called before using this function.
  22.197      const PredMap &predMap() const { return *_pred;}
  22.198  
  22.199 -    ///Checks if a node is reached from the root(s).
  22.200 +    ///Checks if the given node is reached from the root(s).
  22.201  
  22.202      ///Returns \c true if \c v is reached from the root(s).
  22.203      ///
  22.204 @@ -833,7 +839,7 @@
  22.205      ///
  22.206      ///The type of the map that stores the predecessor
  22.207      ///arcs of the shortest paths.
  22.208 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  22.209 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  22.210      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
  22.211      ///Instantiates a PredMap.
  22.212  
  22.213 @@ -848,8 +854,8 @@
  22.214      ///The type of the map that indicates which nodes are processed.
  22.215  
  22.216      ///The type of the map that indicates which nodes are processed.
  22.217 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  22.218 -    ///By default it is a NullMap.
  22.219 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  22.220 +    ///By default, it is a NullMap.
  22.221      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
  22.222      ///Instantiates a ProcessedMap.
  22.223  
  22.224 @@ -868,7 +874,8 @@
  22.225      ///The type of the map that indicates which nodes are reached.
  22.226  
  22.227      ///The type of the map that indicates which nodes are reached.
  22.228 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  22.229 +    ///It must conform to
  22.230 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  22.231      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  22.232      ///Instantiates a ReachedMap.
  22.233  
  22.234 @@ -883,7 +890,7 @@
  22.235      ///The type of the map that stores the distances of the nodes.
  22.236  
  22.237      ///The type of the map that stores the distances of the nodes.
  22.238 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  22.239 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  22.240      typedef typename Digraph::template NodeMap<int> DistMap;
  22.241      ///Instantiates a DistMap.
  22.242  
  22.243 @@ -898,18 +905,14 @@
  22.244      ///The type of the shortest paths.
  22.245  
  22.246      ///The type of the shortest paths.
  22.247 -    ///It must meet the \ref concepts::Path "Path" concept.
  22.248 +    ///It must conform to the \ref concepts::Path "Path" concept.
  22.249      typedef lemon::Path<Digraph> Path;
  22.250    };
  22.251  
  22.252    /// Default traits class used by BfsWizard
  22.253  
  22.254 -  /// To make it easier to use Bfs algorithm
  22.255 -  /// we have created a wizard class.
  22.256 -  /// This \ref BfsWizard class needs default traits,
  22.257 -  /// as well as the \ref Bfs class.
  22.258 -  /// The \ref BfsWizardBase is a class to be the default traits of the
  22.259 -  /// \ref BfsWizard class.
  22.260 +  /// Default traits class used by BfsWizard.
  22.261 +  /// \tparam GR The type of the digraph.
  22.262    template<class GR>
  22.263    class BfsWizardBase : public BfsWizardDefaultTraits<GR>
  22.264    {
  22.265 @@ -937,7 +940,7 @@
  22.266      public:
  22.267      /// Constructor.
  22.268  
  22.269 -    /// This constructor does not require parameters, therefore it initiates
  22.270 +    /// This constructor does not require parameters, it initiates
  22.271      /// all of the attributes to \c 0.
  22.272      BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
  22.273                        _dist(0), _path(0), _di(0) {}
  22.274 @@ -962,12 +965,14 @@
  22.275    ///
  22.276    /// This class should only be used through the \ref bfs() function,
  22.277    /// which makes it easier to use the algorithm.
  22.278 +  ///
  22.279 +  /// \tparam TR The traits class that defines various types used by the
  22.280 +  /// algorithm.
  22.281    template<class TR>
  22.282    class BfsWizard : public TR
  22.283    {
  22.284      typedef TR Base;
  22.285  
  22.286 -    ///The type of the digraph the algorithm runs on.
  22.287      typedef typename TR::Digraph Digraph;
  22.288  
  22.289      typedef typename Digraph::Node Node;
  22.290 @@ -975,16 +980,10 @@
  22.291      typedef typename Digraph::Arc Arc;
  22.292      typedef typename Digraph::OutArcIt OutArcIt;
  22.293  
  22.294 -    ///\brief The type of the map that stores the predecessor
  22.295 -    ///arcs of the shortest paths.
  22.296      typedef typename TR::PredMap PredMap;
  22.297 -    ///\brief The type of the map that stores the distances of the nodes.
  22.298      typedef typename TR::DistMap DistMap;
  22.299 -    ///\brief The type of the map that indicates which nodes are reached.
  22.300      typedef typename TR::ReachedMap ReachedMap;
  22.301 -    ///\brief The type of the map that indicates which nodes are processed.
  22.302      typedef typename TR::ProcessedMap ProcessedMap;
  22.303 -    ///The type of the shortest paths
  22.304      typedef typename TR::Path Path;
  22.305  
  22.306    public:
  22.307 @@ -1054,8 +1053,8 @@
  22.308  
  22.309      ///Runs BFS algorithm to visit all nodes in the digraph.
  22.310  
  22.311 -    ///This method runs BFS algorithm in order to compute
  22.312 -    ///the shortest path to each node.
  22.313 +    ///This method runs BFS algorithm in order to visit all nodes
  22.314 +    ///in the digraph.
  22.315      void run()
  22.316      {
  22.317        run(INVALID);
  22.318 @@ -1067,11 +1066,12 @@
  22.319        static PredMap *createPredMap(const Digraph &) { return 0; };
  22.320        SetPredMapBase(const TR &b) : TR(b) {}
  22.321      };
  22.322 -    ///\brief \ref named-func-param "Named parameter"
  22.323 -    ///for setting PredMap object.
  22.324 +
  22.325 +    ///\brief \ref named-templ-param "Named parameter" for setting
  22.326 +    ///the predecessor map.
  22.327      ///
  22.328 -    ///\ref named-func-param "Named parameter"
  22.329 -    ///for setting PredMap object.
  22.330 +    ///\ref named-templ-param "Named parameter" function for setting
  22.331 +    ///the map that stores the predecessor arcs of the nodes.
  22.332      template<class T>
  22.333      BfsWizard<SetPredMapBase<T> > predMap(const T &t)
  22.334      {
  22.335 @@ -1085,11 +1085,12 @@
  22.336        static ReachedMap *createReachedMap(const Digraph &) { return 0; };
  22.337        SetReachedMapBase(const TR &b) : TR(b) {}
  22.338      };
  22.339 -    ///\brief \ref named-func-param "Named parameter"
  22.340 -    ///for setting ReachedMap object.
  22.341 +
  22.342 +    ///\brief \ref named-templ-param "Named parameter" for setting
  22.343 +    ///the reached map.
  22.344      ///
  22.345 -    /// \ref named-func-param "Named parameter"
  22.346 -    ///for setting ReachedMap object.
  22.347 +    ///\ref named-templ-param "Named parameter" function for setting
  22.348 +    ///the map that indicates which nodes are reached.
  22.349      template<class T>
  22.350      BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
  22.351      {
  22.352 @@ -1103,11 +1104,13 @@
  22.353        static DistMap *createDistMap(const Digraph &) { return 0; };
  22.354        SetDistMapBase(const TR &b) : TR(b) {}
  22.355      };
  22.356 -    ///\brief \ref named-func-param "Named parameter"
  22.357 -    ///for setting DistMap object.
  22.358 +
  22.359 +    ///\brief \ref named-templ-param "Named parameter" for setting
  22.360 +    ///the distance map.
  22.361      ///
  22.362 -    /// \ref named-func-param "Named parameter"
  22.363 -    ///for setting DistMap object.
  22.364 +    ///\ref named-templ-param "Named parameter" function for setting
  22.365 +    ///the map that stores the distances of the nodes calculated
  22.366 +    ///by the algorithm.
  22.367      template<class T>
  22.368      BfsWizard<SetDistMapBase<T> > distMap(const T &t)
  22.369      {
  22.370 @@ -1121,11 +1124,12 @@
  22.371        static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
  22.372        SetProcessedMapBase(const TR &b) : TR(b) {}
  22.373      };
  22.374 -    ///\brief \ref named-func-param "Named parameter"
  22.375 -    ///for setting ProcessedMap object.
  22.376 +
  22.377 +    ///\brief \ref named-func-param "Named parameter" for setting
  22.378 +    ///the processed map.
  22.379      ///
  22.380 -    /// \ref named-func-param "Named parameter"
  22.381 -    ///for setting ProcessedMap object.
  22.382 +    ///\ref named-templ-param "Named parameter" function for setting
  22.383 +    ///the map that indicates which nodes are processed.
  22.384      template<class T>
  22.385      BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
  22.386      {
  22.387 @@ -1264,7 +1268,8 @@
  22.388      /// \brief The type of the map that indicates which nodes are reached.
  22.389      ///
  22.390      /// The type of the map that indicates which nodes are reached.
  22.391 -    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  22.392 +    /// It must conform to
  22.393 +    ///the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  22.394      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  22.395  
  22.396      /// \brief Instantiates a ReachedMap.
  22.397 @@ -1302,11 +1307,11 @@
  22.398    /// \ref BfsVisitor "BfsVisitor<GR>" is an empty visitor, which
  22.399    /// does not observe the BFS events. If you want to observe the BFS
  22.400    /// events, you should implement your own visitor class.
  22.401 -  /// \tparam TR Traits class to set various data types used by the
  22.402 -  /// algorithm. The default traits class is
  22.403 -  /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<GR>".
  22.404 -  /// See \ref BfsVisitDefaultTraits for the documentation of
  22.405 -  /// a BFS visit traits class.
  22.406 +  /// \tparam TR The traits class that defines various types used by the
  22.407 +  /// algorithm. By default, it is \ref BfsVisitDefaultTraits
  22.408 +  /// "BfsVisitDefaultTraits<GR>".
  22.409 +  /// In most cases, this parameter should not be set directly,
  22.410 +  /// consider to use the named template parameters instead.
  22.411  #ifdef DOXYGEN
  22.412    template <typename GR, typename VS, typename TR>
  22.413  #else
  22.414 @@ -1425,8 +1430,8 @@
  22.415      /// \name Execution Control
  22.416      /// The simplest way to execute the BFS algorithm is to use one of the
  22.417      /// member functions called \ref run(Node) "run()".\n
  22.418 -    /// If you need more control on the execution, first you have to call
  22.419 -    /// \ref init(), then you can add several source nodes with
  22.420 +    /// If you need better control on the execution, you have to call
  22.421 +    /// \ref init() first, then you can add several source nodes with
  22.422      /// \ref addSource(). Finally the actual path computation can be
  22.423      /// performed with one of the \ref start() functions.
  22.424  
  22.425 @@ -1698,12 +1703,8 @@
  22.426  
  22.427      /// \brief Runs the algorithm to visit all nodes in the digraph.
  22.428      ///
  22.429 -    /// This method runs the %BFS algorithm in order to
  22.430 -    /// compute the shortest path to each node.
  22.431 -    ///
  22.432 -    /// The algorithm computes
  22.433 -    /// - the shortest path tree (forest),
  22.434 -    /// - the distance of each node from the root(s).
  22.435 +    /// This method runs the %BFS algorithm in order to visit all nodes
  22.436 +    /// in the digraph.
  22.437      ///
  22.438      /// \note <tt>b.run(s)</tt> is just a shortcut of the following code.
  22.439      ///\code
  22.440 @@ -1735,7 +1736,7 @@
  22.441  
  22.442      ///@{
  22.443  
  22.444 -    /// \brief Checks if a node is reached from the root(s).
  22.445 +    /// \brief Checks if the given node is reached from the root(s).
  22.446      ///
  22.447      /// Returns \c true if \c v is reached from the root(s).
  22.448      ///
    23.1 --- a/lemon/bin_heap.h	Tue Dec 20 17:44:38 2011 +0100
    23.2 +++ b/lemon/bin_heap.h	Tue Dec 20 18:15:14 2011 +0100
    23.3 @@ -19,9 +19,9 @@
    23.4  #ifndef LEMON_BIN_HEAP_H
    23.5  #define LEMON_BIN_HEAP_H
    23.6  
    23.7 -///\ingroup auxdat
    23.8 +///\ingroup heaps
    23.9  ///\file
   23.10 -///\brief Binary Heap implementation.
   23.11 +///\brief Binary heap implementation.
   23.12  
   23.13  #include <vector>
   23.14  #include <utility>
   23.15 @@ -29,45 +29,41 @@
   23.16  
   23.17  namespace lemon {
   23.18  
   23.19 -  ///\ingroup auxdat
   23.20 +  /// \ingroup heaps
   23.21    ///
   23.22 -  ///\brief A Binary Heap implementation.
   23.23 +  /// \brief Binary heap data structure.
   23.24    ///
   23.25 -  ///This class implements the \e binary \e heap data structure.
   23.26 +  /// This class implements the \e binary \e heap data structure.
   23.27 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   23.28    ///
   23.29 -  ///A \e heap is a data structure for storing items with specified values
   23.30 -  ///called \e priorities in such a way that finding the item with minimum
   23.31 -  ///priority is efficient. \c CMP specifies the ordering of the priorities.
   23.32 -  ///In a heap one can change the priority of an item, add or erase an
   23.33 -  ///item, etc.
   23.34 -  ///
   23.35 -  ///\tparam PR Type of the priority of the items.
   23.36 -  ///\tparam IM A read and writable item map with int values, used internally
   23.37 -  ///to handle the cross references.
   23.38 -  ///\tparam CMP A functor class for the ordering of the priorities.
   23.39 -  ///The default is \c std::less<PR>.
   23.40 -  ///
   23.41 -  ///\sa FibHeap
   23.42 -  ///\sa Dijkstra
   23.43 +  /// \tparam PR Type of the priorities of the items.
   23.44 +  /// \tparam IM A read-writable item map with \c int values, used
   23.45 +  /// internally to handle the cross references.
   23.46 +  /// \tparam CMP A functor class for comparing the priorities.
   23.47 +  /// The default is \c std::less<PR>.
   23.48 +#ifdef DOXYGEN
   23.49 +  template <typename PR, typename IM, typename CMP>
   23.50 +#else
   23.51    template <typename PR, typename IM, typename CMP = std::less<PR> >
   23.52 +#endif
   23.53    class BinHeap {
   23.54 +  public:
   23.55  
   23.56 -  public:
   23.57 -    ///\e
   23.58 +    /// Type of the item-int map.
   23.59      typedef IM ItemIntMap;
   23.60 -    ///\e
   23.61 +    /// Type of the priorities.
   23.62      typedef PR Prio;
   23.63 -    ///\e
   23.64 +    /// Type of the items stored in the heap.
   23.65      typedef typename ItemIntMap::Key Item;
   23.66 -    ///\e
   23.67 +    /// Type of the item-priority pairs.
   23.68      typedef std::pair<Item,Prio> Pair;
   23.69 -    ///\e
   23.70 +    /// Functor type for comparing the priorities.
   23.71      typedef CMP Compare;
   23.72  
   23.73 -    /// \brief Type to represent the items states.
   23.74 +    /// \brief Type to represent the states of the items.
   23.75      ///
   23.76 -    /// Each Item element have a state associated to it. It may be "in heap",
   23.77 -    /// "pre heap" or "post heap". The latter two are indifferent from the
   23.78 +    /// Each item has a state associated to it. It can be "in heap",
   23.79 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   23.80      /// heap's point of view, but may be useful to the user.
   23.81      ///
   23.82      /// The item-int map must be initialized in such way that it assigns
   23.83 @@ -84,42 +80,43 @@
   23.84      ItemIntMap &_iim;
   23.85  
   23.86    public:
   23.87 -    /// \brief The constructor.
   23.88 +
   23.89 +    /// \brief Constructor.
   23.90      ///
   23.91 -    /// The constructor.
   23.92 -    /// \param map should be given to the constructor, since it is used
   23.93 -    /// internally to handle the cross references. The value of the map
   23.94 -    /// must be \c PRE_HEAP (<tt>-1</tt>) for every item.
   23.95 +    /// Constructor.
   23.96 +    /// \param map A map that assigns \c int values to the items.
   23.97 +    /// It is used internally to handle the cross references.
   23.98 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
   23.99      explicit BinHeap(ItemIntMap &map) : _iim(map) {}
  23.100  
  23.101 -    /// \brief The constructor.
  23.102 +    /// \brief Constructor.
  23.103      ///
  23.104 -    /// The constructor.
  23.105 -    /// \param map should be given to the constructor, since it is used
  23.106 -    /// internally to handle the cross references. The value of the map
  23.107 -    /// should be PRE_HEAP (-1) for each element.
  23.108 -    ///
  23.109 -    /// \param comp The comparator function object.
  23.110 +    /// Constructor.
  23.111 +    /// \param map A map that assigns \c int values to the items.
  23.112 +    /// It is used internally to handle the cross references.
  23.113 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  23.114 +    /// \param comp The function object used for comparing the priorities.
  23.115      BinHeap(ItemIntMap &map, const Compare &comp)
  23.116        : _iim(map), _comp(comp) {}
  23.117  
  23.118  
  23.119 -    /// The number of items stored in the heap.
  23.120 +    /// \brief The number of items stored in the heap.
  23.121      ///
  23.122 -    /// \brief Returns the number of items stored in the heap.
  23.123 +    /// This function returns the number of items stored in the heap.
  23.124      int size() const { return _data.size(); }
  23.125  
  23.126 -    /// \brief Checks if the heap stores no items.
  23.127 +    /// \brief Check if the heap is empty.
  23.128      ///
  23.129 -    /// Returns \c true if and only if the heap stores no items.
  23.130 +    /// This function returns \c true if the heap is empty.
  23.131      bool empty() const { return _data.empty(); }
  23.132  
  23.133 -    /// \brief Make empty this heap.
  23.134 +    /// \brief Make the heap empty.
  23.135      ///
  23.136 -    /// Make empty this heap. It does not change the cross reference map.
  23.137 -    /// If you want to reuse what is not surely empty you should first clear
  23.138 -    /// the heap and after that you should set the cross reference map for
  23.139 -    /// each item to \c PRE_HEAP.
  23.140 +    /// This functon makes the heap empty.
  23.141 +    /// It does not change the cross reference map. If you want to reuse
  23.142 +    /// a heap that is not surely empty, you should first clear it and
  23.143 +    /// then you should set the cross reference map to \c PRE_HEAP
  23.144 +    /// for each item.
  23.145      void clear() {
  23.146        _data.clear();
  23.147      }
  23.148 @@ -127,12 +124,12 @@
  23.149    private:
  23.150      static int parent(int i) { return (i-1)/2; }
  23.151  
  23.152 -    static int second_child(int i) { return 2*i+2; }
  23.153 +    static int secondChild(int i) { return 2*i+2; }
  23.154      bool less(const Pair &p1, const Pair &p2) const {
  23.155        return _comp(p1.second, p2.second);
  23.156      }
  23.157  
  23.158 -    int bubble_up(int hole, Pair p) {
  23.159 +    int bubbleUp(int hole, Pair p) {
  23.160        int par = parent(hole);
  23.161        while( hole>0 && less(p,_data[par]) ) {
  23.162          move(_data[par],hole);
  23.163 @@ -143,8 +140,8 @@
  23.164        return hole;
  23.165      }
  23.166  
  23.167 -    int bubble_down(int hole, Pair p, int length) {
  23.168 -      int child = second_child(hole);
  23.169 +    int bubbleDown(int hole, Pair p, int length) {
  23.170 +      int child = secondChild(hole);
  23.171        while(child < length) {
  23.172          if( less(_data[child-1], _data[child]) ) {
  23.173            --child;
  23.174 @@ -153,7 +150,7 @@
  23.175            goto ok;
  23.176          move(_data[child], hole);
  23.177          hole = child;
  23.178 -        child = second_child(hole);
  23.179 +        child = secondChild(hole);
  23.180        }
  23.181        child--;
  23.182        if( child<length && less(_data[child], p) ) {
  23.183 @@ -171,87 +168,91 @@
  23.184      }
  23.185  
  23.186    public:
  23.187 +
  23.188      /// \brief Insert a pair of item and priority into the heap.
  23.189      ///
  23.190 -    /// Adds \c p.first to the heap with priority \c p.second.
  23.191 +    /// This function inserts \c p.first to the heap with priority
  23.192 +    /// \c p.second.
  23.193      /// \param p The pair to insert.
  23.194 +    /// \pre \c p.first must not be stored in the heap.
  23.195      void push(const Pair &p) {
  23.196        int n = _data.size();
  23.197        _data.resize(n+1);
  23.198 -      bubble_up(n, p);
  23.199 +      bubbleUp(n, p);
  23.200      }
  23.201  
  23.202 -    /// \brief Insert an item into the heap with the given heap.
  23.203 +    /// \brief Insert an item into the heap with the given priority.
  23.204      ///
  23.205 -    /// Adds \c i to the heap with priority \c p.
  23.206 +    /// This function inserts the given item into the heap with the
  23.207 +    /// given priority.
  23.208      /// \param i The item to insert.
  23.209      /// \param p The priority of the item.
  23.210 +    /// \pre \e i must not be stored in the heap.
  23.211      void push(const Item &i, const Prio &p) { push(Pair(i,p)); }
  23.212  
  23.213 -    /// \brief Returns the item with minimum priority relative to \c Compare.
  23.214 +    /// \brief Return the item having minimum priority.
  23.215      ///
  23.216 -    /// This method returns the item with minimum priority relative to \c
  23.217 -    /// Compare.
  23.218 -    /// \pre The heap must be nonempty.
  23.219 +    /// This function returns the item having minimum priority.
  23.220 +    /// \pre The heap must be non-empty.
  23.221      Item top() const {
  23.222        return _data[0].first;
  23.223      }
  23.224  
  23.225 -    /// \brief Returns the minimum priority relative to \c Compare.
  23.226 +    /// \brief The minimum priority.
  23.227      ///
  23.228 -    /// It returns the minimum priority relative to \c Compare.
  23.229 -    /// \pre The heap must be nonempty.
  23.230 +    /// This function returns the minimum priority.
  23.231 +    /// \pre The heap must be non-empty.
  23.232      Prio prio() const {
  23.233        return _data[0].second;
  23.234      }
  23.235  
  23.236 -    /// \brief Deletes the item with minimum priority relative to \c Compare.
  23.237 +    /// \brief Remove the item having minimum priority.
  23.238      ///
  23.239 -    /// This method deletes the item with minimum priority relative to \c
  23.240 -    /// Compare from the heap.
  23.241 +    /// This function removes the item having minimum priority.
  23.242      /// \pre The heap must be non-empty.
  23.243      void pop() {
  23.244        int n = _data.size()-1;
  23.245        _iim.set(_data[0].first, POST_HEAP);
  23.246        if (n > 0) {
  23.247 -        bubble_down(0, _data[n], n);
  23.248 +        bubbleDown(0, _data[n], n);
  23.249        }
  23.250        _data.pop_back();
  23.251      }
  23.252  
  23.253 -    /// \brief Deletes \c i from the heap.
  23.254 +    /// \brief Remove the given item from the heap.
  23.255      ///
  23.256 -    /// This method deletes item \c i from the heap.
  23.257 -    /// \param i The item to erase.
  23.258 -    /// \pre The item should be in the heap.
  23.259 +    /// This function removes the given item from the heap if it is
  23.260 +    /// already stored.
  23.261 +    /// \param i The item to delete.
  23.262 +    /// \pre \e i must be in the heap.
  23.263      void erase(const Item &i) {
  23.264        int h = _iim[i];
  23.265        int n = _data.size()-1;
  23.266        _iim.set(_data[h].first, POST_HEAP);
  23.267        if( h < n ) {
  23.268 -        if ( bubble_up(h, _data[n]) == h) {
  23.269 -          bubble_down(h, _data[n], n);
  23.270 +        if ( bubbleUp(h, _data[n]) == h) {
  23.271 +          bubbleDown(h, _data[n], n);
  23.272          }
  23.273        }
  23.274        _data.pop_back();
  23.275      }
  23.276  
  23.277 -
  23.278 -    /// \brief Returns the priority of \c i.
  23.279 +    /// \brief The priority of the given item.
  23.280      ///
  23.281 -    /// This function returns the priority of item \c i.
  23.282 +    /// This function returns the priority of the given item.
  23.283      /// \param i The item.
  23.284 -    /// \pre \c i must be in the heap.
  23.285 +    /// \pre \e i must be in the heap.
  23.286      Prio operator[](const Item &i) const {
  23.287        int idx = _iim[i];
  23.288        return _data[idx].second;
  23.289      }
  23.290  
  23.291 -    /// \brief \c i gets to the heap with priority \c p independently
  23.292 -    /// if \c i was already there.
  23.293 +    /// \brief Set the priority of an item or insert it, if it is
  23.294 +    /// not stored in the heap.
  23.295      ///
  23.296 -    /// This method calls \ref push(\c i, \c p) if \c i is not stored
  23.297 -    /// in the heap and sets the priority of \c i to \c p otherwise.
  23.298 +    /// This method sets the priority of the given item if it is
  23.299 +    /// already stored in the heap. Otherwise it inserts the given
  23.300 +    /// item into the heap with the given priority.
  23.301      /// \param i The item.
  23.302      /// \param p The priority.
  23.303      void set(const Item &i, const Prio &p) {
  23.304 @@ -260,44 +261,42 @@
  23.305          push(i,p);
  23.306        }
  23.307        else if( _comp(p, _data[idx].second) ) {
  23.308 -        bubble_up(idx, Pair(i,p));
  23.309 +        bubbleUp(idx, Pair(i,p));
  23.310        }
  23.311        else {
  23.312 -        bubble_down(idx, Pair(i,p), _data.size());
  23.313 +        bubbleDown(idx, Pair(i,p), _data.size());
  23.314        }
  23.315      }
  23.316  
  23.317 -    /// \brief Decreases the priority of \c i to \c p.
  23.318 +    /// \brief Decrease the priority of an item to the given value.
  23.319      ///
  23.320 -    /// This method decreases the priority of item \c i to \c p.
  23.321 +    /// This function decreases the priority of an item to the given value.
  23.322      /// \param i The item.
  23.323      /// \param p The priority.
  23.324 -    /// \pre \c i must be stored in the heap with priority at least \c
  23.325 -    /// p relative to \c Compare.
  23.326 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  23.327      void decrease(const Item &i, const Prio &p) {
  23.328        int idx = _iim[i];
  23.329 -      bubble_up(idx, Pair(i,p));
  23.330 +      bubbleUp(idx, Pair(i,p));
  23.331      }
  23.332  
  23.333 -    /// \brief Increases the priority of \c i to \c p.
  23.334 +    /// \brief Increase the priority of an item to the given value.
  23.335      ///
  23.336 -    /// This method sets the priority of item \c i to \c p.
  23.337 +    /// This function increases the priority of an item to the given value.
  23.338      /// \param i The item.
  23.339      /// \param p The priority.
  23.340 -    /// \pre \c i must be stored in the heap with priority at most \c
  23.341 -    /// p relative to \c Compare.
  23.342 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  23.343      void increase(const Item &i, const Prio &p) {
  23.344        int idx = _iim[i];
  23.345 -      bubble_down(idx, Pair(i,p), _data.size());
  23.346 +      bubbleDown(idx, Pair(i,p), _data.size());
  23.347      }
  23.348  
  23.349 -    /// \brief Returns if \c item is in, has already been in, or has
  23.350 -    /// never been in the heap.
  23.351 +    /// \brief Return the state of an item.
  23.352      ///
  23.353 -    /// This method returns PRE_HEAP if \c item has never been in the
  23.354 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  23.355 -    /// otherwise. In the latter case it is possible that \c item will
  23.356 -    /// get back to the heap again.
  23.357 +    /// This method returns \c PRE_HEAP if the given item has never
  23.358 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  23.359 +    /// and \c POST_HEAP otherwise.
  23.360 +    /// In the latter case it is possible that the item will get back
  23.361 +    /// to the heap again.
  23.362      /// \param i The item.
  23.363      State state(const Item &i) const {
  23.364        int s = _iim[i];
  23.365 @@ -306,11 +305,11 @@
  23.366        return State(s);
  23.367      }
  23.368  
  23.369 -    /// \brief Sets the state of the \c item in the heap.
  23.370 +    /// \brief Set the state of an item in the heap.
  23.371      ///
  23.372 -    /// Sets the state of the \c item in the heap. It can be used to
  23.373 -    /// manually clear the heap when it is important to achive the
  23.374 -    /// better time complexity.
  23.375 +    /// This function sets the state of the given item in the heap.
  23.376 +    /// It can be used to manually clear the heap when it is important
  23.377 +    /// to achive better time complexity.
  23.378      /// \param i The item.
  23.379      /// \param st The state. It should not be \c IN_HEAP.
  23.380      void state(const Item& i, State st) {
  23.381 @@ -327,12 +326,13 @@
  23.382        }
  23.383      }
  23.384  
  23.385 -    /// \brief Replaces an item in the heap.
  23.386 +    /// \brief Replace an item in the heap.
  23.387      ///
  23.388 -    /// The \c i item is replaced with \c j item. The \c i item should
  23.389 -    /// be in the heap, while the \c j should be out of the heap. The
  23.390 -    /// \c i item will out of the heap and \c j will be in the heap
  23.391 -    /// with the same prioriority as prevoiusly the \c i item.
  23.392 +    /// This function replaces item \c i with item \c j.
  23.393 +    /// Item \c i must be in the heap, while \c j must be out of the heap.
  23.394 +    /// After calling this method, item \c i will be out of the
  23.395 +    /// heap and \c j will be in the heap with the same prioriority
  23.396 +    /// as item \c i had before.
  23.397      void replace(const Item& i, const Item& j) {
  23.398        int idx = _iim[i];
  23.399        _iim.set(i, _iim[j]);
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/lemon/binomial_heap.h	Tue Dec 20 18:15:14 2011 +0100
    24.3 @@ -0,0 +1,445 @@
    24.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    24.5 + *
    24.6 + * This file is a part of LEMON, a generic C++ optimization library.
    24.7 + *
    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 + * Permission to use, modify and distribute this software is granted
   24.13 + * provided that this copyright notice appears in all copies. For
   24.14 + * precise terms see the accompanying LICENSE file.
   24.15 + *
   24.16 + * This software is provided "AS IS" with no warranty of any kind,
   24.17 + * express or implied, and with no claim as to its suitability for any
   24.18 + * purpose.
   24.19 + *
   24.20 + */
   24.21 +
   24.22 +#ifndef LEMON_BINOMIAL_HEAP_H
   24.23 +#define LEMON_BINOMIAL_HEAP_H
   24.24 +
   24.25 +///\file
   24.26 +///\ingroup heaps
   24.27 +///\brief Binomial Heap implementation.
   24.28 +
   24.29 +#include <vector>
   24.30 +#include <utility>
   24.31 +#include <functional>
   24.32 +#include <lemon/math.h>
   24.33 +#include <lemon/counter.h>
   24.34 +
   24.35 +namespace lemon {
   24.36 +
   24.37 +  /// \ingroup heaps
   24.38 +  ///
   24.39 +  ///\brief Binomial heap data structure.
   24.40 +  ///
   24.41 +  /// This class implements the \e binomial \e heap data structure.
   24.42 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   24.43 +  ///
   24.44 +  /// The methods \ref increase() and \ref erase() are not efficient
   24.45 +  /// in a binomial heap. In case of many calls of these operations,
   24.46 +  /// it is better to use other heap structure, e.g. \ref BinHeap
   24.47 +  /// "binary heap".
   24.48 +  ///
   24.49 +  /// \tparam PR Type of the priorities of the items.
   24.50 +  /// \tparam IM A read-writable item map with \c int values, used
   24.51 +  /// internally to handle the cross references.
   24.52 +  /// \tparam CMP A functor class for comparing the priorities.
   24.53 +  /// The default is \c std::less<PR>.
   24.54 +#ifdef DOXYGEN
   24.55 +  template <typename PR, typename IM, typename CMP>
   24.56 +#else
   24.57 +  template <typename PR, typename IM, typename CMP = std::less<PR> >
   24.58 +#endif
   24.59 +  class BinomialHeap {
   24.60 +  public:
   24.61 +    /// Type of the item-int map.
   24.62 +    typedef IM ItemIntMap;
   24.63 +    /// Type of the priorities.
   24.64 +    typedef PR Prio;
   24.65 +    /// Type of the items stored in the heap.
   24.66 +    typedef typename ItemIntMap::Key Item;
   24.67 +    /// Functor type for comparing the priorities.
   24.68 +    typedef CMP Compare;
   24.69 +
   24.70 +    /// \brief Type to represent the states of the items.
   24.71 +    ///
   24.72 +    /// Each item has a state associated to it. It can be "in heap",
   24.73 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   24.74 +    /// heap's point of view, but may be useful to the user.
   24.75 +    ///
   24.76 +    /// The item-int map must be initialized in such way that it assigns
   24.77 +    /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap.
   24.78 +    enum State {
   24.79 +      IN_HEAP = 0,    ///< = 0.
   24.80 +      PRE_HEAP = -1,  ///< = -1.
   24.81 +      POST_HEAP = -2  ///< = -2.
   24.82 +    };
   24.83 +
   24.84 +  private:
   24.85 +    class Store;
   24.86 +
   24.87 +    std::vector<Store> _data;
   24.88 +    int _min, _head;
   24.89 +    ItemIntMap &_iim;
   24.90 +    Compare _comp;
   24.91 +    int _num_items;
   24.92 +
   24.93 +  public:
   24.94 +    /// \brief Constructor.
   24.95 +    ///
   24.96 +    /// Constructor.
   24.97 +    /// \param map A map that assigns \c int values to the items.
   24.98 +    /// It is used internally to handle the cross references.
   24.99 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  24.100 +    explicit BinomialHeap(ItemIntMap &map)
  24.101 +      : _min(0), _head(-1), _iim(map), _num_items(0) {}
  24.102 +
  24.103 +    /// \brief Constructor.
  24.104 +    ///
  24.105 +    /// Constructor.
  24.106 +    /// \param map A map that assigns \c int values to the items.
  24.107 +    /// It is used internally to handle the cross references.
  24.108 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  24.109 +    /// \param comp The function object used for comparing the priorities.
  24.110 +    BinomialHeap(ItemIntMap &map, const Compare &comp)
  24.111 +      : _min(0), _head(-1), _iim(map), _comp(comp), _num_items(0) {}
  24.112 +
  24.113 +    /// \brief The number of items stored in the heap.
  24.114 +    ///
  24.115 +    /// This function returns the number of items stored in the heap.
  24.116 +    int size() const { return _num_items; }
  24.117 +
  24.118 +    /// \brief Check if the heap is empty.
  24.119 +    ///
  24.120 +    /// This function returns \c true if the heap is empty.
  24.121 +    bool empty() const { return _num_items==0; }
  24.122 +
  24.123 +    /// \brief Make the heap empty.
  24.124 +    ///
  24.125 +    /// This functon makes the heap empty.
  24.126 +    /// It does not change the cross reference map. If you want to reuse
  24.127 +    /// a heap that is not surely empty, you should first clear it and
  24.128 +    /// then you should set the cross reference map to \c PRE_HEAP
  24.129 +    /// for each item.
  24.130 +    void clear() {
  24.131 +      _data.clear(); _min=0; _num_items=0; _head=-1;
  24.132 +    }
  24.133 +
  24.134 +    /// \brief Set the priority of an item or insert it, if it is
  24.135 +    /// not stored in the heap.
  24.136 +    ///
  24.137 +    /// This method sets the priority of the given item if it is
  24.138 +    /// already stored in the heap. Otherwise it inserts the given
  24.139 +    /// item into the heap with the given priority.
  24.140 +    /// \param item The item.
  24.141 +    /// \param value The priority.
  24.142 +    void set (const Item& item, const Prio& value) {
  24.143 +      int i=_iim[item];
  24.144 +      if ( i >= 0 && _data[i].in ) {
  24.145 +        if ( _comp(value, _data[i].prio) ) decrease(item, value);
  24.146 +        if ( _comp(_data[i].prio, value) ) increase(item, value);
  24.147 +      } else push(item, value);
  24.148 +    }
  24.149 +
  24.150 +    /// \brief Insert an item into the heap with the given priority.
  24.151 +    ///
  24.152 +    /// This function inserts the given item into the heap with the
  24.153 +    /// given priority.
  24.154 +    /// \param item The item to insert.
  24.155 +    /// \param value The priority of the item.
  24.156 +    /// \pre \e item must not be stored in the heap.
  24.157 +    void push (const Item& item, const Prio& value) {
  24.158 +      int i=_iim[item];
  24.159 +      if ( i<0 ) {
  24.160 +        int s=_data.size();
  24.161 +        _iim.set( item,s );
  24.162 +        Store st;
  24.163 +        st.name=item;
  24.164 +        st.prio=value;
  24.165 +        _data.push_back(st);
  24.166 +        i=s;
  24.167 +      }
  24.168 +      else {
  24.169 +        _data[i].parent=_data[i].right_neighbor=_data[i].child=-1;
  24.170 +        _data[i].degree=0;
  24.171 +        _data[i].in=true;
  24.172 +        _data[i].prio=value;
  24.173 +      }
  24.174 +
  24.175 +      if( 0==_num_items ) {
  24.176 +        _head=i;
  24.177 +        _min=i;
  24.178 +      } else {
  24.179 +        merge(i);
  24.180 +        if( _comp(_data[i].prio, _data[_min].prio) ) _min=i;
  24.181 +      }
  24.182 +      ++_num_items;
  24.183 +    }
  24.184 +
  24.185 +    /// \brief Return the item having minimum priority.
  24.186 +    ///
  24.187 +    /// This function returns the item having minimum priority.
  24.188 +    /// \pre The heap must be non-empty.
  24.189 +    Item top() const { return _data[_min].name; }
  24.190 +
  24.191 +    /// \brief The minimum priority.
  24.192 +    ///
  24.193 +    /// This function returns the minimum priority.
  24.194 +    /// \pre The heap must be non-empty.
  24.195 +    Prio prio() const { return _data[_min].prio; }
  24.196 +
  24.197 +    /// \brief The priority of the given item.
  24.198 +    ///
  24.199 +    /// This function returns the priority of the given item.
  24.200 +    /// \param item The item.
  24.201 +    /// \pre \e item must be in the heap.
  24.202 +    const Prio& operator[](const Item& item) const {
  24.203 +      return _data[_iim[item]].prio;
  24.204 +    }
  24.205 +
  24.206 +    /// \brief Remove the item having minimum priority.
  24.207 +    ///
  24.208 +    /// This function removes the item having minimum priority.
  24.209 +    /// \pre The heap must be non-empty.
  24.210 +    void pop() {
  24.211 +      _data[_min].in=false;
  24.212 +
  24.213 +      int head_child=-1;
  24.214 +      if ( _data[_min].child!=-1 ) {
  24.215 +        int child=_data[_min].child;
  24.216 +        int neighb;
  24.217 +        while( child!=-1 ) {
  24.218 +          neighb=_data[child].right_neighbor;
  24.219 +          _data[child].parent=-1;
  24.220 +          _data[child].right_neighbor=head_child;
  24.221 +          head_child=child;
  24.222 +          child=neighb;
  24.223 +        }
  24.224 +      }
  24.225 +
  24.226 +      if ( _data[_head].right_neighbor==-1 ) {
  24.227 +        // there was only one root
  24.228 +        _head=head_child;
  24.229 +      }
  24.230 +      else {
  24.231 +        // there were more roots
  24.232 +        if( _head!=_min )  { unlace(_min); }
  24.233 +        else { _head=_data[_head].right_neighbor; }
  24.234 +        merge(head_child);
  24.235 +      }
  24.236 +      _min=findMin();
  24.237 +      --_num_items;
  24.238 +    }
  24.239 +
  24.240 +    /// \brief Remove the given item from the heap.
  24.241 +    ///
  24.242 +    /// This function removes the given item from the heap if it is
  24.243 +    /// already stored.
  24.244 +    /// \param item The item to delete.
  24.245 +    /// \pre \e item must be in the heap.
  24.246 +    void erase (const Item& item) {
  24.247 +      int i=_iim[item];
  24.248 +      if ( i >= 0 && _data[i].in ) {
  24.249 +        decrease( item, _data[_min].prio-1 );
  24.250 +        pop();
  24.251 +      }
  24.252 +    }
  24.253 +
  24.254 +    /// \brief Decrease the priority of an item to the given value.
  24.255 +    ///
  24.256 +    /// This function decreases the priority of an item to the given value.
  24.257 +    /// \param item The item.
  24.258 +    /// \param value The priority.
  24.259 +    /// \pre \e item must be stored in the heap with priority at least \e value.
  24.260 +    void decrease (Item item, const Prio& value) {
  24.261 +      int i=_iim[item];
  24.262 +      int p=_data[i].parent;
  24.263 +      _data[i].prio=value;
  24.264 +
  24.265 +      while( p!=-1 && _comp(value, _data[p].prio) ) {
  24.266 +        _data[i].name=_data[p].name;
  24.267 +        _data[i].prio=_data[p].prio;
  24.268 +        _data[p].name=item;
  24.269 +        _data[p].prio=value;
  24.270 +        _iim[_data[i].name]=i;
  24.271 +        i=p;
  24.272 +        p=_data[p].parent;
  24.273 +      }
  24.274 +      _iim[item]=i;
  24.275 +      if ( _comp(value, _data[_min].prio) ) _min=i;
  24.276 +    }
  24.277 +
  24.278 +    /// \brief Increase the priority of an item to the given value.
  24.279 +    ///
  24.280 +    /// This function increases the priority of an item to the given value.
  24.281 +    /// \param item The item.
  24.282 +    /// \param value The priority.
  24.283 +    /// \pre \e item must be stored in the heap with priority at most \e value.
  24.284 +    void increase (Item item, const Prio& value) {
  24.285 +      erase(item);
  24.286 +      push(item, value);
  24.287 +    }
  24.288 +
  24.289 +    /// \brief Return the state of an item.
  24.290 +    ///
  24.291 +    /// This method returns \c PRE_HEAP if the given item has never
  24.292 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  24.293 +    /// and \c POST_HEAP otherwise.
  24.294 +    /// In the latter case it is possible that the item will get back
  24.295 +    /// to the heap again.
  24.296 +    /// \param item The item.
  24.297 +    State state(const Item &item) const {
  24.298 +      int i=_iim[item];
  24.299 +      if( i>=0 ) {
  24.300 +        if ( _data[i].in ) i=0;
  24.301 +        else i=-2;
  24.302 +      }
  24.303 +      return State(i);
  24.304 +    }
  24.305 +
  24.306 +    /// \brief Set the state of an item in the heap.
  24.307 +    ///
  24.308 +    /// This function sets the state of the given item in the heap.
  24.309 +    /// It can be used to manually clear the heap when it is important
  24.310 +    /// to achive better time complexity.
  24.311 +    /// \param i The item.
  24.312 +    /// \param st The state. It should not be \c IN_HEAP.
  24.313 +    void state(const Item& i, State st) {
  24.314 +      switch (st) {
  24.315 +      case POST_HEAP:
  24.316 +      case PRE_HEAP:
  24.317 +        if (state(i) == IN_HEAP) {
  24.318 +          erase(i);
  24.319 +        }
  24.320 +        _iim[i] = st;
  24.321 +        break;
  24.322 +      case IN_HEAP:
  24.323 +        break;
  24.324 +      }
  24.325 +    }
  24.326 +
  24.327 +  private:
  24.328 +
  24.329 +    // Find the minimum of the roots
  24.330 +    int findMin() {
  24.331 +      if( _head!=-1 ) {
  24.332 +        int min_loc=_head, min_val=_data[_head].prio;
  24.333 +        for( int x=_data[_head].right_neighbor; x!=-1;
  24.334 +             x=_data[x].right_neighbor ) {
  24.335 +          if( _comp( _data[x].prio,min_val ) ) {
  24.336 +            min_val=_data[x].prio;
  24.337 +            min_loc=x;
  24.338 +          }
  24.339 +        }
  24.340 +        return min_loc;
  24.341 +      }
  24.342 +      else return -1;
  24.343 +    }
  24.344 +
  24.345 +    // Merge the heap with another heap starting at the given position
  24.346 +    void merge(int a) {
  24.347 +      if( _head==-1 || a==-1 ) return;
  24.348 +      if( _data[a].right_neighbor==-1 &&
  24.349 +          _data[a].degree<=_data[_head].degree ) {
  24.350 +        _data[a].right_neighbor=_head;
  24.351 +        _head=a;
  24.352 +      } else {
  24.353 +        interleave(a);
  24.354 +      }
  24.355 +      if( _data[_head].right_neighbor==-1 ) return;
  24.356 +
  24.357 +      int x=_head;
  24.358 +      int x_prev=-1, x_next=_data[x].right_neighbor;
  24.359 +      while( x_next!=-1 ) {
  24.360 +        if( _data[x].degree!=_data[x_next].degree ||
  24.361 +            ( _data[x_next].right_neighbor!=-1 &&
  24.362 +              _data[_data[x_next].right_neighbor].degree==_data[x].degree ) ) {
  24.363 +          x_prev=x;
  24.364 +          x=x_next;
  24.365 +        }
  24.366 +        else {
  24.367 +          if( _comp(_data[x_next].prio,_data[x].prio) ) {
  24.368 +            if( x_prev==-1 ) {
  24.369 +              _head=x_next;
  24.370 +            } else {
  24.371 +              _data[x_prev].right_neighbor=x_next;
  24.372 +            }
  24.373 +            fuse(x,x_next);
  24.374 +            x=x_next;
  24.375 +          }
  24.376 +          else {
  24.377 +            _data[x].right_neighbor=_data[x_next].right_neighbor;
  24.378 +            fuse(x_next,x);
  24.379 +          }
  24.380 +        }
  24.381 +        x_next=_data[x].right_neighbor;
  24.382 +      }
  24.383 +    }
  24.384 +
  24.385 +    // Interleave the elements of the given list into the list of the roots
  24.386 +    void interleave(int a) {
  24.387 +      int p=_head, q=a;
  24.388 +      int curr=_data.size();
  24.389 +      _data.push_back(Store());
  24.390 +
  24.391 +      while( p!=-1 || q!=-1 ) {
  24.392 +        if( q==-1 || ( p!=-1 && _data[p].degree<_data[q].degree ) ) {
  24.393 +          _data[curr].right_neighbor=p;
  24.394 +          curr=p;
  24.395 +          p=_data[p].right_neighbor;
  24.396 +        }
  24.397 +        else {
  24.398 +          _data[curr].right_neighbor=q;
  24.399 +          curr=q;
  24.400 +          q=_data[q].right_neighbor;
  24.401 +        }
  24.402 +      }
  24.403 +
  24.404 +      _head=_data.back().right_neighbor;
  24.405 +      _data.pop_back();
  24.406 +    }
  24.407 +
  24.408 +    // Lace node a under node b
  24.409 +    void fuse(int a, int b) {
  24.410 +      _data[a].parent=b;
  24.411 +      _data[a].right_neighbor=_data[b].child;
  24.412 +      _data[b].child=a;
  24.413 +
  24.414 +      ++_data[b].degree;
  24.415 +    }
  24.416 +
  24.417 +    // Unlace node a (if it has siblings)
  24.418 +    void unlace(int a) {
  24.419 +      int neighb=_data[a].right_neighbor;
  24.420 +      int other=_head;
  24.421 +
  24.422 +      while( _data[other].right_neighbor!=a )
  24.423 +        other=_data[other].right_neighbor;
  24.424 +      _data[other].right_neighbor=neighb;
  24.425 +    }
  24.426 +
  24.427 +  private:
  24.428 +
  24.429 +    class Store {
  24.430 +      friend class BinomialHeap;
  24.431 +
  24.432 +      Item name;
  24.433 +      int parent;
  24.434 +      int right_neighbor;
  24.435 +      int child;
  24.436 +      int degree;
  24.437 +      bool in;
  24.438 +      Prio prio;
  24.439 +
  24.440 +      Store() : parent(-1), right_neighbor(-1), child(-1), degree(0),
  24.441 +        in(true) {}
  24.442 +    };
  24.443 +  };
  24.444 +
  24.445 +} //namespace lemon
  24.446 +
  24.447 +#endif //LEMON_BINOMIAL_HEAP_H
  24.448 +
    25.1 --- a/lemon/bits/array_map.h	Tue Dec 20 17:44:38 2011 +0100
    25.2 +++ b/lemon/bits/array_map.h	Tue Dec 20 18:15:14 2011 +0100
    25.3 @@ -2,7 +2,7 @@
    25.4   *
    25.5   * This file is a part of LEMON, a generic C++ optimization library.
    25.6   *
    25.7 - * Copyright (C) 2003-2009
    25.8 + * Copyright (C) 2003-2010
    25.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   25.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   25.11   *
   25.12 @@ -70,7 +70,7 @@
   25.13      typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier;
   25.14  
   25.15    private:
   25.16 -  
   25.17 +
   25.18      // The MapBase of the Map which imlements the core regisitry function.
   25.19      typedef typename Notifier::ObserverBase Parent;
   25.20  
    26.1 --- a/lemon/bits/default_map.h	Tue Dec 20 17:44:38 2011 +0100
    26.2 +++ b/lemon/bits/default_map.h	Tue Dec 20 18:15:14 2011 +0100
    26.3 @@ -2,7 +2,7 @@
    26.4   *
    26.5   * This file is a part of LEMON, a generic C++ optimization library.
    26.6   *
    26.7 - * Copyright (C) 2003-2009
    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 @@ -157,7 +157,7 @@
   26.13  
   26.14    public:
   26.15      typedef DefaultMap<_Graph, _Item, _Value> Map;
   26.16 -    
   26.17 +
   26.18      typedef typename Parent::GraphType GraphType;
   26.19      typedef typename Parent::Value Value;
   26.20  
    27.1 --- a/lemon/bits/edge_set_extender.h	Tue Dec 20 17:44:38 2011 +0100
    27.2 +++ b/lemon/bits/edge_set_extender.h	Tue Dec 20 18:15:14 2011 +0100
    27.3 @@ -1,8 +1,8 @@
    27.4 -/* -*- C++ -*-
    27.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    27.6   *
    27.7 - * This file is a part of LEMON, a generic C++ optimization library
    27.8 + * This file is a part of LEMON, a generic C++ optimization library.
    27.9   *
   27.10 - * Copyright (C) 2003-2008
   27.11 + * Copyright (C) 2003-2010
   27.12   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   27.13   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   27.14   *
   27.15 @@ -63,11 +63,11 @@
   27.16  
   27.17      Node oppositeNode(const Node &n, const Arc &e) const {
   27.18        if (n == Parent::source(e))
   27.19 -	return Parent::target(e);
   27.20 +        return Parent::target(e);
   27.21        else if(n==Parent::target(e))
   27.22 -	return Parent::source(e);
   27.23 +        return Parent::source(e);
   27.24        else
   27.25 -	return INVALID;
   27.26 +        return INVALID;
   27.27      }
   27.28  
   27.29  
   27.30 @@ -91,7 +91,7 @@
   27.31  
   27.32      // Iterable extensions
   27.33  
   27.34 -    class NodeIt : public Node { 
   27.35 +    class NodeIt : public Node {
   27.36        const Digraph* digraph;
   27.37      public:
   27.38  
   27.39 @@ -100,21 +100,21 @@
   27.40        NodeIt(Invalid i) : Node(i) { }
   27.41  
   27.42        explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
   27.43 -	_graph.first(static_cast<Node&>(*this));
   27.44 +        _graph.first(static_cast<Node&>(*this));
   27.45        }
   27.46  
   27.47 -      NodeIt(const Digraph& _graph, const Node& node) 
   27.48 -	: Node(node), digraph(&_graph) {}
   27.49 +      NodeIt(const Digraph& _graph, const Node& node)
   27.50 +        : Node(node), digraph(&_graph) {}
   27.51  
   27.52 -      NodeIt& operator++() { 
   27.53 -	digraph->next(*this);
   27.54 -	return *this; 
   27.55 +      NodeIt& operator++() {
   27.56 +        digraph->next(*this);
   27.57 +        return *this;
   27.58        }
   27.59  
   27.60      };
   27.61  
   27.62  
   27.63 -    class ArcIt : public Arc { 
   27.64 +    class ArcIt : public Arc {
   27.65        const Digraph* digraph;
   27.66      public:
   27.67  
   27.68 @@ -123,21 +123,21 @@
   27.69        ArcIt(Invalid i) : Arc(i) { }
   27.70  
   27.71        explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
   27.72 -	_graph.first(static_cast<Arc&>(*this));
   27.73 +        _graph.first(static_cast<Arc&>(*this));
   27.74        }
   27.75  
   27.76 -      ArcIt(const Digraph& _graph, const Arc& e) : 
   27.77 -	Arc(e), digraph(&_graph) { }
   27.78 +      ArcIt(const Digraph& _graph, const Arc& e) :
   27.79 +        Arc(e), digraph(&_graph) { }
   27.80  
   27.81 -      ArcIt& operator++() { 
   27.82 -	digraph->next(*this);
   27.83 -	return *this; 
   27.84 +      ArcIt& operator++() {
   27.85 +        digraph->next(*this);
   27.86 +        return *this;
   27.87        }
   27.88  
   27.89      };
   27.90  
   27.91  
   27.92 -    class OutArcIt : public Arc { 
   27.93 +    class OutArcIt : public Arc {
   27.94        const Digraph* digraph;
   27.95      public:
   27.96  
   27.97 @@ -145,23 +145,23 @@
   27.98  
   27.99        OutArcIt(Invalid i) : Arc(i) { }
  27.100  
  27.101 -      OutArcIt(const Digraph& _graph, const Node& node) 
  27.102 -	: digraph(&_graph) {
  27.103 -	_graph.firstOut(*this, node);
  27.104 +      OutArcIt(const Digraph& _graph, const Node& node)
  27.105 +        : digraph(&_graph) {
  27.106 +        _graph.firstOut(*this, node);
  27.107        }
  27.108  
  27.109 -      OutArcIt(const Digraph& _graph, const Arc& arc) 
  27.110 -	: Arc(arc), digraph(&_graph) {}
  27.111 +      OutArcIt(const Digraph& _graph, const Arc& arc)
  27.112 +        : Arc(arc), digraph(&_graph) {}
  27.113  
  27.114 -      OutArcIt& operator++() { 
  27.115 -	digraph->nextOut(*this);
  27.116 -	return *this; 
  27.117 +      OutArcIt& operator++() {
  27.118 +        digraph->nextOut(*this);
  27.119 +        return *this;
  27.120        }
  27.121  
  27.122      };
  27.123  
  27.124  
  27.125 -    class InArcIt : public Arc { 
  27.126 +    class InArcIt : public Arc {
  27.127        const Digraph* digraph;
  27.128      public:
  27.129  
  27.130 @@ -169,17 +169,17 @@
  27.131  
  27.132        InArcIt(Invalid i) : Arc(i) { }
  27.133  
  27.134 -      InArcIt(const Digraph& _graph, const Node& node) 
  27.135 -	: digraph(&_graph) {
  27.136 -	_graph.firstIn(*this, node);
  27.137 +      InArcIt(const Digraph& _graph, const Node& node)
  27.138 +        : digraph(&_graph) {
  27.139 +        _graph.firstIn(*this, node);
  27.140        }
  27.141  
  27.142 -      InArcIt(const Digraph& _graph, const Arc& arc) : 
  27.143 -	Arc(arc), digraph(&_graph) {}
  27.144 +      InArcIt(const Digraph& _graph, const Arc& arc) :
  27.145 +        Arc(arc), digraph(&_graph) {}
  27.146  
  27.147 -      InArcIt& operator++() { 
  27.148 -	digraph->nextIn(*this);
  27.149 -	return *this; 
  27.150 +      InArcIt& operator++() {
  27.151 +        digraph->nextIn(*this);
  27.152 +        return *this;
  27.153        }
  27.154  
  27.155      };
  27.156 @@ -215,26 +215,26 @@
  27.157      using Parent::first;
  27.158  
  27.159      // Mappable extension
  27.160 -    
  27.161 +
  27.162      template <typename _Value>
  27.163 -    class ArcMap 
  27.164 +    class ArcMap
  27.165        : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
  27.166        typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
  27.167  
  27.168      public:
  27.169 -      explicit ArcMap(const Digraph& _g) 
  27.170 -	: Parent(_g) {}
  27.171 -      ArcMap(const Digraph& _g, const _Value& _v) 
  27.172 -	: Parent(_g, _v) {}
  27.173 +      explicit ArcMap(const Digraph& _g)
  27.174 +        : Parent(_g) {}
  27.175 +      ArcMap(const Digraph& _g, const _Value& _v)
  27.176 +        : Parent(_g, _v) {}
  27.177  
  27.178        ArcMap& operator=(const ArcMap& cmap) {
  27.179 -	return operator=<ArcMap>(cmap);
  27.180 +        return operator=<ArcMap>(cmap);
  27.181        }
  27.182  
  27.183        template <typename CMap>
  27.184        ArcMap& operator=(const CMap& cmap) {
  27.185          Parent::operator=(cmap);
  27.186 -	return *this;
  27.187 +        return *this;
  27.188        }
  27.189  
  27.190      };
  27.191 @@ -247,7 +247,7 @@
  27.192        notifier(Arc()).add(arc);
  27.193        return arc;
  27.194      }
  27.195 -    
  27.196 +
  27.197      void clear() {
  27.198        notifier(Arc()).clear();
  27.199        Parent::clear();
  27.200 @@ -312,11 +312,11 @@
  27.201  
  27.202      Node oppositeNode(const Node &n, const Edge &e) const {
  27.203        if( n == Parent::u(e))
  27.204 -	return Parent::v(e);
  27.205 +        return Parent::v(e);
  27.206        else if( n == Parent::v(e))
  27.207 -	return Parent::u(e);
  27.208 +        return Parent::u(e);
  27.209        else
  27.210 -	return INVALID;
  27.211 +        return INVALID;
  27.212      }
  27.213  
  27.214      Arc oppositeArc(const Arc &e) const {
  27.215 @@ -340,7 +340,7 @@
  27.216    public:
  27.217  
  27.218      using Parent::notifier;
  27.219 -    
  27.220 +
  27.221      ArcNotifier& notifier(Arc) const {
  27.222        return arc_notifier;
  27.223      }
  27.224 @@ -350,7 +350,7 @@
  27.225      }
  27.226  
  27.227  
  27.228 -    class NodeIt : public Node { 
  27.229 +    class NodeIt : public Node {
  27.230        const Graph* graph;
  27.231      public:
  27.232  
  27.233 @@ -359,21 +359,21 @@
  27.234        NodeIt(Invalid i) : Node(i) { }
  27.235  
  27.236        explicit NodeIt(const Graph& _graph) : graph(&_graph) {
  27.237 -	_graph.first(static_cast<Node&>(*this));
  27.238 +        _graph.first(static_cast<Node&>(*this));
  27.239        }
  27.240  
  27.241 -      NodeIt(const Graph& _graph, const Node& node) 
  27.242 -	: Node(node), graph(&_graph) {}
  27.243 +      NodeIt(const Graph& _graph, const Node& node)
  27.244 +        : Node(node), graph(&_graph) {}
  27.245  
  27.246 -      NodeIt& operator++() { 
  27.247 -	graph->next(*this);
  27.248 -	return *this; 
  27.249 +      NodeIt& operator++() {
  27.250 +        graph->next(*this);
  27.251 +        return *this;
  27.252        }
  27.253  
  27.254      };
  27.255  
  27.256  
  27.257 -    class ArcIt : public Arc { 
  27.258 +    class ArcIt : public Arc {
  27.259        const Graph* graph;
  27.260      public:
  27.261  
  27.262 @@ -382,21 +382,21 @@
  27.263        ArcIt(Invalid i) : Arc(i) { }
  27.264  
  27.265        explicit ArcIt(const Graph& _graph) : graph(&_graph) {
  27.266 -	_graph.first(static_cast<Arc&>(*this));
  27.267 +        _graph.first(static_cast<Arc&>(*this));
  27.268        }
  27.269  
  27.270 -      ArcIt(const Graph& _graph, const Arc& e) : 
  27.271 -	Arc(e), graph(&_graph) { }
  27.272 +      ArcIt(const Graph& _graph, const Arc& e) :
  27.273 +        Arc(e), graph(&_graph) { }
  27.274  
  27.275 -      ArcIt& operator++() { 
  27.276 -	graph->next(*this);
  27.277 -	return *this; 
  27.278 +      ArcIt& operator++() {
  27.279 +        graph->next(*this);
  27.280 +        return *this;
  27.281        }
  27.282  
  27.283      };
  27.284  
  27.285  
  27.286 -    class OutArcIt : public Arc { 
  27.287 +    class OutArcIt : public Arc {
  27.288        const Graph* graph;
  27.289      public:
  27.290  
  27.291 @@ -404,23 +404,23 @@
  27.292  
  27.293        OutArcIt(Invalid i) : Arc(i) { }
  27.294  
  27.295 -      OutArcIt(const Graph& _graph, const Node& node) 
  27.296 -	: graph(&_graph) {
  27.297 -	_graph.firstOut(*this, node);
  27.298 +      OutArcIt(const Graph& _graph, const Node& node)
  27.299 +        : graph(&_graph) {
  27.300 +        _graph.firstOut(*this, node);
  27.301        }
  27.302  
  27.303 -      OutArcIt(const Graph& _graph, const Arc& arc) 
  27.304 -	: Arc(arc), graph(&_graph) {}
  27.305 +      OutArcIt(const Graph& _graph, const Arc& arc)
  27.306 +        : Arc(arc), graph(&_graph) {}
  27.307  
  27.308 -      OutArcIt& operator++() { 
  27.309 -	graph->nextOut(*this);
  27.310 -	return *this; 
  27.311 +      OutArcIt& operator++() {
  27.312 +        graph->nextOut(*this);
  27.313 +        return *this;
  27.314        }
  27.315  
  27.316      };
  27.317  
  27.318  
  27.319 -    class InArcIt : public Arc { 
  27.320 +    class InArcIt : public Arc {
  27.321        const Graph* graph;
  27.322      public:
  27.323  
  27.324 @@ -428,23 +428,23 @@
  27.325  
  27.326        InArcIt(Invalid i) : Arc(i) { }
  27.327  
  27.328 -      InArcIt(const Graph& _graph, const Node& node) 
  27.329 -	: graph(&_graph) {
  27.330 -	_graph.firstIn(*this, node);
  27.331 +      InArcIt(const Graph& _graph, const Node& node)
  27.332 +        : graph(&_graph) {
  27.333 +        _graph.firstIn(*this, node);
  27.334        }
  27.335  
  27.336 -      InArcIt(const Graph& _graph, const Arc& arc) : 
  27.337 -	Arc(arc), graph(&_graph) {}
  27.338 +      InArcIt(const Graph& _graph, const Arc& arc) :
  27.339 +        Arc(arc), graph(&_graph) {}
  27.340  
  27.341 -      InArcIt& operator++() { 
  27.342 -	graph->nextIn(*this);
  27.343 -	return *this; 
  27.344 +      InArcIt& operator++() {
  27.345 +        graph->nextIn(*this);
  27.346 +        return *this;
  27.347        }
  27.348  
  27.349      };
  27.350  
  27.351  
  27.352 -    class EdgeIt : public Parent::Edge { 
  27.353 +    class EdgeIt : public Parent::Edge {
  27.354        const Graph* graph;
  27.355      public:
  27.356  
  27.357 @@ -453,15 +453,15 @@
  27.358        EdgeIt(Invalid i) : Edge(i) { }
  27.359  
  27.360        explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
  27.361 -	_graph.first(static_cast<Edge&>(*this));
  27.362 +        _graph.first(static_cast<Edge&>(*this));
  27.363        }
  27.364  
  27.365 -      EdgeIt(const Graph& _graph, const Edge& e) : 
  27.366 -	Edge(e), graph(&_graph) { }
  27.367 +      EdgeIt(const Graph& _graph, const Edge& e) :
  27.368 +        Edge(e), graph(&_graph) { }
  27.369  
  27.370 -      EdgeIt& operator++() { 
  27.371 -	graph->next(*this);
  27.372 -	return *this; 
  27.373 +      EdgeIt& operator++() {
  27.374 +        graph->next(*this);
  27.375 +        return *this;
  27.376        }
  27.377  
  27.378      };
  27.379 @@ -477,17 +477,17 @@
  27.380        IncEdgeIt(Invalid i) : Edge(i), direction(false) { }
  27.381  
  27.382        IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
  27.383 -	_graph.firstInc(*this, direction, n);
  27.384 +        _graph.firstInc(*this, direction, n);
  27.385        }
  27.386  
  27.387        IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n)
  27.388 -	: graph(&_graph), Edge(ue) {
  27.389 -	direction = (_graph.source(ue) == n);
  27.390 +        : graph(&_graph), Edge(ue) {
  27.391 +        direction = (_graph.source(ue) == n);
  27.392        }
  27.393  
  27.394        IncEdgeIt& operator++() {
  27.395 -	graph->nextInc(*this, direction);
  27.396 -	return *this; 
  27.397 +        graph->nextInc(*this, direction);
  27.398 +        return *this;
  27.399        }
  27.400      };
  27.401  
  27.402 @@ -534,49 +534,49 @@
  27.403  
  27.404  
  27.405      template <typename _Value>
  27.406 -    class ArcMap 
  27.407 +    class ArcMap
  27.408        : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
  27.409        typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
  27.410  
  27.411      public:
  27.412 -      explicit ArcMap(const Graph& _g) 
  27.413 -	: Parent(_g) {}
  27.414 -      ArcMap(const Graph& _g, const _Value& _v) 
  27.415 -	: Parent(_g, _v) {}
  27.416 +      explicit ArcMap(const Graph& _g)
  27.417 +        : Parent(_g) {}
  27.418 +      ArcMap(const Graph& _g, const _Value& _v)
  27.419 +        : Parent(_g, _v) {}
  27.420  
  27.421        ArcMap& operator=(const ArcMap& cmap) {
  27.422 -	return operator=<ArcMap>(cmap);
  27.423 +        return operator=<ArcMap>(cmap);
  27.424        }
  27.425  
  27.426        template <typename CMap>
  27.427        ArcMap& operator=(const CMap& cmap) {
  27.428          Parent::operator=(cmap);
  27.429 -	return *this;
  27.430 +        return *this;
  27.431        }
  27.432  
  27.433      };
  27.434  
  27.435  
  27.436      template <typename _Value>
  27.437 -    class EdgeMap 
  27.438 +    class EdgeMap
  27.439        : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
  27.440        typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
  27.441  
  27.442      public:
  27.443 -      explicit EdgeMap(const Graph& _g) 
  27.444 -	: Parent(_g) {}
  27.445 +      explicit EdgeMap(const Graph& _g)
  27.446 +        : Parent(_g) {}
  27.447  
  27.448 -      EdgeMap(const Graph& _g, const _Value& _v) 
  27.449 -	: Parent(_g, _v) {}
  27.450 +      EdgeMap(const Graph& _g, const _Value& _v)
  27.451 +        : Parent(_g, _v) {}
  27.452  
  27.453        EdgeMap& operator=(const EdgeMap& cmap) {
  27.454 -	return operator=<EdgeMap>(cmap);
  27.455 +        return operator=<EdgeMap>(cmap);
  27.456        }
  27.457  
  27.458        template <typename CMap>
  27.459        EdgeMap& operator=(const CMap& cmap) {
  27.460          Parent::operator=(cmap);
  27.461 -	return *this;
  27.462 +        return *this;
  27.463        }
  27.464  
  27.465      };
  27.466 @@ -593,7 +593,7 @@
  27.467        notifier(Arc()).add(arcs);
  27.468        return edge;
  27.469      }
  27.470 -    
  27.471 +
  27.472      void clear() {
  27.473        notifier(Arc()).clear();
  27.474        notifier(Edge()).clear();
  27.475 @@ -619,7 +619,7 @@
  27.476        edge_notifier.clear();
  27.477        arc_notifier.clear();
  27.478      }
  27.479 -    
  27.480 +
  27.481    };
  27.482  
  27.483  }
    28.1 --- a/lemon/bits/graph_extender.h	Tue Dec 20 17:44:38 2011 +0100
    28.2 +++ b/lemon/bits/graph_extender.h	Tue Dec 20 18:15:14 2011 +0100
    28.3 @@ -56,11 +56,11 @@
    28.4        return Parent::maxArcId();
    28.5      }
    28.6  
    28.7 -    Node fromId(int id, Node) const {
    28.8 +    static Node fromId(int id, Node) {
    28.9        return Parent::nodeFromId(id);
   28.10      }
   28.11  
   28.12 -    Arc fromId(int id, Arc) const {
   28.13 +    static Arc fromId(int id, Arc) {
   28.14        return Parent::arcFromId(id);
   28.15      }
   28.16  
   28.17 @@ -355,15 +355,15 @@
   28.18        return Parent::maxEdgeId();
   28.19      }
   28.20  
   28.21 -    Node fromId(int id, Node) const {
   28.22 +    static Node fromId(int id, Node) {
   28.23        return Parent::nodeFromId(id);
   28.24      }
   28.25  
   28.26 -    Arc fromId(int id, Arc) const {
   28.27 +    static Arc fromId(int id, Arc) {
   28.28        return Parent::arcFromId(id);
   28.29      }
   28.30  
   28.31 -    Edge fromId(int id, Edge) const {
   28.32 +    static Edge fromId(int id, Edge) {
   28.33        return Parent::edgeFromId(id);
   28.34      }
   28.35  
    29.1 --- a/lemon/bits/solver_bits.h	Tue Dec 20 17:44:38 2011 +0100
    29.2 +++ b/lemon/bits/solver_bits.h	Tue Dec 20 18:15:14 2011 +0100
    29.3 @@ -2,7 +2,7 @@
    29.4   *
    29.5   * This file is a part of LEMON, a generic C++ optimization library.
    29.6   *
    29.7 - * Copyright (C) 2003-2008
    29.8 + * Copyright (C) 2003-2010
    29.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   29.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   29.11   *
    30.1 --- a/lemon/bits/windows.cc	Tue Dec 20 17:44:38 2011 +0100
    30.2 +++ b/lemon/bits/windows.cc	Tue Dec 20 18:15:14 2011 +0100
    30.3 @@ -2,7 +2,7 @@
    30.4   *
    30.5   * This file is a part of LEMON, a generic C++ optimization library.
    30.6   *
    30.7 - * Copyright (C) 2003-2009
    30.8 + * Copyright (C) 2003-2010
    30.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   30.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   30.11   *
   30.12 @@ -98,7 +98,7 @@
   30.13        SYSTEMTIME time;
   30.14        GetSystemTime(&time);
   30.15        char buf1[11], buf2[9], buf3[5];
   30.16 -	  if (GetDateFormat(MY_LOCALE, 0, &time,
   30.17 +          if (GetDateFormat(MY_LOCALE, 0, &time,
   30.18                          ("ddd MMM dd"), buf1, 11) &&
   30.19            GetTimeFormat(MY_LOCALE, 0, &time,
   30.20                          ("HH':'mm':'ss"), buf2, 9) &&
    31.1 --- a/lemon/bucket_heap.h	Tue Dec 20 17:44:38 2011 +0100
    31.2 +++ b/lemon/bucket_heap.h	Tue Dec 20 18:15:14 2011 +0100
    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-2009
    31.8 + * Copyright (C) 2003-2010
    31.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   31.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   31.11   *
   31.12 @@ -19,9 +19,9 @@
   31.13  #ifndef LEMON_BUCKET_HEAP_H
   31.14  #define LEMON_BUCKET_HEAP_H
   31.15  
   31.16 -///\ingroup auxdat
   31.17 +///\ingroup heaps
   31.18  ///\file
   31.19 -///\brief Bucket Heap implementation.
   31.20 +///\brief Bucket heap implementation.
   31.21  
   31.22  #include <vector>
   31.23  #include <utility>
   31.24 @@ -53,35 +53,41 @@
   31.25  
   31.26    }
   31.27  
   31.28 -  /// \ingroup auxdat
   31.29 +  /// \ingroup heaps
   31.30    ///
   31.31 -  /// \brief A Bucket Heap implementation.
   31.32 +  /// \brief Bucket heap data structure.
   31.33    ///
   31.34 -  /// This class implements the \e bucket \e heap data structure. A \e heap
   31.35 -  /// is a data structure for storing items with specified values called \e
   31.36 -  /// priorities in such a way that finding the item with minimum priority is
   31.37 -  /// efficient. The bucket heap is very simple implementation, it can store
   31.38 -  /// only integer priorities and it stores for each priority in the
   31.39 -  /// \f$ [0..C) \f$ range a list of items. So it should be used only when
   31.40 -  /// the priorities are small. It is not intended to use as dijkstra heap.
   31.41 +  /// This class implements the \e bucket \e heap data structure.
   31.42 +  /// It practically conforms to the \ref concepts::Heap "heap concept",
   31.43 +  /// but it has some limitations.
   31.44    ///
   31.45 -  /// \param IM A read and write Item int map, used internally
   31.46 -  /// to handle the cross references.
   31.47 -  /// \param MIN If the given parameter is false then instead of the
   31.48 -  /// minimum value the maximum can be retrivied with the top() and
   31.49 -  /// prio() member functions.
   31.50 +  /// The bucket heap is a very simple structure. It can store only
   31.51 +  /// \c int priorities and it maintains a list of items for each priority
   31.52 +  /// in the range <tt>[0..C)</tt>. So it should only be used when the
   31.53 +  /// priorities are small. It is not intended to use as a Dijkstra heap.
   31.54 +  ///
   31.55 +  /// \tparam IM A read-writable item map with \c int values, used
   31.56 +  /// internally to handle the cross references.
   31.57 +  /// \tparam MIN Indicate if the heap is a \e min-heap or a \e max-heap.
   31.58 +  /// The default is \e min-heap. If this parameter is set to \c false,
   31.59 +  /// then the comparison is reversed, so the top(), prio() and pop()
   31.60 +  /// functions deal with the item having maximum priority instead of the
   31.61 +  /// minimum.
   31.62 +  ///
   31.63 +  /// \sa SimpleBucketHeap
   31.64    template <typename IM, bool MIN = true>
   31.65    class BucketHeap {
   31.66  
   31.67    public:
   31.68 -    /// \e
   31.69 -    typedef typename IM::Key Item;
   31.70 -    /// \e
   31.71 +
   31.72 +    /// Type of the item-int map.
   31.73 +    typedef IM ItemIntMap;
   31.74 +    /// Type of the priorities.
   31.75      typedef int Prio;
   31.76 -    /// \e
   31.77 -    typedef std::pair<Item, Prio> Pair;
   31.78 -    /// \e
   31.79 -    typedef IM ItemIntMap;
   31.80 +    /// Type of the items stored in the heap.
   31.81 +    typedef typename ItemIntMap::Key Item;
   31.82 +    /// Type of the item-priority pairs.
   31.83 +    typedef std::pair<Item,Prio> Pair;
   31.84  
   31.85    private:
   31.86  
   31.87 @@ -89,10 +95,10 @@
   31.88  
   31.89    public:
   31.90  
   31.91 -    /// \brief Type to represent the items states.
   31.92 +    /// \brief Type to represent the states of the items.
   31.93      ///
   31.94 -    /// Each Item element have a state associated to it. It may be "in heap",
   31.95 -    /// "pre heap" or "post heap". The latter two are indifferent from the
   31.96 +    /// Each item has a state associated to it. It can be "in heap",
   31.97 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   31.98      /// heap's point of view, but may be useful to the user.
   31.99      ///
  31.100      /// The item-int map must be initialized in such way that it assigns
  31.101 @@ -104,37 +110,39 @@
  31.102      };
  31.103  
  31.104    public:
  31.105 -    /// \brief The constructor.
  31.106 +
  31.107 +    /// \brief Constructor.
  31.108      ///
  31.109 -    /// The constructor.
  31.110 -    /// \param map should be given to the constructor, since it is used
  31.111 -    /// internally to handle the cross references. The value of the map
  31.112 -    /// should be PRE_HEAP (-1) for each element.
  31.113 +    /// Constructor.
  31.114 +    /// \param map A map that assigns \c int values to the items.
  31.115 +    /// It is used internally to handle the cross references.
  31.116 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  31.117      explicit BucketHeap(ItemIntMap &map) : _iim(map), _minimum(0) {}
  31.118  
  31.119 -    /// The number of items stored in the heap.
  31.120 +    /// \brief The number of items stored in the heap.
  31.121      ///
  31.122 -    /// \brief Returns the number of items stored in the heap.
  31.123 +    /// This function returns the number of items stored in the heap.
  31.124      int size() const { return _data.size(); }
  31.125  
  31.126 -    /// \brief Checks if the heap stores no items.
  31.127 +    /// \brief Check if the heap is empty.
  31.128      ///
  31.129 -    /// Returns \c true if and only if the heap stores no items.
  31.130 +    /// This function returns \c true if the heap is empty.
  31.131      bool empty() const { return _data.empty(); }
  31.132  
  31.133 -    /// \brief Make empty this heap.
  31.134 +    /// \brief Make the heap empty.
  31.135      ///
  31.136 -    /// Make empty this heap. It does not change the cross reference
  31.137 -    /// map.  If you want to reuse a heap what is not surely empty you
  31.138 -    /// should first clear the heap and after that you should set the
  31.139 -    /// cross reference map for each item to \c PRE_HEAP.
  31.140 +    /// This functon makes the heap empty.
  31.141 +    /// It does not change the cross reference map. If you want to reuse
  31.142 +    /// a heap that is not surely empty, you should first clear it and
  31.143 +    /// then you should set the cross reference map to \c PRE_HEAP
  31.144 +    /// for each item.
  31.145      void clear() {
  31.146        _data.clear(); _first.clear(); _minimum = 0;
  31.147      }
  31.148  
  31.149    private:
  31.150  
  31.151 -    void relocate_last(int idx) {
  31.152 +    void relocateLast(int idx) {
  31.153        if (idx + 1 < int(_data.size())) {
  31.154          _data[idx] = _data.back();
  31.155          if (_data[idx].prev != -1) {
  31.156 @@ -174,19 +182,24 @@
  31.157      }
  31.158  
  31.159    public:
  31.160 +
  31.161      /// \brief Insert a pair of item and priority into the heap.
  31.162      ///
  31.163 -    /// Adds \c p.first to the heap with priority \c p.second.
  31.164 +    /// This function inserts \c p.first to the heap with priority
  31.165 +    /// \c p.second.
  31.166      /// \param p The pair to insert.
  31.167 +    /// \pre \c p.first must not be stored in the heap.
  31.168      void push(const Pair& p) {
  31.169        push(p.first, p.second);
  31.170      }
  31.171  
  31.172      /// \brief Insert an item into the heap with the given priority.
  31.173      ///
  31.174 -    /// Adds \c i to the heap with priority \c p.
  31.175 +    /// This function inserts the given item into the heap with the
  31.176 +    /// given priority.
  31.177      /// \param i The item to insert.
  31.178      /// \param p The priority of the item.
  31.179 +    /// \pre \e i must not be stored in the heap.
  31.180      void push(const Item &i, const Prio &p) {
  31.181        int idx = _data.size();
  31.182        _iim[i] = idx;
  31.183 @@ -197,10 +210,10 @@
  31.184        }
  31.185      }
  31.186  
  31.187 -    /// \brief Returns the item with minimum priority.
  31.188 +    /// \brief Return the item having minimum priority.
  31.189      ///
  31.190 -    /// This method returns the item with minimum priority.
  31.191 -    /// \pre The heap must be nonempty.
  31.192 +    /// This function returns the item having minimum priority.
  31.193 +    /// \pre The heap must be non-empty.
  31.194      Item top() const {
  31.195        while (_first[_minimum] == -1) {
  31.196          Direction::increase(_minimum);
  31.197 @@ -208,10 +221,10 @@
  31.198        return _data[_first[_minimum]].item;
  31.199      }
  31.200  
  31.201 -    /// \brief Returns the minimum priority.
  31.202 +    /// \brief The minimum priority.
  31.203      ///
  31.204 -    /// It returns the minimum priority.
  31.205 -    /// \pre The heap must be nonempty.
  31.206 +    /// This function returns the minimum priority.
  31.207 +    /// \pre The heap must be non-empty.
  31.208      Prio prio() const {
  31.209        while (_first[_minimum] == -1) {
  31.210          Direction::increase(_minimum);
  31.211 @@ -219,9 +232,9 @@
  31.212        return _minimum;
  31.213      }
  31.214  
  31.215 -    /// \brief Deletes the item with minimum priority.
  31.216 +    /// \brief Remove the item having minimum priority.
  31.217      ///
  31.218 -    /// This method deletes the item with minimum priority from the heap.
  31.219 +    /// This function removes the item having minimum priority.
  31.220      /// \pre The heap must be non-empty.
  31.221      void pop() {
  31.222        while (_first[_minimum] == -1) {
  31.223 @@ -230,37 +243,38 @@
  31.224        int idx = _first[_minimum];
  31.225        _iim[_data[idx].item] = -2;
  31.226        unlace(idx);
  31.227 -      relocate_last(idx);
  31.228 +      relocateLast(idx);
  31.229      }
  31.230  
  31.231 -    /// \brief Deletes \c i from the heap.
  31.232 +    /// \brief Remove the given item from the heap.
  31.233      ///
  31.234 -    /// This method deletes item \c i from the heap, if \c i was
  31.235 -    /// already stored in the heap.
  31.236 -    /// \param i The item to erase.
  31.237 +    /// This function removes the given item from the heap if it is
  31.238 +    /// already stored.
  31.239 +    /// \param i The item to delete.
  31.240 +    /// \pre \e i must be in the heap.
  31.241      void erase(const Item &i) {
  31.242        int idx = _iim[i];
  31.243        _iim[_data[idx].item] = -2;
  31.244        unlace(idx);
  31.245 -      relocate_last(idx);
  31.246 +      relocateLast(idx);
  31.247      }
  31.248  
  31.249 -
  31.250 -    /// \brief Returns the priority of \c i.
  31.251 +    /// \brief The priority of the given item.
  31.252      ///
  31.253 -    /// This function returns the priority of item \c i.
  31.254 -    /// \pre \c i must be in the heap.
  31.255 +    /// This function returns the priority of the given item.
  31.256      /// \param i The item.
  31.257 +    /// \pre \e i must be in the heap.
  31.258      Prio operator[](const Item &i) const {
  31.259        int idx = _iim[i];
  31.260        return _data[idx].value;
  31.261      }
  31.262  
  31.263 -    /// \brief \c i gets to the heap with priority \c p independently
  31.264 -    /// if \c i was already there.
  31.265 +    /// \brief Set the priority of an item or insert it, if it is
  31.266 +    /// not stored in the heap.
  31.267      ///
  31.268 -    /// This method calls \ref push(\c i, \c p) if \c i is not stored
  31.269 -    /// in the heap and sets the priority of \c i to \c p otherwise.
  31.270 +    /// This method sets the priority of the given item if it is
  31.271 +    /// already stored in the heap. Otherwise it inserts the given
  31.272 +    /// item into the heap with the given priority.
  31.273      /// \param i The item.
  31.274      /// \param p The priority.
  31.275      void set(const Item &i, const Prio &p) {
  31.276 @@ -274,13 +288,12 @@
  31.277        }
  31.278      }
  31.279  
  31.280 -    /// \brief Decreases the priority of \c i to \c p.
  31.281 +    /// \brief Decrease the priority of an item to the given value.
  31.282      ///
  31.283 -    /// This method decreases the priority of item \c i to \c p.
  31.284 -    /// \pre \c i must be stored in the heap with priority at least \c
  31.285 -    /// p relative to \c Compare.
  31.286 +    /// This function decreases the priority of an item to the given value.
  31.287      /// \param i The item.
  31.288      /// \param p The priority.
  31.289 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  31.290      void decrease(const Item &i, const Prio &p) {
  31.291        int idx = _iim[i];
  31.292        unlace(idx);
  31.293 @@ -291,13 +304,12 @@
  31.294        lace(idx);
  31.295      }
  31.296  
  31.297 -    /// \brief Increases the priority of \c i to \c p.
  31.298 +    /// \brief Increase the priority of an item to the given value.
  31.299      ///
  31.300 -    /// This method sets the priority of item \c i to \c p.
  31.301 -    /// \pre \c i must be stored in the heap with priority at most \c
  31.302 -    /// p relative to \c Compare.
  31.303 +    /// This function increases the priority of an item to the given value.
  31.304      /// \param i The item.
  31.305      /// \param p The priority.
  31.306 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  31.307      void increase(const Item &i, const Prio &p) {
  31.308        int idx = _iim[i];
  31.309        unlace(idx);
  31.310 @@ -305,13 +317,13 @@
  31.311        lace(idx);
  31.312      }
  31.313  
  31.314 -    /// \brief Returns if \c item is in, has already been in, or has
  31.315 -    /// never been in the heap.
  31.316 +    /// \brief Return the state of an item.
  31.317      ///
  31.318 -    /// This method returns PRE_HEAP if \c item has never been in the
  31.319 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  31.320 -    /// otherwise. In the latter case it is possible that \c item will
  31.321 -    /// get back to the heap again.
  31.322 +    /// This method returns \c PRE_HEAP if the given item has never
  31.323 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  31.324 +    /// and \c POST_HEAP otherwise.
  31.325 +    /// In the latter case it is possible that the item will get back
  31.326 +    /// to the heap again.
  31.327      /// \param i The item.
  31.328      State state(const Item &i) const {
  31.329        int idx = _iim[i];
  31.330 @@ -319,11 +331,11 @@
  31.331        return State(idx);
  31.332      }
  31.333  
  31.334 -    /// \brief Sets the state of the \c item in the heap.
  31.335 +    /// \brief Set the state of an item in the heap.
  31.336      ///
  31.337 -    /// Sets the state of the \c item in the heap. It can be used to
  31.338 -    /// manually clear the heap when it is important to achive the
  31.339 -    /// better time complexity.
  31.340 +    /// This function sets the state of the given item in the heap.
  31.341 +    /// It can be used to manually clear the heap when it is important
  31.342 +    /// to achive better time complexity.
  31.343      /// \param i The item.
  31.344      /// \param st The state. It should not be \c IN_HEAP.
  31.345      void state(const Item& i, State st) {
  31.346 @@ -359,33 +371,44 @@
  31.347  
  31.348    }; // class BucketHeap
  31.349  
  31.350 -  /// \ingroup auxdat
  31.351 +  /// \ingroup heaps
  31.352    ///
  31.353 -  /// \brief A Simplified Bucket Heap implementation.
  31.354 +  /// \brief Simplified bucket heap data structure.
  31.355    ///
  31.356    /// This class implements a simplified \e bucket \e heap data
  31.357 -  /// structure.  It does not provide some functionality but it faster
  31.358 -  /// and simplier data structure than the BucketHeap. The main
  31.359 -  /// difference is that the BucketHeap stores for every key a double
  31.360 -  /// linked list while this class stores just simple lists. In the
  31.361 -  /// other way it does not support erasing each elements just the
  31.362 -  /// minimal and it does not supports key increasing, decreasing.
  31.363 +  /// structure. It does not provide some functionality, but it is
  31.364 +  /// faster and simpler than BucketHeap. The main difference is
  31.365 +  /// that BucketHeap stores a doubly-linked list for each key while
  31.366 +  /// this class stores only simply-linked lists. It supports erasing
  31.367 +  /// only for the item having minimum priority and it does not support
  31.368 +  /// key increasing and decreasing.
  31.369    ///
  31.370 -  /// \param IM A read and write Item int map, used internally
  31.371 -  /// to handle the cross references.
  31.372 -  /// \param MIN If the given parameter is false then instead of the
  31.373 -  /// minimum value the maximum can be retrivied with the top() and
  31.374 -  /// prio() member functions.
  31.375 +  /// Note that this implementation does not conform to the
  31.376 +  /// \ref concepts::Heap "heap concept" due to the lack of some
  31.377 +  /// functionality.
  31.378 +  ///
  31.379 +  /// \tparam IM A read-writable item map with \c int values, used
  31.380 +  /// internally to handle the cross references.
  31.381 +  /// \tparam MIN Indicate if the heap is a \e min-heap or a \e max-heap.
  31.382 +  /// The default is \e min-heap. If this parameter is set to \c false,
  31.383 +  /// then the comparison is reversed, so the top(), prio() and pop()
  31.384 +  /// functions deal with the item having maximum priority instead of the
  31.385 +  /// minimum.
  31.386    ///
  31.387    /// \sa BucketHeap
  31.388    template <typename IM, bool MIN = true >
  31.389    class SimpleBucketHeap {
  31.390  
  31.391    public:
  31.392 -    typedef typename IM::Key Item;
  31.393 +
  31.394 +    /// Type of the item-int map.
  31.395 +    typedef IM ItemIntMap;
  31.396 +    /// Type of the priorities.
  31.397      typedef int Prio;
  31.398 -    typedef std::pair<Item, Prio> Pair;
  31.399 -    typedef IM ItemIntMap;
  31.400 +    /// Type of the items stored in the heap.
  31.401 +    typedef typename ItemIntMap::Key Item;
  31.402 +    /// Type of the item-priority pairs.
  31.403 +    typedef std::pair<Item,Prio> Pair;
  31.404  
  31.405    private:
  31.406  
  31.407 @@ -393,10 +416,10 @@
  31.408  
  31.409    public:
  31.410  
  31.411 -    /// \brief Type to represent the items states.
  31.412 +    /// \brief Type to represent the states of the items.
  31.413      ///
  31.414 -    /// Each Item element have a state associated to it. It may be "in heap",
  31.415 -    /// "pre heap" or "post heap". The latter two are indifferent from the
  31.416 +    /// Each item has a state associated to it. It can be "in heap",
  31.417 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
  31.418      /// heap's point of view, but may be useful to the user.
  31.419      ///
  31.420      /// The item-int map must be initialized in such way that it assigns
  31.421 @@ -409,48 +432,53 @@
  31.422  
  31.423    public:
  31.424  
  31.425 -    /// \brief The constructor.
  31.426 +    /// \brief Constructor.
  31.427      ///
  31.428 -    /// The constructor.
  31.429 -    /// \param map should be given to the constructor, since it is used
  31.430 -    /// internally to handle the cross references. The value of the map
  31.431 -    /// should be PRE_HEAP (-1) for each element.
  31.432 +    /// Constructor.
  31.433 +    /// \param map A map that assigns \c int values to the items.
  31.434 +    /// It is used internally to handle the cross references.
  31.435 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  31.436      explicit SimpleBucketHeap(ItemIntMap &map)
  31.437        : _iim(map), _free(-1), _num(0), _minimum(0) {}
  31.438  
  31.439 -    /// \brief Returns the number of items stored in the heap.
  31.440 +    /// \brief The number of items stored in the heap.
  31.441      ///
  31.442 -    /// The number of items stored in the heap.
  31.443 +    /// This function returns the number of items stored in the heap.
  31.444      int size() const { return _num; }
  31.445  
  31.446 -    /// \brief Checks if the heap stores no items.
  31.447 +    /// \brief Check if the heap is empty.
  31.448      ///
  31.449 -    /// Returns \c true if and only if the heap stores no items.
  31.450 +    /// This function returns \c true if the heap is empty.
  31.451      bool empty() const { return _num == 0; }
  31.452  
  31.453 -    /// \brief Make empty this heap.
  31.454 +    /// \brief Make the heap empty.
  31.455      ///
  31.456 -    /// Make empty this heap. It does not change the cross reference
  31.457 -    /// map.  If you want to reuse a heap what is not surely empty you
  31.458 -    /// should first clear the heap and after that you should set the
  31.459 -    /// cross reference map for each item to \c PRE_HEAP.
  31.460 +    /// This functon makes the heap empty.
  31.461 +    /// It does not change the cross reference map. If you want to reuse
  31.462 +    /// a heap that is not surely empty, you should first clear it and
  31.463 +    /// then you should set the cross reference map to \c PRE_HEAP
  31.464 +    /// for each item.
  31.465      void clear() {
  31.466        _data.clear(); _first.clear(); _free = -1; _num = 0; _minimum = 0;
  31.467      }
  31.468  
  31.469      /// \brief Insert a pair of item and priority into the heap.
  31.470      ///
  31.471 -    /// Adds \c p.first to the heap with priority \c p.second.
  31.472 +    /// This function inserts \c p.first to the heap with priority
  31.473 +    /// \c p.second.
  31.474      /// \param p The pair to insert.
  31.475 +    /// \pre \c p.first must not be stored in the heap.
  31.476      void push(const Pair& p) {
  31.477        push(p.first, p.second);
  31.478      }
  31.479  
  31.480      /// \brief Insert an item into the heap with the given priority.
  31.481      ///
  31.482 -    /// Adds \c i to the heap with priority \c p.
  31.483 +    /// This function inserts the given item into the heap with the
  31.484 +    /// given priority.
  31.485      /// \param i The item to insert.
  31.486      /// \param p The priority of the item.
  31.487 +    /// \pre \e i must not be stored in the heap.
  31.488      void push(const Item &i, const Prio &p) {
  31.489        int idx;
  31.490        if (_free == -1) {
  31.491 @@ -471,10 +499,10 @@
  31.492        ++_num;
  31.493      }
  31.494  
  31.495 -    /// \brief Returns the item with minimum priority.
  31.496 +    /// \brief Return the item having minimum priority.
  31.497      ///
  31.498 -    /// This method returns the item with minimum priority.
  31.499 -    /// \pre The heap must be nonempty.
  31.500 +    /// This function returns the item having minimum priority.
  31.501 +    /// \pre The heap must be non-empty.
  31.502      Item top() const {
  31.503        while (_first[_minimum] == -1) {
  31.504          Direction::increase(_minimum);
  31.505 @@ -482,10 +510,10 @@
  31.506        return _data[_first[_minimum]].item;
  31.507      }
  31.508  
  31.509 -    /// \brief Returns the minimum priority.
  31.510 +    /// \brief The minimum priority.
  31.511      ///
  31.512 -    /// It returns the minimum priority.
  31.513 -    /// \pre The heap must be nonempty.
  31.514 +    /// This function returns the minimum priority.
  31.515 +    /// \pre The heap must be non-empty.
  31.516      Prio prio() const {
  31.517        while (_first[_minimum] == -1) {
  31.518          Direction::increase(_minimum);
  31.519 @@ -493,9 +521,9 @@
  31.520        return _minimum;
  31.521      }
  31.522  
  31.523 -    /// \brief Deletes the item with minimum priority.
  31.524 +    /// \brief Remove the item having minimum priority.
  31.525      ///
  31.526 -    /// This method deletes the item with minimum priority from the heap.
  31.527 +    /// This function removes the item having minimum priority.
  31.528      /// \pre The heap must be non-empty.
  31.529      void pop() {
  31.530        while (_first[_minimum] == -1) {
  31.531 @@ -509,16 +537,15 @@
  31.532        --_num;
  31.533      }
  31.534  
  31.535 -    /// \brief Returns the priority of \c i.
  31.536 +    /// \brief The priority of the given item.
  31.537      ///
  31.538 -    /// This function returns the priority of item \c i.
  31.539 -    /// \warning This operator is not a constant time function
  31.540 -    /// because it scans the whole data structure to find the proper
  31.541 -    /// value.
  31.542 -    /// \pre \c i must be in the heap.
  31.543 +    /// This function returns the priority of the given item.
  31.544      /// \param i The item.
  31.545 +    /// \pre \e i must be in the heap.
  31.546 +    /// \warning This operator is not a constant time function because
  31.547 +    /// it scans the whole data structure to find the proper value.
  31.548      Prio operator[](const Item &i) const {
  31.549 -      for (int k = 0; k < _first.size(); ++k) {
  31.550 +      for (int k = 0; k < int(_first.size()); ++k) {
  31.551          int idx = _first[k];
  31.552          while (idx != -1) {
  31.553            if (_data[idx].item == i) {
  31.554 @@ -530,13 +557,13 @@
  31.555        return -1;
  31.556      }
  31.557  
  31.558 -    /// \brief Returns if \c item is in, has already been in, or has
  31.559 -    /// never been in the heap.
  31.560 +    /// \brief Return the state of an item.
  31.561      ///
  31.562 -    /// This method returns PRE_HEAP if \c item has never been in the
  31.563 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  31.564 -    /// otherwise. In the latter case it is possible that \c item will
  31.565 -    /// get back to the heap again.
  31.566 +    /// This method returns \c PRE_HEAP if the given item has never
  31.567 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  31.568 +    /// and \c POST_HEAP otherwise.
  31.569 +    /// In the latter case it is possible that the item will get back
  31.570 +    /// to the heap again.
  31.571      /// \param i The item.
  31.572      State state(const Item &i) const {
  31.573        int idx = _iim[i];
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/lemon/capacity_scaling.h	Tue Dec 20 18:15:14 2011 +0100
    32.3 @@ -0,0 +1,990 @@
    32.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    32.5 + *
    32.6 + * This file is a part of LEMON, a generic C++ optimization library.
    32.7 + *
    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 + * Permission to use, modify and distribute this software is granted
   32.13 + * provided that this copyright notice appears in all copies. For
   32.14 + * precise terms see the accompanying LICENSE file.
   32.15 + *
   32.16 + * This software is provided "AS IS" with no warranty of any kind,
   32.17 + * express or implied, and with no claim as to its suitability for any
   32.18 + * purpose.
   32.19 + *
   32.20 + */
   32.21 +
   32.22 +#ifndef LEMON_CAPACITY_SCALING_H
   32.23 +#define LEMON_CAPACITY_SCALING_H
   32.24 +
   32.25 +/// \ingroup min_cost_flow_algs
   32.26 +///
   32.27 +/// \file
   32.28 +/// \brief Capacity Scaling algorithm for finding a minimum cost flow.
   32.29 +
   32.30 +#include <vector>
   32.31 +#include <limits>
   32.32 +#include <lemon/core.h>
   32.33 +#include <lemon/bin_heap.h>
   32.34 +
   32.35 +namespace lemon {
   32.36 +
   32.37 +  /// \brief Default traits class of CapacityScaling algorithm.
   32.38 +  ///
   32.39 +  /// Default traits class of CapacityScaling algorithm.
   32.40 +  /// \tparam GR Digraph type.
   32.41 +  /// \tparam V The number type used for flow amounts, capacity bounds
   32.42 +  /// and supply values. By default it is \c int.
   32.43 +  /// \tparam C The number type used for costs and potentials.
   32.44 +  /// By default it is the same as \c V.
   32.45 +  template <typename GR, typename V = int, typename C = V>
   32.46 +  struct CapacityScalingDefaultTraits
   32.47 +  {
   32.48 +    /// The type of the digraph
   32.49 +    typedef GR Digraph;
   32.50 +    /// The type of the flow amounts, capacity bounds and supply values
   32.51 +    typedef V Value;
   32.52 +    /// The type of the arc costs
   32.53 +    typedef C Cost;
   32.54 +
   32.55 +    /// \brief The type of the heap used for internal Dijkstra computations.
   32.56 +    ///
   32.57 +    /// The type of the heap used for internal Dijkstra computations.
   32.58 +    /// It must conform to the \ref lemon::concepts::Heap "Heap" concept,
   32.59 +    /// its priority type must be \c Cost and its cross reference type
   32.60 +    /// must be \ref RangeMap "RangeMap<int>".
   32.61 +    typedef BinHeap<Cost, RangeMap<int> > Heap;
   32.62 +  };
   32.63 +
   32.64 +  /// \addtogroup min_cost_flow_algs
   32.65 +  /// @{
   32.66 +
   32.67 +  /// \brief Implementation of the Capacity Scaling algorithm for
   32.68 +  /// finding a \ref min_cost_flow "minimum cost flow".
   32.69 +  ///
   32.70 +  /// \ref CapacityScaling implements the capacity scaling version
   32.71 +  /// of the successive shortest path algorithm for finding a
   32.72 +  /// \ref min_cost_flow "minimum cost flow" \ref amo93networkflows,
   32.73 +  /// \ref edmondskarp72theoretical. It is an efficient dual
   32.74 +  /// solution method.
   32.75 +  ///
   32.76 +  /// Most of the parameters of the problem (except for the digraph)
   32.77 +  /// can be given using separate functions, and the algorithm can be
   32.78 +  /// executed using the \ref run() function. If some parameters are not
   32.79 +  /// specified, then default values will be used.
   32.80 +  ///
   32.81 +  /// \tparam GR The digraph type the algorithm runs on.
   32.82 +  /// \tparam V The number type used for flow amounts, capacity bounds
   32.83 +  /// and supply values in the algorithm. By default, it is \c int.
   32.84 +  /// \tparam C The number type used for costs and potentials in the
   32.85 +  /// algorithm. By default, it is the same as \c V.
   32.86 +  /// \tparam TR The traits class that defines various types used by the
   32.87 +  /// algorithm. By default, it is \ref CapacityScalingDefaultTraits
   32.88 +  /// "CapacityScalingDefaultTraits<GR, V, C>".
   32.89 +  /// In most cases, this parameter should not be set directly,
   32.90 +  /// consider to use the named template parameters instead.
   32.91 +  ///
   32.92 +  /// \warning Both number types must be signed and all input data must
   32.93 +  /// be integer.
   32.94 +  /// \warning This algorithm does not support negative costs for such
   32.95 +  /// arcs that have infinite upper bound.
   32.96 +#ifdef DOXYGEN
   32.97 +  template <typename GR, typename V, typename C, typename TR>
   32.98 +#else
   32.99 +  template < typename GR, typename V = int, typename C = V,
  32.100 +             typename TR = CapacityScalingDefaultTraits<GR, V, C> >
  32.101 +#endif
  32.102 +  class CapacityScaling
  32.103 +  {
  32.104 +  public:
  32.105 +
  32.106 +    /// The type of the digraph
  32.107 +    typedef typename TR::Digraph Digraph;
  32.108 +    /// The type of the flow amounts, capacity bounds and supply values
  32.109 +    typedef typename TR::Value Value;
  32.110 +    /// The type of the arc costs
  32.111 +    typedef typename TR::Cost Cost;
  32.112 +
  32.113 +    /// The type of the heap used for internal Dijkstra computations
  32.114 +    typedef typename TR::Heap Heap;
  32.115 +
  32.116 +    /// The \ref CapacityScalingDefaultTraits "traits class" of the algorithm
  32.117 +    typedef TR Traits;
  32.118 +
  32.119 +  public:
  32.120 +
  32.121 +    /// \brief Problem type constants for the \c run() function.
  32.122 +    ///
  32.123 +    /// Enum type containing the problem type constants that can be
  32.124 +    /// returned by the \ref run() function of the algorithm.
  32.125 +    enum ProblemType {
  32.126 +      /// The problem has no feasible solution (flow).
  32.127 +      INFEASIBLE,
  32.128 +      /// The problem has optimal solution (i.e. it is feasible and
  32.129 +      /// bounded), and the algorithm has found optimal flow and node
  32.130 +      /// potentials (primal and dual solutions).
  32.131 +      OPTIMAL,
  32.132 +      /// The digraph contains an arc of negative cost and infinite
  32.133 +      /// upper bound. It means that the objective function is unbounded
  32.134 +      /// on that arc, however, note that it could actually be bounded
  32.135 +      /// over the feasible flows, but this algroithm cannot handle
  32.136 +      /// these cases.
  32.137 +      UNBOUNDED
  32.138 +    };
  32.139 +
  32.140 +  private:
  32.141 +
  32.142 +    TEMPLATE_DIGRAPH_TYPEDEFS(GR);
  32.143 +
  32.144 +    typedef std::vector<int> IntVector;
  32.145 +    typedef std::vector<Value> ValueVector;
  32.146 +    typedef std::vector<Cost> CostVector;
  32.147 +    typedef std::vector<char> BoolVector;
  32.148 +    // Note: vector<char> is used instead of vector<bool> for efficiency reasons
  32.149 +
  32.150 +  private:
  32.151 +
  32.152 +    // Data related to the underlying digraph
  32.153 +    const GR &_graph;
  32.154 +    int _node_num;
  32.155 +    int _arc_num;
  32.156 +    int _res_arc_num;
  32.157 +    int _root;
  32.158 +
  32.159 +    // Parameters of the problem
  32.160 +    bool _have_lower;
  32.161 +    Value _sum_supply;
  32.162 +
  32.163 +    // Data structures for storing the digraph
  32.164 +    IntNodeMap _node_id;
  32.165 +    IntArcMap _arc_idf;
  32.166 +    IntArcMap _arc_idb;
  32.167 +    IntVector _first_out;
  32.168 +    BoolVector _forward;
  32.169 +    IntVector _source;
  32.170 +    IntVector _target;
  32.171 +    IntVector _reverse;
  32.172 +
  32.173 +    // Node and arc data
  32.174 +    ValueVector _lower;
  32.175 +    ValueVector _upper;
  32.176 +    CostVector _cost;
  32.177 +    ValueVector _supply;
  32.178 +
  32.179 +    ValueVector _res_cap;
  32.180 +    CostVector _pi;
  32.181 +    ValueVector _excess;
  32.182 +    IntVector _excess_nodes;
  32.183 +    IntVector _deficit_nodes;
  32.184 +
  32.185 +    Value _delta;
  32.186 +    int _factor;
  32.187 +    IntVector _pred;
  32.188 +
  32.189 +  public:
  32.190 +
  32.191 +    /// \brief Constant for infinite upper bounds (capacities).
  32.192 +    ///
  32.193 +    /// Constant for infinite upper bounds (capacities).
  32.194 +    /// It is \c std::numeric_limits<Value>::infinity() if available,
  32.195 +    /// \c std::numeric_limits<Value>::max() otherwise.
  32.196 +    const Value INF;
  32.197 +
  32.198 +  private:
  32.199 +
  32.200 +    // Special implementation of the Dijkstra algorithm for finding
  32.201 +    // shortest paths in the residual network of the digraph with
  32.202 +    // respect to the reduced arc costs and modifying the node
  32.203 +    // potentials according to the found distance labels.
  32.204 +    class ResidualDijkstra
  32.205 +    {
  32.206 +    private:
  32.207 +
  32.208 +      int _node_num;
  32.209 +      bool _geq;
  32.210 +      const IntVector &_first_out;
  32.211 +      const IntVector &_target;
  32.212 +      const CostVector &_cost;
  32.213 +      const ValueVector &_res_cap;
  32.214 +      const ValueVector &_excess;
  32.215 +      CostVector &_pi;
  32.216 +      IntVector &_pred;
  32.217 +
  32.218 +      IntVector _proc_nodes;
  32.219 +      CostVector _dist;
  32.220 +
  32.221 +    public:
  32.222 +
  32.223 +      ResidualDijkstra(CapacityScaling& cs) :
  32.224 +        _node_num(cs._node_num), _geq(cs._sum_supply < 0),
  32.225 +        _first_out(cs._first_out), _target(cs._target), _cost(cs._cost),
  32.226 +        _res_cap(cs._res_cap), _excess(cs._excess), _pi(cs._pi),
  32.227 +        _pred(cs._pred), _dist(cs._node_num)
  32.228 +      {}
  32.229 +
  32.230 +      int run(int s, Value delta = 1) {
  32.231 +        RangeMap<int> heap_cross_ref(_node_num, Heap::PRE_HEAP);
  32.232 +        Heap heap(heap_cross_ref);
  32.233 +        heap.push(s, 0);
  32.234 +        _pred[s] = -1;
  32.235 +        _proc_nodes.clear();
  32.236 +
  32.237 +        // Process nodes
  32.238 +        while (!heap.empty() && _excess[heap.top()] > -delta) {
  32.239 +          int u = heap.top(), v;
  32.240 +          Cost d = heap.prio() + _pi[u], dn;
  32.241 +          _dist[u] = heap.prio();
  32.242 +          _proc_nodes.push_back(u);
  32.243 +          heap.pop();
  32.244 +
  32.245 +          // Traverse outgoing residual arcs
  32.246 +          int last_out = _geq ? _first_out[u+1] : _first_out[u+1] - 1;
  32.247 +          for (int a = _first_out[u]; a != last_out; ++a) {
  32.248 +            if (_res_cap[a] < delta) continue;
  32.249 +            v = _target[a];
  32.250 +            switch (heap.state(v)) {
  32.251 +              case Heap::PRE_HEAP:
  32.252 +                heap.push(v, d + _cost[a] - _pi[v]);
  32.253 +                _pred[v] = a;
  32.254 +                break;
  32.255 +              case Heap::IN_HEAP:
  32.256 +                dn = d + _cost[a] - _pi[v];
  32.257 +                if (dn < heap[v]) {
  32.258 +                  heap.decrease(v, dn);
  32.259 +                  _pred[v] = a;
  32.260 +                }
  32.261 +                break;
  32.262 +              case Heap::POST_HEAP:
  32.263 +                break;
  32.264 +            }
  32.265 +          }
  32.266 +        }
  32.267 +        if (heap.empty()) return -1;
  32.268 +
  32.269 +        // Update potentials of processed nodes
  32.270 +        int t = heap.top();
  32.271 +        Cost dt = heap.prio();
  32.272 +        for (int i = 0; i < int(_proc_nodes.size()); ++i) {
  32.273 +          _pi[_proc_nodes[i]] += _dist[_proc_nodes[i]] - dt;
  32.274 +        }
  32.275 +
  32.276 +        return t;
  32.277 +      }
  32.278 +
  32.279 +    }; //class ResidualDijkstra
  32.280 +
  32.281 +  public:
  32.282 +
  32.283 +    /// \name Named Template Parameters
  32.284 +    /// @{
  32.285 +
  32.286 +    template <typename T>
  32.287 +    struct SetHeapTraits : public Traits {
  32.288 +      typedef T Heap;
  32.289 +    };
  32.290 +
  32.291 +    /// \brief \ref named-templ-param "Named parameter" for setting
  32.292 +    /// \c Heap type.
  32.293 +    ///
  32.294 +    /// \ref named-templ-param "Named parameter" for setting \c Heap
  32.295 +    /// type, which is used for internal Dijkstra computations.
  32.296 +    /// It must conform to the \ref lemon::concepts::Heap "Heap" concept,
  32.297 +    /// its priority type must be \c Cost and its cross reference type
  32.298 +    /// must be \ref RangeMap "RangeMap<int>".
  32.299 +    template <typename T>
  32.300 +    struct SetHeap
  32.301 +      : public CapacityScaling<GR, V, C, SetHeapTraits<T> > {
  32.302 +      typedef  CapacityScaling<GR, V, C, SetHeapTraits<T> > Create;
  32.303 +    };
  32.304 +
  32.305 +    /// @}
  32.306 +
  32.307 +  protected:
  32.308 +
  32.309 +    CapacityScaling() {}
  32.310 +
  32.311 +  public:
  32.312 +
  32.313 +    /// \brief Constructor.
  32.314 +    ///
  32.315 +    /// The constructor of the class.
  32.316 +    ///
  32.317 +    /// \param graph The digraph the algorithm runs on.
  32.318 +    CapacityScaling(const GR& graph) :
  32.319 +      _graph(graph), _node_id(graph), _arc_idf(graph), _arc_idb(graph),
  32.320 +      INF(std::numeric_limits<Value>::has_infinity ?
  32.321 +          std::numeric_limits<Value>::infinity() :
  32.322 +          std::numeric_limits<Value>::max())
  32.323 +    {
  32.324 +      // Check the number types
  32.325 +      LEMON_ASSERT(std::numeric_limits<Value>::is_signed,
  32.326 +        "The flow type of CapacityScaling must be signed");
  32.327 +      LEMON_ASSERT(std::numeric_limits<Cost>::is_signed,
  32.328 +        "The cost type of CapacityScaling must be signed");
  32.329 +
  32.330 +      // Reset data structures
  32.331 +      reset();
  32.332 +    }
  32.333 +
  32.334 +    /// \name Parameters
  32.335 +    /// The parameters of the algorithm can be specified using these
  32.336 +    /// functions.
  32.337 +
  32.338 +    /// @{
  32.339 +
  32.340 +    /// \brief Set the lower bounds on the arcs.
  32.341 +    ///
  32.342 +    /// This function sets the lower bounds on the arcs.
  32.343 +    /// If it is not used before calling \ref run(), the lower bounds
  32.344 +    /// will be set to zero on all arcs.
  32.345 +    ///
  32.346 +    /// \param map An arc map storing the lower bounds.
  32.347 +    /// Its \c Value type must be convertible to the \c Value type
  32.348 +    /// of the algorithm.
  32.349 +    ///
  32.350 +    /// \return <tt>(*this)</tt>
  32.351 +    template <typename LowerMap>
  32.352 +    CapacityScaling& lowerMap(const LowerMap& map) {
  32.353 +      _have_lower = true;
  32.354 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  32.355 +        _lower[_arc_idf[a]] = map[a];
  32.356 +        _lower[_arc_idb[a]] = map[a];
  32.357 +      }
  32.358 +      return *this;
  32.359 +    }
  32.360 +
  32.361 +    /// \brief Set the upper bounds (capacities) on the arcs.
  32.362 +    ///
  32.363 +    /// This function sets the upper bounds (capacities) on the arcs.
  32.364 +    /// If it is not used before calling \ref run(), the upper bounds
  32.365 +    /// will be set to \ref INF on all arcs (i.e. the flow value will be
  32.366 +    /// unbounded from above).
  32.367 +    ///
  32.368 +    /// \param map An arc map storing the upper bounds.
  32.369 +    /// Its \c Value type must be convertible to the \c Value type
  32.370 +    /// of the algorithm.
  32.371 +    ///
  32.372 +    /// \return <tt>(*this)</tt>
  32.373 +    template<typename UpperMap>
  32.374 +    CapacityScaling& upperMap(const UpperMap& map) {
  32.375 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  32.376 +        _upper[_arc_idf[a]] = map[a];
  32.377 +      }
  32.378 +      return *this;
  32.379 +    }
  32.380 +
  32.381 +    /// \brief Set the costs of the arcs.
  32.382 +    ///
  32.383 +    /// This function sets the costs of the arcs.
  32.384 +    /// If it is not used before calling \ref run(), the costs
  32.385 +    /// will be set to \c 1 on all arcs.
  32.386 +    ///
  32.387 +    /// \param map An arc map storing the costs.
  32.388 +    /// Its \c Value type must be convertible to the \c Cost type
  32.389 +    /// of the algorithm.
  32.390 +    ///
  32.391 +    /// \return <tt>(*this)</tt>
  32.392 +    template<typename CostMap>
  32.393 +    CapacityScaling& costMap(const CostMap& map) {
  32.394 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  32.395 +        _cost[_arc_idf[a]] =  map[a];
  32.396 +        _cost[_arc_idb[a]] = -map[a];
  32.397 +      }
  32.398 +      return *this;
  32.399 +    }
  32.400 +
  32.401 +    /// \brief Set the supply values of the nodes.
  32.402 +    ///
  32.403 +    /// This function sets the supply values of the nodes.
  32.404 +    /// If neither this function nor \ref stSupply() is used before
  32.405 +    /// calling \ref run(), the supply of each node will be set to zero.
  32.406 +    ///
  32.407 +    /// \param map A node map storing the supply values.
  32.408 +    /// Its \c Value type must be convertible to the \c Value type
  32.409 +    /// of the algorithm.
  32.410 +    ///
  32.411 +    /// \return <tt>(*this)</tt>
  32.412 +    template<typename SupplyMap>
  32.413 +    CapacityScaling& supplyMap(const SupplyMap& map) {
  32.414 +      for (NodeIt n(_graph); n != INVALID; ++n) {
  32.415 +        _supply[_node_id[n]] = map[n];
  32.416 +      }
  32.417 +      return *this;
  32.418 +    }
  32.419 +
  32.420 +    /// \brief Set single source and target nodes and a supply value.
  32.421 +    ///
  32.422 +    /// This function sets a single source node and a single target node
  32.423 +    /// and the required flow value.
  32.424 +    /// If neither this function nor \ref supplyMap() is used before
  32.425 +    /// calling \ref run(), the supply of each node will be set to zero.
  32.426 +    ///
  32.427 +    /// Using this function has the same effect as using \ref supplyMap()
  32.428 +    /// with such a map in which \c k is assigned to \c s, \c -k is
  32.429 +    /// assigned to \c t and all other nodes have zero supply value.
  32.430 +    ///
  32.431 +    /// \param s The source node.
  32.432 +    /// \param t The target node.
  32.433 +    /// \param k The required amount of flow from node \c s to node \c t
  32.434 +    /// (i.e. the supply of \c s and the demand of \c t).
  32.435 +    ///
  32.436 +    /// \return <tt>(*this)</tt>
  32.437 +    CapacityScaling& stSupply(const Node& s, const Node& t, Value k) {
  32.438 +      for (int i = 0; i != _node_num; ++i) {
  32.439 +        _supply[i] = 0;
  32.440 +      }
  32.441 +      _supply[_node_id[s]] =  k;
  32.442 +      _supply[_node_id[t]] = -k;
  32.443 +      return *this;
  32.444 +    }
  32.445 +
  32.446 +    /// @}
  32.447 +
  32.448 +    /// \name Execution control
  32.449 +    /// The algorithm can be executed using \ref run().
  32.450 +
  32.451 +    /// @{
  32.452 +
  32.453 +    /// \brief Run the algorithm.
  32.454 +    ///
  32.455 +    /// This function runs the algorithm.
  32.456 +    /// The paramters can be specified using functions \ref lowerMap(),
  32.457 +    /// \ref upperMap(), \ref costMap(), \ref supplyMap(), \ref stSupply().
  32.458 +    /// For example,
  32.459 +    /// \code
  32.460 +    ///   CapacityScaling<ListDigraph> cs(graph);
  32.461 +    ///   cs.lowerMap(lower).upperMap(upper).costMap(cost)
  32.462 +    ///     .supplyMap(sup).run();
  32.463 +    /// \endcode
  32.464 +    ///
  32.465 +    /// This function can be called more than once. All the given parameters
  32.466 +    /// are kept for the next call, unless \ref resetParams() or \ref reset()
  32.467 +    /// is used, thus only the modified parameters have to be set again.
  32.468 +    /// If the underlying digraph was also modified after the construction
  32.469 +    /// of the class (or the last \ref reset() call), then the \ref reset()
  32.470 +    /// function must be called.
  32.471 +    ///
  32.472 +    /// \param factor The capacity scaling factor. It must be larger than
  32.473 +    /// one to use scaling. If it is less or equal to one, then scaling
  32.474 +    /// will be disabled.
  32.475 +    ///
  32.476 +    /// \return \c INFEASIBLE if no feasible flow exists,
  32.477 +    /// \n \c OPTIMAL if the problem has optimal solution
  32.478 +    /// (i.e. it is feasible and bounded), and the algorithm has found
  32.479 +    /// optimal flow and node potentials (primal and dual solutions),
  32.480 +    /// \n \c UNBOUNDED if the digraph contains an arc of negative cost
  32.481 +    /// and infinite upper bound. It means that the objective function
  32.482 +    /// is unbounded on that arc, however, note that it could actually be
  32.483 +    /// bounded over the feasible flows, but this algroithm cannot handle
  32.484 +    /// these cases.
  32.485 +    ///
  32.486 +    /// \see ProblemType
  32.487 +    /// \see resetParams(), reset()
  32.488 +    ProblemType run(int factor = 4) {
  32.489 +      _factor = factor;
  32.490 +      ProblemType pt = init();
  32.491 +      if (pt != OPTIMAL) return pt;
  32.492 +      return start();
  32.493 +    }
  32.494 +
  32.495 +    /// \brief Reset all the parameters that have been given before.
  32.496 +    ///
  32.497 +    /// This function resets all the paramaters that have been given
  32.498 +    /// before using functions \ref lowerMap(), \ref upperMap(),
  32.499 +    /// \ref costMap(), \ref supplyMap(), \ref stSupply().
  32.500 +    ///
  32.501 +    /// It is useful for multiple \ref run() calls. Basically, all the given
  32.502 +    /// parameters are kept for the next \ref run() call, unless
  32.503 +    /// \ref resetParams() or \ref reset() is used.
  32.504 +    /// If the underlying digraph was also modified after the construction
  32.505 +    /// of the class or the last \ref reset() call, then the \ref reset()
  32.506 +    /// function must be used, otherwise \ref resetParams() is sufficient.
  32.507 +    ///
  32.508 +    /// For example,
  32.509 +    /// \code
  32.510 +    ///   CapacityScaling<ListDigraph> cs(graph);
  32.511 +    ///
  32.512 +    ///   // First run
  32.513 +    ///   cs.lowerMap(lower).upperMap(upper).costMap(cost)
  32.514 +    ///     .supplyMap(sup).run();
  32.515 +    ///
  32.516 +    ///   // Run again with modified cost map (resetParams() is not called,
  32.517 +    ///   // so only the cost map have to be set again)
  32.518 +    ///   cost[e] += 100;
  32.519 +    ///   cs.costMap(cost).run();
  32.520 +    ///
  32.521 +    ///   // Run again from scratch using resetParams()
  32.522 +    ///   // (the lower bounds will be set to zero on all arcs)
  32.523 +    ///   cs.resetParams();
  32.524 +    ///   cs.upperMap(capacity).costMap(cost)
  32.525 +    ///     .supplyMap(sup).run();
  32.526 +    /// \endcode
  32.527 +    ///
  32.528 +    /// \return <tt>(*this)</tt>
  32.529 +    ///
  32.530 +    /// \see reset(), run()
  32.531 +    CapacityScaling& resetParams() {
  32.532 +      for (int i = 0; i != _node_num; ++i) {
  32.533 +        _supply[i] = 0;
  32.534 +      }
  32.535 +      for (int j = 0; j != _res_arc_num; ++j) {
  32.536 +        _lower[j] = 0;
  32.537 +        _upper[j] = INF;
  32.538 +        _cost[j] = _forward[j] ? 1 : -1;
  32.539 +      }
  32.540 +      _have_lower = false;
  32.541 +      return *this;
  32.542 +    }
  32.543 +
  32.544 +    /// \brief Reset the internal data structures and all the parameters
  32.545 +    /// that have been given before.
  32.546 +    ///
  32.547 +    /// This function resets the internal data structures and all the
  32.548 +    /// paramaters that have been given before using functions \ref lowerMap(),
  32.549 +    /// \ref upperMap(), \ref costMap(), \ref supplyMap(), \ref stSupply().
  32.550 +    ///
  32.551 +    /// It is useful for multiple \ref run() calls. Basically, all the given
  32.552 +    /// parameters are kept for the next \ref run() call, unless
  32.553 +    /// \ref resetParams() or \ref reset() is used.
  32.554 +    /// If the underlying digraph was also modified after the construction
  32.555 +    /// of the class or the last \ref reset() call, then the \ref reset()
  32.556 +    /// function must be used, otherwise \ref resetParams() is sufficient.
  32.557 +    ///
  32.558 +    /// See \ref resetParams() for examples.
  32.559 +    ///
  32.560 +    /// \return <tt>(*this)</tt>
  32.561 +    ///
  32.562 +    /// \see resetParams(), run()
  32.563 +    CapacityScaling& reset() {
  32.564 +      // Resize vectors
  32.565 +      _node_num = countNodes(_graph);
  32.566 +      _arc_num = countArcs(_graph);
  32.567 +      _res_arc_num = 2 * (_arc_num + _node_num);
  32.568 +      _root = _node_num;
  32.569 +      ++_node_num;
  32.570 +
  32.571 +      _first_out.resize(_node_num + 1);
  32.572 +      _forward.resize(_res_arc_num);
  32.573 +      _source.resize(_res_arc_num);
  32.574 +      _target.resize(_res_arc_num);
  32.575 +      _reverse.resize(_res_arc_num);
  32.576 +
  32.577 +      _lower.resize(_res_arc_num);
  32.578 +      _upper.resize(_res_arc_num);
  32.579 +      _cost.resize(_res_arc_num);
  32.580 +      _supply.resize(_node_num);
  32.581 +
  32.582 +      _res_cap.resize(_res_arc_num);
  32.583 +      _pi.resize(_node_num);
  32.584 +      _excess.resize(_node_num);
  32.585 +      _pred.resize(_node_num);
  32.586 +
  32.587 +      // Copy the graph
  32.588 +      int i = 0, j = 0, k = 2 * _arc_num + _node_num - 1;
  32.589 +      for (NodeIt n(_graph); n != INVALID; ++n, ++i) {
  32.590 +        _node_id[n] = i;
  32.591 +      }
  32.592 +      i = 0;
  32.593 +      for (NodeIt n(_graph); n != INVALID; ++n, ++i) {
  32.594 +        _first_out[i] = j;
  32.595 +        for (OutArcIt a(_graph, n); a != INVALID; ++a, ++j) {
  32.596 +          _arc_idf[a] = j;
  32.597 +          _forward[j] = true;
  32.598 +          _source[j] = i;
  32.599 +          _target[j] = _node_id[_graph.runningNode(a)];
  32.600 +        }
  32.601 +        for (InArcIt a(_graph, n); a != INVALID; ++a, ++j) {
  32.602 +          _arc_idb[a] = j;
  32.603 +          _forward[j] = false;
  32.604 +          _source[j] = i;
  32.605 +          _target[j] = _node_id[_graph.runningNode(a)];
  32.606 +        }
  32.607 +        _forward[j] = false;
  32.608 +        _source[j] = i;
  32.609 +        _target[j] = _root;
  32.610 +        _reverse[j] = k;
  32.611 +        _forward[k] = true;
  32.612 +        _source[k] = _root;
  32.613 +        _target[k] = i;
  32.614 +        _reverse[k] = j;
  32.615 +        ++j; ++k;
  32.616 +      }
  32.617 +      _first_out[i] = j;
  32.618 +      _first_out[_node_num] = k;
  32.619 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  32.620 +        int fi = _arc_idf[a];
  32.621 +        int bi = _arc_idb[a];
  32.622 +        _reverse[fi] = bi;
  32.623 +        _reverse[bi] = fi;
  32.624 +      }
  32.625 +
  32.626 +      // Reset parameters
  32.627 +      resetParams();
  32.628 +      return *this;
  32.629 +    }
  32.630 +
  32.631 +    /// @}
  32.632 +
  32.633 +    /// \name Query Functions
  32.634 +    /// The results of the algorithm can be obtained using these
  32.635 +    /// functions.\n
  32.636 +    /// The \ref run() function must be called before using them.
  32.637 +
  32.638 +    /// @{
  32.639 +
  32.640 +    /// \brief Return the total cost of the found flow.
  32.641 +    ///
  32.642 +    /// This function returns the total cost of the found flow.
  32.643 +    /// Its complexity is O(e).
  32.644 +    ///
  32.645 +    /// \note The return type of the function can be specified as a
  32.646 +    /// template parameter. For example,
  32.647 +    /// \code
  32.648 +    ///   cs.totalCost<double>();
  32.649 +    /// \endcode
  32.650 +    /// It is useful if the total cost cannot be stored in the \c Cost
  32.651 +    /// type of the algorithm, which is the default return type of the
  32.652 +    /// function.
  32.653 +    ///
  32.654 +    /// \pre \ref run() must be called before using this function.
  32.655 +    template <typename Number>
  32.656 +    Number totalCost() const {
  32.657 +      Number c = 0;
  32.658 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  32.659 +        int i = _arc_idb[a];
  32.660 +        c += static_cast<Number>(_res_cap[i]) *
  32.661 +             (-static_cast<Number>(_cost[i]));
  32.662 +      }
  32.663 +      return c;
  32.664 +    }
  32.665 +
  32.666 +#ifndef DOXYGEN
  32.667 +    Cost totalCost() const {
  32.668 +      return totalCost<Cost>();
  32.669 +    }
  32.670 +#endif
  32.671 +
  32.672 +    /// \brief Return the flow on the given arc.
  32.673 +    ///
  32.674 +    /// This function returns the flow on the given arc.
  32.675 +    ///
  32.676 +    /// \pre \ref run() must be called before using this function.
  32.677 +    Value flow(const Arc& a) const {
  32.678 +      return _res_cap[_arc_idb[a]];
  32.679 +    }
  32.680 +
  32.681 +    /// \brief Return the flow map (the primal solution).
  32.682 +    ///
  32.683 +    /// This function copies the flow value on each arc into the given
  32.684 +    /// map. The \c Value type of the algorithm must be convertible to
  32.685 +    /// the \c Value type of the map.
  32.686 +    ///
  32.687 +    /// \pre \ref run() must be called before using this function.
  32.688 +    template <typename FlowMap>
  32.689 +    void flowMap(FlowMap &map) const {
  32.690 +      for (ArcIt a(_graph); a != INVALID; ++a) {
  32.691 +        map.set(a, _res_cap[_arc_idb[a]]);
  32.692 +      }
  32.693 +    }
  32.694 +
  32.695 +    /// \brief Return the potential (dual value) of the given node.
  32.696 +    ///
  32.697 +    /// This function returns the potential (dual value) of the
  32.698 +    /// given node.
  32.699 +    ///
  32.700 +    /// \pre \ref run() must be called before using this function.
  32.701 +    Cost potential(const Node& n) const {
  32.702 +      return _pi[_node_id[n]];
  32.703 +    }
  32.704 +
  32.705 +    /// \brief Return the potential map (the dual solution).
  32.706 +    ///
  32.707 +    /// This function copies the potential (dual value) of each node
  32.708 +    /// into the given map.
  32.709 +    /// The \c Cost type of the algorithm must be convertible to the
  32.710 +    /// \c Value type of the map.
  32.711 +    ///
  32.712 +    /// \pre \ref run() must be called before using this function.
  32.713 +    template <typename PotentialMap>
  32.714 +    void potentialMap(PotentialMap &map) const {
  32.715 +      for (NodeIt n(_graph); n != INVALID; ++n) {
  32.716 +        map.set(n, _pi[_node_id[n]]);
  32.717 +      }
  32.718 +    }
  32.719 +
  32.720 +    /// @}
  32.721 +
  32.722 +  private:
  32.723 +
  32.724 +    // Initialize the algorithm
  32.725 +    ProblemType init() {
  32.726 +      if (_node_num <= 1) return INFEASIBLE;
  32.727 +
  32.728 +      // Check the sum of supply values
  32.729 +      _sum_supply = 0;
  32.730 +      for (int i = 0; i != _root; ++i) {
  32.731 +        _sum_supply += _supply[i];
  32.732 +      }
  32.733 +      if (_sum_supply > 0) return INFEASIBLE;
  32.734 +
  32.735 +      // Initialize vectors
  32.736 +      for (int i = 0; i != _root; ++i) {
  32.737 +        _pi[i] = 0;
  32.738 +        _excess[i] = _supply[i];
  32.739 +      }
  32.740 +
  32.741 +      // Remove non-zero lower bounds
  32.742 +      const Value MAX = std::numeric_limits<Value>::max();
  32.743 +      int last_out;
  32.744 +      if (_have_lower) {
  32.745 +        for (int i = 0; i != _root; ++i) {
  32.746 +          last_out = _first_out[i+1];
  32.747 +          for (int j = _first_out[i]; j != last_out; ++j) {
  32.748 +            if (_forward[j]) {
  32.749 +              Value c = _lower[j];
  32.750 +              if (c >= 0) {
  32.751 +                _res_cap[j] = _upper[j] < MAX ? _upper[j] - c : INF;
  32.752 +              } else {
  32.753 +                _res_cap[j] = _upper[j] < MAX + c ? _upper[j] - c : INF;
  32.754 +              }
  32.755 +              _excess[i] -= c;
  32.756 +              _excess[_target[j]] += c;
  32.757 +            } else {
  32.758 +              _res_cap[j] = 0;
  32.759 +            }
  32.760 +          }
  32.761 +        }
  32.762 +      } else {
  32.763 +        for (int j = 0; j != _res_arc_num; ++j) {
  32.764 +          _res_cap[j] = _forward[j] ? _upper[j] : 0;
  32.765 +        }
  32.766 +      }
  32.767 +
  32.768 +      // Handle negative costs
  32.769 +      for (int i = 0; i != _root; ++i) {
  32.770 +        last_out = _first_out[i+1] - 1;
  32.771 +        for (int j = _first_out[i]; j != last_out; ++j) {
  32.772 +          Value rc = _res_cap[j];
  32.773 +          if (_cost[j] < 0 && rc > 0) {
  32.774 +            if (rc >= MAX) return UNBOUNDED;
  32.775 +            _excess[i] -= rc;
  32.776 +            _excess[_target[j]] += rc;
  32.777 +            _res_cap[j] = 0;
  32.778 +            _res_cap[_reverse[j]] += rc;
  32.779 +          }
  32.780 +        }
  32.781 +      }
  32.782 +
  32.783 +      // Handle GEQ supply type
  32.784 +      if (_sum_supply < 0) {
  32.785 +        _pi[_root] = 0;
  32.786 +        _excess[_root] = -_sum_supply;
  32.787 +        for (int a = _first_out[_root]; a != _res_arc_num; ++a) {
  32.788 +          int ra = _reverse[a];
  32.789 +          _res_cap[a] = -_sum_supply + 1;
  32.790 +          _res_cap[ra] = 0;
  32.791 +          _cost[a] = 0;
  32.792 +          _cost[ra] = 0;
  32.793 +        }
  32.794 +      } else {
  32.795 +        _pi[_root] = 0;
  32.796 +        _excess[_root] = 0;
  32.797 +        for (int a = _first_out[_root]; a != _res_arc_num; ++a) {
  32.798 +          int ra = _reverse[a];
  32.799 +          _res_cap[a] = 1;
  32.800 +          _res_cap[ra] = 0;
  32.801 +          _cost[a] = 0;
  32.802 +          _cost[ra] = 0;
  32.803 +        }
  32.804 +      }
  32.805 +
  32.806 +      // Initialize delta value
  32.807 +      if (_factor > 1) {
  32.808 +        // With scaling
  32.809 +        Value max_sup = 0, max_dem = 0, max_cap = 0;
  32.810 +        for (int i = 0; i != _root; ++i) {
  32.811 +          Value ex = _excess[i];
  32.812 +          if ( ex > max_sup) max_sup =  ex;
  32.813 +          if (-ex > max_dem) max_dem = -ex;
  32.814 +          int last_out = _first_out[i+1] - 1;
  32.815 +          for (int j = _first_out[i]; j != last_out; ++j) {
  32.816 +            if (_res_cap[j] > max_cap) max_cap = _res_cap[j];
  32.817 +          }
  32.818 +        }
  32.819 +        max_sup = std::min(std::min(max_sup, max_dem), max_cap);
  32.820 +        for (_delta = 1; 2 * _delta <= max_sup; _delta *= 2) ;
  32.821 +      } else {
  32.822 +        // Without scaling
  32.823 +        _delta = 1;
  32.824 +      }
  32.825 +
  32.826 +      return OPTIMAL;
  32.827 +    }
  32.828 +
  32.829 +    ProblemType start() {
  32.830 +      // Execute the algorithm
  32.831 +      ProblemType pt;
  32.832 +      if (_delta > 1)
  32.833 +        pt = startWithScaling();
  32.834 +      else
  32.835 +        pt = startWithoutScaling();
  32.836 +
  32.837 +      // Handle non-zero lower bounds
  32.838 +      if (_have_lower) {
  32.839 +        int limit = _first_out[_root];
  32.840 +        for (int j = 0; j != limit; ++j) {
  32.841 +          if (!_forward[j]) _res_cap[j] += _lower[j];
  32.842 +        }
  32.843 +      }
  32.844 +
  32.845 +      // Shift potentials if necessary
  32.846 +      Cost pr = _pi[_root];
  32.847 +      if (_sum_supply < 0 || pr > 0) {
  32.848 +        for (int i = 0; i != _node_num; ++i) {
  32.849 +          _pi[i] -= pr;
  32.850 +        }
  32.851 +      }
  32.852 +
  32.853 +      return pt;
  32.854 +    }
  32.855 +
  32.856 +    // Execute the capacity scaling algorithm
  32.857 +    ProblemType startWithScaling() {
  32.858 +      // Perform capacity scaling phases
  32.859 +      int s, t;
  32.860 +      ResidualDijkstra _dijkstra(*this);
  32.861 +      while (true) {
  32.862 +        // Saturate all arcs not satisfying the optimality condition
  32.863 +        int last_out;
  32.864 +        for (int u = 0; u != _node_num; ++u) {
  32.865 +          last_out = _sum_supply < 0 ?
  32.866 +            _first_out[u+1] : _first_out[u+1] - 1;
  32.867 +          for (int a = _first_out[u]; a != last_out; ++a) {
  32.868 +            int v = _target[a];
  32.869 +            Cost c = _cost[a] + _pi[u] - _pi[v];
  32.870 +            Value rc = _res_cap[a];
  32.871 +            if (c < 0 && rc >= _delta) {
  32.872 +              _excess[u] -= rc;
  32.873 +              _excess[v] += rc;
  32.874 +              _res_cap[a] = 0;
  32.875 +              _res_cap[_reverse[a]] += rc;
  32.876 +            }
  32.877 +          }
  32.878 +        }
  32.879 +
  32.880 +        // Find excess nodes and deficit nodes
  32.881 +        _excess_nodes.clear();
  32.882 +        _deficit_nodes.clear();
  32.883 +        for (int u = 0; u != _node_num; ++u) {
  32.884 +          Value ex = _excess[u];
  32.885 +          if (ex >=  _delta) _excess_nodes.push_back(u);
  32.886 +          if (ex <= -_delta) _deficit_nodes.push_back(u);
  32.887 +        }
  32.888 +        int next_node = 0, next_def_node = 0;
  32.889 +
  32.890 +        // Find augmenting shortest paths
  32.891 +        while (next_node < int(_excess_nodes.size())) {
  32.892 +          // Check deficit nodes
  32.893 +          if (_delta > 1) {
  32.894 +            bool delta_deficit = false;
  32.895 +            for ( ; next_def_node < int(_deficit_nodes.size());
  32.896 +                    ++next_def_node ) {
  32.897 +              if (_excess[_deficit_nodes[next_def_node]] <= -_delta) {
  32.898 +                delta_deficit = true;
  32.899 +                break;
  32.900 +              }
  32.901 +            }
  32.902 +            if (!delta_deficit) break;
  32.903 +          }
  32.904 +
  32.905 +          // Run Dijkstra in the residual network
  32.906 +          s = _excess_nodes[next_node];
  32.907 +          if ((t = _dijkstra.run(s, _delta)) == -1) {
  32.908 +            if (_delta > 1) {
  32.909 +              ++next_node;
  32.910 +              continue;
  32.911 +            }
  32.912 +            return INFEASIBLE;
  32.913 +          }
  32.914 +
  32.915 +          // Augment along a shortest path from s to t
  32.916 +          Value d = std::min(_excess[s], -_excess[t]);
  32.917 +          int u = t;
  32.918 +          int a;
  32.919 +          if (d > _delta) {
  32.920 +            while ((a = _pred[u]) != -1) {
  32.921 +              if (_res_cap[a] < d) d = _res_cap[a];
  32.922 +              u = _source[a];
  32.923 +            }
  32.924 +          }
  32.925 +          u = t;
  32.926 +          while ((a = _pred[u]) != -1) {
  32.927 +            _res_cap[a] -= d;
  32.928 +            _res_cap[_reverse[a]] += d;
  32.929 +            u = _source[a];
  32.930 +          }
  32.931 +          _excess[s] -= d;
  32.932 +          _excess[t] += d;
  32.933 +
  32.934 +          if (_excess[s] < _delta) ++next_node;
  32.935 +        }
  32.936 +
  32.937 +        if (_delta == 1) break;
  32.938 +        _delta = _delta <= _factor ? 1 : _delta / _factor;
  32.939 +      }
  32.940 +
  32.941 +      return OPTIMAL;
  32.942 +    }
  32.943 +
  32.944 +    // Execute the successive shortest path algorithm
  32.945 +    ProblemType startWithoutScaling() {
  32.946 +      // Find excess nodes
  32.947 +      _excess_nodes.clear();
  32.948 +      for (int i = 0; i != _node_num; ++i) {
  32.949 +        if (_excess[i] > 0) _excess_nodes.push_back(i);
  32.950 +      }
  32.951 +      if (_excess_nodes.size() == 0) return OPTIMAL;
  32.952 +      int next_node = 0;
  32.953 +
  32.954 +      // Find shortest paths
  32.955 +      int s, t;
  32.956 +      ResidualDijkstra _dijkstra(*this);
  32.957 +      while ( _excess[_excess_nodes[next_node]] > 0 ||
  32.958 +              ++next_node < int(_excess_nodes.size()) )
  32.959 +      {
  32.960 +        // Run Dijkstra in the residual network
  32.961 +        s = _excess_nodes[next_node];
  32.962 +        if ((t = _dijkstra.run(s)) == -1) return INFEASIBLE;
  32.963 +
  32.964 +        // Augment along a shortest path from s to t
  32.965 +        Value d = std::min(_excess[s], -_excess[t]);
  32.966 +        int u = t;
  32.967 +        int a;
  32.968 +        if (d > 1) {
  32.969 +          while ((a = _pred[u]) != -1) {
  32.970 +            if (_res_cap[a] < d) d = _res_cap[a];
  32.971 +            u = _source[a];
  32.972 +          }
  32.973 +        }
  32.974 +        u = t;
  32.975 +        while ((a = _pred[u]) != -1) {
  32.976 +          _res_cap[a] -= d;
  32.977 +          _res_cap[_reverse[a]] += d;
  32.978 +          u = _source[a];
  32.979 +        }
  32.980 +        _excess[s] -= d;
  32.981 +        _excess[t] += d;
  32.982 +      }
  32.983 +
  32.984 +      return OPTIMAL;
  32.985 +    }
  32.986 +
  32.987 +  }; //class CapacityScaling
  32.988 +
  32.989 +  ///@}
  32.990 +
  32.991 +} //namespace lemon
  32.992 +
  32.993 +#endif //LEMON_CAPACITY_SCALING_H
    33.1 --- a/lemon/cbc.cc	Tue Dec 20 17:44:38 2011 +0100
    33.2 +++ b/lemon/cbc.cc	Tue Dec 20 18:15:14 2011 +0100
    33.3 @@ -94,6 +94,18 @@
    33.4      return _prob->numberRows() - 1;
    33.5    }
    33.6  
    33.7 +  int CbcMip::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
    33.8 +    std::vector<int> indexes;
    33.9 +    std::vector<Value> values;
   33.10 +
   33.11 +    for(ExprIterator it = b; it != e; ++it) {
   33.12 +      indexes.push_back(it->first);
   33.13 +      values.push_back(it->second);
   33.14 +    }
   33.15 +
   33.16 +    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
   33.17 +    return _prob->numberRows() - 1;
   33.18 +  }
   33.19  
   33.20    void CbcMip::_eraseCol(int i) {
   33.21      _prob->deleteColumn(i);
    34.1 --- a/lemon/cbc.h	Tue Dec 20 17:44:38 2011 +0100
    34.2 +++ b/lemon/cbc.h	Tue Dec 20 18:15:14 2011 +0100
    34.3 @@ -2,7 +2,7 @@
    34.4   *
    34.5   * This file is a part of LEMON, a generic C++ optimization library.
    34.6   *
    34.7 - * Copyright (C) 2003-2009
    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 @@ -62,6 +62,7 @@
   34.13  
   34.14      virtual int _addCol();
   34.15      virtual int _addRow();
   34.16 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
   34.17  
   34.18      virtual void _eraseCol(int i);
   34.19      virtual void _eraseRow(int i);
   34.20 @@ -120,7 +121,7 @@
   34.21  
   34.22      int _message_level;
   34.23  
   34.24 -    
   34.25 +
   34.26  
   34.27    };
   34.28  
    35.1 --- a/lemon/circulation.h	Tue Dec 20 17:44:38 2011 +0100
    35.2 +++ b/lemon/circulation.h	Tue Dec 20 18:15:14 2011 +0100
    35.3 @@ -2,7 +2,7 @@
    35.4   *
    35.5   * This file is a part of LEMON, a generic C++ optimization library.
    35.6   *
    35.7 - * Copyright (C) 2003-2009
    35.8 + * Copyright (C) 2003-2010
    35.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   35.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
   35.11   *
   35.12 @@ -59,8 +59,8 @@
   35.13  
   35.14      /// \brief The type of supply map.
   35.15      ///
   35.16 -    /// The type of the map that stores the signed supply values of the 
   35.17 -    /// nodes. 
   35.18 +    /// The type of the map that stores the signed supply values of the
   35.19 +    /// nodes.
   35.20      /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
   35.21      typedef SM SupplyMap;
   35.22  
   35.23 @@ -72,7 +72,11 @@
   35.24      /// The type of the map that stores the flow values.
   35.25      /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap"
   35.26      /// concept.
   35.27 +#ifdef DOXYGEN
   35.28 +    typedef GR::ArcMap<Value> FlowMap;
   35.29 +#else
   35.30      typedef typename Digraph::template ArcMap<Value> FlowMap;
   35.31 +#endif
   35.32  
   35.33      /// \brief Instantiates a FlowMap.
   35.34      ///
   35.35 @@ -87,9 +91,12 @@
   35.36      ///
   35.37      /// The elevator type used by the algorithm.
   35.38      ///
   35.39 -    /// \sa Elevator
   35.40 -    /// \sa LinkedElevator
   35.41 +    /// \sa Elevator, LinkedElevator
   35.42 +#ifdef DOXYGEN
   35.43 +    typedef lemon::Elevator<GR, GR::Node> Elevator;
   35.44 +#else
   35.45      typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator;
   35.46 +#endif
   35.47  
   35.48      /// \brief Instantiates an Elevator.
   35.49      ///
   35.50 @@ -134,7 +141,7 @@
   35.51       \f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu)
   35.52       \geq sup(u) \quad \forall u\in V, \f]
   35.53       \f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A. \f]
   35.54 -     
   35.55 +
   35.56       The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be
   35.57       zero or negative in order to have a feasible solution (since the sum
   35.58       of the expressions on the left-hand side of the inequalities is zero).
   35.59 @@ -144,7 +151,7 @@
   35.60       If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand
   35.61       constraints have to be satisfied with equality, i.e. all demands
   35.62       have to be satisfied and all supplies have to be used.
   35.63 -     
   35.64 +
   35.65       If you need the opposite inequalities in the supply/demand constraints
   35.66       (i.e. the total demand is less than the total supply and all the demands
   35.67       have to be satisfied while there could be supplies that are not used),
   35.68 @@ -166,6 +173,11 @@
   35.69       The default map type is \c LM.
   35.70       \tparam SM The type of the supply map. The default map type is
   35.71       \ref concepts::Digraph::NodeMap "GR::NodeMap<UM::Value>".
   35.72 +     \tparam TR The traits class that defines various types used by the
   35.73 +     algorithm. By default, it is \ref CirculationDefaultTraits
   35.74 +     "CirculationDefaultTraits<GR, LM, UM, SM>".
   35.75 +     In most cases, this parameter should not be set directly,
   35.76 +     consider to use the named template parameters instead.
   35.77    */
   35.78  #ifdef DOXYGEN
   35.79  template< typename GR,
   35.80 @@ -299,7 +311,7 @@
   35.81      /// The Elevator should have standard constructor interface to be
   35.82      /// able to automatically created by the algorithm (i.e. the
   35.83      /// digraph and the maximum level should be passed to it).
   35.84 -    /// However an external elevator object could also be passed to the
   35.85 +    /// However, an external elevator object could also be passed to the
   35.86      /// algorithm with the \ref elevator(Elevator&) "elevator()" function
   35.87      /// before calling \ref run() or \ref init().
   35.88      /// \sa SetElevator
   35.89 @@ -325,7 +337,7 @@
   35.90      ///
   35.91      /// \param graph The digraph the algorithm runs on.
   35.92      /// \param lower The lower bounds for the flow values on the arcs.
   35.93 -    /// \param upper The upper bounds (capacities) for the flow values 
   35.94 +    /// \param upper The upper bounds (capacities) for the flow values
   35.95      /// on the arcs.
   35.96      /// \param supply The signed supply values of the nodes.
   35.97      Circulation(const Digraph &graph, const LowerMap &lower,
   35.98 @@ -450,9 +462,10 @@
   35.99        return *_level;
  35.100      }
  35.101  
  35.102 -    /// \brief Sets the tolerance used by algorithm.
  35.103 +    /// \brief Sets the tolerance used by the algorithm.
  35.104      ///
  35.105 -    /// Sets the tolerance used by algorithm.
  35.106 +    /// Sets the tolerance object used by the algorithm.
  35.107 +    /// \return <tt>(*this)</tt>
  35.108      Circulation& tolerance(const Tolerance& tolerance) {
  35.109        _tol = tolerance;
  35.110        return *this;
  35.111 @@ -460,15 +473,16 @@
  35.112  
  35.113      /// \brief Returns a const reference to the tolerance.
  35.114      ///
  35.115 -    /// Returns a const reference to the tolerance.
  35.116 +    /// Returns a const reference to the tolerance object used by
  35.117 +    /// the algorithm.
  35.118      const Tolerance& tolerance() const {
  35.119        return _tol;
  35.120      }
  35.121  
  35.122      /// \name Execution Control
  35.123      /// The simplest way to execute the algorithm is to call \ref run().\n
  35.124 -    /// If you need more control on the initial solution or the execution,
  35.125 -    /// first you have to call one of the \ref init() functions, then
  35.126 +    /// If you need better control on the initial solution or the execution,
  35.127 +    /// you have to call one of the \ref init() functions first, then
  35.128      /// the \ref start() function.
  35.129  
  35.130      ///@{
    36.1 --- a/lemon/clp.cc	Tue Dec 20 17:44:38 2011 +0100
    36.2 +++ b/lemon/clp.cc	Tue Dec 20 18:15:14 2011 +0100
    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-2008
    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 @@ -78,6 +78,19 @@
   36.13      return _prob->numberRows() - 1;
   36.14    }
   36.15  
   36.16 +  int ClpLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
   36.17 +    std::vector<int> indexes;
   36.18 +    std::vector<Value> values;
   36.19 +
   36.20 +    for(ExprIterator it = b; it != e; ++it) {
   36.21 +      indexes.push_back(it->first);
   36.22 +      values.push_back(it->second);
   36.23 +    }
   36.24 +
   36.25 +    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
   36.26 +    return _prob->numberRows() - 1;
   36.27 +  }
   36.28 +
   36.29  
   36.30    void ClpLp::_eraseCol(int c) {
   36.31      _col_names_ref.erase(_prob->getColumnName(c));
    37.1 --- a/lemon/clp.h	Tue Dec 20 17:44:38 2011 +0100
    37.2 +++ b/lemon/clp.h	Tue Dec 20 18:15:14 2011 +0100
    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-2008
    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 @@ -75,6 +75,7 @@
   37.13  
   37.14      virtual int _addCol();
   37.15      virtual int _addRow();
   37.16 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
   37.17  
   37.18      virtual void _eraseCol(int i);
   37.19      virtual void _eraseRow(int i);
   37.20 @@ -137,7 +138,7 @@
   37.21      virtual void _clear();
   37.22  
   37.23      virtual void _messageLevel(MessageLevel);
   37.24 -    
   37.25 +
   37.26    public:
   37.27  
   37.28      ///Solves LP with primal simplex method.
    38.1 --- a/lemon/concepts/digraph.h	Tue Dec 20 17:44:38 2011 +0100
    38.2 +++ b/lemon/concepts/digraph.h	Tue Dec 20 18:15:14 2011 +0100
    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-2009
    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 @@ -35,46 +35,40 @@
   38.13      ///
   38.14      /// \brief Class describing the concept of directed graphs.
   38.15      ///
   38.16 -    /// This class describes the \ref concept "concept" of the
   38.17 -    /// immutable directed digraphs.
   38.18 +    /// This class describes the common interface of all directed
   38.19 +    /// graphs (digraphs).
   38.20      ///
   38.21 -    /// Note that actual digraph implementation like @ref ListDigraph or
   38.22 -    /// @ref SmartDigraph may have several additional functionality.
   38.23 +    /// Like all concept classes, it only provides an interface
   38.24 +    /// without any sensible implementation. So any general algorithm for
   38.25 +    /// directed graphs should compile with this class, but it will not
   38.26 +    /// run properly, of course.
   38.27 +    /// An actual digraph implementation like \ref ListDigraph or
   38.28 +    /// \ref SmartDigraph may have additional functionality.
   38.29      ///
   38.30 -    /// \sa concept
   38.31 +    /// \sa Graph
   38.32      class Digraph {
   38.33      private:
   38.34 -      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
   38.35 +      /// Diraphs are \e not copy constructible. Use DigraphCopy instead.
   38.36 +      Digraph(const Digraph &) {}
   38.37 +      /// \brief Assignment of a digraph to another one is \e not allowed.
   38.38 +      /// Use DigraphCopy instead.
   38.39 +      void operator=(const Digraph &) {}
   38.40  
   38.41 -      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
   38.42 -      ///
   38.43 -      Digraph(const Digraph &) {};
   38.44 -      ///\brief Assignment of \ref Digraph "Digraph"s to another ones are
   38.45 -      ///\e not allowed. Use DigraphCopy() instead.
   38.46 +    public:
   38.47 +      /// Default constructor.
   38.48 +      Digraph() { }
   38.49  
   38.50 -      ///Assignment of \ref Digraph "Digraph"s to another ones are
   38.51 -      ///\e not allowed.  Use DigraphCopy() instead.
   38.52 -
   38.53 -      void operator=(const Digraph &) {}
   38.54 -    public:
   38.55 -      ///\e
   38.56 -
   38.57 -      /// Defalult constructor.
   38.58 -
   38.59 -      /// Defalult constructor.
   38.60 -      ///
   38.61 -      Digraph() { }
   38.62 -      /// Class for identifying a node of the digraph
   38.63 +      /// The node type of the digraph
   38.64  
   38.65        /// This class identifies a node of the digraph. It also serves
   38.66        /// as a base class of the node iterators,
   38.67 -      /// thus they will convert to this type.
   38.68 +      /// thus they convert to this type.
   38.69        class Node {
   38.70        public:
   38.71          /// Default constructor
   38.72  
   38.73 -        /// @warning The default constructor sets the iterator
   38.74 -        /// to an undefined value.
   38.75 +        /// Default constructor.
   38.76 +        /// \warning It sets the object to an undefined value.
   38.77          Node() { }
   38.78          /// Copy constructor.
   38.79  
   38.80 @@ -82,40 +76,39 @@
   38.81          ///
   38.82          Node(const Node&) { }
   38.83  
   38.84 -        /// Invalid constructor \& conversion.
   38.85 +        /// %Invalid constructor \& conversion.
   38.86  
   38.87 -        /// This constructor initializes the iterator to be invalid.
   38.88 +        /// Initializes the object to be invalid.
   38.89          /// \sa Invalid for more details.
   38.90          Node(Invalid) { }
   38.91          /// Equality operator
   38.92  
   38.93 +        /// Equality operator.
   38.94 +        ///
   38.95          /// Two iterators are equal if and only if they point to the
   38.96 -        /// same object or both are invalid.
   38.97 +        /// same object or both are \c INVALID.
   38.98          bool operator==(Node) const { return true; }
   38.99  
  38.100          /// Inequality operator
  38.101  
  38.102 -        /// \sa operator==(Node n)
  38.103 -        ///
  38.104 +        /// Inequality operator.
  38.105          bool operator!=(Node) const { return true; }
  38.106  
  38.107          /// Artificial ordering operator.
  38.108  
  38.109 -        /// To allow the use of digraph descriptors as key type in std::map or
  38.110 -        /// similar associative container we require this.
  38.111 +        /// Artificial ordering operator.
  38.112          ///
  38.113 -        /// \note This operator only have to define some strict ordering of
  38.114 -        /// the items; this order has nothing to do with the iteration
  38.115 -        /// ordering of the items.
  38.116 +        /// \note This operator only has to define some strict ordering of
  38.117 +        /// the nodes; this order has nothing to do with the iteration
  38.118 +        /// ordering of the nodes.
  38.119          bool operator<(Node) const { return false; }
  38.120 -
  38.121        };
  38.122  
  38.123 -      /// This iterator goes through each node.
  38.124 +      /// Iterator class for the nodes.
  38.125  
  38.126 -      /// This iterator goes through each node.
  38.127 -      /// Its usage is quite simple, for example you can count the number
  38.128 -      /// of nodes in digraph \c g of type \c Digraph like this:
  38.129 +      /// This iterator goes through each node of the digraph.
  38.130 +      /// Its usage is quite simple, for example, you can count the number
  38.131 +      /// of nodes in a digraph \c g of type \c %Digraph like this:
  38.132        ///\code
  38.133        /// int count=0;
  38.134        /// for (Digraph::NodeIt n(g); n!=INVALID; ++n) ++count;
  38.135 @@ -124,30 +117,28 @@
  38.136        public:
  38.137          /// Default constructor
  38.138  
  38.139 -        /// @warning The default constructor sets the iterator
  38.140 -        /// to an undefined value.
  38.141 +        /// Default constructor.
  38.142 +        /// \warning It sets the iterator to an undefined value.
  38.143          NodeIt() { }
  38.144          /// Copy constructor.
  38.145  
  38.146          /// Copy constructor.
  38.147          ///
  38.148          NodeIt(const NodeIt& n) : Node(n) { }
  38.149 -        /// Invalid constructor \& conversion.
  38.150 +        /// %Invalid constructor \& conversion.
  38.151  
  38.152 -        /// Initialize the iterator to be invalid.
  38.153 +        /// Initializes the iterator to be invalid.
  38.154          /// \sa Invalid for more details.
  38.155          NodeIt(Invalid) { }
  38.156          /// Sets the iterator to the first node.
  38.157  
  38.158 -        /// Sets the iterator to the first node of \c g.
  38.159 +        /// Sets the iterator to the first node of the given digraph.
  38.160          ///
  38.161 -        NodeIt(const Digraph&) { }
  38.162 -        /// Node -> NodeIt conversion.
  38.163 +        explicit NodeIt(const Digraph&) { }
  38.164 +        /// Sets the iterator to the given node.
  38.165  
  38.166 -        /// Sets the iterator to the node of \c the digraph pointed by
  38.167 -        /// the trivial iterator.
  38.168 -        /// This feature necessitates that each time we
  38.169 -        /// iterate the arc-set, the iteration order is the same.
  38.170 +        /// Sets the iterator to the given node of the given digraph.
  38.171 +        ///
  38.172          NodeIt(const Digraph&, const Node&) { }
  38.173          /// Next node.
  38.174  
  38.175 @@ -157,7 +148,7 @@
  38.176        };
  38.177  
  38.178  
  38.179 -      /// Class for identifying an arc of the digraph
  38.180 +      /// The arc type of the digraph
  38.181  
  38.182        /// This class identifies an arc of the digraph. It also serves
  38.183        /// as a base class of the arc iterators,
  38.184 @@ -166,207 +157,214 @@
  38.185        public:
  38.186          /// Default constructor
  38.187  
  38.188 -        /// @warning The default constructor sets the iterator
  38.189 -        /// to an undefined value.
  38.190 +        /// Default constructor.
  38.191 +        /// \warning It sets the object to an undefined value.
  38.192          Arc() { }
  38.193          /// Copy constructor.
  38.194  
  38.195          /// Copy constructor.
  38.196          ///
  38.197          Arc(const Arc&) { }
  38.198 -        /// Initialize the iterator to be invalid.
  38.199 +        /// %Invalid constructor \& conversion.
  38.200  
  38.201 -        /// Initialize the iterator to be invalid.
  38.202 -        ///
  38.203 +        /// Initializes the object to be invalid.
  38.204 +        /// \sa Invalid for more details.
  38.205          Arc(Invalid) { }
  38.206          /// Equality operator
  38.207  
  38.208 +        /// Equality operator.
  38.209 +        ///
  38.210          /// Two iterators are equal if and only if they point to the
  38.211 -        /// same object or both are invalid.
  38.212 +        /// same object or both are \c INVALID.
  38.213          bool operator==(Arc) const { return true; }
  38.214          /// Inequality operator
  38.215  
  38.216 -        /// \sa operator==(Arc n)
  38.217 -        ///
  38.218 +        /// Inequality operator.
  38.219          bool operator!=(Arc) const { return true; }
  38.220  
  38.221          /// Artificial ordering operator.
  38.222  
  38.223 -        /// To allow the use of digraph descriptors as key type in std::map or
  38.224 -        /// similar associative container we require this.
  38.225 +        /// Artificial ordering operator.
  38.226          ///
  38.227 -        /// \note This operator only have to define some strict ordering of
  38.228 -        /// the items; this order has nothing to do with the iteration
  38.229 -        /// ordering of the items.
  38.230 +        /// \note This operator only has to define some strict ordering of
  38.231 +        /// the arcs; this order has nothing to do with the iteration
  38.232 +        /// ordering of the arcs.
  38.233          bool operator<(Arc) const { return false; }
  38.234        };
  38.235  
  38.236 -      /// This iterator goes trough the outgoing arcs of a node.
  38.237 +      /// Iterator class for the outgoing arcs of a node.
  38.238  
  38.239        /// This iterator goes trough the \e outgoing arcs of a certain node
  38.240        /// of a digraph.
  38.241 -      /// Its usage is quite simple, for example you can count the number
  38.242 +      /// Its usage is quite simple, for example, you can count the number
  38.243        /// of outgoing arcs of a node \c n
  38.244 -      /// in digraph \c g of type \c Digraph as follows.
  38.245 +      /// in a digraph \c g of type \c %Digraph as follows.
  38.246        ///\code
  38.247        /// int count=0;
  38.248 -      /// for (Digraph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
  38.249 +      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
  38.250        ///\endcode
  38.251 -
  38.252        class OutArcIt : public Arc {
  38.253        public:
  38.254          /// Default constructor
  38.255  
  38.256 -        /// @warning The default constructor sets the iterator
  38.257 -        /// to an undefined value.
  38.258 +        /// Default constructor.
  38.259 +        /// \warning It sets the iterator to an undefined value.
  38.260          OutArcIt() { }
  38.261          /// Copy constructor.
  38.262  
  38.263          /// Copy constructor.
  38.264          ///
  38.265          OutArcIt(const OutArcIt& e) : Arc(e) { }
  38.266 -        /// Initialize the iterator to be invalid.
  38.267 +        /// %Invalid constructor \& conversion.
  38.268  
  38.269 -        /// Initialize the iterator to be invalid.
  38.270 +        /// Initializes the iterator to be invalid.
  38.271 +        /// \sa Invalid for more details.
  38.272 +        OutArcIt(Invalid) { }
  38.273 +        /// Sets the iterator to the first outgoing arc.
  38.274 +
  38.275 +        /// Sets the iterator to the first outgoing arc of the given node.
  38.276          ///
  38.277 -        OutArcIt(Invalid) { }
  38.278 -        /// This constructor sets the iterator to the first outgoing arc.
  38.279 +        OutArcIt(const Digraph&, const Node&) { }
  38.280 +        /// Sets the iterator to the given arc.
  38.281  
  38.282 -        /// This constructor sets the iterator to the first outgoing arc of
  38.283 -        /// the node.
  38.284 -        OutArcIt(const Digraph&, const Node&) { }
  38.285 -        /// Arc -> OutArcIt conversion
  38.286 -
  38.287 -        /// Sets the iterator to the value of the trivial iterator.
  38.288 -        /// This feature necessitates that each time we
  38.289 -        /// iterate the arc-set, the iteration order is the same.
  38.290 +        /// Sets the iterator to the given arc of the given digraph.
  38.291 +        ///
  38.292          OutArcIt(const Digraph&, const Arc&) { }
  38.293 -        ///Next outgoing arc
  38.294 +        /// Next outgoing arc
  38.295  
  38.296          /// Assign the iterator to the next
  38.297          /// outgoing arc of the corresponding node.
  38.298          OutArcIt& operator++() { return *this; }
  38.299        };
  38.300  
  38.301 -      /// This iterator goes trough the incoming arcs of a node.
  38.302 +      /// Iterator class for the incoming arcs of a node.
  38.303  
  38.304        /// This iterator goes trough the \e incoming arcs of a certain node
  38.305        /// of a digraph.
  38.306 -      /// Its usage is quite simple, for example you can count the number
  38.307 -      /// of outgoing arcs of a node \c n
  38.308 -      /// in digraph \c g of type \c Digraph as follows.
  38.309 +      /// Its usage is quite simple, for example, you can count the number
  38.310 +      /// of incoming arcs of a node \c n
  38.311 +      /// in a digraph \c g of type \c %Digraph as follows.
  38.312        ///\code
  38.313        /// int count=0;
  38.314 -      /// for(Digraph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
  38.315 +      /// for(Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
  38.316        ///\endcode
  38.317 -
  38.318        class InArcIt : public Arc {
  38.319        public:
  38.320          /// Default constructor
  38.321  
  38.322 -        /// @warning The default constructor sets the iterator
  38.323 -        /// to an undefined value.
  38.324 +        /// Default constructor.
  38.325 +        /// \warning It sets the iterator to an undefined value.
  38.326          InArcIt() { }
  38.327          /// Copy constructor.
  38.328  
  38.329          /// Copy constructor.
  38.330          ///
  38.331          InArcIt(const InArcIt& e) : Arc(e) { }
  38.332 -        /// Initialize the iterator to be invalid.
  38.333 +        /// %Invalid constructor \& conversion.
  38.334  
  38.335 -        /// Initialize the iterator to be invalid.
  38.336 +        /// Initializes the iterator to be invalid.
  38.337 +        /// \sa Invalid for more details.
  38.338 +        InArcIt(Invalid) { }
  38.339 +        /// Sets the iterator to the first incoming arc.
  38.340 +
  38.341 +        /// Sets the iterator to the first incoming arc of the given node.
  38.342          ///
  38.343 -        InArcIt(Invalid) { }
  38.344 -        /// This constructor sets the iterator to first incoming arc.
  38.345 +        InArcIt(const Digraph&, const Node&) { }
  38.346 +        /// Sets the iterator to the given arc.
  38.347  
  38.348 -        /// This constructor set the iterator to the first incoming arc of
  38.349 -        /// the node.
  38.350 -        InArcIt(const Digraph&, const Node&) { }
  38.351 -        /// Arc -> InArcIt conversion
  38.352 -
  38.353 -        /// Sets the iterator to the value of the trivial iterator \c e.
  38.354 -        /// This feature necessitates that each time we
  38.355 -        /// iterate the arc-set, the iteration order is the same.
  38.356 +        /// Sets the iterator to the given arc of the given digraph.
  38.357 +        ///
  38.358          InArcIt(const Digraph&, const Arc&) { }
  38.359          /// Next incoming arc
  38.360  
  38.361 -        /// Assign the iterator to the next inarc of the corresponding node.
  38.362 -        ///
  38.363 +        /// Assign the iterator to the next
  38.364 +        /// incoming arc of the corresponding node.
  38.365          InArcIt& operator++() { return *this; }
  38.366        };
  38.367 -      /// This iterator goes through each arc.
  38.368  
  38.369 -      /// This iterator goes through each arc of a digraph.
  38.370 -      /// Its usage is quite simple, for example you can count the number
  38.371 -      /// of arcs in a digraph \c g of type \c Digraph as follows:
  38.372 +      /// Iterator class for the arcs.
  38.373 +
  38.374 +      /// This iterator goes through each arc of the digraph.
  38.375 +      /// Its usage is quite simple, for example, you can count the number
  38.376 +      /// of arcs in a digraph \c g of type \c %Digraph as follows:
  38.377        ///\code
  38.378        /// int count=0;
  38.379 -      /// for(Digraph::ArcIt e(g); e!=INVALID; ++e) ++count;
  38.380 +      /// for(Digraph::ArcIt a(g); a!=INVALID; ++a) ++count;
  38.381        ///\endcode
  38.382        class ArcIt : public Arc {
  38.383        public:
  38.384          /// Default constructor
  38.385  
  38.386 -        /// @warning The default constructor sets the iterator
  38.387 -        /// to an undefined value.
  38.388 +        /// Default constructor.
  38.389 +        /// \warning It sets the iterator to an undefined value.
  38.390          ArcIt() { }
  38.391          /// Copy constructor.
  38.392  
  38.393          /// Copy constructor.
  38.394          ///
  38.395          ArcIt(const ArcIt& e) : Arc(e) { }
  38.396 -        /// Initialize the iterator to be invalid.
  38.397 +        /// %Invalid constructor \& conversion.
  38.398  
  38.399 -        /// Initialize the iterator to be invalid.
  38.400 +        /// Initializes the iterator to be invalid.
  38.401 +        /// \sa Invalid for more details.
  38.402 +        ArcIt(Invalid) { }
  38.403 +        /// Sets the iterator to the first arc.
  38.404 +
  38.405 +        /// Sets the iterator to the first arc of the given digraph.
  38.406          ///
  38.407 -        ArcIt(Invalid) { }
  38.408 -        /// This constructor sets the iterator to the first arc.
  38.409 +        explicit ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
  38.410 +        /// Sets the iterator to the given arc.
  38.411  
  38.412 -        /// This constructor sets the iterator to the first arc of \c g.
  38.413 -        ///@param g the digraph
  38.414 -        ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
  38.415 -        /// Arc -> ArcIt conversion
  38.416 -
  38.417 -        /// Sets the iterator to the value of the trivial iterator \c e.
  38.418 -        /// This feature necessitates that each time we
  38.419 -        /// iterate the arc-set, the iteration order is the same.
  38.420 +        /// Sets the iterator to the given arc of the given digraph.
  38.421 +        ///
  38.422          ArcIt(const Digraph&, const Arc&) { }
  38.423 -        ///Next arc
  38.424 +        /// Next arc
  38.425  
  38.426          /// Assign the iterator to the next arc.
  38.427 +        ///
  38.428          ArcIt& operator++() { return *this; }
  38.429        };
  38.430 -      ///Gives back the target node of an arc.
  38.431  
  38.432 -      ///Gives back the target node of an arc.
  38.433 +      /// \brief The source node of the arc.
  38.434        ///
  38.435 -      Node target(Arc) const { return INVALID; }
  38.436 -      ///Gives back the source node of an arc.
  38.437 -
  38.438 -      ///Gives back the source node of an arc.
  38.439 -      ///
  38.440 +      /// Returns the source node of the given arc.
  38.441        Node source(Arc) const { return INVALID; }
  38.442  
  38.443 -      /// \brief Returns the ID of the node.
  38.444 +      /// \brief The target node of the arc.
  38.445 +      ///
  38.446 +      /// Returns the target node of the given arc.
  38.447 +      Node target(Arc) const { return INVALID; }
  38.448 +
  38.449 +      /// \brief The ID of the node.
  38.450 +      ///
  38.451 +      /// Returns the ID of the given node.
  38.452        int id(Node) const { return -1; }
  38.453  
  38.454 -      /// \brief Returns the ID of the arc.
  38.455 +      /// \brief The ID of the arc.
  38.456 +      ///
  38.457 +      /// Returns the ID of the given arc.
  38.458        int id(Arc) const { return -1; }
  38.459  
  38.460 -      /// \brief Returns the node with the given ID.
  38.461 +      /// \brief The node with the given ID.
  38.462        ///
  38.463 -      /// \pre The argument should be a valid node ID in the graph.
  38.464 +      /// Returns the node with the given ID.
  38.465 +      /// \pre The argument should be a valid node ID in the digraph.
  38.466        Node nodeFromId(int) const { return INVALID; }
  38.467  
  38.468 -      /// \brief Returns the arc with the given ID.
  38.469 +      /// \brief The arc with the given ID.
  38.470        ///
  38.471 -      /// \pre The argument should be a valid arc ID in the graph.
  38.472 +      /// Returns the arc with the given ID.
  38.473 +      /// \pre The argument should be a valid arc ID in the digraph.
  38.474        Arc arcFromId(int) const { return INVALID; }
  38.475  
  38.476 -      /// \brief Returns an upper bound on the node IDs.
  38.477 +      /// \brief An upper bound on the node IDs.
  38.478 +      ///
  38.479 +      /// Returns an upper bound on the node IDs.
  38.480        int maxNodeId() const { return -1; }
  38.481  
  38.482 -      /// \brief Returns an upper bound on the arc IDs.
  38.483 +      /// \brief An upper bound on the arc IDs.
  38.484 +      ///
  38.485 +      /// Returns an upper bound on the arc IDs.
  38.486        int maxArcId() const { return -1; }
  38.487  
  38.488        void first(Node&) const {}
  38.489 @@ -392,50 +390,51 @@
  38.490        // Dummy parameter.
  38.491        int maxId(Arc) const { return -1; }
  38.492  
  38.493 +      /// \brief The opposite node on the arc.
  38.494 +      ///
  38.495 +      /// Returns the opposite node on the given arc.
  38.496 +      Node oppositeNode(Node, Arc) const { return INVALID; }
  38.497 +
  38.498        /// \brief The base node of the iterator.
  38.499        ///
  38.500 -      /// Gives back the base node of the iterator.
  38.501 -      /// It is always the target of the pointed arc.
  38.502 -      Node baseNode(const InArcIt&) const { return INVALID; }
  38.503 +      /// Returns the base node of the given outgoing arc iterator
  38.504 +      /// (i.e. the source node of the corresponding arc).
  38.505 +      Node baseNode(OutArcIt) const { return INVALID; }
  38.506  
  38.507        /// \brief The running node of the iterator.
  38.508        ///
  38.509 -      /// Gives back the running node of the iterator.
  38.510 -      /// It is always the source of the pointed arc.
  38.511 -      Node runningNode(const InArcIt&) const { return INVALID; }
  38.512 +      /// Returns the running node of the given outgoing arc iterator
  38.513 +      /// (i.e. the target node of the corresponding arc).
  38.514 +      Node runningNode(OutArcIt) const { return INVALID; }
  38.515  
  38.516        /// \brief The base node of the iterator.
  38.517        ///
  38.518 -      /// Gives back the base node of the iterator.
  38.519 -      /// It is always the source of the pointed arc.
  38.520 -      Node baseNode(const OutArcIt&) const { return INVALID; }
  38.521 +      /// Returns the base node of the given incomming arc iterator
  38.522 +      /// (i.e. the target node of the corresponding arc).
  38.523 +      Node baseNode(InArcIt) const { return INVALID; }
  38.524  
  38.525        /// \brief The running node of the iterator.
  38.526        ///
  38.527 -      /// Gives back the running node of the iterator.
  38.528 -      /// It is always the target of the pointed arc.
  38.529 -      Node runningNode(const OutArcIt&) const { return INVALID; }
  38.530 +      /// Returns the running node of the given incomming arc iterator
  38.531 +      /// (i.e. the source node of the corresponding arc).
  38.532 +      Node runningNode(InArcIt) const { return INVALID; }
  38.533  
  38.534 -      /// \brief The opposite node on the given arc.
  38.535 +      /// \brief Standard graph map type for the nodes.
  38.536        ///
  38.537 -      /// Gives back the opposite node on the given arc.
  38.538 -      Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
  38.539 -
  38.540 -      /// \brief Reference map of the nodes to type \c T.
  38.541 -      ///
  38.542 -      /// Reference map of the nodes to type \c T.
  38.543 +      /// Standard graph map type for the nodes.
  38.544 +      /// It conforms to the ReferenceMap concept.
  38.545        template<class T>
  38.546        class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
  38.547        public:
  38.548  
  38.549 -        ///\e
  38.550 -        NodeMap(const Digraph&) { }
  38.551 -        ///\e
  38.552 +        /// Constructor
  38.553 +        explicit NodeMap(const Digraph&) { }
  38.554 +        /// Constructor with given initial value
  38.555          NodeMap(const Digraph&, T) { }
  38.556  
  38.557        private:
  38.558          ///Copy constructor
  38.559 -        NodeMap(const NodeMap& nm) : 
  38.560 +        NodeMap(const NodeMap& nm) :
  38.561            ReferenceMap<Node, T, T&, const T&>(nm) { }
  38.562          ///Assignment operator
  38.563          template <typename CMap>
  38.564 @@ -445,17 +444,19 @@
  38.565          }
  38.566        };
  38.567  
  38.568 -      /// \brief Reference map of the arcs to type \c T.
  38.569 +      /// \brief Standard graph map type for the arcs.
  38.570        ///
  38.571 -      /// Reference map of the arcs to type \c T.
  38.572 +      /// Standard graph map type for the arcs.
  38.573 +      /// It conforms to the ReferenceMap concept.
  38.574        template<class T>
  38.575        class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
  38.576        public:
  38.577  
  38.578 -        ///\e
  38.579 -        ArcMap(const Digraph&) { }
  38.580 -        ///\e
  38.581 +        /// Constructor
  38.582 +        explicit ArcMap(const Digraph&) { }
  38.583 +        /// Constructor with given initial value
  38.584          ArcMap(const Digraph&, T) { }
  38.585 +
  38.586        private:
  38.587          ///Copy constructor
  38.588          ArcMap(const ArcMap& em) :
    39.1 --- a/lemon/concepts/graph.h	Tue Dec 20 17:44:38 2011 +0100
    39.2 +++ b/lemon/concepts/graph.h	Tue Dec 20 18:15:14 2011 +0100
    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-2009
    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 @@ -18,12 +18,14 @@
   39.13  
   39.14  ///\ingroup graph_concepts
   39.15  ///\file
   39.16 -///\brief The concept of Undirected Graphs.
   39.17 +///\brief The concept of undirected graphs.
   39.18  
   39.19  #ifndef LEMON_CONCEPTS_GRAPH_H
   39.20  #define LEMON_CONCEPTS_GRAPH_H
   39.21  
   39.22  #include <lemon/concepts/graph_components.h>
   39.23 +#include <lemon/concepts/maps.h>
   39.24 +#include <lemon/concept_check.h>
   39.25  #include <lemon/core.h>
   39.26  
   39.27  namespace lemon {
   39.28 @@ -31,63 +33,74 @@
   39.29  
   39.30      /// \ingroup graph_concepts
   39.31      ///
   39.32 -    /// \brief Class describing the concept of Undirected Graphs.
   39.33 +    /// \brief Class describing the concept of undirected graphs.
   39.34      ///
   39.35 -    /// This class describes the common interface of all Undirected
   39.36 -    /// Graphs.
   39.37 +    /// This class describes the common interface of all undirected
   39.38 +    /// graphs.
   39.39      ///
   39.40 -    /// As all concept describing classes it provides only interface
   39.41 -    /// without any sensible implementation. So any algorithm for
   39.42 -    /// undirected graph should compile with this class, but it will not
   39.43 +    /// Like all concept classes, it only provides an interface
   39.44 +    /// without any sensible implementation. So any general algorithm for
   39.45 +    /// undirected graphs should compile with this class, but it will not
   39.46      /// run properly, of course.
   39.47 +    /// An actual graph implementation like \ref ListGraph or
   39.48 +    /// \ref SmartGraph may have additional functionality.
   39.49      ///
   39.50 -    /// The LEMON undirected graphs also fulfill the concept of
   39.51 -    /// directed graphs (\ref lemon::concepts::Digraph "Digraph
   39.52 -    /// Concept"). Each edges can be seen as two opposite
   39.53 -    /// directed arc and consequently the undirected graph can be
   39.54 -    /// seen as the direceted graph of these directed arcs. The
   39.55 -    /// Graph has the Edge inner class for the edges and
   39.56 -    /// the Arc type for the directed arcs. The Arc type is
   39.57 -    /// convertible to Edge or inherited from it so from a directed
   39.58 -    /// arc we can get the represented edge.
   39.59 +    /// The undirected graphs also fulfill the concept of \ref Digraph
   39.60 +    /// "directed graphs", since each edge can also be regarded as two
   39.61 +    /// oppositely directed arcs.
   39.62 +    /// Undirected graphs provide an Edge type for the undirected edges and
   39.63 +    /// an Arc type for the directed arcs. The Arc type is convertible to
   39.64 +    /// Edge or inherited from it, i.e. the corresponding edge can be
   39.65 +    /// obtained from an arc.
   39.66 +    /// EdgeIt and EdgeMap classes can be used for the edges, while ArcIt
   39.67 +    /// and ArcMap classes can be used for the arcs (just like in digraphs).
   39.68 +    /// Both InArcIt and OutArcIt iterates on the same edges but with
   39.69 +    /// opposite direction. IncEdgeIt also iterates on the same edges
   39.70 +    /// as OutArcIt and InArcIt, but it is not convertible to Arc,
   39.71 +    /// only to Edge.
   39.72      ///
   39.73 -    /// In the sense of the LEMON each edge has a default
   39.74 -    /// direction (it should be in every computer implementation,
   39.75 -    /// because the order of edge's nodes defines an
   39.76 -    /// orientation). With the default orientation we can define that
   39.77 -    /// the directed arc is forward or backward directed. With the \c
   39.78 -    /// direction() and \c direct() function we can get the direction
   39.79 -    /// of the directed arc and we can direct an edge.
   39.80 +    /// In LEMON, each undirected edge has an inherent orientation.
   39.81 +    /// Thus it can defined if an arc is forward or backward oriented in
   39.82 +    /// an undirected graph with respect to this default oriantation of
   39.83 +    /// the represented edge.
   39.84 +    /// With the direction() and direct() functions the direction
   39.85 +    /// of an arc can be obtained and set, respectively.
   39.86      ///
   39.87 -    /// The EdgeIt is an iterator for the edges. We can use
   39.88 -    /// the EdgeMap to map values for the edges. The InArcIt and
   39.89 -    /// OutArcIt iterates on the same edges but with opposite
   39.90 -    /// direction. The IncEdgeIt iterates also on the same edges
   39.91 -    /// as the OutArcIt and InArcIt but it is not convertible to Arc just
   39.92 -    /// to Edge.
   39.93 +    /// Only nodes and edges can be added to or removed from an undirected
   39.94 +    /// graph and the corresponding arcs are added or removed automatically.
   39.95 +    ///
   39.96 +    /// \sa Digraph
   39.97      class Graph {
   39.98 +    private:
   39.99 +      /// Graphs are \e not copy constructible. Use DigraphCopy instead.
  39.100 +      Graph(const Graph&) {}
  39.101 +      /// \brief Assignment of a graph to another one is \e not allowed.
  39.102 +      /// Use DigraphCopy instead.
  39.103 +      void operator=(const Graph&) {}
  39.104 +
  39.105      public:
  39.106 -      /// \brief The undirected graph should be tagged by the
  39.107 -      /// UndirectedTag.
  39.108 +      /// Default constructor.
  39.109 +      Graph() {}
  39.110 +
  39.111 +      /// \brief Undirected graphs should be tagged with \c UndirectedTag.
  39.112        ///
  39.113 -      /// The undirected graph should be tagged by the UndirectedTag. This
  39.114 -      /// tag helps the enable_if technics to make compile time
  39.115 +      /// Undirected graphs should be tagged with \c UndirectedTag.
  39.116 +      ///
  39.117 +      /// This tag helps the \c enable_if technics to make compile time
  39.118        /// specializations for undirected graphs.
  39.119        typedef True UndirectedTag;
  39.120  
  39.121 -      /// \brief The base type of node iterators,
  39.122 -      /// or in other words, the trivial node iterator.
  39.123 -      ///
  39.124 -      /// This is the base type of each node iterator,
  39.125 -      /// thus each kind of node iterator converts to this.
  39.126 -      /// More precisely each kind of node iterator should be inherited
  39.127 -      /// from the trivial node iterator.
  39.128 +      /// The node type of the graph
  39.129 +
  39.130 +      /// This class identifies a node of the graph. It also serves
  39.131 +      /// as a base class of the node iterators,
  39.132 +      /// thus they convert to this type.
  39.133        class Node {
  39.134        public:
  39.135          /// Default constructor
  39.136  
  39.137 -        /// @warning The default constructor sets the iterator
  39.138 -        /// to an undefined value.
  39.139 +        /// Default constructor.
  39.140 +        /// \warning It sets the object to an undefined value.
  39.141          Node() { }
  39.142          /// Copy constructor.
  39.143  
  39.144 @@ -95,40 +108,40 @@
  39.145          ///
  39.146          Node(const Node&) { }
  39.147  
  39.148 -        /// Invalid constructor \& conversion.
  39.149 +        /// %Invalid constructor \& conversion.
  39.150  
  39.151 -        /// This constructor initializes the iterator to be invalid.
  39.152 +        /// Initializes the object to be invalid.
  39.153          /// \sa Invalid for more details.
  39.154          Node(Invalid) { }
  39.155          /// Equality operator
  39.156  
  39.157 +        /// Equality operator.
  39.158 +        ///
  39.159          /// Two iterators are equal if and only if they point to the
  39.160 -        /// same object or both are invalid.
  39.161 +        /// same object or both are \c INVALID.
  39.162          bool operator==(Node) const { return true; }
  39.163  
  39.164          /// Inequality operator
  39.165  
  39.166 -        /// \sa operator==(Node n)
  39.167 -        ///
  39.168 +        /// Inequality operator.
  39.169          bool operator!=(Node) const { return true; }
  39.170  
  39.171          /// Artificial ordering operator.
  39.172  
  39.173 -        /// To allow the use of graph descriptors as key type in std::map or
  39.174 -        /// similar associative container we require this.
  39.175 +        /// Artificial ordering operator.
  39.176          ///
  39.177 -        /// \note This operator only have to define some strict ordering of
  39.178 +        /// \note This operator only has to define some strict ordering of
  39.179          /// the items; this order has nothing to do with the iteration
  39.180          /// ordering of the items.
  39.181          bool operator<(Node) const { return false; }
  39.182  
  39.183        };
  39.184  
  39.185 -      /// This iterator goes through each node.
  39.186 +      /// Iterator class for the nodes.
  39.187  
  39.188 -      /// This iterator goes through each node.
  39.189 -      /// Its usage is quite simple, for example you can count the number
  39.190 -      /// of nodes in graph \c g of type \c Graph like this:
  39.191 +      /// This iterator goes through each node of the graph.
  39.192 +      /// Its usage is quite simple, for example, you can count the number
  39.193 +      /// of nodes in a graph \c g of type \c %Graph like this:
  39.194        ///\code
  39.195        /// int count=0;
  39.196        /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
  39.197 @@ -137,30 +150,28 @@
  39.198        public:
  39.199          /// Default constructor
  39.200  
  39.201 -        /// @warning The default constructor sets the iterator
  39.202 -        /// to an undefined value.
  39.203 +        /// Default constructor.
  39.204 +        /// \warning It sets the iterator to an undefined value.
  39.205          NodeIt() { }
  39.206          /// Copy constructor.
  39.207  
  39.208          /// Copy constructor.
  39.209          ///
  39.210          NodeIt(const NodeIt& n) : Node(n) { }
  39.211 -        /// Invalid constructor \& conversion.
  39.212 +        /// %Invalid constructor \& conversion.
  39.213  
  39.214 -        /// Initialize the iterator to be invalid.
  39.215 +        /// Initializes the iterator to be invalid.
  39.216          /// \sa Invalid for more details.
  39.217          NodeIt(Invalid) { }
  39.218          /// Sets the iterator to the first node.
  39.219  
  39.220 -        /// Sets the iterator to the first node of \c g.
  39.221 +        /// Sets the iterator to the first node of the given digraph.
  39.222          ///
  39.223 -        NodeIt(const Graph&) { }
  39.224 -        /// Node -> NodeIt conversion.
  39.225 +        explicit NodeIt(const Graph&) { }
  39.226 +        /// Sets the iterator to the given node.
  39.227  
  39.228 -        /// Sets the iterator to the node of \c the graph pointed by
  39.229 -        /// the trivial iterator.
  39.230 -        /// This feature necessitates that each time we
  39.231 -        /// iterate the arc-set, the iteration order is the same.
  39.232 +        /// Sets the iterator to the given node of the given digraph.
  39.233 +        ///
  39.234          NodeIt(const Graph&, const Node&) { }
  39.235          /// Next node.
  39.236  
  39.237 @@ -170,54 +181,55 @@
  39.238        };
  39.239  
  39.240  
  39.241 -      /// The base type of the edge iterators.
  39.242 +      /// The edge type of the graph
  39.243  
  39.244 -      /// The base type of the edge iterators.
  39.245 -      ///
  39.246 +      /// This class identifies an edge of the graph. It also serves
  39.247 +      /// as a base class of the edge iterators,
  39.248 +      /// thus they will convert to this type.
  39.249        class Edge {
  39.250        public:
  39.251          /// Default constructor
  39.252  
  39.253 -        /// @warning The default constructor sets the iterator
  39.254 -        /// to an undefined value.
  39.255 +        /// Default constructor.
  39.256 +        /// \warning It sets the object to an undefined value.
  39.257          Edge() { }
  39.258          /// Copy constructor.
  39.259  
  39.260          /// Copy constructor.
  39.261          ///
  39.262          Edge(const Edge&) { }
  39.263 -        /// Initialize the iterator to be invalid.
  39.264 +        /// %Invalid constructor \& conversion.
  39.265  
  39.266 -        /// Initialize the iterator to be invalid.
  39.267 -        ///
  39.268 +        /// Initializes the object to be invalid.
  39.269 +        /// \sa Invalid for more details.
  39.270          Edge(Invalid) { }
  39.271          /// Equality operator
  39.272  
  39.273 +        /// Equality operator.
  39.274 +        ///
  39.275          /// Two iterators are equal if and only if they point to the
  39.276 -        /// same object or both are invalid.
  39.277 +        /// same object or both are \c INVALID.
  39.278          bool operator==(Edge) const { return true; }
  39.279          /// Inequality operator
  39.280  
  39.281 -        /// \sa operator==(Edge n)
  39.282 -        ///
  39.283 +        /// Inequality operator.
  39.284          bool operator!=(Edge) const { return true; }
  39.285  
  39.286          /// Artificial ordering operator.
  39.287  
  39.288 -        /// To allow the use of graph descriptors as key type in std::map or
  39.289 -        /// similar associative container we require this.
  39.290 +        /// Artificial ordering operator.
  39.291          ///
  39.292 -        /// \note This operator only have to define some strict ordering of
  39.293 -        /// the items; this order has nothing to do with the iteration
  39.294 -        /// ordering of the items.
  39.295 +        /// \note This operator only has to define some strict ordering of
  39.296 +        /// the edges; this order has nothing to do with the iteration
  39.297 +        /// ordering of the edges.
  39.298          bool operator<(Edge) const { return false; }
  39.299        };
  39.300  
  39.301 -      /// This iterator goes through each edge.
  39.302 +      /// Iterator class for the edges.
  39.303  
  39.304 -      /// This iterator goes through each edge of a graph.
  39.305 -      /// Its usage is quite simple, for example you can count the number
  39.306 -      /// of edges in a graph \c g of type \c Graph as follows:
  39.307 +      /// This iterator goes through each edge of the graph.
  39.308 +      /// Its usage is quite simple, for example, you can count the number
  39.309 +      /// of edges in a graph \c g of type \c %Graph as follows:
  39.310        ///\code
  39.311        /// int count=0;
  39.312        /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
  39.313 @@ -226,290 +238,285 @@
  39.314        public:
  39.315          /// Default constructor
  39.316  
  39.317 -        /// @warning The default constructor sets the iterator
  39.318 -        /// to an undefined value.
  39.319 +        /// Default constructor.
  39.320 +        /// \warning It sets the iterator to an undefined value.
  39.321          EdgeIt() { }
  39.322          /// Copy constructor.
  39.323  
  39.324          /// Copy constructor.
  39.325          ///
  39.326          EdgeIt(const EdgeIt& e) : Edge(e) { }
  39.327 -        /// Initialize the iterator to be invalid.
  39.328 +        /// %Invalid constructor \& conversion.
  39.329  
  39.330 -        /// Initialize the iterator to be invalid.
  39.331 +        /// Initializes the iterator to be invalid.
  39.332 +        /// \sa Invalid for more details.
  39.333 +        EdgeIt(Invalid) { }
  39.334 +        /// Sets the iterator to the first edge.
  39.335 +
  39.336 +        /// Sets the iterator to the first edge of the given graph.
  39.337          ///
  39.338 -        EdgeIt(Invalid) { }
  39.339 -        /// This constructor sets the iterator to the first edge.
  39.340 +        explicit EdgeIt(const Graph&) { }
  39.341 +        /// Sets the iterator to the given edge.
  39.342  
  39.343 -        /// This constructor sets the iterator to the first edge.
  39.344 -        EdgeIt(const Graph&) { }
  39.345 -        /// Edge -> EdgeIt conversion
  39.346 -
  39.347 -        /// Sets the iterator to the value of the trivial iterator.
  39.348 -        /// This feature necessitates that each time we
  39.349 -        /// iterate the edge-set, the iteration order is the
  39.350 -        /// same.
  39.351 +        /// Sets the iterator to the given edge of the given graph.
  39.352 +        ///
  39.353          EdgeIt(const Graph&, const Edge&) { }
  39.354          /// Next edge
  39.355  
  39.356          /// Assign the iterator to the next edge.
  39.357 +        ///
  39.358          EdgeIt& operator++() { return *this; }
  39.359        };
  39.360  
  39.361 -      /// \brief This iterator goes trough the incident undirected
  39.362 -      /// arcs of a node.
  39.363 -      ///
  39.364 -      /// This iterator goes trough the incident edges
  39.365 -      /// of a certain node of a graph. You should assume that the
  39.366 -      /// loop arcs will be iterated twice.
  39.367 -      ///
  39.368 -      /// Its usage is quite simple, for example you can compute the
  39.369 -      /// degree (i.e. count the number of incident arcs of a node \c n
  39.370 -      /// in graph \c g of type \c Graph as follows.
  39.371 +      /// Iterator class for the incident edges of a node.
  39.372 +
  39.373 +      /// This iterator goes trough the incident undirected edges
  39.374 +      /// of a certain node of a graph.
  39.375 +      /// Its usage is quite simple, for example, you can compute the
  39.376 +      /// degree (i.e. the number of incident edges) of a node \c n
  39.377 +      /// in a graph \c g of type \c %Graph as follows.
  39.378        ///
  39.379        ///\code
  39.380        /// int count=0;
  39.381        /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
  39.382        ///\endcode
  39.383 +      ///
  39.384 +      /// \warning Loop edges will be iterated twice.
  39.385        class IncEdgeIt : public Edge {
  39.386        public:
  39.387          /// Default constructor
  39.388  
  39.389 -        /// @warning The default constructor sets the iterator
  39.390 -        /// to an undefined value.
  39.391 +        /// Default constructor.
  39.392 +        /// \warning It sets the iterator to an undefined value.
  39.393          IncEdgeIt() { }
  39.394          /// Copy constructor.
  39.395  
  39.396          /// Copy constructor.
  39.397          ///
  39.398          IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
  39.399 -        /// Initialize the iterator to be invalid.
  39.400 +        /// %Invalid constructor \& conversion.
  39.401  
  39.402 -        /// Initialize the iterator to be invalid.
  39.403 +        /// Initializes the iterator to be invalid.
  39.404 +        /// \sa Invalid for more details.
  39.405 +        IncEdgeIt(Invalid) { }
  39.406 +        /// Sets the iterator to the first incident edge.
  39.407 +
  39.408 +        /// Sets the iterator to the first incident edge of the given node.
  39.409          ///
  39.410 -        IncEdgeIt(Invalid) { }
  39.411 -        /// This constructor sets the iterator to first incident arc.
  39.412 +        IncEdgeIt(const Graph&, const Node&) { }
  39.413 +        /// Sets the iterator to the given edge.
  39.414  
  39.415 -        /// This constructor set the iterator to the first incident arc of
  39.416 -        /// the node.
  39.417 -        IncEdgeIt(const Graph&, const Node&) { }
  39.418 -        /// Edge -> IncEdgeIt conversion
  39.419 +        /// Sets the iterator to the given edge of the given graph.
  39.420 +        ///
  39.421 +        IncEdgeIt(const Graph&, const Edge&) { }
  39.422 +        /// Next incident edge
  39.423  
  39.424 -        /// Sets the iterator to the value of the trivial iterator \c e.
  39.425 -        /// This feature necessitates that each time we
  39.426 -        /// iterate the arc-set, the iteration order is the same.
  39.427 -        IncEdgeIt(const Graph&, const Edge&) { }
  39.428 -        /// Next incident arc
  39.429 -
  39.430 -        /// Assign the iterator to the next incident arc
  39.431 +        /// Assign the iterator to the next incident edge
  39.432          /// of the corresponding node.
  39.433          IncEdgeIt& operator++() { return *this; }
  39.434        };
  39.435  
  39.436 -      /// The directed arc type.
  39.437 +      /// The arc type of the graph
  39.438  
  39.439 -      /// The directed arc type. It can be converted to the
  39.440 -      /// edge or it should be inherited from the undirected
  39.441 -      /// edge.
  39.442 +      /// This class identifies a directed arc of the graph. It also serves
  39.443 +      /// as a base class of the arc iterators,
  39.444 +      /// thus they will convert to this type.
  39.445        class Arc {
  39.446        public:
  39.447          /// Default constructor
  39.448  
  39.449 -        /// @warning The default constructor sets the iterator
  39.450 -        /// to an undefined value.
  39.451 +        /// Default constructor.
  39.452 +        /// \warning It sets the object to an undefined value.
  39.453          Arc() { }
  39.454          /// Copy constructor.
  39.455  
  39.456          /// Copy constructor.
  39.457          ///
  39.458          Arc(const Arc&) { }
  39.459 -        /// Initialize the iterator to be invalid.
  39.460 +        /// %Invalid constructor \& conversion.
  39.461  
  39.462 -        /// Initialize the iterator to be invalid.
  39.463 -        ///
  39.464 +        /// Initializes the object to be invalid.
  39.465 +        /// \sa Invalid for more details.
  39.466          Arc(Invalid) { }
  39.467          /// Equality operator
  39.468  
  39.469 +        /// Equality operator.
  39.470 +        ///
  39.471          /// Two iterators are equal if and only if they point to the
  39.472 -        /// same object or both are invalid.
  39.473 +        /// same object or both are \c INVALID.
  39.474          bool operator==(Arc) const { return true; }
  39.475          /// Inequality operator
  39.476  
  39.477 -        /// \sa operator==(Arc n)
  39.478 -        ///
  39.479 +        /// Inequality operator.
  39.480          bool operator!=(Arc) const { return true; }
  39.481  
  39.482          /// Artificial ordering operator.
  39.483  
  39.484 -        /// To allow the use of graph descriptors as key type in std::map or
  39.485 -        /// similar associative container we require this.
  39.486 +        /// Artificial ordering operator.
  39.487          ///
  39.488 -        /// \note This operator only have to define some strict ordering of
  39.489 -        /// the items; this order has nothing to do with the iteration
  39.490 -        /// ordering of the items.
  39.491 +        /// \note This operator only has to define some strict ordering of
  39.492 +        /// the arcs; this order has nothing to do with the iteration
  39.493 +        /// ordering of the arcs.
  39.494          bool operator<(Arc) const { return false; }
  39.495  
  39.496 -        /// Converison to Edge
  39.497 +        /// Converison to \c Edge
  39.498 +
  39.499 +        /// Converison to \c Edge.
  39.500 +        ///
  39.501          operator Edge() const { return Edge(); }
  39.502        };
  39.503 -      /// This iterator goes through each directed arc.
  39.504  
  39.505 -      /// This iterator goes through each arc of a graph.
  39.506 -      /// Its usage is quite simple, for example you can count the number
  39.507 -      /// of arcs in a graph \c g of type \c Graph as follows:
  39.508 +      /// Iterator class for the arcs.
  39.509 +
  39.510 +      /// This iterator goes through each directed arc of the graph.
  39.511 +      /// Its usage is quite simple, for example, you can count the number
  39.512 +      /// of arcs in a graph \c g of type \c %Graph as follows:
  39.513        ///\code
  39.514        /// int count=0;
  39.515 -      /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
  39.516 +      /// for(Graph::ArcIt a(g); a!=INVALID; ++a) ++count;
  39.517        ///\endcode
  39.518        class ArcIt : public Arc {
  39.519        public:
  39.520          /// Default constructor
  39.521  
  39.522 -        /// @warning The default constructor sets the iterator
  39.523 -        /// to an undefined value.
  39.524 +        /// Default constructor.
  39.525 +        /// \warning It sets the iterator to an undefined value.
  39.526          ArcIt() { }
  39.527          /// Copy constructor.
  39.528  
  39.529          /// Copy constructor.
  39.530          ///
  39.531          ArcIt(const ArcIt& e) : Arc(e) { }
  39.532 -        /// Initialize the iterator to be invalid.
  39.533 +        /// %Invalid constructor \& conversion.
  39.534  
  39.535 -        /// Initialize the iterator to be invalid.
  39.536 +        /// Initializes the iterator to be invalid.
  39.537 +        /// \sa Invalid for more details.
  39.538 +        ArcIt(Invalid) { }
  39.539 +        /// Sets the iterator to the first arc.
  39.540 +
  39.541 +        /// Sets the iterator to the first arc of the given graph.
  39.542          ///
  39.543 -        ArcIt(Invalid) { }
  39.544 -        /// This constructor sets the iterator to the first arc.
  39.545 +        explicit ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
  39.546 +        /// Sets the iterator to the given arc.
  39.547  
  39.548 -        /// This constructor sets the iterator to the first arc of \c g.
  39.549 -        ///@param g the graph
  39.550 -        ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
  39.551 -        /// Arc -> ArcIt conversion
  39.552 -
  39.553 -        /// Sets the iterator to the value of the trivial iterator \c e.
  39.554 -        /// This feature necessitates that each time we
  39.555 -        /// iterate the arc-set, the iteration order is the same.
  39.556 +        /// Sets the iterator to the given arc of the given graph.
  39.557 +        ///
  39.558          ArcIt(const Graph&, const Arc&) { }
  39.559 -        ///Next arc
  39.560 +        /// Next arc
  39.561  
  39.562          /// Assign the iterator to the next arc.
  39.563 +        ///
  39.564          ArcIt& operator++() { return *this; }
  39.565        };
  39.566  
  39.567 -      /// This iterator goes trough the outgoing directed arcs of a node.
  39.568 +      /// Iterator class for the outgoing arcs of a node.
  39.569  
  39.570 -      /// This iterator goes trough the \e outgoing arcs of a certain node
  39.571 -      /// of a graph.
  39.572 -      /// Its usage is quite simple, for example you can count the number
  39.573 +      /// This iterator goes trough the \e outgoing directed arcs of a
  39.574 +      /// certain node of a graph.
  39.575 +      /// Its usage is quite simple, for example, you can count the number
  39.576        /// of outgoing arcs of a node \c n
  39.577 -      /// in graph \c g of type \c Graph as follows.
  39.578 +      /// in a graph \c g of type \c %Graph as follows.
  39.579        ///\code
  39.580        /// int count=0;
  39.581 -      /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
  39.582 +      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
  39.583        ///\endcode
  39.584 -
  39.585        class OutArcIt : public Arc {
  39.586        public:
  39.587          /// Default constructor
  39.588  
  39.589 -        /// @warning The default constructor sets the iterator
  39.590 -        /// to an undefined value.
  39.591 +        /// Default constructor.
  39.592 +        /// \warning It sets the iterator to an undefined value.
  39.593          OutArcIt() { }
  39.594          /// Copy constructor.
  39.595  
  39.596          /// Copy constructor.
  39.597          ///
  39.598          OutArcIt(const OutArcIt& e) : Arc(e) { }
  39.599 -        /// Initialize the iterator to be invalid.
  39.600 +        /// %Invalid constructor \& conversion.
  39.601  
  39.602 -        /// Initialize the iterator to be invalid.
  39.603 +        /// Initializes the iterator to be invalid.
  39.604 +        /// \sa Invalid for more details.
  39.605 +        OutArcIt(Invalid) { }
  39.606 +        /// Sets the iterator to the first outgoing arc.
  39.607 +
  39.608 +        /// Sets the iterator to the first outgoing arc of the given node.
  39.609          ///
  39.610 -        OutArcIt(Invalid) { }
  39.611 -        /// This constructor sets the iterator to the first outgoing arc.
  39.612 -
  39.613 -        /// This constructor sets the iterator to the first outgoing arc of
  39.614 -        /// the node.
  39.615 -        ///@param n the node
  39.616 -        ///@param g the graph
  39.617          OutArcIt(const Graph& n, const Node& g) {
  39.618            ignore_unused_variable_warning(n);
  39.619            ignore_unused_variable_warning(g);
  39.620          }
  39.621 -        /// Arc -> OutArcIt conversion
  39.622 +        /// Sets the iterator to the given arc.
  39.623  
  39.624 -        /// Sets the iterator to the value of the trivial iterator.
  39.625 -        /// This feature necessitates that each time we
  39.626 -        /// iterate the arc-set, the iteration order is the same.
  39.627 +        /// Sets the iterator to the given arc of the given graph.
  39.628 +        ///
  39.629          OutArcIt(const Graph&, const Arc&) { }
  39.630 -        ///Next outgoing arc
  39.631 +        /// Next outgoing arc
  39.632  
  39.633          /// Assign the iterator to the next
  39.634          /// outgoing arc of the corresponding node.
  39.635          OutArcIt& operator++() { return *this; }
  39.636        };
  39.637  
  39.638 -      /// This iterator goes trough the incoming directed arcs of a node.
  39.639 +      /// Iterator class for the incoming arcs of a node.
  39.640  
  39.641 -      /// This iterator goes trough the \e incoming arcs of a certain node
  39.642 -      /// of a graph.
  39.643 -      /// Its usage is quite simple, for example you can count the number
  39.644 -      /// of outgoing arcs of a node \c n
  39.645 -      /// in graph \c g of type \c Graph as follows.
  39.646 +      /// This iterator goes trough the \e incoming directed arcs of a
  39.647 +      /// certain node of a graph.
  39.648 +      /// Its usage is quite simple, for example, you can count the number
  39.649 +      /// of incoming arcs of a node \c n
  39.650 +      /// in a graph \c g of type \c %Graph as follows.
  39.651        ///\code
  39.652        /// int count=0;
  39.653 -      /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
  39.654 +      /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
  39.655        ///\endcode
  39.656 -
  39.657        class InArcIt : public Arc {
  39.658        public:
  39.659          /// Default constructor
  39.660  
  39.661 -        /// @warning The default constructor sets the iterator
  39.662 -        /// to an undefined value.
  39.663 +        /// Default constructor.
  39.664 +        /// \warning It sets the iterator to an undefined value.
  39.665          InArcIt() { }
  39.666          /// Copy constructor.
  39.667  
  39.668          /// Copy constructor.
  39.669          ///
  39.670          InArcIt(const InArcIt& e) : Arc(e) { }
  39.671 -        /// Initialize the iterator to be invalid.
  39.672 +        /// %Invalid constructor \& conversion.
  39.673  
  39.674 -        /// Initialize the iterator to be invalid.
  39.675 +        /// Initializes the iterator to be invalid.
  39.676 +        /// \sa Invalid for more details.
  39.677 +        InArcIt(Invalid) { }
  39.678 +        /// Sets the iterator to the first incoming arc.
  39.679 +
  39.680 +        /// Sets the iterator to the first incoming arc of the given node.
  39.681          ///
  39.682 -        InArcIt(Invalid) { }
  39.683 -        /// This constructor sets the iterator to first incoming arc.
  39.684 -
  39.685 -        /// This constructor set the iterator to the first incoming arc of
  39.686 -        /// the node.
  39.687 -        ///@param n the node
  39.688 -        ///@param g the graph
  39.689          InArcIt(const Graph& g, const Node& n) {
  39.690            ignore_unused_variable_warning(n);
  39.691            ignore_unused_variable_warning(g);
  39.692          }
  39.693 -        /// Arc -> InArcIt conversion
  39.694 +        /// Sets the iterator to the given arc.
  39.695  
  39.696 -        /// Sets the iterator to the value of the trivial iterator \c e.
  39.697 -        /// This feature necessitates that each time we
  39.698 -        /// iterate the arc-set, the iteration order is the same.
  39.699 +        /// Sets the iterator to the given arc of the given graph.
  39.700 +        ///
  39.701          InArcIt(const Graph&, const Arc&) { }
  39.702          /// Next incoming arc
  39.703  
  39.704 -        /// Assign the iterator to the next inarc of the corresponding node.
  39.705 -        ///
  39.706 +        /// Assign the iterator to the next
  39.707 +        /// incoming arc of the corresponding node.
  39.708          InArcIt& operator++() { return *this; }
  39.709        };
  39.710  
  39.711 -      /// \brief Reference map of the nodes to type \c T.
  39.712 +      /// \brief Standard graph map type for the nodes.
  39.713        ///
  39.714 -      /// Reference map of the nodes to type \c T.
  39.715 +      /// Standard graph map type for the nodes.
  39.716 +      /// It conforms to the ReferenceMap concept.
  39.717        template<class T>
  39.718        class NodeMap : public ReferenceMap<Node, T, T&, const T&>
  39.719        {
  39.720        public:
  39.721  
  39.722 -        ///\e
  39.723 -        NodeMap(const Graph&) { }
  39.724 -        ///\e
  39.725 +        /// Constructor
  39.726 +        explicit NodeMap(const Graph&) { }
  39.727 +        /// Constructor with given initial value
  39.728          NodeMap(const Graph&, T) { }
  39.729  
  39.730        private:
  39.731 @@ -524,18 +531,20 @@
  39.732          }
  39.733        };
  39.734  
  39.735 -      /// \brief Reference map of the arcs to type \c T.
  39.736 +      /// \brief Standard graph map type for the arcs.
  39.737        ///
  39.738 -      /// Reference map of the arcs to type \c T.
  39.739 +      /// Standard graph map type for the arcs.
  39.740 +      /// It conforms to the ReferenceMap concept.
  39.741        template<class T>
  39.742        class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
  39.743        {
  39.744        public:
  39.745  
  39.746 -        ///\e
  39.747 -        ArcMap(const Graph&) { }
  39.748 -        ///\e
  39.749 +        /// Constructor
  39.750 +        explicit ArcMap(const Graph&) { }
  39.751 +        /// Constructor with given initial value
  39.752          ArcMap(const Graph&, T) { }
  39.753 +
  39.754        private:
  39.755          ///Copy constructor
  39.756          ArcMap(const ArcMap& em) :
  39.757 @@ -548,18 +557,20 @@
  39.758          }
  39.759        };
  39.760  
  39.761 -      /// Reference map of the edges to type \c T.
  39.762 -
  39.763 -      /// Reference map of the edges to type \c T.
  39.764 +      /// \brief Standard graph map type for the edges.
  39.765 +      ///
  39.766 +      /// Standard graph map type for the edges.
  39.767 +      /// It conforms to the ReferenceMap concept.
  39.768        template<class T>
  39.769        class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
  39.770        {
  39.771        public:
  39.772  
  39.773 -        ///\e
  39.774 -        EdgeMap(const Graph&) { }
  39.775 -        ///\e
  39.776 +        /// Constructor
  39.777 +        explicit EdgeMap(const Graph&) { }
  39.778 +        /// Constructor with given initial value
  39.779          EdgeMap(const Graph&, T) { }
  39.780 +
  39.781        private:
  39.782          ///Copy constructor
  39.783          EdgeMap(const EdgeMap& em) :
  39.784 @@ -572,107 +583,124 @@
  39.785          }
  39.786        };
  39.787  
  39.788 -      /// \brief Direct the given edge.
  39.789 +      /// \brief The first node of the edge.
  39.790        ///
  39.791 -      /// Direct the given edge. The returned arc source
  39.792 -      /// will be the given node.
  39.793 -      Arc direct(const Edge&, const Node&) const {
  39.794 -        return INVALID;
  39.795 -      }
  39.796 -
  39.797 -      /// \brief Direct the given edge.
  39.798 +      /// Returns the first node of the given edge.
  39.799        ///
  39.800 -      /// Direct the given edge. The returned arc
  39.801 -      /// represents the given edge and the direction comes
  39.802 -      /// from the bool parameter. The source of the edge and
  39.803 -      /// the directed arc is the same when the given bool is true.
  39.804 -      Arc direct(const Edge&, bool) const {
  39.805 -        return INVALID;
  39.806 -      }
  39.807 -
  39.808 -      /// \brief Returns true if the arc has default orientation.
  39.809 -      ///
  39.810 -      /// Returns whether the given directed arc is same orientation as
  39.811 -      /// the corresponding edge's default orientation.
  39.812 -      bool direction(Arc) const { return true; }
  39.813 -
  39.814 -      /// \brief Returns the opposite directed arc.
  39.815 -      ///
  39.816 -      /// Returns the opposite directed arc.
  39.817 -      Arc oppositeArc(Arc) const { return INVALID; }
  39.818 -
  39.819 -      /// \brief Opposite node on an arc
  39.820 -      ///
  39.821 -      /// \return The opposite of the given node on the given edge.
  39.822 -      Node oppositeNode(Node, Edge) const { return INVALID; }
  39.823 -
  39.824 -      /// \brief First node of the edge.
  39.825 -      ///
  39.826 -      /// \return The first node of the given edge.
  39.827 -      ///
  39.828 -      /// Naturally edges don't have direction and thus
  39.829 -      /// don't have source and target node. However we use \c u() and \c v()
  39.830 -      /// methods to query the two nodes of the arc. The direction of the
  39.831 -      /// arc which arises this way is called the inherent direction of the
  39.832 -      /// edge, and is used to define the "default" direction
  39.833 -      /// of the directed versions of the arcs.
  39.834 +      /// Edges don't have source and target nodes, however, methods
  39.835 +      /// u() and v() are used to query the two end-nodes of an edge.
  39.836 +      /// The orientation of an edge that arises this way is called
  39.837 +      /// the inherent direction, it is used to define the default
  39.838 +      /// direction for the corresponding arcs.
  39.839        /// \sa v()
  39.840        /// \sa direction()
  39.841        Node u(Edge) const { return INVALID; }
  39.842  
  39.843 -      /// \brief Second node of the edge.
  39.844 +      /// \brief The second node of the edge.
  39.845        ///
  39.846 -      /// \return The second node of the given edge.
  39.847 +      /// Returns the second node of the given edge.
  39.848        ///
  39.849 -      /// Naturally edges don't have direction and thus
  39.850 -      /// don't have source and target node. However we use \c u() and \c v()
  39.851 -      /// methods to query the two nodes of the arc. The direction of the
  39.852 -      /// arc which arises this way is called the inherent direction of the
  39.853 -      /// edge, and is used to define the "default" direction
  39.854 -      /// of the directed versions of the arcs.
  39.855 +      /// Edges don't have source and target nodes, however, methods
  39.856 +      /// u() and v() are used to query the two end-nodes of an edge.
  39.857 +      /// The orientation of an edge that arises this way is called
  39.858 +      /// the inherent direction, it is used to define the default
  39.859 +      /// direction for the corresponding arcs.
  39.860        /// \sa u()
  39.861        /// \sa direction()
  39.862        Node v(Edge) const { return INVALID; }
  39.863  
  39.864 -      /// \brief Source node of the directed arc.
  39.865 +      /// \brief The source node of the arc.
  39.866 +      ///
  39.867 +      /// Returns the source node of the given arc.
  39.868        Node source(Arc) const { return INVALID; }
  39.869  
  39.870 -      /// \brief Target node of the directed arc.
  39.871 +      /// \brief The target node of the arc.
  39.872 +      ///
  39.873 +      /// Returns the target node of the given arc.
  39.874        Node target(Arc) const { return INVALID; }
  39.875