Merge #179 (Port the min mean cycle algorithms)
authorAlpar Juttner <alpar@cs.elte.hu>
Thu, 05 Nov 2009 08:39:49 +0100
changeset 817432c54cec63c
parent 816 e746fb14e680
parent 804 9fbbd802020f
child 818 8452ca46e29a
Merge #179 (Port the min mean cycle algorithms)
doc/groups.dox
lemon/Makefile.am
test/CMakeLists.txt
test/Makefile.am
     1.1 --- a/CMakeLists.txt	Tue Aug 18 10:08:28 2009 +0200
     1.2 +++ b/CMakeLists.txt	Thu Nov 05 08:39:49 2009 +0100
     1.3 @@ -35,6 +35,8 @@
     1.4  CHECK_TYPE_SIZE("long long" LONG_LONG)
     1.5  SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
     1.6  
     1.7 +INCLUDE(FindPythonInterp)
     1.8 +
     1.9  ENABLE_TESTING()
    1.10  
    1.11  ADD_SUBDIRECTORY(lemon)
     2.1 --- a/Makefile.am	Tue Aug 18 10:08:28 2009 +0200
     2.2 +++ b/Makefile.am	Thu Nov 05 08:39:49 2009 +0100
     2.3 @@ -17,6 +17,7 @@
     2.4  	cmake/FindCPLEX.cmake \
     2.5  	cmake/FindGLPK.cmake \
     2.6  	cmake/FindCOIN.cmake \
     2.7 +	cmake/LEMONConfig.cmake.in \
     2.8  	cmake/version.cmake.in \
     2.9  	cmake/version.cmake \
    2.10  	cmake/nsis/lemon.ico \
     3.1 --- a/configure.ac	Tue Aug 18 10:08:28 2009 +0200
     3.2 +++ b/configure.ac	Thu Nov 05 08:39:49 2009 +0100
     3.3 @@ -41,6 +41,7 @@
     3.4  AC_PROG_LIBTOOL
     3.5  
     3.6  AC_CHECK_PROG([doxygen_found],[doxygen],[yes],[no])
     3.7 +AC_CHECK_PROG([python_found],[python],[yes],[no])
     3.8  AC_CHECK_PROG([gs_found],[gs],[yes],[no])
     3.9  
    3.10  dnl Detect Intel compiler.
     4.1 --- a/doc/CMakeLists.txt	Tue Aug 18 10:08:28 2009 +0200
     4.2 +++ b/doc/CMakeLists.txt	Thu Nov 05 08:39:49 2009 +0100
     4.3 @@ -9,7 +9,7 @@
     4.4    @ONLY
     4.5  )
     4.6  
     4.7 -IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
     4.8 +IF(DOXYGEN_EXECUTABLE AND PYTHONINTERP_FOUND AND GHOSTSCRIPT_EXECUTABLE)
     4.9    FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
    4.10    SET(GHOSTSCRIPT_OPTIONS -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha)
    4.11    ADD_CUSTOM_TARGET(html
    4.12 @@ -28,6 +28,7 @@
    4.13      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
    4.14      COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
    4.15      COMMAND ${CMAKE_COMMAND} -E remove_directory html
    4.16 +    COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/bib2dox.py ${CMAKE_CURRENT_SOURCE_DIR}/references.bib >references.dox
    4.17      COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
    4.18      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    4.19    )
     5.1 --- a/doc/Doxyfile.in	Tue Aug 18 10:08:28 2009 +0200
     5.2 +++ b/doc/Doxyfile.in	Thu Nov 05 08:39:49 2009 +0100
     5.3 @@ -1,4 +1,4 @@
     5.4 -# Doxyfile 1.5.7.1
     5.5 +# Doxyfile 1.5.9
     5.6  
     5.7  #---------------------------------------------------------------------------
     5.8  # Project related configuration options
     5.9 @@ -21,7 +21,6 @@
    5.10  JAVADOC_AUTOBRIEF      = NO
    5.11  QT_AUTOBRIEF           = NO
    5.12  MULTILINE_CPP_IS_BRIEF = NO
    5.13 -DETAILS_AT_TOP         = YES
    5.14  INHERIT_DOCS           = NO
    5.15  SEPARATE_MEMBER_PAGES  = NO
    5.16  TAB_SIZE               = 8
    5.17 @@ -91,7 +90,8 @@
    5.18                           "@abs_top_srcdir@/lemon/concepts" \
    5.19                           "@abs_top_srcdir@/demo" \
    5.20                           "@abs_top_srcdir@/tools" \
    5.21 -                         "@abs_top_srcdir@/test/test_tools.h"
    5.22 +                         "@abs_top_srcdir@/test/test_tools.h" \
    5.23 +                         "@abs_top_builddir@/doc/references.dox"
    5.24  INPUT_ENCODING         = UTF-8
    5.25  FILE_PATTERNS          = *.h \
    5.26                           *.cc \
    5.27 @@ -223,7 +223,7 @@
    5.28  EXPAND_AS_DEFINED      = 
    5.29  SKIP_FUNCTION_MACROS   = YES
    5.30  #---------------------------------------------------------------------------
    5.31 -# Configuration::additions related to external references   
    5.32 +# Options related to the search engine   
    5.33  #---------------------------------------------------------------------------
    5.34  TAGFILES               = "@abs_top_srcdir@/doc/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/  "
    5.35  GENERATE_TAGFILE       = html/lemon.tag
     6.1 --- a/doc/Makefile.am	Tue Aug 18 10:08:28 2009 +0200
     6.2 +++ b/doc/Makefile.am	Thu Nov 05 08:39:49 2009 +0100
     6.3 @@ -66,7 +66,19 @@
     6.4  	  exit 1; \
     6.5  	fi
     6.6  
     6.7 -html-local: $(DOC_PNG_IMAGES)
     6.8 +references.dox: doc/references.bib
     6.9 +	if test ${python_found} = yes; then \
    6.10 +	  cd doc; \
    6.11 +	  python @abs_top_srcdir@/scripts/bib2dox.py @abs_top_builddir@/$< >$@; \
    6.12 +	  cd ..; \
    6.13 +	else \
    6.14 +	  echo; \
    6.15 +	  echo "Python not found."; \
    6.16 +	  echo; \
    6.17 +	  exit 1; \
    6.18 +	fi
    6.19 +
    6.20 +html-local: $(DOC_PNG_IMAGES) references.dox
    6.21  	if test ${doxygen_found} = yes; then \
    6.22  	  cd doc; \
    6.23  	  doxygen Doxyfile; \
     7.1 --- a/doc/groups.dox	Tue Aug 18 10:08:28 2009 +0200
     7.2 +++ b/doc/groups.dox	Thu Nov 05 08:39:49 2009 +0100
     7.3 @@ -226,14 +226,6 @@
     7.4  */
     7.5  
     7.6  /**
     7.7 -@defgroup matrices Matrices
     7.8 -@ingroup datas
     7.9 -\brief Two dimensional data storages implemented in LEMON.
    7.10 -
    7.11 -This group contains two dimensional data storages implemented in LEMON.
    7.12 -*/
    7.13 -
    7.14 -/**
    7.15  @defgroup paths Path Structures
    7.16  @ingroup datas
    7.17  \brief %Path structures implemented in LEMON.
    7.18 @@ -246,7 +238,36 @@
    7.19  efficient to have e.g. the Dijkstra algorithm to store its result in
    7.20  any kind of path structure.
    7.21  
    7.22 -\sa lemon::concepts::Path
    7.23 +\sa \ref concepts::Path "Path concept"
    7.24 +*/
    7.25 +
    7.26 +/**
    7.27 +@defgroup heaps Heap Structures
    7.28 +@ingroup datas
    7.29 +\brief %Heap structures implemented in LEMON.
    7.30 +
    7.31 +This group contains the heap structures implemented in LEMON.
    7.32 +
    7.33 +LEMON provides several heap classes. They are efficient implementations
    7.34 +of the abstract data type \e priority \e queue. They store items with
    7.35 +specified values called \e priorities in such a way that finding and
    7.36 +removing the item with minimum priority are efficient.
    7.37 +The basic operations are adding and erasing items, changing the priority
    7.38 +of an item, etc.
    7.39 +
    7.40 +Heaps are crucial in several algorithms, such as Dijkstra and Prim.
    7.41 +The heap implementations have the same interface, thus any of them can be
    7.42 +used easily in such algorithms.
    7.43 +
    7.44 +\sa \ref concepts::Heap "Heap concept"
    7.45 +*/
    7.46 +
    7.47 +/**
    7.48 +@defgroup matrices Matrices
    7.49 +@ingroup datas
    7.50 +\brief Two dimensional data storages implemented in LEMON.
    7.51 +
    7.52 +This group contains two dimensional data storages implemented in LEMON.
    7.53  */
    7.54  
    7.55  /**
    7.56 @@ -259,6 +280,28 @@
    7.57  */
    7.58  
    7.59  /**
    7.60 +@defgroup geomdat Geometric Data Structures
    7.61 +@ingroup auxdat
    7.62 +\brief Geometric data structures implemented in LEMON.
    7.63 +
    7.64 +This group contains geometric data structures implemented in LEMON.
    7.65 +
    7.66 + - \ref lemon::dim2::Point "dim2::Point" implements a two dimensional
    7.67 +   vector with the usual operations.
    7.68 + - \ref lemon::dim2::Box "dim2::Box" can be used to determine the
    7.69 +   rectangular bounding box of a set of \ref lemon::dim2::Point
    7.70 +   "dim2::Point"'s.
    7.71 +*/
    7.72 +
    7.73 +/**
    7.74 +@defgroup matrices Matrices
    7.75 +@ingroup auxdat
    7.76 +\brief Two dimensional data storages implemented in LEMON.
    7.77 +
    7.78 +This group contains two dimensional data storages implemented in LEMON.
    7.79 +*/
    7.80 +
    7.81 +/**
    7.82  @defgroup algs Algorithms
    7.83  \brief This group contains the several algorithms
    7.84  implemented in LEMON.
    7.85 @@ -273,7 +316,8 @@
    7.86  \brief Common graph search algorithms.
    7.87  
    7.88  This group contains the common graph search algorithms, namely
    7.89 -\e breadth-first \e search (BFS) and \e depth-first \e search (DFS).
    7.90 +\e breadth-first \e search (BFS) and \e depth-first \e search (DFS)
    7.91 +\ref clrs01algorithms.
    7.92  */
    7.93  
    7.94  /**
    7.95 @@ -281,7 +325,8 @@
    7.96  @ingroup algs
    7.97  \brief Algorithms for finding shortest paths.
    7.98  
    7.99 -This group contains the algorithms for finding shortest paths in digraphs.
   7.100 +This group contains the algorithms for finding shortest paths in digraphs
   7.101 +\ref clrs01algorithms.
   7.102  
   7.103   - \ref Dijkstra algorithm for finding shortest paths from a source node
   7.104     when all arc lengths are non-negative.
   7.105 @@ -298,12 +343,21 @@
   7.106  */
   7.107  
   7.108  /**
   7.109 +@defgroup spantree Minimum Spanning Tree Algorithms
   7.110 +@ingroup algs
   7.111 +\brief Algorithms for finding minimum cost spanning trees and arborescences.
   7.112 +
   7.113 +This group contains the algorithms for finding minimum cost spanning
   7.114 +trees and arborescences \ref clrs01algorithms.
   7.115 +*/
   7.116 +
   7.117 +/**
   7.118  @defgroup max_flow Maximum Flow Algorithms
   7.119  @ingroup algs
   7.120  \brief Algorithms for finding maximum flows.
   7.121  
   7.122  This group contains the algorithms for finding maximum flows and
   7.123 -feasible circulations.
   7.124 +feasible circulations \ref clrs01algorithms, \ref amo93networkflows.
   7.125  
   7.126  The \e maximum \e flow \e problem is to find a flow of maximum value between
   7.127  a single source and a single target. Formally, there is a \f$G=(V,A)\f$
   7.128 @@ -318,12 +372,16 @@
   7.129  \f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f]
   7.130  
   7.131  LEMON contains several algorithms for solving maximum flow problems:
   7.132 -- \ref EdmondsKarp Edmonds-Karp algorithm.
   7.133 -- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm.
   7.134 -- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees.
   7.135 -- \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees.
   7.136 +- \ref EdmondsKarp Edmonds-Karp algorithm
   7.137 +  \ref edmondskarp72theoretical.
   7.138 +- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm
   7.139 +  \ref goldberg88newapproach.
   7.140 +- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees
   7.141 +  \ref dinic70algorithm, \ref sleator83dynamic.
   7.142 +- \ref GoldbergTarjan !Preflow push-relabel algorithm with dynamic trees
   7.143 +  \ref goldberg88newapproach, \ref sleator83dynamic.
   7.144  
   7.145 -In most cases the \ref Preflow "Preflow" algorithm provides the
   7.146 +In most cases the \ref Preflow algorithm provides the
   7.147  fastest method for computing a maximum flow. All implementations
   7.148  also provide functions to query the minimum cut, which is the dual
   7.149  problem of maximum flow.
   7.150 @@ -341,18 +399,22 @@
   7.151  \brief Algorithms for finding minimum cost flows and circulations.
   7.152  
   7.153  This group contains the algorithms for finding minimum cost flows and
   7.154 -circulations. For more information about this problem and its dual
   7.155 -solution see \ref min_cost_flow "Minimum Cost Flow Problem".
   7.156 +circulations \ref amo93networkflows. For more information about this
   7.157 +problem and its dual solution, see \ref min_cost_flow
   7.158 +"Minimum Cost Flow Problem".
   7.159  
   7.160  LEMON contains several algorithms for this problem.
   7.161   - \ref NetworkSimplex Primal Network Simplex algorithm with various
   7.162 -   pivot strategies.
   7.163 +   pivot strategies \ref dantzig63linearprog, \ref kellyoneill91netsimplex.
   7.164   - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on
   7.165 -   cost scaling.
   7.166 +   cost scaling \ref goldberg90approximation, \ref goldberg97efficient,
   7.167 +   \ref bunnagel98efficient.
   7.168   - \ref CapacityScaling Successive Shortest %Path algorithm with optional
   7.169 -   capacity scaling.
   7.170 - - \ref CancelAndTighten The Cancel and Tighten algorithm.
   7.171 - - \ref CycleCanceling Cycle-Canceling algorithms.
   7.172 +   capacity scaling \ref edmondskarp72theoretical.
   7.173 + - \ref CancelAndTighten The Cancel and Tighten algorithm
   7.174 +   \ref goldberg89cyclecanceling.
   7.175 + - \ref CycleCanceling Cycle-Canceling algorithms
   7.176 +   \ref klein67primal, \ref goldberg89cyclecanceling.
   7.177  
   7.178  In general NetworkSimplex is the most efficient implementation,
   7.179  but in special cases other algorithms could be faster.
   7.180 @@ -375,7 +437,7 @@
   7.181  cut is the \f$X\f$ solution of the next optimization problem:
   7.182  
   7.183  \f[ \min_{X \subset V, X\not\in \{\emptyset, V\}}
   7.184 -    \sum_{uv\in A, u\in X, v\not\in X}cap(uv) \f]
   7.185 +    \sum_{uv\in A: u\in X, v\not\in X}cap(uv) \f]
   7.186  
   7.187  LEMON contains several algorithms related to minimum cut problems:
   7.188  
   7.189 @@ -425,30 +487,6 @@
   7.190  */
   7.191  
   7.192  /**
   7.193 -@defgroup graph_properties Connectivity and Other Graph Properties
   7.194 -@ingroup algs
   7.195 -\brief Algorithms for discovering the graph properties
   7.196 -
   7.197 -This group contains the algorithms for discovering the graph properties
   7.198 -like connectivity, bipartiteness, euler property, simplicity etc.
   7.199 -
   7.200 -\image html edge_biconnected_components.png
   7.201 -\image latex edge_biconnected_components.eps "bi-edge-connected components" width=\textwidth
   7.202 -*/
   7.203 -
   7.204 -/**
   7.205 -@defgroup planar Planarity Embedding and Drawing
   7.206 -@ingroup algs
   7.207 -\brief Algorithms for planarity checking, embedding and drawing
   7.208 -
   7.209 -This group contains the algorithms for planarity checking,
   7.210 -embedding and drawing.
   7.211 -
   7.212 -\image html planar.png
   7.213 -\image latex planar.eps "Plane graph" width=\textwidth
   7.214 -*/
   7.215 -
   7.216 -/**
   7.217  @defgroup matching Matching Algorithms
   7.218  @ingroup algs
   7.219  \brief Algorithms for finding matchings in graphs and bipartite graphs.
   7.220 @@ -489,12 +527,36 @@
   7.221  */
   7.222  
   7.223  /**
   7.224 -@defgroup spantree Minimum Spanning Tree Algorithms
   7.225 +@defgroup graph_properties Connectivity and Other Graph Properties
   7.226  @ingroup algs
   7.227 -\brief Algorithms for finding minimum cost spanning trees and arborescences.
   7.228 +\brief Algorithms for discovering the graph properties
   7.229  
   7.230 -This group contains the algorithms for finding minimum cost spanning
   7.231 -trees and arborescences.
   7.232 +This group contains the algorithms for discovering the graph properties
   7.233 +like connectivity, bipartiteness, euler property, simplicity etc.
   7.234 +
   7.235 +\image html connected_components.png
   7.236 +\image latex connected_components.eps "Connected components" width=\textwidth
   7.237 +*/
   7.238 +
   7.239 +/**
   7.240 +@defgroup planar Planarity Embedding and Drawing
   7.241 +@ingroup algs
   7.242 +\brief Algorithms for planarity checking, embedding and drawing
   7.243 +
   7.244 +This group contains the algorithms for planarity checking,
   7.245 +embedding and drawing.
   7.246 +
   7.247 +\image html planar.png
   7.248 +\image latex planar.eps "Plane graph" width=\textwidth
   7.249 +*/
   7.250 +
   7.251 +/**
   7.252 +@defgroup approx Approximation Algorithms
   7.253 +@ingroup algs
   7.254 +\brief Approximation algorithms.
   7.255 +
   7.256 +This group contains the approximation and heuristic algorithms
   7.257 +implemented in LEMON.
   7.258  */
   7.259  
   7.260  /**
   7.261 @@ -507,15 +569,6 @@
   7.262  */
   7.263  
   7.264  /**
   7.265 -@defgroup approx Approximation Algorithms
   7.266 -@ingroup algs
   7.267 -\brief Approximation algorithms.
   7.268 -
   7.269 -This group contains the approximation and heuristic algorithms
   7.270 -implemented in LEMON.
   7.271 -*/
   7.272 -
   7.273 -/**
   7.274  @defgroup gen_opt_group General Optimization Tools
   7.275  \brief This group contains some general optimization frameworks
   7.276  implemented in LEMON.
   7.277 @@ -525,13 +578,16 @@
   7.278  */
   7.279  
   7.280  /**
   7.281 -@defgroup lp_group Lp and Mip Solvers
   7.282 +@defgroup lp_group LP and MIP Solvers
   7.283  @ingroup gen_opt_group
   7.284 -\brief Lp and Mip solver interfaces for LEMON.
   7.285 +\brief LP and MIP solver interfaces for LEMON.
   7.286  
   7.287 -This group contains Lp and Mip solver interfaces for LEMON. The
   7.288 -various LP solvers could be used in the same manner with this
   7.289 -interface.
   7.290 +This group contains LP and MIP solver interfaces for LEMON.
   7.291 +Various LP solvers could be used in the same manner with this
   7.292 +high-level interface.
   7.293 +
   7.294 +The currently supported solvers are \ref glpk, \ref clp, \ref cbc,
   7.295 +\ref cplex, \ref soplex.
   7.296  */
   7.297  
   7.298  /**
   7.299 @@ -621,7 +677,7 @@
   7.300  */
   7.301  
   7.302  /**
   7.303 -@defgroup dimacs_group DIMACS format
   7.304 +@defgroup dimacs_group DIMACS Format
   7.305  @ingroup io_group
   7.306  \brief Read and write files in DIMACS format
   7.307  
   7.308 @@ -670,8 +726,8 @@
   7.309  @ingroup concept
   7.310  \brief Skeleton and concept checking classes for graph structures
   7.311  
   7.312 -This group contains the skeletons and concept checking classes of LEMON's
   7.313 -graph structures and helper classes used to implement these.
   7.314 +This group contains the skeletons and concept checking classes of
   7.315 +graph structures.
   7.316  */
   7.317  
   7.318  /**
   7.319 @@ -683,6 +739,15 @@
   7.320  */
   7.321  
   7.322  /**
   7.323 +@defgroup tools Standalone Utility Applications
   7.324 +
   7.325 +Some utility applications are listed here.
   7.326 +
   7.327 +The standard compilation procedure (<tt>./configure;make</tt>) will compile
   7.328 +them, as well.
   7.329 +*/
   7.330 +
   7.331 +/**
   7.332  \anchor demoprograms
   7.333  
   7.334  @defgroup demos Demo Programs
   7.335 @@ -694,13 +759,4 @@
   7.336  <tt>make check</tt> commands.
   7.337  */
   7.338  
   7.339 -/**
   7.340 -@defgroup tools Standalone Utility Applications
   7.341 -
   7.342 -Some utility applications are listed here.
   7.343 -
   7.344 -The standard compilation procedure (<tt>./configure;make</tt>) will compile
   7.345 -them, as well.
   7.346 -*/
   7.347 -
   7.348  }
     8.1 --- a/doc/mainpage.dox	Tue Aug 18 10:08:28 2009 +0200
     8.2 +++ b/doc/mainpage.dox	Thu Nov 05 08:39:49 2009 +0100
     8.3 @@ -21,14 +21,11 @@
     8.4  
     8.5  \section intro Introduction
     8.6  
     8.7 -\subsection whatis What is LEMON
     8.8 -
     8.9 -LEMON stands for <b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
    8.10 -and <b>O</b>ptimization in <b>N</b>etworks.
    8.11 -It is a C++ template
    8.12 -library aimed at combinatorial optimization tasks which
    8.13 -often involve in working
    8.14 -with graphs.
    8.15 +<b>LEMON</b> stands for <i><b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
    8.16 +and <b>O</b>ptimization in <b>N</b>etworks</i>.
    8.17 +It is a C++ template library providing efficient implementation of common
    8.18 +data structures and algorithms with focus on combinatorial optimization
    8.19 +problems in graphs and networks.
    8.20  
    8.21  <b>
    8.22  LEMON is an <a class="el" href="http://opensource.org/">open&nbsp;source</a>
    8.23 @@ -38,7 +35,16 @@
    8.24  \ref license "license terms".
    8.25  </b>
    8.26  
    8.27 -\subsection howtoread How to read the documentation
    8.28 +The project is maintained by the 
    8.29 +<a href="http://www.cs.elte.hu/egres/">Egerv&aacute;ry Research Group on
    8.30 +Combinatorial Optimization</a> \ref egres
    8.31 +at the Operations Research Department of the
    8.32 +<a href="http://www.elte.hu/">E&ouml;tv&ouml;s Lor&aacute;nd University,
    8.33 +Budapest</a>, Hungary.
    8.34 +LEMON is also a member of the <a href="http://www.coin-or.org/">COIN-OR</a>
    8.35 +initiative \ref coinor.
    8.36 +
    8.37 +\section howtoread How to Read the Documentation
    8.38  
    8.39  If you would like to get to know the library, see
    8.40  <a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>.
     9.1 --- a/doc/min_cost_flow.dox	Tue Aug 18 10:08:28 2009 +0200
     9.2 +++ b/doc/min_cost_flow.dox	Thu Nov 05 08:39:49 2009 +0100
     9.3 @@ -26,7 +26,7 @@
     9.4  The \e minimum \e cost \e flow \e problem is to find a feasible flow of
     9.5  minimum total cost from a set of supply nodes to a set of demand nodes
     9.6  in a network with capacity constraints (lower and upper bounds)
     9.7 -and arc costs.
     9.8 +and arc costs \ref amo93networkflows.
     9.9  
    9.10  Formally, let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$,
    9.11  \f$upper: A\rightarrow\mathbf{R}\cup\{+\infty\}\f$ denote the lower and
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/doc/references.bib	Thu Nov 05 08:39:49 2009 +0100
    10.3 @@ -0,0 +1,301 @@
    10.4 +%%%%% Defining LEMON %%%%%
    10.5 +
    10.6 +@misc{lemon,
    10.7 +  key =          {LEMON},
    10.8 +  title =        {{LEMON} -- {L}ibrary for {E}fficient {M}odeling and
    10.9 +                  {O}ptimization in {N}etworks},
   10.10 +  howpublished = {\url{http://lemon.cs.elte.hu/}},
   10.11 +  year =         2009
   10.12 +}
   10.13 +
   10.14 +@misc{egres,
   10.15 +  key =          {EGRES},
   10.16 +  title =        {{EGRES} -- {E}gerv{\'a}ry {R}esearch {G}roup on
   10.17 +                  {C}ombinatorial {O}ptimization},
   10.18 +  url =          {http://www.cs.elte.hu/egres/}
   10.19 +}
   10.20 +
   10.21 +@misc{coinor,
   10.22 +  key =          {COIN-OR},
   10.23 +  title =        {{COIN-OR} -- {C}omputational {I}nfrastructure for
   10.24 +                  {O}perations {R}esearch},
   10.25 +  url =          {http://www.coin-or.org/}
   10.26 +}
   10.27 +
   10.28 +
   10.29 +%%%%% Other libraries %%%%%%
   10.30 +
   10.31 +@misc{boost,
   10.32 +  key =          {Boost},
   10.33 +  title =        {{B}oost {C++} {L}ibraries},
   10.34 +  url =          {http://www.boost.org/}
   10.35 +}
   10.36 +
   10.37 +@book{bglbook,
   10.38 +  author =       {Jeremy G. Siek and Lee-Quan Lee and Andrew
   10.39 +                  Lumsdaine},
   10.40 +  title =        {The Boost Graph Library: User Guide and Reference
   10.41 +                  Manual},
   10.42 +  publisher =    {Addison-Wesley},
   10.43 +  year =         2002
   10.44 +}
   10.45 +
   10.46 +@misc{leda,
   10.47 +  key =          {LEDA},
   10.48 +  title =        {{LEDA} -- {L}ibrary of {E}fficient {D}ata {T}ypes and
   10.49 +                  {A}lgorithms},
   10.50 +  url =          {http://www.algorithmic-solutions.com/}
   10.51 +}
   10.52 +
   10.53 +@book{ledabook,
   10.54 +  author =       {Kurt Mehlhorn and Stefan N{\"a}her},
   10.55 +  title =        {{LEDA}: {A} platform for combinatorial and geometric
   10.56 +                  computing},
   10.57 +  isbn =         {0-521-56329-1},
   10.58 +  publisher =    {Cambridge University Press},
   10.59 +  address =      {New York, NY, USA},
   10.60 +  year =         1999
   10.61 +}
   10.62 +
   10.63 +
   10.64 +%%%%% Tools that LEMON depends on %%%%%
   10.65 +
   10.66 +@misc{cmake,
   10.67 +  key =          {CMake},
   10.68 +  title =        {{CMake} -- {C}ross {P}latform {M}ake},
   10.69 +  url =          {http://www.cmake.org/}
   10.70 +}
   10.71 +
   10.72 +@misc{doxygen,
   10.73 +  key =          {Doxygen},
   10.74 +  title =        {{Doxygen} -- {S}ource code documentation generator
   10.75 +                  tool},
   10.76 +  url =          {http://www.doxygen.org/}
   10.77 +}
   10.78 +
   10.79 +
   10.80 +%%%%% LP/MIP libraries %%%%%
   10.81 +
   10.82 +@misc{glpk,
   10.83 +  key =          {GLPK},
   10.84 +  title =        {{GLPK} -- {GNU} {L}inear {P}rogramming {K}it},
   10.85 +  url =          {http://www.gnu.org/software/glpk/}
   10.86 +}
   10.87 +
   10.88 +@misc{clp,
   10.89 +  key =          {Clp},
   10.90 +  title =        {{Clp} -- {Coin-Or} {L}inear {P}rogramming},
   10.91 +  url =          {http://projects.coin-or.org/Clp/}
   10.92 +}
   10.93 +
   10.94 +@misc{cbc,
   10.95 +  key =          {Cbc},
   10.96 +  title =        {{Cbc} -- {Coin-Or} {B}ranch and {C}ut},
   10.97 +  url =          {http://projects.coin-or.org/Cbc/}
   10.98 +}
   10.99 +
  10.100 +@misc{cplex,
  10.101 +  key =          {CPLEX},
  10.102 +  title =        {{ILOG} {CPLEX}},
  10.103 +  url =          {http://www.ilog.com/}
  10.104 +}
  10.105 +
  10.106 +@misc{soplex,
  10.107 +  key =          {SoPlex},
  10.108 +  title =        {{SoPlex} -- {T}he {S}equential {O}bject-{O}riented
  10.109 +                  {S}implex},
  10.110 +  url =          {http://soplex.zib.de/}
  10.111 +}
  10.112 +
  10.113 +
  10.114 +%%%%% General books %%%%%
  10.115 +
  10.116 +@book{amo93networkflows,
  10.117 +  author =       {Ravindra K. Ahuja and Thomas L. Magnanti and James
  10.118 +                  B. Orlin},
  10.119 +  title =        {Network Flows: Theory, Algorithms, and Applications},
  10.120 +  publisher =    {Prentice-Hall, Inc.},
  10.121 +  year =         1993,
  10.122 +  month =        feb,
  10.123 +  isbn =         {978-0136175490}
  10.124 +}
  10.125 +
  10.126 +@book{schrijver03combinatorial,
  10.127 +  author =       {Alexander Schrijver},
  10.128 +  title =        {Combinatorial Optimization: Polyhedra and Efficiency},
  10.129 +  publisher =    {Springer-Verlag},
  10.130 +  year =         2003,
  10.131 +  isbn =         {978-3540443896}
  10.132 +}
  10.133 +
  10.134 +@book{clrs01algorithms,
  10.135 +  author =       {Thomas H. Cormen and Charles E. Leiserson and Ronald
  10.136 +                  L. Rivest and Clifford Stein},
  10.137 +  title =        {Introduction to Algorithms},
  10.138 +  publisher =    {The MIT Press},
  10.139 +  year =         2001,
  10.140 +  edition =      {2nd}
  10.141 +}
  10.142 +
  10.143 +@book{stroustrup00cpp,
  10.144 +  author =       {Bjarne Stroustrup},
  10.145 +  title =        {The C++ Programming Language},
  10.146 +  edition =      {3rd},
  10.147 +  publisher =    {Addison-Wesley Professional},
  10.148 +  isbn =         0201700735,
  10.149 +  month =        {February},
  10.150 +  year =         2000
  10.151 +}
  10.152 +
  10.153 +
  10.154 +%%%%% Maximum flow algorithms %%%%%
  10.155 +
  10.156 +@article{edmondskarp72theoretical,
  10.157 +  author =       {Jack Edmonds and Richard M. Karp},
  10.158 +  title =        {Theoretical improvements in algorithmic efficiency
  10.159 +                  for network flow problems},
  10.160 +  journal =      {Journal of the ACM},
  10.161 +  year =         1972,
  10.162 +  volume =       19,
  10.163 +  number =       2,
  10.164 +  pages =        {248-264}
  10.165 +}
  10.166 +
  10.167 +@article{goldberg88newapproach,
  10.168 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  10.169 +  title =        {A new approach to the maximum flow problem},
  10.170 +  journal =      {Journal of the ACM},
  10.171 +  year =         1988,
  10.172 +  volume =       35,
  10.173 +  number =       4,
  10.174 +  pages =        {921-940}
  10.175 +}
  10.176 +
  10.177 +@article{dinic70algorithm,
  10.178 +  author =       {E. A. Dinic},
  10.179 +  title =        {Algorithm for solution of a problem of maximum flow
  10.180 +                  in a network with power estimation},
  10.181 +  journal =      {Soviet Math. Doklady},
  10.182 +  year =         1970,
  10.183 +  volume =       11,
  10.184 +  pages =        {1277-1280}
  10.185 +}
  10.186 +
  10.187 +@article{goldberg08partial,
  10.188 +  author =       {Andrew V. Goldberg},
  10.189 +  title =        {The Partial Augment-Relabel Algorithm for the
  10.190 +                  Maximum Flow Problem},
  10.191 +  journal =      {16th Annual European Symposium on Algorithms},
  10.192 +  year =         2008,
  10.193 +  pages =        {466-477}
  10.194 +}
  10.195 +
  10.196 +@article{sleator83dynamic,
  10.197 +  author =       {Daniel D. Sleator and Robert E. Tarjan},
  10.198 +  title =        {A data structure for dynamic trees},
  10.199 +  journal =      {Journal of Computer and System Sciences},
  10.200 +  year =         1983,
  10.201 +  volume =       26,
  10.202 +  number =       3,
  10.203 +  pages =        {362-391}
  10.204 +}
  10.205 +
  10.206 +
  10.207 +%%%%% Minimum mean cycle algorithms %%%%%
  10.208 +
  10.209 +@article{karp78characterization,
  10.210 +  author =       {Richard M. Karp},
  10.211 +  title =        {A characterization of the minimum cycle mean in a
  10.212 +                  digraph},
  10.213 +  journal =      {Discrete Math.},
  10.214 +  year =         1978,
  10.215 +  volume =       23,
  10.216 +  pages =        {309-311}
  10.217 +}
  10.218 +
  10.219 +@article{dasdan98minmeancycle,
  10.220 +  author =       {Ali Dasdan and Rajesh K. Gupta},
  10.221 +  title =        {Faster Maximum and Minimum Mean Cycle Alogrithms for
  10.222 +                  System Performance Analysis},
  10.223 +  journal =      {IEEE Transactions on Computer-Aided Design of
  10.224 +                  Integrated Circuits and Systems},
  10.225 +  year =         1998,
  10.226 +  volume =       17,
  10.227 +  number =       10,
  10.228 +  pages =        {889-899}
  10.229 +}
  10.230 +
  10.231 +
  10.232 +%%%%% Minimum cost flow algorithms %%%%%
  10.233 +
  10.234 +@article{klein67primal,
  10.235 +  author =       {Morton Klein},
  10.236 +  title =        {A primal method for minimal cost flows with
  10.237 +                  applications to the assignment and transportation
  10.238 +                  problems},
  10.239 +  journal =      {Management Science},
  10.240 +  year =         1967,
  10.241 +  volume =       14,
  10.242 +  pages =        {205-220}
  10.243 +}
  10.244 +
  10.245 +@article{goldberg89cyclecanceling,
  10.246 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  10.247 +  title =        {Finding minimum-cost circulations by canceling
  10.248 +                  negative cycles},
  10.249 +  journal =      {Journal of the ACM},
  10.250 +  year =         1989,
  10.251 +  volume =       36,
  10.252 +  number =       4,
  10.253 +  pages =        {873-886}
  10.254 +}
  10.255 +
  10.256 +@article{goldberg90approximation,
  10.257 +  author =       {Andrew V. Goldberg and Robert E. Tarjan},
  10.258 +  title =        {Finding Minimum-Cost Circulations by Successive
  10.259 +                  Approximation},
  10.260 +  journal =      {Mathematics of Operations Research},
  10.261 +  year =         1990,
  10.262 +  volume =       15,
  10.263 +  number =       3,
  10.264 +  pages =        {430-466}
  10.265 +}
  10.266 +
  10.267 +@article{goldberg97efficient,
  10.268 +  author =       {Andrew V. Goldberg},
  10.269 +  title =        {An Efficient Implementation of a Scaling
  10.270 +                  Minimum-Cost Flow Algorithm},
  10.271 +  journal =      {Journal of Algorithms},
  10.272 +  year =         1997,
  10.273 +  volume =       22,
  10.274 +  number =       1,
  10.275 +  pages =        {1-29}
  10.276 +}
  10.277 +
  10.278 +@article{bunnagel98efficient,
  10.279 +  author =       {Ursula B{\"u}nnagel and Bernhard Korte and Jens
  10.280 +                  Vygen},
  10.281 +  title =        {Efficient implementation of the {G}oldberg-{T}arjan
  10.282 +                  minimum-cost flow algorithm},
  10.283 +  journal =      {Optimization Methods and Software},
  10.284 +  year =         1998,
  10.285 +  volume =       10,
  10.286 +  pages =        {157-174}
  10.287 +}
  10.288 +
  10.289 +@book{dantzig63linearprog,
  10.290 +  author =       {George B. Dantzig},
  10.291 +  title =        {Linear Programming and Extensions},
  10.292 +  publisher =    {Princeton University Press},
  10.293 +  year =         1963
  10.294 +}
  10.295 +
  10.296 +@mastersthesis{kellyoneill91netsimplex,
  10.297 +  author =       {Damian J. Kelly and Garrett M. O'Neill},
  10.298 +  title =        {The Minimum Cost Flow Problem and The Network
  10.299 +                  Simplex Method},
  10.300 +  school =       {University College},
  10.301 +  address =      {Dublin, Ireland},
  10.302 +  year =         1991,
  10.303 +  month =        sep,
  10.304 +}
    11.1 --- a/lemon/Makefile.am	Tue Aug 18 10:08:28 2009 +0200
    11.2 +++ b/lemon/Makefile.am	Thu Nov 05 08:39:49 2009 +0100
    11.3 @@ -57,8 +57,10 @@
    11.4  	lemon/adaptors.h \
    11.5  	lemon/arg_parser.h \
    11.6  	lemon/assert.h \
    11.7 +	lemon/bellman_ford.h \
    11.8  	lemon/bfs.h \
    11.9  	lemon/bin_heap.h \
   11.10 +	lemon/binom_heap.h \
   11.11  	lemon/bucket_heap.h \
   11.12  	lemon/cbc.h \
   11.13  	lemon/circulation.h \
   11.14 @@ -78,6 +80,7 @@
   11.15  	lemon/error.h \
   11.16  	lemon/euler.h \
   11.17  	lemon/fib_heap.h \
   11.18 +	lemon/fourary_heap.h \
   11.19  	lemon/full_graph.h \
   11.20  	lemon/glpk.h \
   11.21  	lemon/gomory_hu.h \
   11.22 @@ -87,6 +90,7 @@
   11.23  	lemon/howard.h \
   11.24  	lemon/hypercube_graph.h \
   11.25  	lemon/karp.h \
   11.26 +	lemon/kary_heap.h \
   11.27  	lemon/kruskal.h \
   11.28  	lemon/hao_orlin.h \
   11.29  	lemon/lgf_reader.h \
   11.30 @@ -95,13 +99,13 @@
   11.31  	lemon/lp.h \
   11.32  	lemon/lp_base.h \
   11.33  	lemon/lp_skeleton.h \
   11.34 -	lemon/list_graph.h \
   11.35  	lemon/maps.h \
   11.36  	lemon/matching.h \
   11.37  	lemon/math.h \
   11.38  	lemon/min_cost_arborescence.h \
   11.39  	lemon/nauty_reader.h \
   11.40  	lemon/network_simplex.h \
   11.41 +	lemon/pairing_heap.h \
   11.42  	lemon/path.h \
   11.43  	lemon/preflow.h \
   11.44  	lemon/radix_heap.h \
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/lemon/bellman_ford.h	Thu Nov 05 08:39:49 2009 +0100
    12.3 @@ -0,0 +1,1100 @@
    12.4 +/* -*- C++ -*-
    12.5 + *
    12.6 + * This file is a part of LEMON, a generic C++ optimization library
    12.7 + *
    12.8 + * Copyright (C) 2003-2008
    12.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   12.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   12.11 + *
   12.12 + * Permission to use, modify and distribute this software is granted
   12.13 + * provided that this copyright notice appears in all copies. For
   12.14 + * precise terms see the accompanying LICENSE file.
   12.15 + *
   12.16 + * This software is provided "AS IS" with no warranty of any kind,
   12.17 + * express or implied, and with no claim as to its suitability for any
   12.18 + * purpose.
   12.19 + *
   12.20 + */
   12.21 +
   12.22 +#ifndef LEMON_BELLMAN_FORD_H
   12.23 +#define LEMON_BELLMAN_FORD_H
   12.24 +
   12.25 +/// \ingroup shortest_path
   12.26 +/// \file
   12.27 +/// \brief Bellman-Ford algorithm.
   12.28 +
   12.29 +#include <lemon/bits/path_dump.h>
   12.30 +#include <lemon/core.h>
   12.31 +#include <lemon/error.h>
   12.32 +#include <lemon/maps.h>
   12.33 +#include <lemon/path.h>
   12.34 +
   12.35 +#include <limits>
   12.36 +
   12.37 +namespace lemon {
   12.38 +
   12.39 +  /// \brief Default OperationTraits for the BellmanFord algorithm class.
   12.40 +  ///  
   12.41 +  /// This operation traits class defines all computational operations
   12.42 +  /// and constants that are used in the Bellman-Ford algorithm.
   12.43 +  /// The default implementation is based on the \c numeric_limits class.
   12.44 +  /// If the numeric type does not have infinity value, then the maximum
   12.45 +  /// value is used as extremal infinity value.
   12.46 +  template <
   12.47 +    typename V, 
   12.48 +    bool has_inf = std::numeric_limits<V>::has_infinity>
   12.49 +  struct BellmanFordDefaultOperationTraits {
   12.50 +    /// \e
   12.51 +    typedef V Value;
   12.52 +    /// \brief Gives back the zero value of the type.
   12.53 +    static Value zero() {
   12.54 +      return static_cast<Value>(0);
   12.55 +    }
   12.56 +    /// \brief Gives back the positive infinity value of the type.
   12.57 +    static Value infinity() {
   12.58 +      return std::numeric_limits<Value>::infinity();
   12.59 +    }
   12.60 +    /// \brief Gives back the sum of the given two elements.
   12.61 +    static Value plus(const Value& left, const Value& right) {
   12.62 +      return left + right;
   12.63 +    }
   12.64 +    /// \brief Gives back \c true only if the first value is less than
   12.65 +    /// the second.
   12.66 +    static bool less(const Value& left, const Value& right) {
   12.67 +      return left < right;
   12.68 +    }
   12.69 +  };
   12.70 +
   12.71 +  template <typename V>
   12.72 +  struct BellmanFordDefaultOperationTraits<V, false> {
   12.73 +    typedef V Value;
   12.74 +    static Value zero() {
   12.75 +      return static_cast<Value>(0);
   12.76 +    }
   12.77 +    static Value infinity() {
   12.78 +      return std::numeric_limits<Value>::max();
   12.79 +    }
   12.80 +    static Value plus(const Value& left, const Value& right) {
   12.81 +      if (left == infinity() || right == infinity()) return infinity();
   12.82 +      return left + right;
   12.83 +    }
   12.84 +    static bool less(const Value& left, const Value& right) {
   12.85 +      return left < right;
   12.86 +    }
   12.87 +  };
   12.88 +  
   12.89 +  /// \brief Default traits class of BellmanFord class.
   12.90 +  ///
   12.91 +  /// Default traits class of BellmanFord class.
   12.92 +  /// \param GR The type of the digraph.
   12.93 +  /// \param LEN The type of the length map.
   12.94 +  template<typename GR, typename LEN>
   12.95 +  struct BellmanFordDefaultTraits {
   12.96 +    /// The type of the digraph the algorithm runs on. 
   12.97 +    typedef GR Digraph;
   12.98 +
   12.99 +    /// \brief The type of the map that stores the arc lengths.
  12.100 +    ///
  12.101 +    /// The type of the map that stores the arc lengths.
  12.102 +    /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
  12.103 +    typedef LEN LengthMap;
  12.104 +
  12.105 +    /// The type of the arc lengths.
  12.106 +    typedef typename LEN::Value Value;
  12.107 +
  12.108 +    /// \brief Operation traits for Bellman-Ford algorithm.
  12.109 +    ///
  12.110 +    /// It defines the used operations and the infinity value for the
  12.111 +    /// given \c Value type.
  12.112 +    /// \see BellmanFordDefaultOperationTraits
  12.113 +    typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
  12.114 + 
  12.115 +    /// \brief The type of the map that stores the last arcs of the 
  12.116 +    /// shortest paths.
  12.117 +    /// 
  12.118 +    /// The type of the map that stores the last
  12.119 +    /// arcs of the shortest paths.
  12.120 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  12.121 +    typedef typename GR::template NodeMap<typename GR::Arc> PredMap;
  12.122 +
  12.123 +    /// \brief Instantiates a \c PredMap.
  12.124 +    /// 
  12.125 +    /// This function instantiates a \ref PredMap. 
  12.126 +    /// \param g is the digraph to which we would like to define the
  12.127 +    /// \ref PredMap.
  12.128 +    static PredMap *createPredMap(const GR& g) {
  12.129 +      return new PredMap(g);
  12.130 +    }
  12.131 +
  12.132 +    /// \brief The type of the map that stores the distances of the nodes.
  12.133 +    ///
  12.134 +    /// The type of the map that stores the distances of the nodes.
  12.135 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  12.136 +    typedef typename GR::template NodeMap<typename LEN::Value> DistMap;
  12.137 +
  12.138 +    /// \brief Instantiates a \c DistMap.
  12.139 +    ///
  12.140 +    /// This function instantiates a \ref DistMap. 
  12.141 +    /// \param g is the digraph to which we would like to define the 
  12.142 +    /// \ref DistMap.
  12.143 +    static DistMap *createDistMap(const GR& g) {
  12.144 +      return new DistMap(g);
  12.145 +    }
  12.146 +
  12.147 +  };
  12.148 +  
  12.149 +  /// \brief %BellmanFord algorithm class.
  12.150 +  ///
  12.151 +  /// \ingroup shortest_path
  12.152 +  /// This class provides an efficient implementation of the Bellman-Ford 
  12.153 +  /// algorithm. The maximum time complexity of the algorithm is
  12.154 +  /// <tt>O(ne)</tt>.
  12.155 +  ///
  12.156 +  /// The Bellman-Ford algorithm solves the single-source shortest path
  12.157 +  /// problem when the arcs can have negative lengths, but the digraph
  12.158 +  /// should not contain directed cycles with negative total length.
  12.159 +  /// If all arc costs are non-negative, consider to use the Dijkstra
  12.160 +  /// algorithm instead, since it is more efficient.
  12.161 +  ///
  12.162 +  /// The arc lengths are passed to the algorithm using a
  12.163 +  /// \ref concepts::ReadMap "ReadMap", so it is easy to change it to any 
  12.164 +  /// kind of length. The type of the length values is determined by the
  12.165 +  /// \ref concepts::ReadMap::Value "Value" type of the length map.
  12.166 +  ///
  12.167 +  /// There is also a \ref bellmanFord() "function-type interface" for the
  12.168 +  /// Bellman-Ford algorithm, which is convenient in the simplier cases and
  12.169 +  /// it can be used easier.
  12.170 +  ///
  12.171 +  /// \tparam GR The type of the digraph the algorithm runs on.
  12.172 +  /// The default type is \ref ListDigraph.
  12.173 +  /// \tparam LEN A \ref concepts::ReadMap "readable" arc map that specifies
  12.174 +  /// the lengths of the arcs. The default map type is
  12.175 +  /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
  12.176 +#ifdef DOXYGEN
  12.177 +  template <typename GR, typename LEN, typename TR>
  12.178 +#else
  12.179 +  template <typename GR=ListDigraph,
  12.180 +            typename LEN=typename GR::template ArcMap<int>,
  12.181 +            typename TR=BellmanFordDefaultTraits<GR,LEN> >
  12.182 +#endif
  12.183 +  class BellmanFord {
  12.184 +  public:
  12.185 +
  12.186 +    ///The type of the underlying digraph.
  12.187 +    typedef typename TR::Digraph Digraph;
  12.188 +    
  12.189 +    /// \brief The type of the arc lengths.
  12.190 +    typedef typename TR::LengthMap::Value Value;
  12.191 +    /// \brief The type of the map that stores the arc lengths.
  12.192 +    typedef typename TR::LengthMap LengthMap;
  12.193 +    /// \brief The type of the map that stores the last
  12.194 +    /// arcs of the shortest paths.
  12.195 +    typedef typename TR::PredMap PredMap;
  12.196 +    /// \brief The type of the map that stores the distances of the nodes.
  12.197 +    typedef typename TR::DistMap DistMap;
  12.198 +    /// The type of the paths.
  12.199 +    typedef PredMapPath<Digraph, PredMap> Path;
  12.200 +    ///\brief The \ref BellmanFordDefaultOperationTraits
  12.201 +    /// "operation traits class" of the algorithm.
  12.202 +    typedef typename TR::OperationTraits OperationTraits;
  12.203 +
  12.204 +    ///The \ref BellmanFordDefaultTraits "traits class" of the algorithm.
  12.205 +    typedef TR Traits;
  12.206 +
  12.207 +  private:
  12.208 +
  12.209 +    typedef typename Digraph::Node Node;
  12.210 +    typedef typename Digraph::NodeIt NodeIt;
  12.211 +    typedef typename Digraph::Arc Arc;
  12.212 +    typedef typename Digraph::OutArcIt OutArcIt;
  12.213 +
  12.214 +    // Pointer to the underlying digraph.
  12.215 +    const Digraph *_gr;
  12.216 +    // Pointer to the length map
  12.217 +    const LengthMap *_length;
  12.218 +    // Pointer to the map of predecessors arcs.
  12.219 +    PredMap *_pred;
  12.220 +    // Indicates if _pred is locally allocated (true) or not.
  12.221 +    bool _local_pred;
  12.222 +    // Pointer to the map of distances.
  12.223 +    DistMap *_dist;
  12.224 +    // Indicates if _dist is locally allocated (true) or not.
  12.225 +    bool _local_dist;
  12.226 +
  12.227 +    typedef typename Digraph::template NodeMap<bool> MaskMap;
  12.228 +    MaskMap *_mask;
  12.229 +
  12.230 +    std::vector<Node> _process;
  12.231 +
  12.232 +    // Creates the maps if necessary.
  12.233 +    void create_maps() {
  12.234 +      if(!_pred) {
  12.235 +	_local_pred = true;
  12.236 +	_pred = Traits::createPredMap(*_gr);
  12.237 +      }
  12.238 +      if(!_dist) {
  12.239 +	_local_dist = true;
  12.240 +	_dist = Traits::createDistMap(*_gr);
  12.241 +      }
  12.242 +      _mask = new MaskMap(*_gr, false);
  12.243 +    }
  12.244 +    
  12.245 +  public :
  12.246 + 
  12.247 +    typedef BellmanFord Create;
  12.248 +
  12.249 +    /// \name Named Template Parameters
  12.250 +
  12.251 +    ///@{
  12.252 +
  12.253 +    template <class T>
  12.254 +    struct SetPredMapTraits : public Traits {
  12.255 +      typedef T PredMap;
  12.256 +      static PredMap *createPredMap(const Digraph&) {
  12.257 +        LEMON_ASSERT(false, "PredMap is not initialized");
  12.258 +        return 0; // ignore warnings
  12.259 +      }
  12.260 +    };
  12.261 +
  12.262 +    /// \brief \ref named-templ-param "Named parameter" for setting
  12.263 +    /// \c PredMap type.
  12.264 +    ///
  12.265 +    /// \ref named-templ-param "Named parameter" for setting
  12.266 +    /// \c PredMap type.
  12.267 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  12.268 +    template <class T>
  12.269 +    struct SetPredMap 
  12.270 +      : public BellmanFord< Digraph, LengthMap, SetPredMapTraits<T> > {
  12.271 +      typedef BellmanFord< Digraph, LengthMap, SetPredMapTraits<T> > Create;
  12.272 +    };
  12.273 +    
  12.274 +    template <class T>
  12.275 +    struct SetDistMapTraits : public Traits {
  12.276 +      typedef T DistMap;
  12.277 +      static DistMap *createDistMap(const Digraph&) {
  12.278 +        LEMON_ASSERT(false, "DistMap is not initialized");
  12.279 +        return 0; // ignore warnings
  12.280 +      }
  12.281 +    };
  12.282 +
  12.283 +    /// \brief \ref named-templ-param "Named parameter" for setting
  12.284 +    /// \c DistMap type.
  12.285 +    ///
  12.286 +    /// \ref named-templ-param "Named parameter" for setting
  12.287 +    /// \c DistMap type.
  12.288 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  12.289 +    template <class T>
  12.290 +    struct SetDistMap 
  12.291 +      : public BellmanFord< Digraph, LengthMap, SetDistMapTraits<T> > {
  12.292 +      typedef BellmanFord< Digraph, LengthMap, SetDistMapTraits<T> > Create;
  12.293 +    };
  12.294 +
  12.295 +    template <class T>
  12.296 +    struct SetOperationTraitsTraits : public Traits {
  12.297 +      typedef T OperationTraits;
  12.298 +    };
  12.299 +    
  12.300 +    /// \brief \ref named-templ-param "Named parameter" for setting 
  12.301 +    /// \c OperationTraits type.
  12.302 +    ///
  12.303 +    /// \ref named-templ-param "Named parameter" for setting
  12.304 +    /// \c OperationTraits type.
  12.305 +    /// For more information see \ref BellmanFordDefaultOperationTraits.
  12.306 +    template <class T>
  12.307 +    struct SetOperationTraits
  12.308 +      : public BellmanFord< Digraph, LengthMap, SetOperationTraitsTraits<T> > {
  12.309 +      typedef BellmanFord< Digraph, LengthMap, SetOperationTraitsTraits<T> >
  12.310 +      Create;
  12.311 +    };
  12.312 +    
  12.313 +    ///@}
  12.314 +
  12.315 +  protected:
  12.316 +    
  12.317 +    BellmanFord() {}
  12.318 +
  12.319 +  public:      
  12.320 +    
  12.321 +    /// \brief Constructor.
  12.322 +    ///
  12.323 +    /// Constructor.
  12.324 +    /// \param g The digraph the algorithm runs on.
  12.325 +    /// \param length The length map used by the algorithm.
  12.326 +    BellmanFord(const Digraph& g, const LengthMap& length) :
  12.327 +      _gr(&g), _length(&length),
  12.328 +      _pred(0), _local_pred(false),
  12.329 +      _dist(0), _local_dist(false), _mask(0) {}
  12.330 +    
  12.331 +    ///Destructor.
  12.332 +    ~BellmanFord() {
  12.333 +      if(_local_pred) delete _pred;
  12.334 +      if(_local_dist) delete _dist;
  12.335 +      if(_mask) delete _mask;
  12.336 +    }
  12.337 +
  12.338 +    /// \brief Sets the length map.
  12.339 +    ///
  12.340 +    /// Sets the length map.
  12.341 +    /// \return <tt>(*this)</tt>
  12.342 +    BellmanFord &lengthMap(const LengthMap &map) {
  12.343 +      _length = &map;
  12.344 +      return *this;
  12.345 +    }
  12.346 +
  12.347 +    /// \brief Sets the map that stores the predecessor arcs.
  12.348 +    ///
  12.349 +    /// Sets the map that stores the predecessor arcs.
  12.350 +    /// If you don't use this function before calling \ref run()
  12.351 +    /// or \ref init(), an instance will be allocated automatically.
  12.352 +    /// The destructor deallocates this automatically allocated map,
  12.353 +    /// of course.
  12.354 +    /// \return <tt>(*this)</tt>
  12.355 +    BellmanFord &predMap(PredMap &map) {
  12.356 +      if(_local_pred) {
  12.357 +	delete _pred;
  12.358 +	_local_pred=false;
  12.359 +      }
  12.360 +      _pred = &map;
  12.361 +      return *this;
  12.362 +    }
  12.363 +
  12.364 +    /// \brief Sets the map that stores the distances of the nodes.
  12.365 +    ///
  12.366 +    /// Sets the map that stores the distances of the nodes calculated
  12.367 +    /// by the algorithm.
  12.368 +    /// If you don't use this function before calling \ref run()
  12.369 +    /// or \ref init(), an instance will be allocated automatically.
  12.370 +    /// The destructor deallocates this automatically allocated map,
  12.371 +    /// of course.
  12.372 +    /// \return <tt>(*this)</tt>
  12.373 +    BellmanFord &distMap(DistMap &map) {
  12.374 +      if(_local_dist) {
  12.375 +	delete _dist;
  12.376 +	_local_dist=false;
  12.377 +      }
  12.378 +      _dist = &map;
  12.379 +      return *this;
  12.380 +    }
  12.381 +
  12.382 +    /// \name Execution Control
  12.383 +    /// The simplest way to execute the Bellman-Ford algorithm is to use
  12.384 +    /// one of the member functions called \ref run().\n
  12.385 +    /// If you need better control on the execution, you have to call
  12.386 +    /// \ref init() first, then you can add several source nodes
  12.387 +    /// with \ref addSource(). Finally the actual path computation can be
  12.388 +    /// performed with \ref start(), \ref checkedStart() or
  12.389 +    /// \ref limitedStart().
  12.390 +
  12.391 +    ///@{
  12.392 +
  12.393 +    /// \brief Initializes the internal data structures.
  12.394 +    /// 
  12.395 +    /// Initializes the internal data structures. The optional parameter
  12.396 +    /// is the initial distance of each node.
  12.397 +    void init(const Value value = OperationTraits::infinity()) {
  12.398 +      create_maps();
  12.399 +      for (NodeIt it(*_gr); it != INVALID; ++it) {
  12.400 +	_pred->set(it, INVALID);
  12.401 +	_dist->set(it, value);
  12.402 +      }
  12.403 +      _process.clear();
  12.404 +      if (OperationTraits::less(value, OperationTraits::infinity())) {
  12.405 +	for (NodeIt it(*_gr); it != INVALID; ++it) {
  12.406 +	  _process.push_back(it);
  12.407 +	  _mask->set(it, true);
  12.408 +	}
  12.409 +      }
  12.410 +    }
  12.411 +    
  12.412 +    /// \brief Adds a new source node.
  12.413 +    ///
  12.414 +    /// This function adds a new source node. The optional second parameter
  12.415 +    /// is the initial distance of the node.
  12.416 +    void addSource(Node source, Value dst = OperationTraits::zero()) {
  12.417 +      _dist->set(source, dst);
  12.418 +      if (!(*_mask)[source]) {
  12.419 +	_process.push_back(source);
  12.420 +	_mask->set(source, true);
  12.421 +      }
  12.422 +    }
  12.423 +
  12.424 +    /// \brief Executes one round from the Bellman-Ford algorithm.
  12.425 +    ///
  12.426 +    /// If the algoritm calculated the distances in the previous round
  12.427 +    /// exactly for the paths of at most \c k arcs, then this function
  12.428 +    /// will calculate the distances exactly for the paths of at most
  12.429 +    /// <tt>k+1</tt> arcs. Performing \c k iterations using this function
  12.430 +    /// calculates the shortest path distances exactly for the paths
  12.431 +    /// consisting of at most \c k arcs.
  12.432 +    ///
  12.433 +    /// \warning The paths with limited arc number cannot be retrieved
  12.434 +    /// easily with \ref path() or \ref predArc() functions. If you also
  12.435 +    /// need the shortest paths and not only the distances, you should
  12.436 +    /// store the \ref predMap() "predecessor map" after each iteration
  12.437 +    /// and build the path manually.
  12.438 +    ///
  12.439 +    /// \return \c true when the algorithm have not found more shorter
  12.440 +    /// paths.
  12.441 +    ///
  12.442 +    /// \see ActiveIt
  12.443 +    bool processNextRound() {
  12.444 +      for (int i = 0; i < int(_process.size()); ++i) {
  12.445 +	_mask->set(_process[i], false);
  12.446 +      }
  12.447 +      std::vector<Node> nextProcess;
  12.448 +      std::vector<Value> values(_process.size());
  12.449 +      for (int i = 0; i < int(_process.size()); ++i) {
  12.450 +	values[i] = (*_dist)[_process[i]];
  12.451 +      }
  12.452 +      for (int i = 0; i < int(_process.size()); ++i) {
  12.453 +	for (OutArcIt it(*_gr, _process[i]); it != INVALID; ++it) {
  12.454 +	  Node target = _gr->target(it);
  12.455 +	  Value relaxed = OperationTraits::plus(values[i], (*_length)[it]);
  12.456 +	  if (OperationTraits::less(relaxed, (*_dist)[target])) {
  12.457 +	    _pred->set(target, it);
  12.458 +	    _dist->set(target, relaxed);
  12.459 +	    if (!(*_mask)[target]) {
  12.460 +	      _mask->set(target, true);
  12.461 +	      nextProcess.push_back(target);
  12.462 +	    }
  12.463 +	  }	  
  12.464 +	}
  12.465 +      }
  12.466 +      _process.swap(nextProcess);
  12.467 +      return _process.empty();
  12.468 +    }
  12.469 +
  12.470 +    /// \brief Executes one weak round from the Bellman-Ford algorithm.
  12.471 +    ///
  12.472 +    /// If the algorithm calculated the distances in the previous round
  12.473 +    /// at least for the paths of at most \c k arcs, then this function
  12.474 +    /// will calculate the distances at least for the paths of at most
  12.475 +    /// <tt>k+1</tt> arcs.
  12.476 +    /// This function does not make it possible to calculate the shortest
  12.477 +    /// path distances exactly for paths consisting of at most \c k arcs,
  12.478 +    /// this is why it is called weak round.
  12.479 +    ///
  12.480 +    /// \return \c true when the algorithm have not found more shorter
  12.481 +    /// paths.
  12.482 +    ///
  12.483 +    /// \see ActiveIt
  12.484 +    bool processNextWeakRound() {
  12.485 +      for (int i = 0; i < int(_process.size()); ++i) {
  12.486 +	_mask->set(_process[i], false);
  12.487 +      }
  12.488 +      std::vector<Node> nextProcess;
  12.489 +      for (int i = 0; i < int(_process.size()); ++i) {
  12.490 +	for (OutArcIt it(*_gr, _process[i]); it != INVALID; ++it) {
  12.491 +	  Node target = _gr->target(it);
  12.492 +	  Value relaxed = 
  12.493 +	    OperationTraits::plus((*_dist)[_process[i]], (*_length)[it]);
  12.494 +	  if (OperationTraits::less(relaxed, (*_dist)[target])) {
  12.495 +	    _pred->set(target, it);
  12.496 +	    _dist->set(target, relaxed);
  12.497 +	    if (!(*_mask)[target]) {
  12.498 +	      _mask->set(target, true);
  12.499 +	      nextProcess.push_back(target);
  12.500 +	    }
  12.501 +	  }	  
  12.502 +	}
  12.503 +      }
  12.504 +      _process.swap(nextProcess);
  12.505 +      return _process.empty();
  12.506 +    }
  12.507 +
  12.508 +    /// \brief Executes the algorithm.
  12.509 +    ///
  12.510 +    /// Executes the algorithm.
  12.511 +    ///
  12.512 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  12.513 +    /// in order to compute the shortest path to each node.
  12.514 +    ///
  12.515 +    /// The algorithm computes
  12.516 +    /// - the shortest path tree (forest),
  12.517 +    /// - the distance of each node from the root(s).
  12.518 +    ///
  12.519 +    /// \pre init() must be called and at least one root node should be
  12.520 +    /// added with addSource() before using this function.
  12.521 +    void start() {
  12.522 +      int num = countNodes(*_gr) - 1;
  12.523 +      for (int i = 0; i < num; ++i) {
  12.524 +	if (processNextWeakRound()) break;
  12.525 +      }
  12.526 +    }
  12.527 +
  12.528 +    /// \brief Executes the algorithm and checks the negative cycles.
  12.529 +    ///
  12.530 +    /// Executes the algorithm and checks the negative cycles.
  12.531 +    ///
  12.532 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  12.533 +    /// in order to compute the shortest path to each node and also checks
  12.534 +    /// if the digraph contains cycles with negative total length.
  12.535 +    ///
  12.536 +    /// The algorithm computes 
  12.537 +    /// - the shortest path tree (forest),
  12.538 +    /// - the distance of each node from the root(s).
  12.539 +    /// 
  12.540 +    /// \return \c false if there is a negative cycle in the digraph.
  12.541 +    ///
  12.542 +    /// \pre init() must be called and at least one root node should be
  12.543 +    /// added with addSource() before using this function. 
  12.544 +    bool checkedStart() {
  12.545 +      int num = countNodes(*_gr);
  12.546 +      for (int i = 0; i < num; ++i) {
  12.547 +	if (processNextWeakRound()) return true;
  12.548 +      }
  12.549 +      return _process.empty();
  12.550 +    }
  12.551 +
  12.552 +    /// \brief Executes the algorithm with arc number limit.
  12.553 +    ///
  12.554 +    /// Executes the algorithm with arc number limit.
  12.555 +    ///
  12.556 +    /// This method runs the Bellman-Ford algorithm from the root node(s)
  12.557 +    /// in order to compute the shortest path distance for each node
  12.558 +    /// using only the paths consisting of at most \c num arcs.
  12.559 +    ///
  12.560 +    /// The algorithm computes
  12.561 +    /// - the limited distance of each node from the root(s),
  12.562 +    /// - the predecessor arc for each node.
  12.563 +    ///
  12.564 +    /// \warning The paths with limited arc number cannot be retrieved
  12.565 +    /// easily with \ref path() or \ref predArc() functions. If you also
  12.566 +    /// need the shortest paths and not only the distances, you should
  12.567 +    /// store the \ref predMap() "predecessor map" after each iteration
  12.568 +    /// and build the path manually.
  12.569 +    ///
  12.570 +    /// \pre init() must be called and at least one root node should be
  12.571 +    /// added with addSource() before using this function. 
  12.572 +    void limitedStart(int num) {
  12.573 +      for (int i = 0; i < num; ++i) {
  12.574 +	if (processNextRound()) break;
  12.575 +      }
  12.576 +    }
  12.577 +    
  12.578 +    /// \brief Runs the algorithm from the given root node.
  12.579 +    ///    
  12.580 +    /// This method runs the Bellman-Ford algorithm from the given root
  12.581 +    /// node \c s in order to compute the shortest path to each node.
  12.582 +    ///
  12.583 +    /// The algorithm computes
  12.584 +    /// - the shortest path tree (forest),
  12.585 +    /// - the distance of each node from the root(s).
  12.586 +    ///
  12.587 +    /// \note bf.run(s) is just a shortcut of the following code.
  12.588 +    /// \code
  12.589 +    ///   bf.init();
  12.590 +    ///   bf.addSource(s);
  12.591 +    ///   bf.start();
  12.592 +    /// \endcode
  12.593 +    void run(Node s) {
  12.594 +      init();
  12.595 +      addSource(s);
  12.596 +      start();
  12.597 +    }
  12.598 +    
  12.599 +    /// \brief Runs the algorithm from the given root node with arc
  12.600 +    /// number limit.
  12.601 +    ///    
  12.602 +    /// This method runs the Bellman-Ford algorithm from the given root
  12.603 +    /// node \c s in order to compute the shortest path distance for each
  12.604 +    /// node using only the paths consisting of at most \c num arcs.
  12.605 +    ///
  12.606 +    /// The algorithm computes
  12.607 +    /// - the limited distance of each node from the root(s),
  12.608 +    /// - the predecessor arc for each node.
  12.609 +    ///
  12.610 +    /// \warning The paths with limited arc number cannot be retrieved
  12.611 +    /// easily with \ref path() or \ref predArc() functions. If you also
  12.612 +    /// need the shortest paths and not only the distances, you should
  12.613 +    /// store the \ref predMap() "predecessor map" after each iteration
  12.614 +    /// and build the path manually.
  12.615 +    ///
  12.616 +    /// \note bf.run(s, num) is just a shortcut of the following code.
  12.617 +    /// \code
  12.618 +    ///   bf.init();
  12.619 +    ///   bf.addSource(s);
  12.620 +    ///   bf.limitedStart(num);
  12.621 +    /// \endcode
  12.622 +    void run(Node s, int num) {
  12.623 +      init();
  12.624 +      addSource(s);
  12.625 +      limitedStart(num);
  12.626 +    }
  12.627 +    
  12.628 +    ///@}
  12.629 +
  12.630 +    /// \brief LEMON iterator for getting the active nodes.
  12.631 +    ///
  12.632 +    /// This class provides a common style LEMON iterator that traverses
  12.633 +    /// the active nodes of the Bellman-Ford algorithm after the last
  12.634 +    /// phase. These nodes should be checked in the next phase to
  12.635 +    /// find augmenting arcs outgoing from them.
  12.636 +    class ActiveIt {
  12.637 +    public:
  12.638 +
  12.639 +      /// \brief Constructor.
  12.640 +      ///
  12.641 +      /// Constructor for getting the active nodes of the given BellmanFord
  12.642 +      /// instance. 
  12.643 +      ActiveIt(const BellmanFord& algorithm) : _algorithm(&algorithm)
  12.644 +      {
  12.645 +        _index = _algorithm->_process.size() - 1;
  12.646 +      }
  12.647 +
  12.648 +      /// \brief Invalid constructor.
  12.649 +      ///
  12.650 +      /// Invalid constructor.
  12.651 +      ActiveIt(Invalid) : _algorithm(0), _index(-1) {}
  12.652 +
  12.653 +      /// \brief Conversion to \c Node.
  12.654 +      ///
  12.655 +      /// Conversion to \c Node.
  12.656 +      operator Node() const { 
  12.657 +        return _index >= 0 ? _algorithm->_process[_index] : INVALID;
  12.658 +      }
  12.659 +
  12.660 +      /// \brief Increment operator.
  12.661 +      ///
  12.662 +      /// Increment operator.
  12.663 +      ActiveIt& operator++() {
  12.664 +        --_index;
  12.665 +        return *this; 
  12.666 +      }
  12.667 +
  12.668 +      bool operator==(const ActiveIt& it) const { 
  12.669 +        return static_cast<Node>(*this) == static_cast<Node>(it); 
  12.670 +      }
  12.671 +      bool operator!=(const ActiveIt& it) const { 
  12.672 +        return static_cast<Node>(*this) != static_cast<Node>(it); 
  12.673 +      }
  12.674 +      bool operator<(const ActiveIt& it) const { 
  12.675 +        return static_cast<Node>(*this) < static_cast<Node>(it); 
  12.676 +      }
  12.677 +      
  12.678 +    private:
  12.679 +      const BellmanFord* _algorithm;
  12.680 +      int _index;
  12.681 +    };
  12.682 +    
  12.683 +    /// \name Query Functions
  12.684 +    /// The result of the Bellman-Ford algorithm can be obtained using these
  12.685 +    /// functions.\n
  12.686 +    /// Either \ref run() or \ref init() should be called before using them.
  12.687 +    
  12.688 +    ///@{
  12.689 +
  12.690 +    /// \brief The shortest path to the given node.
  12.691 +    ///    
  12.692 +    /// Gives back the shortest path to the given node from the root(s).
  12.693 +    ///
  12.694 +    /// \warning \c t should be reached from the root(s).
  12.695 +    ///
  12.696 +    /// \pre Either \ref run() or \ref init() must be called before
  12.697 +    /// using this function.
  12.698 +    Path path(Node t) const
  12.699 +    {
  12.700 +      return Path(*_gr, *_pred, t);
  12.701 +    }
  12.702 +	  
  12.703 +    /// \brief The distance of the given node from the root(s).
  12.704 +    ///
  12.705 +    /// Returns the distance of the given node from the root(s).
  12.706 +    ///
  12.707 +    /// \warning If node \c v is not reached from the root(s), then
  12.708 +    /// the return value of this function is undefined.
  12.709 +    ///
  12.710 +    /// \pre Either \ref run() or \ref init() must be called before
  12.711 +    /// using this function.
  12.712 +    Value dist(Node v) const { return (*_dist)[v]; }
  12.713 +
  12.714 +    /// \brief Returns the 'previous arc' of the shortest path tree for
  12.715 +    /// the given node.
  12.716 +    ///
  12.717 +    /// This function returns the 'previous arc' of the shortest path
  12.718 +    /// tree for node \c v, i.e. it returns the last arc of a
  12.719 +    /// shortest path from a root to \c v. It is \c INVALID if \c v
  12.720 +    /// is not reached from the root(s) or if \c v is a root.
  12.721 +    ///
  12.722 +    /// The shortest path tree used here is equal to the shortest path
  12.723 +    /// tree used in \ref predNode() and \predMap().
  12.724 +    ///
  12.725 +    /// \pre Either \ref run() or \ref init() must be called before
  12.726 +    /// using this function.
  12.727 +    Arc predArc(Node v) const { return (*_pred)[v]; }
  12.728 +
  12.729 +    /// \brief Returns the 'previous node' of the shortest path tree for
  12.730 +    /// the given node.
  12.731 +    ///
  12.732 +    /// This function returns the 'previous node' of the shortest path
  12.733 +    /// tree for node \c v, i.e. it returns the last but one node of
  12.734 +    /// a shortest path from a root to \c v. It is \c INVALID if \c v
  12.735 +    /// is not reached from the root(s) or if \c v is a root.
  12.736 +    ///
  12.737 +    /// The shortest path tree used here is equal to the shortest path
  12.738 +    /// tree used in \ref predArc() and \predMap().
  12.739 +    ///
  12.740 +    /// \pre Either \ref run() or \ref init() must be called before
  12.741 +    /// using this function.
  12.742 +    Node predNode(Node v) const { 
  12.743 +      return (*_pred)[v] == INVALID ? INVALID : _gr->source((*_pred)[v]); 
  12.744 +    }
  12.745 +    
  12.746 +    /// \brief Returns a const reference to the node map that stores the
  12.747 +    /// distances of the nodes.
  12.748 +    ///
  12.749 +    /// Returns a const reference to the node map that stores the distances
  12.750 +    /// of the nodes calculated by the algorithm.
  12.751 +    ///
  12.752 +    /// \pre Either \ref run() or \ref init() must be called before
  12.753 +    /// using this function.
  12.754 +    const DistMap &distMap() const { return *_dist;}
  12.755 + 
  12.756 +    /// \brief Returns a const reference to the node map that stores the
  12.757 +    /// predecessor arcs.
  12.758 +    ///
  12.759 +    /// Returns a const reference to the node map that stores the predecessor
  12.760 +    /// arcs, which form the shortest path tree (forest).
  12.761 +    ///
  12.762 +    /// \pre Either \ref run() or \ref init() must be called before
  12.763 +    /// using this function.
  12.764 +    const PredMap &predMap() const { return *_pred; }
  12.765 + 
  12.766 +    /// \brief Checks if a node is reached from the root(s).
  12.767 +    ///
  12.768 +    /// Returns \c true if \c v is reached from the root(s).
  12.769 +    ///
  12.770 +    /// \pre Either \ref run() or \ref init() must be called before
  12.771 +    /// using this function.
  12.772 +    bool reached(Node v) const {
  12.773 +      return (*_dist)[v] != OperationTraits::infinity();
  12.774 +    }
  12.775 +
  12.776 +    /// \brief Gives back a negative cycle.
  12.777 +    ///    
  12.778 +    /// This function gives back a directed cycle with negative total
  12.779 +    /// length if the algorithm has already found one.
  12.780 +    /// Otherwise it gives back an empty path.
  12.781 +    lemon::Path<Digraph> negativeCycle() {
  12.782 +      typename Digraph::template NodeMap<int> state(*_gr, -1);
  12.783 +      lemon::Path<Digraph> cycle;
  12.784 +      for (int i = 0; i < int(_process.size()); ++i) {
  12.785 +        if (state[_process[i]] != -1) continue;
  12.786 +        for (Node v = _process[i]; (*_pred)[v] != INVALID;
  12.787 +             v = _gr->source((*_pred)[v])) {
  12.788 +          if (state[v] == i) {
  12.789 +            cycle.addFront((*_pred)[v]);
  12.790 +            for (Node u = _gr->source((*_pred)[v]); u != v;
  12.791 +                 u = _gr->source((*_pred)[u])) {
  12.792 +              cycle.addFront((*_pred)[u]);
  12.793 +            }
  12.794 +            return cycle;
  12.795 +          }
  12.796 +          else if (state[v] >= 0) {
  12.797 +            break;
  12.798 +          }
  12.799 +          state[v] = i;
  12.800 +        }
  12.801 +      }
  12.802 +      return cycle;
  12.803 +    }
  12.804 +    
  12.805 +    ///@}
  12.806 +  };
  12.807 + 
  12.808 +  /// \brief Default traits class of bellmanFord() function.
  12.809 +  ///
  12.810 +  /// Default traits class of bellmanFord() function.
  12.811 +  /// \tparam GR The type of the digraph.
  12.812 +  /// \tparam LEN The type of the length map.
  12.813 +  template <typename GR, typename LEN>
  12.814 +  struct BellmanFordWizardDefaultTraits {
  12.815 +    /// The type of the digraph the algorithm runs on. 
  12.816 +    typedef GR Digraph;
  12.817 +
  12.818 +    /// \brief The type of the map that stores the arc lengths.
  12.819 +    ///
  12.820 +    /// The type of the map that stores the arc lengths.
  12.821 +    /// It must meet the \ref concepts::ReadMap "ReadMap" concept.
  12.822 +    typedef LEN LengthMap;
  12.823 +
  12.824 +    /// The type of the arc lengths.
  12.825 +    typedef typename LEN::Value Value;
  12.826 +
  12.827 +    /// \brief Operation traits for Bellman-Ford algorithm.
  12.828 +    ///
  12.829 +    /// It defines the used operations and the infinity value for the
  12.830 +    /// given \c Value type.
  12.831 +    /// \see BellmanFordDefaultOperationTraits
  12.832 +    typedef BellmanFordDefaultOperationTraits<Value> OperationTraits;
  12.833 +
  12.834 +    /// \brief The type of the map that stores the last
  12.835 +    /// arcs of the shortest paths.
  12.836 +    /// 
  12.837 +    /// The type of the map that stores the last arcs of the shortest paths.
  12.838 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  12.839 +    typedef typename GR::template NodeMap<typename GR::Arc> PredMap;
  12.840 +
  12.841 +    /// \brief Instantiates a \c PredMap.
  12.842 +    /// 
  12.843 +    /// This function instantiates a \ref PredMap.
  12.844 +    /// \param g is the digraph to which we would like to define the
  12.845 +    /// \ref PredMap.
  12.846 +    static PredMap *createPredMap(const GR &g) {
  12.847 +      return new PredMap(g);
  12.848 +    }
  12.849 +
  12.850 +    /// \brief The type of the map that stores the distances of the nodes.
  12.851 +    ///
  12.852 +    /// The type of the map that stores the distances of the nodes.
  12.853 +    /// It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  12.854 +    typedef typename GR::template NodeMap<Value> DistMap;
  12.855 +
  12.856 +    /// \brief Instantiates a \c DistMap.
  12.857 +    ///
  12.858 +    /// This function instantiates a \ref DistMap. 
  12.859 +    /// \param g is the digraph to which we would like to define the
  12.860 +    /// \ref DistMap.
  12.861 +    static DistMap *createDistMap(const GR &g) {
  12.862 +      return new DistMap(g);
  12.863 +    }
  12.864 +
  12.865 +    ///The type of the shortest paths.
  12.866 +
  12.867 +    ///The type of the shortest paths.
  12.868 +    ///It must meet the \ref concepts::Path "Path" concept.
  12.869 +    typedef lemon::Path<Digraph> Path;
  12.870 +  };
  12.871 +  
  12.872 +  /// \brief Default traits class used by BellmanFordWizard.
  12.873 +  ///
  12.874 +  /// Default traits class used by BellmanFordWizard.
  12.875 +  /// \tparam GR The type of the digraph.
  12.876 +  /// \tparam LEN The type of the length map.
  12.877 +  template <typename GR, typename LEN>
  12.878 +  class BellmanFordWizardBase 
  12.879 +    : public BellmanFordWizardDefaultTraits<GR, LEN> {
  12.880 +
  12.881 +    typedef BellmanFordWizardDefaultTraits<GR, LEN> Base;
  12.882 +  protected:
  12.883 +    // Type of the nodes in the digraph.
  12.884 +    typedef typename Base::Digraph::Node Node;
  12.885 +
  12.886 +    // Pointer to the underlying digraph.
  12.887 +    void *_graph;
  12.888 +    // Pointer to the length map
  12.889 +    void *_length;
  12.890 +    // Pointer to the map of predecessors arcs.
  12.891 +    void *_pred;
  12.892 +    // Pointer to the map of distances.
  12.893 +    void *_dist;
  12.894 +    //Pointer to the shortest path to the target node.
  12.895 +    void *_path;
  12.896 +    //Pointer to the distance of the target node.
  12.897 +    void *_di;
  12.898 +
  12.899 +    public:
  12.900 +    /// Constructor.
  12.901 +    
  12.902 +    /// This constructor does not require parameters, it initiates
  12.903 +    /// all of the attributes to default values \c 0.
  12.904 +    BellmanFordWizardBase() :
  12.905 +      _graph(0), _length(0), _pred(0), _dist(0), _path(0), _di(0) {}
  12.906 +
  12.907 +    /// Constructor.
  12.908 +    
  12.909 +    /// This constructor requires two parameters,
  12.910 +    /// others are initiated to \c 0.
  12.911 +    /// \param gr The digraph the algorithm runs on.
  12.912 +    /// \param len The length map.
  12.913 +    BellmanFordWizardBase(const GR& gr, 
  12.914 +			  const LEN& len) :
  12.915 +      _graph(reinterpret_cast<void*>(const_cast<GR*>(&gr))), 
  12.916 +      _length(reinterpret_cast<void*>(const_cast<LEN*>(&len))), 
  12.917 +      _pred(0), _dist(0), _path(0), _di(0) {}
  12.918 +
  12.919 +  };
  12.920 +  
  12.921 +  /// \brief Auxiliary class for the function-type interface of the
  12.922 +  /// \ref BellmanFord "Bellman-Ford" algorithm.
  12.923 +  ///
  12.924 +  /// This auxiliary class is created to implement the
  12.925 +  /// \ref bellmanFord() "function-type interface" of the
  12.926 +  /// \ref BellmanFord "Bellman-Ford" algorithm.
  12.927 +  /// It does not have own \ref run() method, it uses the
  12.928 +  /// functions and features of the plain \ref BellmanFord.
  12.929 +  ///
  12.930 +  /// This class should only be used through the \ref bellmanFord()
  12.931 +  /// function, which makes it easier to use the algorithm.
  12.932 +  template<class TR>
  12.933 +  class BellmanFordWizard : public TR {
  12.934 +    typedef TR Base;
  12.935 +
  12.936 +    typedef typename TR::Digraph Digraph;
  12.937 +
  12.938 +    typedef typename Digraph::Node Node;
  12.939 +    typedef typename Digraph::NodeIt NodeIt;
  12.940 +    typedef typename Digraph::Arc Arc;
  12.941 +    typedef typename Digraph::OutArcIt ArcIt;
  12.942 +    
  12.943 +    typedef typename TR::LengthMap LengthMap;
  12.944 +    typedef typename LengthMap::Value Value;
  12.945 +    typedef typename TR::PredMap PredMap;
  12.946 +    typedef typename TR::DistMap DistMap;
  12.947 +    typedef typename TR::Path Path;
  12.948 +
  12.949 +  public:
  12.950 +    /// Constructor.
  12.951 +    BellmanFordWizard() : TR() {}
  12.952 +
  12.953 +    /// \brief Constructor that requires parameters.
  12.954 +    ///
  12.955 +    /// Constructor that requires parameters.
  12.956 +    /// These parameters will be the default values for the traits class.
  12.957 +    /// \param gr The digraph the algorithm runs on.
  12.958 +    /// \param len The length map.
  12.959 +    BellmanFordWizard(const Digraph& gr, const LengthMap& len) 
  12.960 +      : TR(gr, len) {}
  12.961 +
  12.962 +    /// \brief Copy constructor
  12.963 +    BellmanFordWizard(const TR &b) : TR(b) {}
  12.964 +
  12.965 +    ~BellmanFordWizard() {}
  12.966 +
  12.967 +    /// \brief Runs the Bellman-Ford algorithm from the given source node.
  12.968 +    ///    
  12.969 +    /// This method runs the Bellman-Ford algorithm from the given source
  12.970 +    /// node in order to compute the shortest path to each node.
  12.971 +    void run(Node s) {
  12.972 +      BellmanFord<Digraph,LengthMap,TR> 
  12.973 +	bf(*reinterpret_cast<const Digraph*>(Base::_graph), 
  12.974 +           *reinterpret_cast<const LengthMap*>(Base::_length));
  12.975 +      if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
  12.976 +      if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
  12.977 +      bf.run(s);
  12.978 +    }
  12.979 +
  12.980 +    /// \brief Runs the Bellman-Ford algorithm to find the shortest path
  12.981 +    /// between \c s and \c t.
  12.982 +    ///
  12.983 +    /// This method runs the Bellman-Ford algorithm from node \c s
  12.984 +    /// in order to compute the shortest path to node \c t.
  12.985 +    /// Actually, it computes the shortest path to each node, but using
  12.986 +    /// this function you can retrieve the distance and the shortest path
  12.987 +    /// for a single target node easier.
  12.988 +    ///
  12.989 +    /// \return \c true if \c t is reachable form \c s.
  12.990 +    bool run(Node s, Node t) {
  12.991 +      BellmanFord<Digraph,LengthMap,TR>
  12.992 +        bf(*reinterpret_cast<const Digraph*>(Base::_graph),
  12.993 +           *reinterpret_cast<const LengthMap*>(Base::_length));
  12.994 +      if (Base::_pred) bf.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
  12.995 +      if (Base::_dist) bf.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
  12.996 +      bf.run(s);
  12.997 +      if (Base::_path) *reinterpret_cast<Path*>(Base::_path) = bf.path(t);
  12.998 +      if (Base::_di) *reinterpret_cast<Value*>(Base::_di) = bf.dist(t);
  12.999 +      return bf.reached(t);
 12.1000 +    }
 12.1001 +
 12.1002 +    template<class T>
 12.1003 +    struct SetPredMapBase : public Base {
 12.1004 +      typedef T PredMap;
 12.1005 +      static PredMap *createPredMap(const Digraph &) { return 0; };
 12.1006 +      SetPredMapBase(const TR &b) : TR(b) {}
 12.1007 +    };
 12.1008 +    
 12.1009 +    /// \brief \ref named-templ-param "Named parameter" for setting
 12.1010 +    /// the predecessor map.
 12.1011 +    ///
 12.1012 +    /// \ref named-templ-param "Named parameter" for setting
 12.1013 +    /// the map that stores the predecessor arcs of the nodes.
 12.1014 +    template<class T>
 12.1015 +    BellmanFordWizard<SetPredMapBase<T> > predMap(const T &t) {
 12.1016 +      Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
 12.1017 +      return BellmanFordWizard<SetPredMapBase<T> >(*this);
 12.1018 +    }
 12.1019 +    
 12.1020 +    template<class T>
 12.1021 +    struct SetDistMapBase : public Base {
 12.1022 +      typedef T DistMap;
 12.1023 +      static DistMap *createDistMap(const Digraph &) { return 0; };
 12.1024 +      SetDistMapBase(const TR &b) : TR(b) {}
 12.1025 +    };
 12.1026 +    
 12.1027 +    /// \brief \ref named-templ-param "Named parameter" for setting
 12.1028 +    /// the distance map.
 12.1029 +    ///
 12.1030 +    /// \ref named-templ-param "Named parameter" for setting
 12.1031 +    /// the map that stores the distances of the nodes calculated
 12.1032 +    /// by the algorithm.
 12.1033 +    template<class T>
 12.1034 +    BellmanFordWizard<SetDistMapBase<T> > distMap(const T &t) {
 12.1035 +      Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
 12.1036 +      return BellmanFordWizard<SetDistMapBase<T> >(*this);
 12.1037 +    }
 12.1038 +
 12.1039 +    template<class T>
 12.1040 +    struct SetPathBase : public Base {
 12.1041 +      typedef T Path;
 12.1042 +      SetPathBase(const TR &b) : TR(b) {}
 12.1043 +    };
 12.1044 +
 12.1045 +    /// \brief \ref named-func-param "Named parameter" for getting
 12.1046 +    /// the shortest path to the target node.
 12.1047 +    ///
 12.1048 +    /// \ref named-func-param "Named parameter" for getting
 12.1049 +    /// the shortest path to the target node.
 12.1050 +    template<class T>
 12.1051 +    BellmanFordWizard<SetPathBase<T> > path(const T &t)
 12.1052 +    {
 12.1053 +      Base::_path=reinterpret_cast<void*>(const_cast<T*>(&t));
 12.1054 +      return BellmanFordWizard<SetPathBase<T> >(*this);
 12.1055 +    }
 12.1056 +
 12.1057 +    /// \brief \ref named-func-param "Named parameter" for getting
 12.1058 +    /// the distance of the target node.
 12.1059 +    ///
 12.1060 +    /// \ref named-func-param "Named parameter" for getting
 12.1061 +    /// the distance of the target node.
 12.1062 +    BellmanFordWizard dist(const Value &d)
 12.1063 +    {
 12.1064 +      Base::_di=reinterpret_cast<void*>(const_cast<Value*>(&d));
 12.1065 +      return *this;
 12.1066 +    }
 12.1067 +    
 12.1068 +  };
 12.1069 +  
 12.1070 +  /// \brief Function type interface for the \ref BellmanFord "Bellman-Ford"
 12.1071 +  /// algorithm.
 12.1072 +  ///
 12.1073 +  /// \ingroup shortest_path
 12.1074 +  /// Function type interface for the \ref BellmanFord "Bellman-Ford"
 12.1075 +  /// algorithm.
 12.1076 +  ///
 12.1077 +  /// This function also has several \ref named-templ-func-param 
 12.1078 +  /// "named parameters", they are declared as the members of class 
 12.1079 +  /// \ref BellmanFordWizard.
 12.1080 +  /// The following examples show how to use these parameters.
 12.1081 +  /// \code
 12.1082 +  ///   // Compute shortest path from node s to each node
 12.1083 +  ///   bellmanFord(g,length).predMap(preds).distMap(dists).run(s);
 12.1084 +  ///
 12.1085 +  ///   // Compute shortest path from s to t
 12.1086 +  ///   bool reached = bellmanFord(g,length).path(p).dist(d).run(s,t);
 12.1087 +  /// \endcode
 12.1088 +  /// \warning Don't forget to put the \ref BellmanFordWizard::run() "run()"
 12.1089 +  /// to the end of the parameter list.
 12.1090 +  /// \sa BellmanFordWizard
 12.1091 +  /// \sa BellmanFord
 12.1092 +  template<typename GR, typename LEN>
 12.1093 +  BellmanFordWizard<BellmanFordWizardBase<GR,LEN> >
 12.1094 +  bellmanFord(const GR& digraph,
 12.1095 +	      const LEN& length)
 12.1096 +  {
 12.1097 +    return BellmanFordWizard<BellmanFordWizardBase<GR,LEN> >(digraph, length);
 12.1098 +  }
 12.1099 +
 12.1100 +} //END OF NAMESPACE LEMON
 12.1101 +
 12.1102 +#endif
 12.1103 +
    13.1 --- a/lemon/bfs.h	Tue Aug 18 10:08:28 2009 +0200
    13.2 +++ b/lemon/bfs.h	Thu Nov 05 08:39:49 2009 +0100
    13.3 @@ -47,7 +47,7 @@
    13.4      ///
    13.5      ///The type of the map that stores the predecessor
    13.6      ///arcs of the shortest paths.
    13.7 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    13.8 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    13.9      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
   13.10      ///Instantiates a \c PredMap.
   13.11  
   13.12 @@ -62,7 +62,8 @@
   13.13      ///The type of the map that indicates which nodes are processed.
   13.14  
   13.15      ///The type of the map that indicates which nodes are processed.
   13.16 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   13.17 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   13.18 +    ///By default it is a NullMap.
   13.19      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   13.20      ///Instantiates a \c ProcessedMap.
   13.21  
   13.22 @@ -81,7 +82,7 @@
   13.23      ///The type of the map that indicates which nodes are reached.
   13.24  
   13.25      ///The type of the map that indicates which nodes are reached.
   13.26 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   13.27 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   13.28      typedef typename Digraph::template NodeMap<bool> ReachedMap;
   13.29      ///Instantiates a \c ReachedMap.
   13.30  
   13.31 @@ -96,7 +97,7 @@
   13.32      ///The type of the map that stores the distances of the nodes.
   13.33  
   13.34      ///The type of the map that stores the distances of the nodes.
   13.35 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   13.36 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   13.37      typedef typename Digraph::template NodeMap<int> DistMap;
   13.38      ///Instantiates a \c DistMap.
   13.39  
   13.40 @@ -225,7 +226,7 @@
   13.41      ///
   13.42      ///\ref named-templ-param "Named parameter" for setting
   13.43      ///\c PredMap type.
   13.44 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   13.45 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   13.46      template <class T>
   13.47      struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > {
   13.48        typedef Bfs< Digraph, SetPredMapTraits<T> > Create;
   13.49 @@ -245,7 +246,7 @@
   13.50      ///
   13.51      ///\ref named-templ-param "Named parameter" for setting
   13.52      ///\c DistMap type.
   13.53 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   13.54 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   13.55      template <class T>
   13.56      struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > {
   13.57        typedef Bfs< Digraph, SetDistMapTraits<T> > Create;
   13.58 @@ -265,7 +266,7 @@
   13.59      ///
   13.60      ///\ref named-templ-param "Named parameter" for setting
   13.61      ///\c ReachedMap type.
   13.62 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   13.63 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   13.64      template <class T>
   13.65      struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > {
   13.66        typedef Bfs< Digraph, SetReachedMapTraits<T> > Create;
   13.67 @@ -285,7 +286,7 @@
   13.68      ///
   13.69      ///\ref named-templ-param "Named parameter" for setting
   13.70      ///\c ProcessedMap type.
   13.71 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   13.72 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   13.73      template <class T>
   13.74      struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > {
   13.75        typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create;
   13.76 @@ -413,8 +414,8 @@
   13.77      ///\name Execution Control
   13.78      ///The simplest way to execute the BFS algorithm is to use one of the
   13.79      ///member functions called \ref run(Node) "run()".\n
   13.80 -    ///If you need more control on the execution, first you have to call
   13.81 -    ///\ref init(), then you can add several source nodes with
   13.82 +    ///If you need better control on the execution, you have to call
   13.83 +    ///\ref init() first, then you can add several source nodes with
   13.84      ///\ref addSource(). Finally the actual path computation can be
   13.85      ///performed with one of the \ref start() functions.
   13.86  
   13.87 @@ -737,9 +738,9 @@
   13.88  
   13.89      ///@{
   13.90  
   13.91 -    ///The shortest path to a node.
   13.92 +    ///The shortest path to the given node.
   13.93  
   13.94 -    ///Returns the shortest path to a node.
   13.95 +    ///Returns the shortest path to the given node from the root(s).
   13.96      ///
   13.97      ///\warning \c t should be reached from the root(s).
   13.98      ///
   13.99 @@ -747,9 +748,9 @@
  13.100      ///must be called before using this function.
  13.101      Path path(Node t) const { return Path(*G, *_pred, t); }
  13.102  
  13.103 -    ///The distance of a node from the root(s).
  13.104 +    ///The distance of the given node from the root(s).
  13.105  
  13.106 -    ///Returns the distance of a node from the root(s).
  13.107 +    ///Returns the distance of the given node from the root(s).
  13.108      ///
  13.109      ///\warning If node \c v is not reached from the root(s), then
  13.110      ///the return value of this function is undefined.
  13.111 @@ -758,29 +759,31 @@
  13.112      ///must be called before using this function.
  13.113      int dist(Node v) const { return (*_dist)[v]; }
  13.114  
  13.115 -    ///Returns the 'previous arc' of the shortest path tree for a node.
  13.116 -
  13.117 +    ///\brief Returns the 'previous arc' of the shortest path tree for
  13.118 +    ///the given node.
  13.119 +    ///
  13.120      ///This function returns the 'previous arc' of the shortest path
  13.121      ///tree for the node \c v, i.e. it returns the last arc of a
  13.122      ///shortest path from a root to \c v. It is \c INVALID if \c v
  13.123      ///is not reached from the root(s) or if \c v is a root.
  13.124      ///
  13.125      ///The shortest path tree used here is equal to the shortest path
  13.126 -    ///tree used in \ref predNode().
  13.127 +    ///tree used in \ref predNode() and \ref predMap().
  13.128      ///
  13.129      ///\pre Either \ref run(Node) "run()" or \ref init()
  13.130      ///must be called before using this function.
  13.131      Arc predArc(Node v) const { return (*_pred)[v];}
  13.132  
  13.133 -    ///Returns the 'previous node' of the shortest path tree for a node.
  13.134 -
  13.135 +    ///\brief Returns the 'previous node' of the shortest path tree for
  13.136 +    ///the given node.
  13.137 +    ///
  13.138      ///This function returns the 'previous node' of the shortest path
  13.139      ///tree for the node \c v, i.e. it returns the last but one node
  13.140 -    ///from a shortest path from a root to \c v. It is \c INVALID
  13.141 +    ///of a shortest path from a root to \c v. It is \c INVALID
  13.142      ///if \c v is not reached from the root(s) or if \c v is a root.
  13.143      ///
  13.144      ///The shortest path tree used here is equal to the shortest path
  13.145 -    ///tree used in \ref predArc().
  13.146 +    ///tree used in \ref predArc() and \ref predMap().
  13.147      ///
  13.148      ///\pre Either \ref run(Node) "run()" or \ref init()
  13.149      ///must be called before using this function.
  13.150 @@ -801,13 +804,13 @@
  13.151      ///predecessor arcs.
  13.152      ///
  13.153      ///Returns a const reference to the node map that stores the predecessor
  13.154 -    ///arcs, which form the shortest path tree.
  13.155 +    ///arcs, which form the shortest path tree (forest).
  13.156      ///
  13.157      ///\pre Either \ref run(Node) "run()" or \ref init()
  13.158      ///must be called before using this function.
  13.159      const PredMap &predMap() const { return *_pred;}
  13.160  
  13.161 -    ///Checks if a node is reached from the root(s).
  13.162 +    ///Checks if the given node is reached from the root(s).
  13.163  
  13.164      ///Returns \c true if \c v is reached from the root(s).
  13.165      ///
  13.166 @@ -833,7 +836,7 @@
  13.167      ///
  13.168      ///The type of the map that stores the predecessor
  13.169      ///arcs of the shortest paths.
  13.170 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  13.171 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  13.172      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
  13.173      ///Instantiates a PredMap.
  13.174  
  13.175 @@ -848,7 +851,7 @@
  13.176      ///The type of the map that indicates which nodes are processed.
  13.177  
  13.178      ///The type of the map that indicates which nodes are processed.
  13.179 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  13.180 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  13.181      ///By default it is a NullMap.
  13.182      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
  13.183      ///Instantiates a ProcessedMap.
  13.184 @@ -868,7 +871,7 @@
  13.185      ///The type of the map that indicates which nodes are reached.
  13.186  
  13.187      ///The type of the map that indicates which nodes are reached.
  13.188 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  13.189 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  13.190      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  13.191      ///Instantiates a ReachedMap.
  13.192  
  13.193 @@ -883,7 +886,7 @@
  13.194      ///The type of the map that stores the distances of the nodes.
  13.195  
  13.196      ///The type of the map that stores the distances of the nodes.
  13.197 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  13.198 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  13.199      typedef typename Digraph::template NodeMap<int> DistMap;
  13.200      ///Instantiates a DistMap.
  13.201  
  13.202 @@ -898,18 +901,14 @@
  13.203      ///The type of the shortest paths.
  13.204  
  13.205      ///The type of the shortest paths.
  13.206 -    ///It must meet the \ref concepts::Path "Path" concept.
  13.207 +    ///It must conform to the \ref concepts::Path "Path" concept.
  13.208      typedef lemon::Path<Digraph> Path;
  13.209    };
  13.210  
  13.211    /// Default traits class used by BfsWizard
  13.212  
  13.213 -  /// To make it easier to use Bfs algorithm
  13.214 -  /// we have created a wizard class.
  13.215 -  /// This \ref BfsWizard class needs default traits,
  13.216 -  /// as well as the \ref Bfs class.
  13.217 -  /// The \ref BfsWizardBase is a class to be the default traits of the
  13.218 -  /// \ref BfsWizard class.
  13.219 +  /// Default traits class used by BfsWizard.
  13.220 +  /// \tparam GR The type of the digraph.
  13.221    template<class GR>
  13.222    class BfsWizardBase : public BfsWizardDefaultTraits<GR>
  13.223    {
  13.224 @@ -937,7 +936,7 @@
  13.225      public:
  13.226      /// Constructor.
  13.227  
  13.228 -    /// This constructor does not require parameters, therefore it initiates
  13.229 +    /// This constructor does not require parameters, it initiates
  13.230      /// all of the attributes to \c 0.
  13.231      BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
  13.232                        _dist(0), _path(0), _di(0) {}
  13.233 @@ -967,7 +966,6 @@
  13.234    {
  13.235      typedef TR Base;
  13.236  
  13.237 -    ///The type of the digraph the algorithm runs on.
  13.238      typedef typename TR::Digraph Digraph;
  13.239  
  13.240      typedef typename Digraph::Node Node;
  13.241 @@ -975,16 +973,10 @@
  13.242      typedef typename Digraph::Arc Arc;
  13.243      typedef typename Digraph::OutArcIt OutArcIt;
  13.244  
  13.245 -    ///\brief The type of the map that stores the predecessor
  13.246 -    ///arcs of the shortest paths.
  13.247      typedef typename TR::PredMap PredMap;
  13.248 -    ///\brief The type of the map that stores the distances of the nodes.
  13.249      typedef typename TR::DistMap DistMap;
  13.250 -    ///\brief The type of the map that indicates which nodes are reached.
  13.251      typedef typename TR::ReachedMap ReachedMap;
  13.252 -    ///\brief The type of the map that indicates which nodes are processed.
  13.253      typedef typename TR::ProcessedMap ProcessedMap;
  13.254 -    ///The type of the shortest paths
  13.255      typedef typename TR::Path Path;
  13.256  
  13.257    public:
  13.258 @@ -1067,11 +1059,12 @@
  13.259        static PredMap *createPredMap(const Digraph &) { return 0; };
  13.260        SetPredMapBase(const TR &b) : TR(b) {}
  13.261      };
  13.262 -    ///\brief \ref named-func-param "Named parameter"
  13.263 -    ///for setting PredMap object.
  13.264 +
  13.265 +    ///\brief \ref named-templ-param "Named parameter" for setting
  13.266 +    ///the predecessor map.
  13.267      ///
  13.268 -    ///\ref named-func-param "Named parameter"
  13.269 -    ///for setting PredMap object.
  13.270 +    ///\ref named-templ-param "Named parameter" function for setting
  13.271 +    ///the map that stores the predecessor arcs of the nodes.
  13.272      template<class T>
  13.273      BfsWizard<SetPredMapBase<T> > predMap(const T &t)
  13.274      {
  13.275 @@ -1085,11 +1078,12 @@
  13.276        static ReachedMap *createReachedMap(const Digraph &) { return 0; };
  13.277        SetReachedMapBase(const TR &b) : TR(b) {}
  13.278      };
  13.279 -    ///\brief \ref named-func-param "Named parameter"
  13.280 -    ///for setting ReachedMap object.
  13.281 +
  13.282 +    ///\brief \ref named-templ-param "Named parameter" for setting
  13.283 +    ///the reached map.
  13.284      ///
  13.285 -    /// \ref named-func-param "Named parameter"
  13.286 -    ///for setting ReachedMap object.
  13.287 +    ///\ref named-templ-param "Named parameter" function for setting
  13.288 +    ///the map that indicates which nodes are reached.
  13.289      template<class T>
  13.290      BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
  13.291      {
  13.292 @@ -1103,11 +1097,13 @@
  13.293        static DistMap *createDistMap(const Digraph &) { return 0; };
  13.294        SetDistMapBase(const TR &b) : TR(b) {}
  13.295      };
  13.296 -    ///\brief \ref named-func-param "Named parameter"
  13.297 -    ///for setting DistMap object.
  13.298 +
  13.299 +    ///\brief \ref named-templ-param "Named parameter" for setting
  13.300 +    ///the distance map.
  13.301      ///
  13.302 -    /// \ref named-func-param "Named parameter"
  13.303 -    ///for setting DistMap object.
  13.304 +    ///\ref named-templ-param "Named parameter" function for setting
  13.305 +    ///the map that stores the distances of the nodes calculated
  13.306 +    ///by the algorithm.
  13.307      template<class T>
  13.308      BfsWizard<SetDistMapBase<T> > distMap(const T &t)
  13.309      {
  13.310 @@ -1121,11 +1117,12 @@
  13.311        static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
  13.312        SetProcessedMapBase(const TR &b) : TR(b) {}
  13.313      };
  13.314 -    ///\brief \ref named-func-param "Named parameter"
  13.315 -    ///for setting ProcessedMap object.
  13.316 +
  13.317 +    ///\brief \ref named-func-param "Named parameter" for setting
  13.318 +    ///the processed map.
  13.319      ///
  13.320 -    /// \ref named-func-param "Named parameter"
  13.321 -    ///for setting ProcessedMap object.
  13.322 +    ///\ref named-templ-param "Named parameter" function for setting
  13.323 +    ///the map that indicates which nodes are processed.
  13.324      template<class T>
  13.325      BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
  13.326      {
  13.327 @@ -1264,7 +1261,7 @@
  13.328      /// \brief The type of the map that indicates which nodes are reached.
  13.329      ///
  13.330      /// The type of the map that indicates which nodes are reached.
  13.331 -    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  13.332 +    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  13.333      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  13.334  
  13.335      /// \brief Instantiates a ReachedMap.
  13.336 @@ -1425,8 +1422,8 @@
  13.337      /// \name Execution Control
  13.338      /// The simplest way to execute the BFS algorithm is to use one of the
  13.339      /// member functions called \ref run(Node) "run()".\n
  13.340 -    /// If you need more control on the execution, first you have to call
  13.341 -    /// \ref init(), then you can add several source nodes with
  13.342 +    /// If you need better control on the execution, you have to call
  13.343 +    /// \ref init() first, then you can add several source nodes with
  13.344      /// \ref addSource(). Finally the actual path computation can be
  13.345      /// performed with one of the \ref start() functions.
  13.346  
  13.347 @@ -1735,7 +1732,7 @@
  13.348  
  13.349      ///@{
  13.350  
  13.351 -    /// \brief Checks if a node is reached from the root(s).
  13.352 +    /// \brief Checks if the given node is reached from the root(s).
  13.353      ///
  13.354      /// Returns \c true if \c v is reached from the root(s).
  13.355      ///
    14.1 --- a/lemon/bin_heap.h	Tue Aug 18 10:08:28 2009 +0200
    14.2 +++ b/lemon/bin_heap.h	Thu Nov 05 08:39:49 2009 +0100
    14.3 @@ -19,9 +19,9 @@
    14.4  #ifndef LEMON_BIN_HEAP_H
    14.5  #define LEMON_BIN_HEAP_H
    14.6  
    14.7 -///\ingroup auxdat
    14.8 +///\ingroup heaps
    14.9  ///\file
   14.10 -///\brief Binary Heap implementation.
   14.11 +///\brief Binary heap implementation.
   14.12  
   14.13  #include <vector>
   14.14  #include <utility>
   14.15 @@ -29,45 +29,41 @@
   14.16  
   14.17  namespace lemon {
   14.18  
   14.19 -  ///\ingroup auxdat
   14.20 +  /// \ingroup heaps
   14.21    ///
   14.22 -  ///\brief A Binary Heap implementation.
   14.23 +  /// \brief Binary heap data structure.
   14.24    ///
   14.25 -  ///This class implements the \e binary \e heap data structure.
   14.26 +  /// This class implements the \e binary \e heap data structure.
   14.27 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   14.28    ///
   14.29 -  ///A \e heap is a data structure for storing items with specified values
   14.30 -  ///called \e priorities in such a way that finding the item with minimum
   14.31 -  ///priority is efficient. \c CMP specifies the ordering of the priorities.
   14.32 -  ///In a heap one can change the priority of an item, add or erase an
   14.33 -  ///item, etc.
   14.34 -  ///
   14.35 -  ///\tparam PR Type of the priority of the items.
   14.36 -  ///\tparam IM A read and writable item map with int values, used internally
   14.37 -  ///to handle the cross references.
   14.38 -  ///\tparam CMP A functor class for the ordering of the priorities.
   14.39 -  ///The default is \c std::less<PR>.
   14.40 -  ///
   14.41 -  ///\sa FibHeap
   14.42 -  ///\sa Dijkstra
   14.43 +  /// \tparam PR Type of the priorities of the items.
   14.44 +  /// \tparam IM A read-writable item map with \c int values, used
   14.45 +  /// internally to handle the cross references.
   14.46 +  /// \tparam CMP A functor class for comparing the priorities.
   14.47 +  /// The default is \c std::less<PR>.
   14.48 +#ifdef DOXYGEN
   14.49 +  template <typename PR, typename IM, typename CMP>
   14.50 +#else
   14.51    template <typename PR, typename IM, typename CMP = std::less<PR> >
   14.52 +#endif
   14.53    class BinHeap {
   14.54 +  public:
   14.55  
   14.56 -  public:
   14.57 -    ///\e
   14.58 +    /// Type of the item-int map.
   14.59      typedef IM ItemIntMap;
   14.60 -    ///\e
   14.61 +    /// Type of the priorities.
   14.62      typedef PR Prio;
   14.63 -    ///\e
   14.64 +    /// Type of the items stored in the heap.
   14.65      typedef typename ItemIntMap::Key Item;
   14.66 -    ///\e
   14.67 +    /// Type of the item-priority pairs.
   14.68      typedef std::pair<Item,Prio> Pair;
   14.69 -    ///\e
   14.70 +    /// Functor type for comparing the priorities.
   14.71      typedef CMP Compare;
   14.72  
   14.73 -    /// \brief Type to represent the items states.
   14.74 +    /// \brief Type to represent the states of the items.
   14.75      ///
   14.76 -    /// Each Item element have a state associated to it. It may be "in heap",
   14.77 -    /// "pre heap" or "post heap". The latter two are indifferent from the
   14.78 +    /// Each item has a state associated to it. It can be "in heap",
   14.79 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   14.80      /// heap's point of view, but may be useful to the user.
   14.81      ///
   14.82      /// The item-int map must be initialized in such way that it assigns
   14.83 @@ -84,42 +80,43 @@
   14.84      ItemIntMap &_iim;
   14.85  
   14.86    public:
   14.87 -    /// \brief The constructor.
   14.88 +
   14.89 +    /// \brief Constructor.
   14.90      ///
   14.91 -    /// The constructor.
   14.92 -    /// \param map should be given to the constructor, since it is used
   14.93 -    /// internally to handle the cross references. The value of the map
   14.94 -    /// must be \c PRE_HEAP (<tt>-1</tt>) for every item.
   14.95 +    /// Constructor.
   14.96 +    /// \param map A map that assigns \c int values to the items.
   14.97 +    /// It is used internally to handle the cross references.
   14.98 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
   14.99      explicit BinHeap(ItemIntMap &map) : _iim(map) {}
  14.100  
  14.101 -    /// \brief The constructor.
  14.102 +    /// \brief Constructor.
  14.103      ///
  14.104 -    /// The constructor.
  14.105 -    /// \param map should be given to the constructor, since it is used
  14.106 -    /// internally to handle the cross references. The value of the map
  14.107 -    /// should be PRE_HEAP (-1) for each element.
  14.108 -    ///
  14.109 -    /// \param comp The comparator function object.
  14.110 +    /// Constructor.
  14.111 +    /// \param map A map that assigns \c int values to the items.
  14.112 +    /// It is used internally to handle the cross references.
  14.113 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  14.114 +    /// \param comp The function object used for comparing the priorities.
  14.115      BinHeap(ItemIntMap &map, const Compare &comp)
  14.116        : _iim(map), _comp(comp) {}
  14.117  
  14.118  
  14.119 -    /// The number of items stored in the heap.
  14.120 +    /// \brief The number of items stored in the heap.
  14.121      ///
  14.122 -    /// \brief Returns the number of items stored in the heap.
  14.123 +    /// This function returns the number of items stored in the heap.
  14.124      int size() const { return _data.size(); }
  14.125  
  14.126 -    /// \brief Checks if the heap stores no items.
  14.127 +    /// \brief Check if the heap is empty.
  14.128      ///
  14.129 -    /// Returns \c true if and only if the heap stores no items.
  14.130 +    /// This function returns \c true if the heap is empty.
  14.131      bool empty() const { return _data.empty(); }
  14.132  
  14.133 -    /// \brief Make empty this heap.
  14.134 +    /// \brief Make the heap empty.
  14.135      ///
  14.136 -    /// Make empty this heap. It does not change the cross reference map.
  14.137 -    /// If you want to reuse what is not surely empty you should first clear
  14.138 -    /// the heap and after that you should set the cross reference map for
  14.139 -    /// each item to \c PRE_HEAP.
  14.140 +    /// This functon makes the heap empty.
  14.141 +    /// It does not change the cross reference map. If you want to reuse
  14.142 +    /// a heap that is not surely empty, you should first clear it and
  14.143 +    /// then you should set the cross reference map to \c PRE_HEAP
  14.144 +    /// for each item.
  14.145      void clear() {
  14.146        _data.clear();
  14.147      }
  14.148 @@ -127,12 +124,12 @@
  14.149    private:
  14.150      static int parent(int i) { return (i-1)/2; }
  14.151  
  14.152 -    static int second_child(int i) { return 2*i+2; }
  14.153 +    static int secondChild(int i) { return 2*i+2; }
  14.154      bool less(const Pair &p1, const Pair &p2) const {
  14.155        return _comp(p1.second, p2.second);
  14.156      }
  14.157  
  14.158 -    int bubble_up(int hole, Pair p) {
  14.159 +    int bubbleUp(int hole, Pair p) {
  14.160        int par = parent(hole);
  14.161        while( hole>0 && less(p,_data[par]) ) {
  14.162          move(_data[par],hole);
  14.163 @@ -143,8 +140,8 @@
  14.164        return hole;
  14.165      }
  14.166  
  14.167 -    int bubble_down(int hole, Pair p, int length) {
  14.168 -      int child = second_child(hole);
  14.169 +    int bubbleDown(int hole, Pair p, int length) {
  14.170 +      int child = secondChild(hole);
  14.171        while(child < length) {
  14.172          if( less(_data[child-1], _data[child]) ) {
  14.173            --child;
  14.174 @@ -153,7 +150,7 @@
  14.175            goto ok;
  14.176          move(_data[child], hole);
  14.177          hole = child;
  14.178 -        child = second_child(hole);
  14.179 +        child = secondChild(hole);
  14.180        }
  14.181        child--;
  14.182        if( child<length && less(_data[child], p) ) {
  14.183 @@ -171,87 +168,91 @@
  14.184      }
  14.185  
  14.186    public:
  14.187 +
  14.188      /// \brief Insert a pair of item and priority into the heap.
  14.189      ///
  14.190 -    /// Adds \c p.first to the heap with priority \c p.second.
  14.191 +    /// This function inserts \c p.first to the heap with priority
  14.192 +    /// \c p.second.
  14.193      /// \param p The pair to insert.
  14.194 +    /// \pre \c p.first must not be stored in the heap.
  14.195      void push(const Pair &p) {
  14.196        int n = _data.size();
  14.197        _data.resize(n+1);
  14.198 -      bubble_up(n, p);
  14.199 +      bubbleUp(n, p);
  14.200      }
  14.201  
  14.202 -    /// \brief Insert an item into the heap with the given heap.
  14.203 +    /// \brief Insert an item into the heap with the given priority.
  14.204      ///
  14.205 -    /// Adds \c i to the heap with priority \c p.
  14.206 +    /// This function inserts the given item into the heap with the
  14.207 +    /// given priority.
  14.208      /// \param i The item to insert.
  14.209      /// \param p The priority of the item.
  14.210 +    /// \pre \e i must not be stored in the heap.
  14.211      void push(const Item &i, const Prio &p) { push(Pair(i,p)); }
  14.212  
  14.213 -    /// \brief Returns the item with minimum priority relative to \c Compare.
  14.214 +    /// \brief Return the item having minimum priority.
  14.215      ///
  14.216 -    /// This method returns the item with minimum priority relative to \c
  14.217 -    /// Compare.
  14.218 -    /// \pre The heap must be nonempty.
  14.219 +    /// This function returns the item having minimum priority.
  14.220 +    /// \pre The heap must be non-empty.
  14.221      Item top() const {
  14.222        return _data[0].first;
  14.223      }
  14.224  
  14.225 -    /// \brief Returns the minimum priority relative to \c Compare.
  14.226 +    /// \brief The minimum priority.
  14.227      ///
  14.228 -    /// It returns the minimum priority relative to \c Compare.
  14.229 -    /// \pre The heap must be nonempty.
  14.230 +    /// This function returns the minimum priority.
  14.231 +    /// \pre The heap must be non-empty.
  14.232      Prio prio() const {
  14.233        return _data[0].second;
  14.234      }
  14.235  
  14.236 -    /// \brief Deletes the item with minimum priority relative to \c Compare.
  14.237 +    /// \brief Remove the item having minimum priority.
  14.238      ///
  14.239 -    /// This method deletes the item with minimum priority relative to \c
  14.240 -    /// Compare from the heap.
  14.241 +    /// This function removes the item having minimum priority.
  14.242      /// \pre The heap must be non-empty.
  14.243      void pop() {
  14.244        int n = _data.size()-1;
  14.245        _iim.set(_data[0].first, POST_HEAP);
  14.246        if (n > 0) {
  14.247 -        bubble_down(0, _data[n], n);
  14.248 +        bubbleDown(0, _data[n], n);
  14.249        }
  14.250        _data.pop_back();
  14.251      }
  14.252  
  14.253 -    /// \brief Deletes \c i from the heap.
  14.254 +    /// \brief Remove the given item from the heap.
  14.255      ///
  14.256 -    /// This method deletes item \c i from the heap.
  14.257 -    /// \param i The item to erase.
  14.258 -    /// \pre The item should be in the heap.
  14.259 +    /// This function removes the given item from the heap if it is
  14.260 +    /// already stored.
  14.261 +    /// \param i The item to delete.
  14.262 +    /// \pre \e i must be in the heap.
  14.263      void erase(const Item &i) {
  14.264        int h = _iim[i];
  14.265        int n = _data.size()-1;
  14.266        _iim.set(_data[h].first, POST_HEAP);
  14.267        if( h < n ) {
  14.268 -        if ( bubble_up(h, _data[n]) == h) {
  14.269 -          bubble_down(h, _data[n], n);
  14.270 +        if ( bubbleUp(h, _data[n]) == h) {
  14.271 +          bubbleDown(h, _data[n], n);
  14.272          }
  14.273        }
  14.274        _data.pop_back();
  14.275      }
  14.276  
  14.277 -
  14.278 -    /// \brief Returns the priority of \c i.
  14.279 +    /// \brief The priority of the given item.
  14.280      ///
  14.281 -    /// This function returns the priority of item \c i.
  14.282 +    /// This function returns the priority of the given item.
  14.283      /// \param i The item.
  14.284 -    /// \pre \c i must be in the heap.
  14.285 +    /// \pre \e i must be in the heap.
  14.286      Prio operator[](const Item &i) const {
  14.287        int idx = _iim[i];
  14.288        return _data[idx].second;
  14.289      }
  14.290  
  14.291 -    /// \brief \c i gets to the heap with priority \c p independently
  14.292 -    /// if \c i was already there.
  14.293 +    /// \brief Set the priority of an item or insert it, if it is
  14.294 +    /// not stored in the heap.
  14.295      ///
  14.296 -    /// This method calls \ref push(\c i, \c p) if \c i is not stored
  14.297 -    /// in the heap and sets the priority of \c i to \c p otherwise.
  14.298 +    /// This method sets the priority of the given item if it is
  14.299 +    /// already stored in the heap. Otherwise it inserts the given
  14.300 +    /// item into the heap with the given priority.
  14.301      /// \param i The item.
  14.302      /// \param p The priority.
  14.303      void set(const Item &i, const Prio &p) {
  14.304 @@ -260,44 +261,42 @@
  14.305          push(i,p);
  14.306        }
  14.307        else if( _comp(p, _data[idx].second) ) {
  14.308 -        bubble_up(idx, Pair(i,p));
  14.309 +        bubbleUp(idx, Pair(i,p));
  14.310        }
  14.311        else {
  14.312 -        bubble_down(idx, Pair(i,p), _data.size());
  14.313 +        bubbleDown(idx, Pair(i,p), _data.size());
  14.314        }
  14.315      }
  14.316  
  14.317 -    /// \brief Decreases the priority of \c i to \c p.
  14.318 +    /// \brief Decrease the priority of an item to the given value.
  14.319      ///
  14.320 -    /// This method decreases the priority of item \c i to \c p.
  14.321 +    /// This function decreases the priority of an item to the given value.
  14.322      /// \param i The item.
  14.323      /// \param p The priority.
  14.324 -    /// \pre \c i must be stored in the heap with priority at least \c
  14.325 -    /// p relative to \c Compare.
  14.326 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  14.327      void decrease(const Item &i, const Prio &p) {
  14.328        int idx = _iim[i];
  14.329 -      bubble_up(idx, Pair(i,p));
  14.330 +      bubbleUp(idx, Pair(i,p));
  14.331      }
  14.332  
  14.333 -    /// \brief Increases the priority of \c i to \c p.
  14.334 +    /// \brief Increase the priority of an item to the given value.
  14.335      ///
  14.336 -    /// This method sets the priority of item \c i to \c p.
  14.337 +    /// This function increases the priority of an item to the given value.
  14.338      /// \param i The item.
  14.339      /// \param p The priority.
  14.340 -    /// \pre \c i must be stored in the heap with priority at most \c
  14.341 -    /// p relative to \c Compare.
  14.342 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  14.343      void increase(const Item &i, const Prio &p) {
  14.344        int idx = _iim[i];
  14.345 -      bubble_down(idx, Pair(i,p), _data.size());
  14.346 +      bubbleDown(idx, Pair(i,p), _data.size());
  14.347      }
  14.348  
  14.349 -    /// \brief Returns if \c item is in, has already been in, or has
  14.350 -    /// never been in the heap.
  14.351 +    /// \brief Return the state of an item.
  14.352      ///
  14.353 -    /// This method returns PRE_HEAP if \c item has never been in the
  14.354 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  14.355 -    /// otherwise. In the latter case it is possible that \c item will
  14.356 -    /// get back to the heap again.
  14.357 +    /// This method returns \c PRE_HEAP if the given item has never
  14.358 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  14.359 +    /// and \c POST_HEAP otherwise.
  14.360 +    /// In the latter case it is possible that the item will get back
  14.361 +    /// to the heap again.
  14.362      /// \param i The item.
  14.363      State state(const Item &i) const {
  14.364        int s = _iim[i];
  14.365 @@ -306,11 +305,11 @@
  14.366        return State(s);
  14.367      }
  14.368  
  14.369 -    /// \brief Sets the state of the \c item in the heap.
  14.370 +    /// \brief Set the state of an item in the heap.
  14.371      ///
  14.372 -    /// Sets the state of the \c item in the heap. It can be used to
  14.373 -    /// manually clear the heap when it is important to achive the
  14.374 -    /// better time complexity.
  14.375 +    /// This function sets the state of the given item in the heap.
  14.376 +    /// It can be used to manually clear the heap when it is important
  14.377 +    /// to achive better time complexity.
  14.378      /// \param i The item.
  14.379      /// \param st The state. It should not be \c IN_HEAP.
  14.380      void state(const Item& i, State st) {
  14.381 @@ -327,12 +326,13 @@
  14.382        }
  14.383      }
  14.384  
  14.385 -    /// \brief Replaces an item in the heap.
  14.386 +    /// \brief Replace an item in the heap.
  14.387      ///
  14.388 -    /// The \c i item is replaced with \c j item. The \c i item should
  14.389 -    /// be in the heap, while the \c j should be out of the heap. The
  14.390 -    /// \c i item will out of the heap and \c j will be in the heap
  14.391 -    /// with the same prioriority as prevoiusly the \c i item.
  14.392 +    /// This function replaces item \c i with item \c j.
  14.393 +    /// Item \c i must be in the heap, while \c j must be out of the heap.
  14.394 +    /// After calling this method, item \c i will be out of the
  14.395 +    /// heap and \c j will be in the heap with the same prioriority
  14.396 +    /// as item \c i had before.
  14.397      void replace(const Item& i, const Item& j) {
  14.398        int idx = _iim[i];
  14.399        _iim.set(i, _iim[j]);
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/lemon/binom_heap.h	Thu Nov 05 08:39:49 2009 +0100
    15.3 @@ -0,0 +1,445 @@
    15.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    15.5 + *
    15.6 + * This file is a part of LEMON, a generic C++ optimization library.
    15.7 + *
    15.8 + * Copyright (C) 2003-2009
    15.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   15.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   15.11 + *
   15.12 + * Permission to use, modify and distribute this software is granted
   15.13 + * provided that this copyright notice appears in all copies. For
   15.14 + * precise terms see the accompanying LICENSE file.
   15.15 + *
   15.16 + * This software is provided "AS IS" with no warranty of any kind,
   15.17 + * express or implied, and with no claim as to its suitability for any
   15.18 + * purpose.
   15.19 + *
   15.20 + */
   15.21 +
   15.22 +#ifndef LEMON_BINOM_HEAP_H
   15.23 +#define LEMON_BINOM_HEAP_H
   15.24 +
   15.25 +///\file
   15.26 +///\ingroup heaps
   15.27 +///\brief Binomial Heap implementation.
   15.28 +
   15.29 +#include <vector>
   15.30 +#include <utility>
   15.31 +#include <functional>
   15.32 +#include <lemon/math.h>
   15.33 +#include <lemon/counter.h>
   15.34 +
   15.35 +namespace lemon {
   15.36 +
   15.37 +  /// \ingroup heaps
   15.38 +  ///
   15.39 +  ///\brief Binomial heap data structure.
   15.40 +  ///
   15.41 +  /// This class implements the \e binomial \e heap data structure.
   15.42 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   15.43 +  ///
   15.44 +  /// The methods \ref increase() and \ref erase() are not efficient
   15.45 +  /// in a binomial heap. In case of many calls of these operations,
   15.46 +  /// it is better to use other heap structure, e.g. \ref BinHeap
   15.47 +  /// "binary heap".
   15.48 +  ///
   15.49 +  /// \tparam PR Type of the priorities of the items.
   15.50 +  /// \tparam IM A read-writable item map with \c int values, used
   15.51 +  /// internally to handle the cross references.
   15.52 +  /// \tparam CMP A functor class for comparing the priorities.
   15.53 +  /// The default is \c std::less<PR>.
   15.54 +#ifdef DOXYGEN
   15.55 +  template <typename PR, typename IM, typename CMP>
   15.56 +#else
   15.57 +  template <typename PR, typename IM, typename CMP = std::less<PR> >
   15.58 +#endif
   15.59 +  class BinomHeap {
   15.60 +  public:
   15.61 +    /// Type of the item-int map.
   15.62 +    typedef IM ItemIntMap;
   15.63 +    /// Type of the priorities.
   15.64 +    typedef PR Prio;
   15.65 +    /// Type of the items stored in the heap.
   15.66 +    typedef typename ItemIntMap::Key Item;
   15.67 +    /// Functor type for comparing the priorities.
   15.68 +    typedef CMP Compare;
   15.69 +
   15.70 +    /// \brief Type to represent the states of the items.
   15.71 +    ///
   15.72 +    /// Each item has a state associated to it. It can be "in heap",
   15.73 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   15.74 +    /// heap's point of view, but may be useful to the user.
   15.75 +    ///
   15.76 +    /// The item-int map must be initialized in such way that it assigns
   15.77 +    /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap.
   15.78 +    enum State {
   15.79 +      IN_HEAP = 0,    ///< = 0.
   15.80 +      PRE_HEAP = -1,  ///< = -1.
   15.81 +      POST_HEAP = -2  ///< = -2.
   15.82 +    };
   15.83 +
   15.84 +  private:
   15.85 +    class Store;
   15.86 +
   15.87 +    std::vector<Store> _data;
   15.88 +    int _min, _head;
   15.89 +    ItemIntMap &_iim;
   15.90 +    Compare _comp;
   15.91 +    int _num_items;
   15.92 +
   15.93 +  public:
   15.94 +    /// \brief Constructor.
   15.95 +    ///
   15.96 +    /// Constructor.
   15.97 +    /// \param map A map that assigns \c int values to the items.
   15.98 +    /// It is used internally to handle the cross references.
   15.99 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  15.100 +    explicit BinomHeap(ItemIntMap &map)
  15.101 +      : _min(0), _head(-1), _iim(map), _num_items(0) {}
  15.102 +
  15.103 +    /// \brief Constructor.
  15.104 +    ///
  15.105 +    /// Constructor.
  15.106 +    /// \param map A map that assigns \c int values to the items.
  15.107 +    /// It is used internally to handle the cross references.
  15.108 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  15.109 +    /// \param comp The function object used for comparing the priorities.
  15.110 +    BinomHeap(ItemIntMap &map, const Compare &comp)
  15.111 +      : _min(0), _head(-1), _iim(map), _comp(comp), _num_items(0) {}
  15.112 +
  15.113 +    /// \brief The number of items stored in the heap.
  15.114 +    ///
  15.115 +    /// This function returns the number of items stored in the heap.
  15.116 +    int size() const { return _num_items; }
  15.117 +
  15.118 +    /// \brief Check if the heap is empty.
  15.119 +    ///
  15.120 +    /// This function returns \c true if the heap is empty.
  15.121 +    bool empty() const { return _num_items==0; }
  15.122 +
  15.123 +    /// \brief Make the heap empty.
  15.124 +    ///
  15.125 +    /// This functon makes the heap empty.
  15.126 +    /// It does not change the cross reference map. If you want to reuse
  15.127 +    /// a heap that is not surely empty, you should first clear it and
  15.128 +    /// then you should set the cross reference map to \c PRE_HEAP
  15.129 +    /// for each item.
  15.130 +    void clear() {
  15.131 +      _data.clear(); _min=0; _num_items=0; _head=-1;
  15.132 +    }
  15.133 +
  15.134 +    /// \brief Set the priority of an item or insert it, if it is
  15.135 +    /// not stored in the heap.
  15.136 +    ///
  15.137 +    /// This method sets the priority of the given item if it is
  15.138 +    /// already stored in the heap. Otherwise it inserts the given
  15.139 +    /// item into the heap with the given priority.
  15.140 +    /// \param item The item.
  15.141 +    /// \param value The priority.
  15.142 +    void set (const Item& item, const Prio& value) {
  15.143 +      int i=_iim[item];
  15.144 +      if ( i >= 0 && _data[i].in ) {
  15.145 +        if ( _comp(value, _data[i].prio) ) decrease(item, value);
  15.146 +        if ( _comp(_data[i].prio, value) ) increase(item, value);
  15.147 +      } else push(item, value);
  15.148 +    }
  15.149 +
  15.150 +    /// \brief Insert an item into the heap with the given priority.
  15.151 +    ///
  15.152 +    /// This function inserts the given item into the heap with the
  15.153 +    /// given priority.
  15.154 +    /// \param item The item to insert.
  15.155 +    /// \param value The priority of the item.
  15.156 +    /// \pre \e item must not be stored in the heap.
  15.157 +    void push (const Item& item, const Prio& value) {
  15.158 +      int i=_iim[item];
  15.159 +      if ( i<0 ) {
  15.160 +        int s=_data.size();
  15.161 +        _iim.set( item,s );
  15.162 +        Store st;
  15.163 +        st.name=item;
  15.164 +        st.prio=value;
  15.165 +        _data.push_back(st);
  15.166 +        i=s;
  15.167 +      }
  15.168 +      else {
  15.169 +        _data[i].parent=_data[i].right_neighbor=_data[i].child=-1;
  15.170 +        _data[i].degree=0;
  15.171 +        _data[i].in=true;
  15.172 +        _data[i].prio=value;
  15.173 +      }
  15.174 +
  15.175 +      if( 0==_num_items ) {
  15.176 +        _head=i;
  15.177 +        _min=i;
  15.178 +      } else {
  15.179 +        merge(i);
  15.180 +        if( _comp(_data[i].prio, _data[_min].prio) ) _min=i;
  15.181 +      }
  15.182 +      ++_num_items;
  15.183 +    }
  15.184 +
  15.185 +    /// \brief Return the item having minimum priority.
  15.186 +    ///
  15.187 +    /// This function returns the item having minimum priority.
  15.188 +    /// \pre The heap must be non-empty.
  15.189 +    Item top() const { return _data[_min].name; }
  15.190 +
  15.191 +    /// \brief The minimum priority.
  15.192 +    ///
  15.193 +    /// This function returns the minimum priority.
  15.194 +    /// \pre The heap must be non-empty.
  15.195 +    Prio prio() const { return _data[_min].prio; }
  15.196 +
  15.197 +    /// \brief The priority of the given item.
  15.198 +    ///
  15.199 +    /// This function returns the priority of the given item.
  15.200 +    /// \param item The item.
  15.201 +    /// \pre \e item must be in the heap.
  15.202 +    const Prio& operator[](const Item& item) const {
  15.203 +      return _data[_iim[item]].prio;
  15.204 +    }
  15.205 +
  15.206 +    /// \brief Remove the item having minimum priority.
  15.207 +    ///
  15.208 +    /// This function removes the item having minimum priority.
  15.209 +    /// \pre The heap must be non-empty.
  15.210 +    void pop() {
  15.211 +      _data[_min].in=false;
  15.212 +
  15.213 +      int head_child=-1;
  15.214 +      if ( _data[_min].child!=-1 ) {
  15.215 +        int child=_data[_min].child;
  15.216 +        int neighb;
  15.217 +        while( child!=-1 ) {
  15.218 +          neighb=_data[child].right_neighbor;
  15.219 +          _data[child].parent=-1;
  15.220 +          _data[child].right_neighbor=head_child;
  15.221 +          head_child=child;
  15.222 +          child=neighb;
  15.223 +        }
  15.224 +      }
  15.225 +
  15.226 +      if ( _data[_head].right_neighbor==-1 ) {
  15.227 +        // there was only one root
  15.228 +        _head=head_child;
  15.229 +      }
  15.230 +      else {
  15.231 +        // there were more roots
  15.232 +        if( _head!=_min )  { unlace(_min); }
  15.233 +        else { _head=_data[_head].right_neighbor; }
  15.234 +        merge(head_child);
  15.235 +      }
  15.236 +      _min=findMin();
  15.237 +      --_num_items;
  15.238 +    }
  15.239 +
  15.240 +    /// \brief Remove the given item from the heap.
  15.241 +    ///
  15.242 +    /// This function removes the given item from the heap if it is
  15.243 +    /// already stored.
  15.244 +    /// \param item The item to delete.
  15.245 +    /// \pre \e item must be in the heap.
  15.246 +    void erase (const Item& item) {
  15.247 +      int i=_iim[item];
  15.248 +      if ( i >= 0 && _data[i].in ) {
  15.249 +        decrease( item, _data[_min].prio-1 );
  15.250 +        pop();
  15.251 +      }
  15.252 +    }
  15.253 +
  15.254 +    /// \brief Decrease the priority of an item to the given value.
  15.255 +    ///
  15.256 +    /// This function decreases the priority of an item to the given value.
  15.257 +    /// \param item The item.
  15.258 +    /// \param value The priority.
  15.259 +    /// \pre \e item must be stored in the heap with priority at least \e value.
  15.260 +    void decrease (Item item, const Prio& value) {
  15.261 +      int i=_iim[item];
  15.262 +      int p=_data[i].parent;
  15.263 +      _data[i].prio=value;
  15.264 +      
  15.265 +      while( p!=-1 && _comp(value, _data[p].prio) ) {
  15.266 +        _data[i].name=_data[p].name;
  15.267 +        _data[i].prio=_data[p].prio;
  15.268 +        _data[p].name=item;
  15.269 +        _data[p].prio=value;
  15.270 +        _iim[_data[i].name]=i;
  15.271 +        i=p;
  15.272 +        p=_data[p].parent;
  15.273 +      }
  15.274 +      _iim[item]=i;
  15.275 +      if ( _comp(value, _data[_min].prio) ) _min=i;
  15.276 +    }
  15.277 +
  15.278 +    /// \brief Increase the priority of an item to the given value.
  15.279 +    ///
  15.280 +    /// This function increases the priority of an item to the given value.
  15.281 +    /// \param item The item.
  15.282 +    /// \param value The priority.
  15.283 +    /// \pre \e item must be stored in the heap with priority at most \e value.
  15.284 +    void increase (Item item, const Prio& value) {
  15.285 +      erase(item);
  15.286 +      push(item, value);
  15.287 +    }
  15.288 +
  15.289 +    /// \brief Return the state of an item.
  15.290 +    ///
  15.291 +    /// This method returns \c PRE_HEAP if the given item has never
  15.292 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  15.293 +    /// and \c POST_HEAP otherwise.
  15.294 +    /// In the latter case it is possible that the item will get back
  15.295 +    /// to the heap again.
  15.296 +    /// \param item The item.
  15.297 +    State state(const Item &item) const {
  15.298 +      int i=_iim[item];
  15.299 +      if( i>=0 ) {
  15.300 +        if ( _data[i].in ) i=0;
  15.301 +        else i=-2;
  15.302 +      }
  15.303 +      return State(i);
  15.304 +    }
  15.305 +
  15.306 +    /// \brief Set the state of an item in the heap.
  15.307 +    ///
  15.308 +    /// This function sets the state of the given item in the heap.
  15.309 +    /// It can be used to manually clear the heap when it is important
  15.310 +    /// to achive better time complexity.
  15.311 +    /// \param i The item.
  15.312 +    /// \param st The state. It should not be \c IN_HEAP.
  15.313 +    void state(const Item& i, State st) {
  15.314 +      switch (st) {
  15.315 +      case POST_HEAP:
  15.316 +      case PRE_HEAP:
  15.317 +        if (state(i) == IN_HEAP) {
  15.318 +          erase(i);
  15.319 +        }
  15.320 +        _iim[i] = st;
  15.321 +        break;
  15.322 +      case IN_HEAP:
  15.323 +        break;
  15.324 +      }
  15.325 +    }
  15.326 +
  15.327 +  private:
  15.328 +    
  15.329 +    // Find the minimum of the roots
  15.330 +    int findMin() {
  15.331 +      if( _head!=-1 ) {
  15.332 +        int min_loc=_head, min_val=_data[_head].prio;
  15.333 +        for( int x=_data[_head].right_neighbor; x!=-1;
  15.334 +             x=_data[x].right_neighbor ) {
  15.335 +          if( _comp( _data[x].prio,min_val ) ) {
  15.336 +            min_val=_data[x].prio;
  15.337 +            min_loc=x;
  15.338 +          }
  15.339 +        }
  15.340 +        return min_loc;
  15.341 +      }
  15.342 +      else return -1;
  15.343 +    }
  15.344 +
  15.345 +    // Merge the heap with another heap starting at the given position
  15.346 +    void merge(int a) {
  15.347 +      if( _head==-1 || a==-1 ) return;
  15.348 +      if( _data[a].right_neighbor==-1 &&
  15.349 +          _data[a].degree<=_data[_head].degree ) {
  15.350 +        _data[a].right_neighbor=_head;
  15.351 +        _head=a;
  15.352 +      } else {
  15.353 +        interleave(a);
  15.354 +      }
  15.355 +      if( _data[_head].right_neighbor==-1 ) return;
  15.356 +      
  15.357 +      int x=_head;
  15.358 +      int x_prev=-1, x_next=_data[x].right_neighbor;
  15.359 +      while( x_next!=-1 ) {
  15.360 +        if( _data[x].degree!=_data[x_next].degree ||
  15.361 +            ( _data[x_next].right_neighbor!=-1 &&
  15.362 +              _data[_data[x_next].right_neighbor].degree==_data[x].degree ) ) {
  15.363 +          x_prev=x;
  15.364 +          x=x_next;
  15.365 +        }
  15.366 +        else {
  15.367 +          if( _comp(_data[x_next].prio,_data[x].prio) ) {
  15.368 +            if( x_prev==-1 ) {
  15.369 +              _head=x_next;
  15.370 +            } else {
  15.371 +              _data[x_prev].right_neighbor=x_next;
  15.372 +            }
  15.373 +            fuse(x,x_next);
  15.374 +            x=x_next;
  15.375 +          }
  15.376 +          else {
  15.377 +            _data[x].right_neighbor=_data[x_next].right_neighbor;
  15.378 +            fuse(x_next,x);
  15.379 +          }
  15.380 +        }
  15.381 +        x_next=_data[x].right_neighbor;
  15.382 +      }
  15.383 +    }
  15.384 +
  15.385 +    // Interleave the elements of the given list into the list of the roots
  15.386 +    void interleave(int a) {
  15.387 +      int p=_head, q=a;
  15.388 +      int curr=_data.size();
  15.389 +      _data.push_back(Store());
  15.390 +      
  15.391 +      while( p!=-1 || q!=-1 ) {
  15.392 +        if( q==-1 || ( p!=-1 && _data[p].degree<_data[q].degree ) ) {
  15.393 +          _data[curr].right_neighbor=p;
  15.394 +          curr=p;
  15.395 +          p=_data[p].right_neighbor;
  15.396 +        }
  15.397 +        else {
  15.398 +          _data[curr].right_neighbor=q;
  15.399 +          curr=q;
  15.400 +          q=_data[q].right_neighbor;
  15.401 +        }
  15.402 +      }
  15.403 +      
  15.404 +      _head=_data.back().right_neighbor;
  15.405 +      _data.pop_back();
  15.406 +    }
  15.407 +
  15.408 +    // Lace node a under node b
  15.409 +    void fuse(int a, int b) {
  15.410 +      _data[a].parent=b;
  15.411 +      _data[a].right_neighbor=_data[b].child;
  15.412 +      _data[b].child=a;
  15.413 +
  15.414 +      ++_data[b].degree;
  15.415 +    }
  15.416 +
  15.417 +    // Unlace node a (if it has siblings)
  15.418 +    void unlace(int a) {
  15.419 +      int neighb=_data[a].right_neighbor;
  15.420 +      int other=_head;
  15.421 +
  15.422 +      while( _data[other].right_neighbor!=a )
  15.423 +        other=_data[other].right_neighbor;
  15.424 +      _data[other].right_neighbor=neighb;
  15.425 +    }
  15.426 +
  15.427 +  private:
  15.428 +
  15.429 +    class Store {
  15.430 +      friend class BinomHeap;
  15.431 +
  15.432 +      Item name;
  15.433 +      int parent;
  15.434 +      int right_neighbor;
  15.435 +      int child;
  15.436 +      int degree;
  15.437 +      bool in;
  15.438 +      Prio prio;
  15.439 +
  15.440 +      Store() : parent(-1), right_neighbor(-1), child(-1), degree(0),
  15.441 +        in(true) {}
  15.442 +    };
  15.443 +  };
  15.444 +
  15.445 +} //namespace lemon
  15.446 +
  15.447 +#endif //LEMON_BINOM_HEAP_H
  15.448 +
    16.1 --- a/lemon/bits/edge_set_extender.h	Tue Aug 18 10:08:28 2009 +0200
    16.2 +++ b/lemon/bits/edge_set_extender.h	Thu Nov 05 08:39:49 2009 +0100
    16.3 @@ -537,7 +537,7 @@
    16.4        typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
    16.5  
    16.6      public:
    16.7 -      ArcMap(const Graph& _g) 
    16.8 +      explicit ArcMap(const Graph& _g) 
    16.9  	: Parent(_g) {}
   16.10        ArcMap(const Graph& _g, const _Value& _v) 
   16.11  	: Parent(_g, _v) {}
   16.12 @@ -561,7 +561,7 @@
   16.13        typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   16.14  
   16.15      public:
   16.16 -      EdgeMap(const Graph& _g) 
   16.17 +      explicit EdgeMap(const Graph& _g) 
   16.18  	: Parent(_g) {}
   16.19  
   16.20        EdgeMap(const Graph& _g, const _Value& _v) 
    17.1 --- a/lemon/bits/graph_extender.h	Tue Aug 18 10:08:28 2009 +0200
    17.2 +++ b/lemon/bits/graph_extender.h	Thu Nov 05 08:39:49 2009 +0100
    17.3 @@ -604,7 +604,7 @@
    17.4        typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
    17.5  
    17.6      public:
    17.7 -      NodeMap(const Graph& graph)
    17.8 +      explicit NodeMap(const Graph& graph)
    17.9          : Parent(graph) {}
   17.10        NodeMap(const Graph& graph, const _Value& value)
   17.11          : Parent(graph, value) {}
   17.12 @@ -628,7 +628,7 @@
   17.13        typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
   17.14  
   17.15      public:
   17.16 -      ArcMap(const Graph& graph)
   17.17 +      explicit ArcMap(const Graph& graph)
   17.18          : Parent(graph) {}
   17.19        ArcMap(const Graph& graph, const _Value& value)
   17.20          : Parent(graph, value) {}
   17.21 @@ -652,7 +652,7 @@
   17.22        typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   17.23  
   17.24      public:
   17.25 -      EdgeMap(const Graph& graph)
   17.26 +      explicit EdgeMap(const Graph& graph)
   17.27          : Parent(graph) {}
   17.28  
   17.29        EdgeMap(const Graph& graph, const _Value& value)
    18.1 --- a/lemon/bits/map_extender.h	Tue Aug 18 10:08:28 2009 +0200
    18.2 +++ b/lemon/bits/map_extender.h	Thu Nov 05 08:39:49 2009 +0100
    18.3 @@ -49,6 +49,8 @@
    18.4      typedef typename Parent::Reference Reference;
    18.5      typedef typename Parent::ConstReference ConstReference;
    18.6  
    18.7 +    typedef typename Parent::ReferenceMapTag ReferenceMapTag;
    18.8 +
    18.9      class MapIt;
   18.10      class ConstMapIt;
   18.11  
   18.12 @@ -191,6 +193,8 @@
   18.13      typedef typename Parent::Reference Reference;
   18.14      typedef typename Parent::ConstReference ConstReference;
   18.15  
   18.16 +    typedef typename Parent::ReferenceMapTag ReferenceMapTag;
   18.17 +
   18.18      class MapIt;
   18.19      class ConstMapIt;
   18.20  
    19.1 --- a/lemon/bucket_heap.h	Tue Aug 18 10:08:28 2009 +0200
    19.2 +++ b/lemon/bucket_heap.h	Thu Nov 05 08:39:49 2009 +0100
    19.3 @@ -19,9 +19,9 @@
    19.4  #ifndef LEMON_BUCKET_HEAP_H
    19.5  #define LEMON_BUCKET_HEAP_H
    19.6  
    19.7 -///\ingroup auxdat
    19.8 +///\ingroup heaps
    19.9  ///\file
   19.10 -///\brief Bucket Heap implementation.
   19.11 +///\brief Bucket heap implementation.
   19.12  
   19.13  #include <vector>
   19.14  #include <utility>
   19.15 @@ -53,35 +53,41 @@
   19.16  
   19.17    }
   19.18  
   19.19 -  /// \ingroup auxdat
   19.20 +  /// \ingroup heaps
   19.21    ///
   19.22 -  /// \brief A Bucket Heap implementation.
   19.23 +  /// \brief Bucket heap data structure.
   19.24    ///
   19.25 -  /// This class implements the \e bucket \e heap data structure. A \e heap
   19.26 -  /// is a data structure for storing items with specified values called \e
   19.27 -  /// priorities in such a way that finding the item with minimum priority is
   19.28 -  /// efficient. The bucket heap is very simple implementation, it can store
   19.29 -  /// only integer priorities and it stores for each priority in the
   19.30 -  /// \f$ [0..C) \f$ range a list of items. So it should be used only when
   19.31 -  /// the priorities are small. It is not intended to use as dijkstra heap.
   19.32 +  /// This class implements the \e bucket \e heap data structure.
   19.33 +  /// It practically conforms to the \ref concepts::Heap "heap concept",
   19.34 +  /// but it has some limitations.
   19.35    ///
   19.36 -  /// \param IM A read and write Item int map, used internally
   19.37 -  /// to handle the cross references.
   19.38 -  /// \param MIN If the given parameter is false then instead of the
   19.39 -  /// minimum value the maximum can be retrivied with the top() and
   19.40 -  /// prio() member functions.
   19.41 +  /// The bucket heap is a very simple structure. It can store only
   19.42 +  /// \c int priorities and it maintains a list of items for each priority
   19.43 +  /// in the range <tt>[0..C)</tt>. So it should only be used when the
   19.44 +  /// priorities are small. It is not intended to use as a Dijkstra heap.
   19.45 +  ///
   19.46 +  /// \tparam IM A read-writable item map with \c int values, used
   19.47 +  /// internally to handle the cross references.
   19.48 +  /// \tparam MIN Indicate if the heap is a \e min-heap or a \e max-heap.
   19.49 +  /// The default is \e min-heap. If this parameter is set to \c false,
   19.50 +  /// then the comparison is reversed, so the top(), prio() and pop()
   19.51 +  /// functions deal with the item having maximum priority instead of the
   19.52 +  /// minimum.
   19.53 +  ///
   19.54 +  /// \sa SimpleBucketHeap
   19.55    template <typename IM, bool MIN = true>
   19.56    class BucketHeap {
   19.57  
   19.58    public:
   19.59 -    /// \e
   19.60 -    typedef typename IM::Key Item;
   19.61 -    /// \e
   19.62 +
   19.63 +    /// Type of the item-int map.
   19.64 +    typedef IM ItemIntMap;
   19.65 +    /// Type of the priorities.
   19.66      typedef int Prio;
   19.67 -    /// \e
   19.68 -    typedef std::pair<Item, Prio> Pair;
   19.69 -    /// \e
   19.70 -    typedef IM ItemIntMap;
   19.71 +    /// Type of the items stored in the heap.
   19.72 +    typedef typename ItemIntMap::Key Item;
   19.73 +    /// Type of the item-priority pairs.
   19.74 +    typedef std::pair<Item,Prio> Pair;
   19.75  
   19.76    private:
   19.77  
   19.78 @@ -89,10 +95,10 @@
   19.79  
   19.80    public:
   19.81  
   19.82 -    /// \brief Type to represent the items states.
   19.83 +    /// \brief Type to represent the states of the items.
   19.84      ///
   19.85 -    /// Each Item element have a state associated to it. It may be "in heap",
   19.86 -    /// "pre heap" or "post heap". The latter two are indifferent from the
   19.87 +    /// Each item has a state associated to it. It can be "in heap",
   19.88 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   19.89      /// heap's point of view, but may be useful to the user.
   19.90      ///
   19.91      /// The item-int map must be initialized in such way that it assigns
   19.92 @@ -104,37 +110,39 @@
   19.93      };
   19.94  
   19.95    public:
   19.96 -    /// \brief The constructor.
   19.97 +
   19.98 +    /// \brief Constructor.
   19.99      ///
  19.100 -    /// The constructor.
  19.101 -    /// \param map should be given to the constructor, since it is used
  19.102 -    /// internally to handle the cross references. The value of the map
  19.103 -    /// should be PRE_HEAP (-1) for each element.
  19.104 +    /// Constructor.
  19.105 +    /// \param map A map that assigns \c int values to the items.
  19.106 +    /// It is used internally to handle the cross references.
  19.107 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  19.108      explicit BucketHeap(ItemIntMap &map) : _iim(map), _minimum(0) {}
  19.109  
  19.110 -    /// The number of items stored in the heap.
  19.111 +    /// \brief The number of items stored in the heap.
  19.112      ///
  19.113 -    /// \brief Returns the number of items stored in the heap.
  19.114 +    /// This function returns the number of items stored in the heap.
  19.115      int size() const { return _data.size(); }
  19.116  
  19.117 -    /// \brief Checks if the heap stores no items.
  19.118 +    /// \brief Check if the heap is empty.
  19.119      ///
  19.120 -    /// Returns \c true if and only if the heap stores no items.
  19.121 +    /// This function returns \c true if the heap is empty.
  19.122      bool empty() const { return _data.empty(); }
  19.123  
  19.124 -    /// \brief Make empty this heap.
  19.125 +    /// \brief Make the heap empty.
  19.126      ///
  19.127 -    /// Make empty this heap. It does not change the cross reference
  19.128 -    /// map.  If you want to reuse a heap what is not surely empty you
  19.129 -    /// should first clear the heap and after that you should set the
  19.130 -    /// cross reference map for each item to \c PRE_HEAP.
  19.131 +    /// This functon makes the heap empty.
  19.132 +    /// It does not change the cross reference map. If you want to reuse
  19.133 +    /// a heap that is not surely empty, you should first clear it and
  19.134 +    /// then you should set the cross reference map to \c PRE_HEAP
  19.135 +    /// for each item.
  19.136      void clear() {
  19.137        _data.clear(); _first.clear(); _minimum = 0;
  19.138      }
  19.139  
  19.140    private:
  19.141  
  19.142 -    void relocate_last(int idx) {
  19.143 +    void relocateLast(int idx) {
  19.144        if (idx + 1 < int(_data.size())) {
  19.145          _data[idx] = _data.back();
  19.146          if (_data[idx].prev != -1) {
  19.147 @@ -174,19 +182,24 @@
  19.148      }
  19.149  
  19.150    public:
  19.151 +
  19.152      /// \brief Insert a pair of item and priority into the heap.
  19.153      ///
  19.154 -    /// Adds \c p.first to the heap with priority \c p.second.
  19.155 +    /// This function inserts \c p.first to the heap with priority
  19.156 +    /// \c p.second.
  19.157      /// \param p The pair to insert.
  19.158 +    /// \pre \c p.first must not be stored in the heap.
  19.159      void push(const Pair& p) {
  19.160        push(p.first, p.second);
  19.161      }
  19.162  
  19.163      /// \brief Insert an item into the heap with the given priority.
  19.164      ///
  19.165 -    /// Adds \c i to the heap with priority \c p.
  19.166 +    /// This function inserts the given item into the heap with the
  19.167 +    /// given priority.
  19.168      /// \param i The item to insert.
  19.169      /// \param p The priority of the item.
  19.170 +    /// \pre \e i must not be stored in the heap.
  19.171      void push(const Item &i, const Prio &p) {
  19.172        int idx = _data.size();
  19.173        _iim[i] = idx;
  19.174 @@ -197,10 +210,10 @@
  19.175        }
  19.176      }
  19.177  
  19.178 -    /// \brief Returns the item with minimum priority.
  19.179 +    /// \brief Return the item having minimum priority.
  19.180      ///
  19.181 -    /// This method returns the item with minimum priority.
  19.182 -    /// \pre The heap must be nonempty.
  19.183 +    /// This function returns the item having minimum priority.
  19.184 +    /// \pre The heap must be non-empty.
  19.185      Item top() const {
  19.186        while (_first[_minimum] == -1) {
  19.187          Direction::increase(_minimum);
  19.188 @@ -208,10 +221,10 @@
  19.189        return _data[_first[_minimum]].item;
  19.190      }
  19.191  
  19.192 -    /// \brief Returns the minimum priority.
  19.193 +    /// \brief The minimum priority.
  19.194      ///
  19.195 -    /// It returns the minimum priority.
  19.196 -    /// \pre The heap must be nonempty.
  19.197 +    /// This function returns the minimum priority.
  19.198 +    /// \pre The heap must be non-empty.
  19.199      Prio prio() const {
  19.200        while (_first[_minimum] == -1) {
  19.201          Direction::increase(_minimum);
  19.202 @@ -219,9 +232,9 @@
  19.203        return _minimum;
  19.204      }
  19.205  
  19.206 -    /// \brief Deletes the item with minimum priority.
  19.207 +    /// \brief Remove the item having minimum priority.
  19.208      ///
  19.209 -    /// This method deletes the item with minimum priority from the heap.
  19.210 +    /// This function removes the item having minimum priority.
  19.211      /// \pre The heap must be non-empty.
  19.212      void pop() {
  19.213        while (_first[_minimum] == -1) {
  19.214 @@ -230,37 +243,38 @@
  19.215        int idx = _first[_minimum];
  19.216        _iim[_data[idx].item] = -2;
  19.217        unlace(idx);
  19.218 -      relocate_last(idx);
  19.219 +      relocateLast(idx);
  19.220      }
  19.221  
  19.222 -    /// \brief Deletes \c i from the heap.
  19.223 +    /// \brief Remove the given item from the heap.
  19.224      ///
  19.225 -    /// This method deletes item \c i from the heap, if \c i was
  19.226 -    /// already stored in the heap.
  19.227 -    /// \param i The item to erase.
  19.228 +    /// This function removes the given item from the heap if it is
  19.229 +    /// already stored.
  19.230 +    /// \param i The item to delete.
  19.231 +    /// \pre \e i must be in the heap.
  19.232      void erase(const Item &i) {
  19.233        int idx = _iim[i];
  19.234        _iim[_data[idx].item] = -2;
  19.235        unlace(idx);
  19.236 -      relocate_last(idx);
  19.237 +      relocateLast(idx);
  19.238      }
  19.239  
  19.240 -
  19.241 -    /// \brief Returns the priority of \c i.
  19.242 +    /// \brief The priority of the given item.
  19.243      ///
  19.244 -    /// This function returns the priority of item \c i.
  19.245 -    /// \pre \c i must be in the heap.
  19.246 +    /// This function returns the priority of the given item.
  19.247      /// \param i The item.
  19.248 +    /// \pre \e i must be in the heap.
  19.249      Prio operator[](const Item &i) const {
  19.250        int idx = _iim[i];
  19.251        return _data[idx].value;
  19.252      }
  19.253  
  19.254 -    /// \brief \c i gets to the heap with priority \c p independently
  19.255 -    /// if \c i was already there.
  19.256 +    /// \brief Set the priority of an item or insert it, if it is
  19.257 +    /// not stored in the heap.
  19.258      ///
  19.259 -    /// This method calls \ref push(\c i, \c p) if \c i is not stored
  19.260 -    /// in the heap and sets the priority of \c i to \c p otherwise.
  19.261 +    /// This method sets the priority of the given item if it is
  19.262 +    /// already stored in the heap. Otherwise it inserts the given
  19.263 +    /// item into the heap with the given priority.
  19.264      /// \param i The item.
  19.265      /// \param p The priority.
  19.266      void set(const Item &i, const Prio &p) {
  19.267 @@ -274,13 +288,12 @@
  19.268        }
  19.269      }
  19.270  
  19.271 -    /// \brief Decreases the priority of \c i to \c p.
  19.272 +    /// \brief Decrease the priority of an item to the given value.
  19.273      ///
  19.274 -    /// This method decreases the priority of item \c i to \c p.
  19.275 -    /// \pre \c i must be stored in the heap with priority at least \c
  19.276 -    /// p relative to \c Compare.
  19.277 +    /// This function decreases the priority of an item to the given value.
  19.278      /// \param i The item.
  19.279      /// \param p The priority.
  19.280 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  19.281      void decrease(const Item &i, const Prio &p) {
  19.282        int idx = _iim[i];
  19.283        unlace(idx);
  19.284 @@ -291,13 +304,12 @@
  19.285        lace(idx);
  19.286      }
  19.287  
  19.288 -    /// \brief Increases the priority of \c i to \c p.
  19.289 +    /// \brief Increase the priority of an item to the given value.
  19.290      ///
  19.291 -    /// This method sets the priority of item \c i to \c p.
  19.292 -    /// \pre \c i must be stored in the heap with priority at most \c
  19.293 -    /// p relative to \c Compare.
  19.294 +    /// This function increases the priority of an item to the given value.
  19.295      /// \param i The item.
  19.296      /// \param p The priority.
  19.297 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  19.298      void increase(const Item &i, const Prio &p) {
  19.299        int idx = _iim[i];
  19.300        unlace(idx);
  19.301 @@ -305,13 +317,13 @@
  19.302        lace(idx);
  19.303      }
  19.304  
  19.305 -    /// \brief Returns if \c item is in, has already been in, or has
  19.306 -    /// never been in the heap.
  19.307 +    /// \brief Return the state of an item.
  19.308      ///
  19.309 -    /// This method returns PRE_HEAP if \c item has never been in the
  19.310 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  19.311 -    /// otherwise. In the latter case it is possible that \c item will
  19.312 -    /// get back to the heap again.
  19.313 +    /// This method returns \c PRE_HEAP if the given item has never
  19.314 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  19.315 +    /// and \c POST_HEAP otherwise.
  19.316 +    /// In the latter case it is possible that the item will get back
  19.317 +    /// to the heap again.
  19.318      /// \param i The item.
  19.319      State state(const Item &i) const {
  19.320        int idx = _iim[i];
  19.321 @@ -319,11 +331,11 @@
  19.322        return State(idx);
  19.323      }
  19.324  
  19.325 -    /// \brief Sets the state of the \c item in the heap.
  19.326 +    /// \brief Set the state of an item in the heap.
  19.327      ///
  19.328 -    /// Sets the state of the \c item in the heap. It can be used to
  19.329 -    /// manually clear the heap when it is important to achive the
  19.330 -    /// better time complexity.
  19.331 +    /// This function sets the state of the given item in the heap.
  19.332 +    /// It can be used to manually clear the heap when it is important
  19.333 +    /// to achive better time complexity.
  19.334      /// \param i The item.
  19.335      /// \param st The state. It should not be \c IN_HEAP.
  19.336      void state(const Item& i, State st) {
  19.337 @@ -359,33 +371,44 @@
  19.338  
  19.339    }; // class BucketHeap
  19.340  
  19.341 -  /// \ingroup auxdat
  19.342 +  /// \ingroup heaps
  19.343    ///
  19.344 -  /// \brief A Simplified Bucket Heap implementation.
  19.345 +  /// \brief Simplified bucket heap data structure.
  19.346    ///
  19.347    /// This class implements a simplified \e bucket \e heap data
  19.348 -  /// structure.  It does not provide some functionality but it faster
  19.349 -  /// and simplier data structure than the BucketHeap. The main
  19.350 -  /// difference is that the BucketHeap stores for every key a double
  19.351 -  /// linked list while this class stores just simple lists. In the
  19.352 -  /// other way it does not support erasing each elements just the
  19.353 -  /// minimal and it does not supports key increasing, decreasing.
  19.354 +  /// structure. It does not provide some functionality, but it is
  19.355 +  /// faster and simpler than BucketHeap. The main difference is
  19.356 +  /// that BucketHeap stores a doubly-linked list for each key while
  19.357 +  /// this class stores only simply-linked lists. It supports erasing
  19.358 +  /// only for the item having minimum priority and it does not support
  19.359 +  /// key increasing and decreasing.
  19.360    ///
  19.361 -  /// \param IM A read and write Item int map, used internally
  19.362 -  /// to handle the cross references.
  19.363 -  /// \param MIN If the given parameter is false then instead of the
  19.364 -  /// minimum value the maximum can be retrivied with the top() and
  19.365 -  /// prio() member functions.
  19.366 +  /// Note that this implementation does not conform to the
  19.367 +  /// \ref concepts::Heap "heap concept" due to the lack of some 
  19.368 +  /// functionality.
  19.369 +  ///
  19.370 +  /// \tparam IM A read-writable item map with \c int values, used
  19.371 +  /// internally to handle the cross references.
  19.372 +  /// \tparam MIN Indicate if the heap is a \e min-heap or a \e max-heap.
  19.373 +  /// The default is \e min-heap. If this parameter is set to \c false,
  19.374 +  /// then the comparison is reversed, so the top(), prio() and pop()
  19.375 +  /// functions deal with the item having maximum priority instead of the
  19.376 +  /// minimum.
  19.377    ///
  19.378    /// \sa BucketHeap
  19.379    template <typename IM, bool MIN = true >
  19.380    class SimpleBucketHeap {
  19.381  
  19.382    public:
  19.383 -    typedef typename IM::Key Item;
  19.384 +
  19.385 +    /// Type of the item-int map.
  19.386 +    typedef IM ItemIntMap;
  19.387 +    /// Type of the priorities.
  19.388      typedef int Prio;
  19.389 -    typedef std::pair<Item, Prio> Pair;
  19.390 -    typedef IM ItemIntMap;
  19.391 +    /// Type of the items stored in the heap.
  19.392 +    typedef typename ItemIntMap::Key Item;
  19.393 +    /// Type of the item-priority pairs.
  19.394 +    typedef std::pair<Item,Prio> Pair;
  19.395  
  19.396    private:
  19.397  
  19.398 @@ -393,10 +416,10 @@
  19.399  
  19.400    public:
  19.401  
  19.402 -    /// \brief Type to represent the items states.
  19.403 +    /// \brief Type to represent the states of the items.
  19.404      ///
  19.405 -    /// Each Item element have a state associated to it. It may be "in heap",
  19.406 -    /// "pre heap" or "post heap". The latter two are indifferent from the
  19.407 +    /// Each item has a state associated to it. It can be "in heap",
  19.408 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
  19.409      /// heap's point of view, but may be useful to the user.
  19.410      ///
  19.411      /// The item-int map must be initialized in such way that it assigns
  19.412 @@ -409,48 +432,53 @@
  19.413  
  19.414    public:
  19.415  
  19.416 -    /// \brief The constructor.
  19.417 +    /// \brief Constructor.
  19.418      ///
  19.419 -    /// The constructor.
  19.420 -    /// \param map should be given to the constructor, since it is used
  19.421 -    /// internally to handle the cross references. The value of the map
  19.422 -    /// should be PRE_HEAP (-1) for each element.
  19.423 +    /// Constructor.
  19.424 +    /// \param map A map that assigns \c int values to the items.
  19.425 +    /// It is used internally to handle the cross references.
  19.426 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  19.427      explicit SimpleBucketHeap(ItemIntMap &map)
  19.428        : _iim(map), _free(-1), _num(0), _minimum(0) {}
  19.429  
  19.430 -    /// \brief Returns the number of items stored in the heap.
  19.431 +    /// \brief The number of items stored in the heap.
  19.432      ///
  19.433 -    /// The number of items stored in the heap.
  19.434 +    /// This function returns the number of items stored in the heap.
  19.435      int size() const { return _num; }
  19.436  
  19.437 -    /// \brief Checks if the heap stores no items.
  19.438 +    /// \brief Check if the heap is empty.
  19.439      ///
  19.440 -    /// Returns \c true if and only if the heap stores no items.
  19.441 +    /// This function returns \c true if the heap is empty.
  19.442      bool empty() const { return _num == 0; }
  19.443  
  19.444 -    /// \brief Make empty this heap.
  19.445 +    /// \brief Make the heap empty.
  19.446      ///
  19.447 -    /// Make empty this heap. It does not change the cross reference
  19.448 -    /// map.  If you want to reuse a heap what is not surely empty you
  19.449 -    /// should first clear the heap and after that you should set the
  19.450 -    /// cross reference map for each item to \c PRE_HEAP.
  19.451 +    /// This functon makes the heap empty.
  19.452 +    /// It does not change the cross reference map. If you want to reuse
  19.453 +    /// a heap that is not surely empty, you should first clear it and
  19.454 +    /// then you should set the cross reference map to \c PRE_HEAP
  19.455 +    /// for each item.
  19.456      void clear() {
  19.457        _data.clear(); _first.clear(); _free = -1; _num = 0; _minimum = 0;
  19.458      }
  19.459  
  19.460      /// \brief Insert a pair of item and priority into the heap.
  19.461      ///
  19.462 -    /// Adds \c p.first to the heap with priority \c p.second.
  19.463 +    /// This function inserts \c p.first to the heap with priority
  19.464 +    /// \c p.second.
  19.465      /// \param p The pair to insert.
  19.466 +    /// \pre \c p.first must not be stored in the heap.
  19.467      void push(const Pair& p) {
  19.468        push(p.first, p.second);
  19.469      }
  19.470  
  19.471      /// \brief Insert an item into the heap with the given priority.
  19.472      ///
  19.473 -    /// Adds \c i to the heap with priority \c p.
  19.474 +    /// This function inserts the given item into the heap with the
  19.475 +    /// given priority.
  19.476      /// \param i The item to insert.
  19.477      /// \param p The priority of the item.
  19.478 +    /// \pre \e i must not be stored in the heap.
  19.479      void push(const Item &i, const Prio &p) {
  19.480        int idx;
  19.481        if (_free == -1) {
  19.482 @@ -471,10 +499,10 @@
  19.483        ++_num;
  19.484      }
  19.485  
  19.486 -    /// \brief Returns the item with minimum priority.
  19.487 +    /// \brief Return the item having minimum priority.
  19.488      ///
  19.489 -    /// This method returns the item with minimum priority.
  19.490 -    /// \pre The heap must be nonempty.
  19.491 +    /// This function returns the item having minimum priority.
  19.492 +    /// \pre The heap must be non-empty.
  19.493      Item top() const {
  19.494        while (_first[_minimum] == -1) {
  19.495          Direction::increase(_minimum);
  19.496 @@ -482,10 +510,10 @@
  19.497        return _data[_first[_minimum]].item;
  19.498      }
  19.499  
  19.500 -    /// \brief Returns the minimum priority.
  19.501 +    /// \brief The minimum priority.
  19.502      ///
  19.503 -    /// It returns the minimum priority.
  19.504 -    /// \pre The heap must be nonempty.
  19.505 +    /// This function returns the minimum priority.
  19.506 +    /// \pre The heap must be non-empty.
  19.507      Prio prio() const {
  19.508        while (_first[_minimum] == -1) {
  19.509          Direction::increase(_minimum);
  19.510 @@ -493,9 +521,9 @@
  19.511        return _minimum;
  19.512      }
  19.513  
  19.514 -    /// \brief Deletes the item with minimum priority.
  19.515 +    /// \brief Remove the item having minimum priority.
  19.516      ///
  19.517 -    /// This method deletes the item with minimum priority from the heap.
  19.518 +    /// This function removes the item having minimum priority.
  19.519      /// \pre The heap must be non-empty.
  19.520      void pop() {
  19.521        while (_first[_minimum] == -1) {
  19.522 @@ -509,16 +537,15 @@
  19.523        --_num;
  19.524      }
  19.525  
  19.526 -    /// \brief Returns the priority of \c i.
  19.527 +    /// \brief The priority of the given item.
  19.528      ///
  19.529 -    /// This function returns the priority of item \c i.
  19.530 -    /// \warning This operator is not a constant time function
  19.531 -    /// because it scans the whole data structure to find the proper
  19.532 -    /// value.
  19.533 -    /// \pre \c i must be in the heap.
  19.534 +    /// This function returns the priority of the given item.
  19.535      /// \param i The item.
  19.536 +    /// \pre \e i must be in the heap.
  19.537 +    /// \warning This operator is not a constant time function because
  19.538 +    /// it scans the whole data structure to find the proper value.
  19.539      Prio operator[](const Item &i) const {
  19.540 -      for (int k = 0; k < _first.size(); ++k) {
  19.541 +      for (int k = 0; k < int(_first.size()); ++k) {
  19.542          int idx = _first[k];
  19.543          while (idx != -1) {
  19.544            if (_data[idx].item == i) {
  19.545 @@ -530,13 +557,13 @@
  19.546        return -1;
  19.547      }
  19.548  
  19.549 -    /// \brief Returns if \c item is in, has already been in, or has
  19.550 -    /// never been in the heap.
  19.551 +    /// \brief Return the state of an item.
  19.552      ///
  19.553 -    /// This method returns PRE_HEAP if \c item has never been in the
  19.554 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  19.555 -    /// otherwise. In the latter case it is possible that \c item will
  19.556 -    /// get back to the heap again.
  19.557 +    /// This method returns \c PRE_HEAP if the given item has never
  19.558 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  19.559 +    /// and \c POST_HEAP otherwise.
  19.560 +    /// In the latter case it is possible that the item will get back
  19.561 +    /// to the heap again.
  19.562      /// \param i The item.
  19.563      State state(const Item &i) const {
  19.564        int idx = _iim[i];
    20.1 --- a/lemon/cbc.cc	Tue Aug 18 10:08:28 2009 +0200
    20.2 +++ b/lemon/cbc.cc	Thu Nov 05 08:39:49 2009 +0100
    20.3 @@ -94,6 +94,18 @@
    20.4      return _prob->numberRows() - 1;
    20.5    }
    20.6  
    20.7 +  int CbcMip::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
    20.8 +    std::vector<int> indexes;
    20.9 +    std::vector<Value> values;
   20.10 +
   20.11 +    for(ExprIterator it = b; it != e; ++it) {
   20.12 +      indexes.push_back(it->first);
   20.13 +      values.push_back(it->second);
   20.14 +    }
   20.15 +
   20.16 +    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
   20.17 +    return _prob->numberRows() - 1;
   20.18 +  }
   20.19  
   20.20    void CbcMip::_eraseCol(int i) {
   20.21      _prob->deleteColumn(i);
    21.1 --- a/lemon/cbc.h	Tue Aug 18 10:08:28 2009 +0200
    21.2 +++ b/lemon/cbc.h	Thu Nov 05 08:39:49 2009 +0100
    21.3 @@ -62,6 +62,7 @@
    21.4  
    21.5      virtual int _addCol();
    21.6      virtual int _addRow();
    21.7 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    21.8  
    21.9      virtual void _eraseCol(int i);
   21.10      virtual void _eraseRow(int i);
    22.1 --- a/lemon/circulation.h	Tue Aug 18 10:08:28 2009 +0200
    22.2 +++ b/lemon/circulation.h	Thu Nov 05 08:39:49 2009 +0100
    22.3 @@ -72,7 +72,11 @@
    22.4      /// The type of the map that stores the flow values.
    22.5      /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap"
    22.6      /// concept.
    22.7 +#ifdef DOXYGEN
    22.8 +    typedef GR::ArcMap<Value> FlowMap;
    22.9 +#else
   22.10      typedef typename Digraph::template ArcMap<Value> FlowMap;
   22.11 +#endif
   22.12  
   22.13      /// \brief Instantiates a FlowMap.
   22.14      ///
   22.15 @@ -87,9 +91,12 @@
   22.16      ///
   22.17      /// The elevator type used by the algorithm.
   22.18      ///
   22.19 -    /// \sa Elevator
   22.20 -    /// \sa LinkedElevator
   22.21 +    /// \sa Elevator, LinkedElevator
   22.22 +#ifdef DOXYGEN
   22.23 +    typedef lemon::Elevator<GR, GR::Node> Elevator;
   22.24 +#else
   22.25      typedef lemon::Elevator<Digraph, typename Digraph::Node> Elevator;
   22.26 +#endif
   22.27  
   22.28      /// \brief Instantiates an Elevator.
   22.29      ///
   22.30 @@ -450,25 +457,27 @@
   22.31        return *_level;
   22.32      }
   22.33  
   22.34 -    /// \brief Sets the tolerance used by algorithm.
   22.35 +    /// \brief Sets the tolerance used by the algorithm.
   22.36      ///
   22.37 -    /// Sets the tolerance used by algorithm.
   22.38 -    Circulation& tolerance(const Tolerance& tolerance) const {
   22.39 +    /// Sets the tolerance object used by the algorithm.
   22.40 +    /// \return <tt>(*this)</tt>
   22.41 +    Circulation& tolerance(const Tolerance& tolerance) {
   22.42        _tol = tolerance;
   22.43        return *this;
   22.44      }
   22.45  
   22.46      /// \brief Returns a const reference to the tolerance.
   22.47      ///
   22.48 -    /// Returns a const reference to the tolerance.
   22.49 +    /// Returns a const reference to the tolerance object used by
   22.50 +    /// the algorithm.
   22.51      const Tolerance& tolerance() const {
   22.52 -      return tolerance;
   22.53 +      return _tol;
   22.54      }
   22.55  
   22.56      /// \name Execution Control
   22.57      /// The simplest way to execute the algorithm is to call \ref run().\n
   22.58 -    /// If you need more control on the initial solution or the execution,
   22.59 -    /// first you have to call one of the \ref init() functions, then
   22.60 +    /// If you need better control on the initial solution or the execution,
   22.61 +    /// you have to call one of the \ref init() functions first, then
   22.62      /// the \ref start() function.
   22.63  
   22.64      ///@{
    23.1 --- a/lemon/clp.cc	Tue Aug 18 10:08:28 2009 +0200
    23.2 +++ b/lemon/clp.cc	Thu Nov 05 08:39:49 2009 +0100
    23.3 @@ -78,6 +78,19 @@
    23.4      return _prob->numberRows() - 1;
    23.5    }
    23.6  
    23.7 +  int ClpLp::_addRow(Value l, ExprIterator b, ExprIterator e, Value u) {
    23.8 +    std::vector<int> indexes;
    23.9 +    std::vector<Value> values;
   23.10 +
   23.11 +    for(ExprIterator it = b; it != e; ++it) {
   23.12 +      indexes.push_back(it->first);
   23.13 +      values.push_back(it->second);
   23.14 +    }
   23.15 +
   23.16 +    _prob->addRow(values.size(), &indexes.front(), &values.front(), l, u);
   23.17 +    return _prob->numberRows() - 1;
   23.18 +  }
   23.19 +
   23.20  
   23.21    void ClpLp::_eraseCol(int c) {
   23.22      _col_names_ref.erase(_prob->getColumnName(c));
    24.1 --- a/lemon/clp.h	Tue Aug 18 10:08:28 2009 +0200
    24.2 +++ b/lemon/clp.h	Thu Nov 05 08:39:49 2009 +0100
    24.3 @@ -75,6 +75,7 @@
    24.4  
    24.5      virtual int _addCol();
    24.6      virtual int _addRow();
    24.7 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    24.8  
    24.9      virtual void _eraseCol(int i);
   24.10      virtual void _eraseRow(int i);
    25.1 --- a/lemon/concepts/digraph.h	Tue Aug 18 10:08:28 2009 +0200
    25.2 +++ b/lemon/concepts/digraph.h	Thu Nov 05 08:39:49 2009 +0100
    25.3 @@ -35,46 +35,40 @@
    25.4      ///
    25.5      /// \brief Class describing the concept of directed graphs.
    25.6      ///
    25.7 -    /// This class describes the \ref concept "concept" of the
    25.8 -    /// immutable directed digraphs.
    25.9 +    /// This class describes the common interface of all directed
   25.10 +    /// graphs (digraphs).
   25.11      ///
   25.12 -    /// Note that actual digraph implementation like @ref ListDigraph or
   25.13 -    /// @ref SmartDigraph may have several additional functionality.
   25.14 +    /// Like all concept classes, it only provides an interface
   25.15 +    /// without any sensible implementation. So any general algorithm for
   25.16 +    /// directed graphs should compile with this class, but it will not
   25.17 +    /// run properly, of course.
   25.18 +    /// An actual digraph implementation like \ref ListDigraph or
   25.19 +    /// \ref SmartDigraph may have additional functionality.
   25.20      ///
   25.21 -    /// \sa concept
   25.22 +    /// \sa Graph
   25.23      class Digraph {
   25.24      private:
   25.25 -      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
   25.26 +      /// Diraphs are \e not copy constructible. Use DigraphCopy instead.
   25.27 +      Digraph(const Digraph &) {}
   25.28 +      /// \brief Assignment of a digraph to another one is \e not allowed.
   25.29 +      /// Use DigraphCopy instead.
   25.30 +      void operator=(const Digraph &) {}
   25.31  
   25.32 -      ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
   25.33 -      ///
   25.34 -      Digraph(const Digraph &) {};
   25.35 -      ///\brief Assignment of \ref Digraph "Digraph"s to another ones are
   25.36 -      ///\e not allowed. Use DigraphCopy() instead.
   25.37 +    public:
   25.38 +      /// Default constructor.
   25.39 +      Digraph() { }
   25.40  
   25.41 -      ///Assignment of \ref Digraph "Digraph"s to another ones are
   25.42 -      ///\e not allowed.  Use DigraphCopy() instead.
   25.43 -
   25.44 -      void operator=(const Digraph &) {}
   25.45 -    public:
   25.46 -      ///\e
   25.47 -
   25.48 -      /// Defalult constructor.
   25.49 -
   25.50 -      /// Defalult constructor.
   25.51 -      ///
   25.52 -      Digraph() { }
   25.53 -      /// Class for identifying a node of the digraph
   25.54 +      /// The node type of the digraph
   25.55  
   25.56        /// This class identifies a node of the digraph. It also serves
   25.57        /// as a base class of the node iterators,
   25.58 -      /// thus they will convert to this type.
   25.59 +      /// thus they convert to this type.
   25.60        class Node {
   25.61        public:
   25.62          /// Default constructor
   25.63  
   25.64 -        /// @warning The default constructor sets the iterator
   25.65 -        /// to an undefined value.
   25.66 +        /// Default constructor.
   25.67 +        /// \warning It sets the object to an undefined value.
   25.68          Node() { }
   25.69          /// Copy constructor.
   25.70  
   25.71 @@ -82,40 +76,39 @@
   25.72          ///
   25.73          Node(const Node&) { }
   25.74  
   25.75 -        /// Invalid constructor \& conversion.
   25.76 +        /// %Invalid constructor \& conversion.
   25.77  
   25.78 -        /// This constructor initializes the iterator to be invalid.
   25.79 +        /// Initializes the object to be invalid.
   25.80          /// \sa Invalid for more details.
   25.81          Node(Invalid) { }
   25.82          /// Equality operator
   25.83  
   25.84 +        /// Equality operator.
   25.85 +        ///
   25.86          /// Two iterators are equal if and only if they point to the
   25.87 -        /// same object or both are invalid.
   25.88 +        /// same object or both are \c INVALID.
   25.89          bool operator==(Node) const { return true; }
   25.90  
   25.91          /// Inequality operator
   25.92  
   25.93 -        /// \sa operator==(Node n)
   25.94 -        ///
   25.95 +        /// Inequality operator.
   25.96          bool operator!=(Node) const { return true; }
   25.97  
   25.98          /// Artificial ordering operator.
   25.99  
  25.100 -        /// To allow the use of digraph descriptors as key type in std::map or
  25.101 -        /// similar associative container we require this.
  25.102 +        /// Artificial ordering operator.
  25.103          ///
  25.104 -        /// \note This operator only have to define some strict ordering of
  25.105 -        /// the items; this order has nothing to do with the iteration
  25.106 -        /// ordering of the items.
  25.107 +        /// \note This operator only has to define some strict ordering of
  25.108 +        /// the nodes; this order has nothing to do with the iteration
  25.109 +        /// ordering of the nodes.
  25.110          bool operator<(Node) const { return false; }
  25.111 -
  25.112        };
  25.113  
  25.114 -      /// This iterator goes through each node.
  25.115 +      /// Iterator class for the nodes.
  25.116  
  25.117 -      /// This iterator goes through each node.
  25.118 +      /// This iterator goes through each node of the digraph.
  25.119        /// Its usage is quite simple, for example you can count the number
  25.120 -      /// of nodes in digraph \c g of type \c Digraph like this:
  25.121 +      /// of nodes in a digraph \c g of type \c %Digraph like this:
  25.122        ///\code
  25.123        /// int count=0;
  25.124        /// for (Digraph::NodeIt n(g); n!=INVALID; ++n) ++count;
  25.125 @@ -124,30 +117,28 @@
  25.126        public:
  25.127          /// Default constructor
  25.128  
  25.129 -        /// @warning The default constructor sets the iterator
  25.130 -        /// to an undefined value.
  25.131 +        /// Default constructor.
  25.132 +        /// \warning It sets the iterator to an undefined value.
  25.133          NodeIt() { }
  25.134          /// Copy constructor.
  25.135  
  25.136          /// Copy constructor.
  25.137          ///
  25.138          NodeIt(const NodeIt& n) : Node(n) { }
  25.139 -        /// Invalid constructor \& conversion.
  25.140 +        /// %Invalid constructor \& conversion.
  25.141  
  25.142 -        /// Initialize the iterator to be invalid.
  25.143 +        /// Initializes the iterator to be invalid.
  25.144          /// \sa Invalid for more details.
  25.145          NodeIt(Invalid) { }
  25.146          /// Sets the iterator to the first node.
  25.147  
  25.148 -        /// Sets the iterator to the first node of \c g.
  25.149 +        /// Sets the iterator to the first node of the given digraph.
  25.150          ///
  25.151 -        NodeIt(const Digraph&) { }
  25.152 -        /// Node -> NodeIt conversion.
  25.153 +        explicit NodeIt(const Digraph&) { }
  25.154 +        /// Sets the iterator to the given node.
  25.155  
  25.156 -        /// Sets the iterator to the node of \c the digraph pointed by
  25.157 -        /// the trivial iterator.
  25.158 -        /// This feature necessitates that each time we
  25.159 -        /// iterate the arc-set, the iteration order is the same.
  25.160 +        /// Sets the iterator to the given node of the given digraph.
  25.161 +        ///
  25.162          NodeIt(const Digraph&, const Node&) { }
  25.163          /// Next node.
  25.164  
  25.165 @@ -157,7 +148,7 @@
  25.166        };
  25.167  
  25.168  
  25.169 -      /// Class for identifying an arc of the digraph
  25.170 +      /// The arc type of the digraph
  25.171  
  25.172        /// This class identifies an arc of the digraph. It also serves
  25.173        /// as a base class of the arc iterators,
  25.174 @@ -166,207 +157,214 @@
  25.175        public:
  25.176          /// Default constructor
  25.177  
  25.178 -        /// @warning The default constructor sets the iterator
  25.179 -        /// to an undefined value.
  25.180 +        /// Default constructor.
  25.181 +        /// \warning It sets the object to an undefined value.
  25.182          Arc() { }
  25.183          /// Copy constructor.
  25.184  
  25.185          /// Copy constructor.
  25.186          ///
  25.187          Arc(const Arc&) { }
  25.188 -        /// Initialize the iterator to be invalid.
  25.189 +        /// %Invalid constructor \& conversion.
  25.190  
  25.191 -        /// Initialize the iterator to be invalid.
  25.192 -        ///
  25.193 +        /// Initializes the object to be invalid.
  25.194 +        /// \sa Invalid for more details.
  25.195          Arc(Invalid) { }
  25.196          /// Equality operator
  25.197  
  25.198 +        /// Equality operator.
  25.199 +        ///
  25.200          /// Two iterators are equal if and only if they point to the
  25.201 -        /// same object or both are invalid.
  25.202 +        /// same object or both are \c INVALID.
  25.203          bool operator==(Arc) const { return true; }
  25.204          /// Inequality operator
  25.205  
  25.206 -        /// \sa operator==(Arc n)
  25.207 -        ///
  25.208 +        /// Inequality operator.
  25.209          bool operator!=(Arc) const { return true; }
  25.210  
  25.211          /// Artificial ordering operator.
  25.212  
  25.213 -        /// To allow the use of digraph descriptors as key type in std::map or
  25.214 -        /// similar associative container we require this.
  25.215 +        /// Artificial ordering operator.
  25.216          ///
  25.217 -        /// \note This operator only have to define some strict ordering of
  25.218 -        /// the items; this order has nothing to do with the iteration
  25.219 -        /// ordering of the items.
  25.220 +        /// \note This operator only has to define some strict ordering of
  25.221 +        /// the arcs; this order has nothing to do with the iteration
  25.222 +        /// ordering of the arcs.
  25.223          bool operator<(Arc) const { return false; }
  25.224        };
  25.225  
  25.226 -      /// This iterator goes trough the outgoing arcs of a node.
  25.227 +      /// Iterator class for the outgoing arcs of a node.
  25.228  
  25.229        /// This iterator goes trough the \e outgoing arcs of a certain node
  25.230        /// of a digraph.
  25.231        /// Its usage is quite simple, for example you can count the number
  25.232        /// of outgoing arcs of a node \c n
  25.233 -      /// in digraph \c g of type \c Digraph as follows.
  25.234 +      /// in a digraph \c g of type \c %Digraph as follows.
  25.235        ///\code
  25.236        /// int count=0;
  25.237 -      /// for (Digraph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
  25.238 +      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
  25.239        ///\endcode
  25.240 -
  25.241        class OutArcIt : public Arc {
  25.242        public:
  25.243          /// Default constructor
  25.244  
  25.245 -        /// @warning The default constructor sets the iterator
  25.246 -        /// to an undefined value.
  25.247 +        /// Default constructor.
  25.248 +        /// \warning It sets the iterator to an undefined value.
  25.249          OutArcIt() { }
  25.250          /// Copy constructor.
  25.251  
  25.252          /// Copy constructor.
  25.253          ///
  25.254          OutArcIt(const OutArcIt& e) : Arc(e) { }
  25.255 -        /// Initialize the iterator to be invalid.
  25.256 +        /// %Invalid constructor \& conversion.
  25.257  
  25.258 -        /// Initialize the iterator to be invalid.
  25.259 +        /// Initializes the iterator to be invalid.
  25.260 +        /// \sa Invalid for more details.
  25.261 +        OutArcIt(Invalid) { }
  25.262 +        /// Sets the iterator to the first outgoing arc.
  25.263 +
  25.264 +        /// Sets the iterator to the first outgoing arc of the given node.
  25.265          ///
  25.266 -        OutArcIt(Invalid) { }
  25.267 -        /// This constructor sets the iterator to the first outgoing arc.
  25.268 +        OutArcIt(const Digraph&, const Node&) { }
  25.269 +        /// Sets the iterator to the given arc.
  25.270  
  25.271 -        /// This constructor sets the iterator to the first outgoing arc of
  25.272 -        /// the node.
  25.273 -        OutArcIt(const Digraph&, const Node&) { }
  25.274 -        /// Arc -> OutArcIt conversion
  25.275 -
  25.276 -        /// Sets the iterator to the value of the trivial iterator.
  25.277 -        /// This feature necessitates that each time we
  25.278 -        /// iterate the arc-set, the iteration order is the same.
  25.279 +        /// Sets the iterator to the given arc of the given digraph.
  25.280 +        ///
  25.281          OutArcIt(const Digraph&, const Arc&) { }
  25.282 -        ///Next outgoing arc
  25.283 +        /// Next outgoing arc
  25.284  
  25.285          /// Assign the iterator to the next
  25.286          /// outgoing arc of the corresponding node.
  25.287          OutArcIt& operator++() { return *this; }
  25.288        };
  25.289  
  25.290 -      /// This iterator goes trough the incoming arcs of a node.
  25.291 +      /// Iterator class for the incoming arcs of a node.
  25.292  
  25.293        /// This iterator goes trough the \e incoming arcs of a certain node
  25.294        /// of a digraph.
  25.295        /// Its usage is quite simple, for example you can count the number
  25.296 -      /// of outgoing arcs of a node \c n
  25.297 -      /// in digraph \c g of type \c Digraph as follows.
  25.298 +      /// of incoming arcs of a node \c n
  25.299 +      /// in a digraph \c g of type \c %Digraph as follows.
  25.300        ///\code
  25.301        /// int count=0;
  25.302 -      /// for(Digraph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
  25.303 +      /// for(Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
  25.304        ///\endcode
  25.305 -
  25.306        class InArcIt : public Arc {
  25.307        public:
  25.308          /// Default constructor
  25.309  
  25.310 -        /// @warning The default constructor sets the iterator
  25.311 -        /// to an undefined value.
  25.312 +        /// Default constructor.
  25.313 +        /// \warning It sets the iterator to an undefined value.
  25.314          InArcIt() { }
  25.315          /// Copy constructor.
  25.316  
  25.317          /// Copy constructor.
  25.318          ///
  25.319          InArcIt(const InArcIt& e) : Arc(e) { }
  25.320 -        /// Initialize the iterator to be invalid.
  25.321 +        /// %Invalid constructor \& conversion.
  25.322  
  25.323 -        /// Initialize the iterator to be invalid.
  25.324 +        /// Initializes the iterator to be invalid.
  25.325 +        /// \sa Invalid for more details.
  25.326 +        InArcIt(Invalid) { }
  25.327 +        /// Sets the iterator to the first incoming arc.
  25.328 +
  25.329 +        /// Sets the iterator to the first incoming arc of the given node.
  25.330          ///
  25.331 -        InArcIt(Invalid) { }
  25.332 -        /// This constructor sets the iterator to first incoming arc.
  25.333 +        InArcIt(const Digraph&, const Node&) { }
  25.334 +        /// Sets the iterator to the given arc.
  25.335  
  25.336 -        /// This constructor set the iterator to the first incoming arc of
  25.337 -        /// the node.
  25.338 -        InArcIt(const Digraph&, const Node&) { }
  25.339 -        /// Arc -> InArcIt conversion
  25.340 -
  25.341 -        /// Sets the iterator to the value of the trivial iterator \c e.
  25.342 -        /// This feature necessitates that each time we
  25.343 -        /// iterate the arc-set, the iteration order is the same.
  25.344 +        /// Sets the iterator to the given arc of the given digraph.
  25.345 +        ///
  25.346          InArcIt(const Digraph&, const Arc&) { }
  25.347          /// Next incoming arc
  25.348  
  25.349 -        /// Assign the iterator to the next inarc of the corresponding node.
  25.350 -        ///
  25.351 +        /// Assign the iterator to the next
  25.352 +        /// incoming arc of the corresponding node.
  25.353          InArcIt& operator++() { return *this; }
  25.354        };
  25.355 -      /// This iterator goes through each arc.
  25.356  
  25.357 -      /// This iterator goes through each arc of a digraph.
  25.358 +      /// Iterator class for the arcs.
  25.359 +
  25.360 +      /// This iterator goes through each arc of the digraph.
  25.361        /// Its usage is quite simple, for example you can count the number
  25.362 -      /// of arcs in a digraph \c g of type \c Digraph as follows:
  25.363 +      /// of arcs in a digraph \c g of type \c %Digraph as follows:
  25.364        ///\code
  25.365        /// int count=0;
  25.366 -      /// for(Digraph::ArcIt e(g); e!=INVALID; ++e) ++count;
  25.367 +      /// for(Digraph::ArcIt a(g); a!=INVALID; ++a) ++count;
  25.368        ///\endcode
  25.369        class ArcIt : public Arc {
  25.370        public:
  25.371          /// Default constructor
  25.372  
  25.373 -        /// @warning The default constructor sets the iterator
  25.374 -        /// to an undefined value.
  25.375 +        /// Default constructor.
  25.376 +        /// \warning It sets the iterator to an undefined value.
  25.377          ArcIt() { }
  25.378          /// Copy constructor.
  25.379  
  25.380          /// Copy constructor.
  25.381          ///
  25.382          ArcIt(const ArcIt& e) : Arc(e) { }
  25.383 -        /// Initialize the iterator to be invalid.
  25.384 +        /// %Invalid constructor \& conversion.
  25.385  
  25.386 -        /// Initialize the iterator to be invalid.
  25.387 +        /// Initializes the iterator to be invalid.
  25.388 +        /// \sa Invalid for more details.
  25.389 +        ArcIt(Invalid) { }
  25.390 +        /// Sets the iterator to the first arc.
  25.391 +
  25.392 +        /// Sets the iterator to the first arc of the given digraph.
  25.393          ///
  25.394 -        ArcIt(Invalid) { }
  25.395 -        /// This constructor sets the iterator to the first arc.
  25.396 +        explicit ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
  25.397 +        /// Sets the iterator to the given arc.
  25.398  
  25.399 -        /// This constructor sets the iterator to the first arc of \c g.
  25.400 -        ///@param g the digraph
  25.401 -        ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
  25.402 -        /// Arc -> ArcIt conversion
  25.403 -
  25.404 -        /// Sets the iterator to the value of the trivial iterator \c e.
  25.405 -        /// This feature necessitates that each time we
  25.406 -        /// iterate the arc-set, the iteration order is the same.
  25.407 +        /// Sets the iterator to the given arc of the given digraph.
  25.408 +        ///
  25.409          ArcIt(const Digraph&, const Arc&) { }
  25.410 -        ///Next arc
  25.411 +        /// Next arc
  25.412  
  25.413          /// Assign the iterator to the next arc.
  25.414 +        ///
  25.415          ArcIt& operator++() { return *this; }
  25.416        };
  25.417 -      ///Gives back the target node of an arc.
  25.418  
  25.419 -      ///Gives back the target node of an arc.
  25.420 +      /// \brief The source node of the arc.
  25.421        ///
  25.422 -      Node target(Arc) const { return INVALID; }
  25.423 -      ///Gives back the source node of an arc.
  25.424 -
  25.425 -      ///Gives back the source node of an arc.
  25.426 -      ///
  25.427 +      /// Returns the source node of the given arc.
  25.428        Node source(Arc) const { return INVALID; }
  25.429  
  25.430 -      /// \brief Returns the ID of the node.
  25.431 +      /// \brief The target node of the arc.
  25.432 +      ///
  25.433 +      /// Returns the target node of the given arc.
  25.434 +      Node target(Arc) const { return INVALID; }
  25.435 +
  25.436 +      /// \brief The ID of the node.
  25.437 +      ///
  25.438 +      /// Returns the ID of the given node.
  25.439        int id(Node) const { return -1; }
  25.440  
  25.441 -      /// \brief Returns the ID of the arc.
  25.442 +      /// \brief The ID of the arc.
  25.443 +      ///
  25.444 +      /// Returns the ID of the given arc.
  25.445        int id(Arc) const { return -1; }
  25.446  
  25.447 -      /// \brief Returns the node with the given ID.
  25.448 +      /// \brief The node with the given ID.
  25.449        ///
  25.450 -      /// \pre The argument should be a valid node ID in the graph.
  25.451 +      /// Returns the node with the given ID.
  25.452 +      /// \pre The argument should be a valid node ID in the digraph.
  25.453        Node nodeFromId(int) const { return INVALID; }
  25.454  
  25.455 -      /// \brief Returns the arc with the given ID.
  25.456 +      /// \brief The arc with the given ID.
  25.457        ///
  25.458 -      /// \pre The argument should be a valid arc ID in the graph.
  25.459 +      /// Returns the arc with the given ID.
  25.460 +      /// \pre The argument should be a valid arc ID in the digraph.
  25.461        Arc arcFromId(int) const { return INVALID; }
  25.462  
  25.463 -      /// \brief Returns an upper bound on the node IDs.
  25.464 +      /// \brief An upper bound on the node IDs.
  25.465 +      ///
  25.466 +      /// Returns an upper bound on the node IDs.
  25.467        int maxNodeId() const { return -1; }
  25.468  
  25.469 -      /// \brief Returns an upper bound on the arc IDs.
  25.470 +      /// \brief An upper bound on the arc IDs.
  25.471 +      ///
  25.472 +      /// Returns an upper bound on the arc IDs.
  25.473        int maxArcId() const { return -1; }
  25.474  
  25.475        void first(Node&) const {}
  25.476 @@ -392,45 +390,46 @@
  25.477        // Dummy parameter.
  25.478        int maxId(Arc) const { return -1; }
  25.479  
  25.480 +      /// \brief The opposite node on the arc.
  25.481 +      ///
  25.482 +      /// Returns the opposite node on the given arc.
  25.483 +      Node oppositeNode(Node, Arc) const { return INVALID; }
  25.484 +
  25.485        /// \brief The base node of the iterator.
  25.486        ///
  25.487 -      /// Gives back the base node of the iterator.
  25.488 -      /// It is always the target of the pointed arc.
  25.489 -      Node baseNode(const InArcIt&) const { return INVALID; }
  25.490 +      /// Returns the base node of the given outgoing arc iterator
  25.491 +      /// (i.e. the source node of the corresponding arc).
  25.492 +      Node baseNode(OutArcIt) const { return INVALID; }
  25.493  
  25.494        /// \brief The running node of the iterator.
  25.495        ///
  25.496 -      /// Gives back the running node of the iterator.
  25.497 -      /// It is always the source of the pointed arc.
  25.498 -      Node runningNode(const InArcIt&) const { return INVALID; }
  25.499 +      /// Returns the running node of the given outgoing arc iterator
  25.500 +      /// (i.e. the target node of the corresponding arc).
  25.501 +      Node runningNode(OutArcIt) const { return INVALID; }
  25.502  
  25.503        /// \brief The base node of the iterator.
  25.504        ///
  25.505 -      /// Gives back the base node of the iterator.
  25.506 -      /// It is always the source of the pointed arc.
  25.507 -      Node baseNode(const OutArcIt&) const { return INVALID; }
  25.508 +      /// Returns the base node of the given incomming arc iterator
  25.509 +      /// (i.e. the target node of the corresponding arc).
  25.510 +      Node baseNode(InArcIt) const { return INVALID; }
  25.511  
  25.512        /// \brief The running node of the iterator.
  25.513        ///
  25.514 -      /// Gives back the running node of the iterator.
  25.515 -      /// It is always the target of the pointed arc.
  25.516 -      Node runningNode(const OutArcIt&) const { return INVALID; }
  25.517 +      /// Returns the running node of the given incomming arc iterator
  25.518 +      /// (i.e. the source node of the corresponding arc).
  25.519 +      Node runningNode(InArcIt) const { return INVALID; }
  25.520  
  25.521 -      /// \brief The opposite node on the given arc.
  25.522 +      /// \brief Standard graph map type for the nodes.
  25.523        ///
  25.524 -      /// Gives back the opposite node on the given arc.
  25.525 -      Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
  25.526 -
  25.527 -      /// \brief Reference map of the nodes to type \c T.
  25.528 -      ///
  25.529 -      /// Reference map of the nodes to type \c T.
  25.530 +      /// Standard graph map type for the nodes.
  25.531 +      /// It conforms to the ReferenceMap concept.
  25.532        template<class T>
  25.533        class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
  25.534        public:
  25.535  
  25.536 -        ///\e
  25.537 -        NodeMap(const Digraph&) { }
  25.538 -        ///\e
  25.539 +        /// Constructor
  25.540 +        explicit NodeMap(const Digraph&) { }
  25.541 +        /// Constructor with given initial value
  25.542          NodeMap(const Digraph&, T) { }
  25.543  
  25.544        private:
  25.545 @@ -445,17 +444,19 @@
  25.546          }
  25.547        };
  25.548  
  25.549 -      /// \brief Reference map of the arcs to type \c T.
  25.550 +      /// \brief Standard graph map type for the arcs.
  25.551        ///
  25.552 -      /// Reference map of the arcs to type \c T.
  25.553 +      /// Standard graph map type for the arcs.
  25.554 +      /// It conforms to the ReferenceMap concept.
  25.555        template<class T>
  25.556        class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
  25.557        public:
  25.558  
  25.559 -        ///\e
  25.560 -        ArcMap(const Digraph&) { }
  25.561 -        ///\e
  25.562 +        /// Constructor
  25.563 +        explicit ArcMap(const Digraph&) { }
  25.564 +        /// Constructor with given initial value
  25.565          ArcMap(const Digraph&, T) { }
  25.566 +
  25.567        private:
  25.568          ///Copy constructor
  25.569          ArcMap(const ArcMap& em) :
    26.1 --- a/lemon/concepts/graph.h	Tue Aug 18 10:08:28 2009 +0200
    26.2 +++ b/lemon/concepts/graph.h	Thu Nov 05 08:39:49 2009 +0100
    26.3 @@ -18,12 +18,14 @@
    26.4  
    26.5  ///\ingroup graph_concepts
    26.6  ///\file
    26.7 -///\brief The concept of Undirected Graphs.
    26.8 +///\brief The concept of undirected graphs.
    26.9  
   26.10  #ifndef LEMON_CONCEPTS_GRAPH_H
   26.11  #define LEMON_CONCEPTS_GRAPH_H
   26.12  
   26.13  #include <lemon/concepts/graph_components.h>
   26.14 +#include <lemon/concepts/maps.h>
   26.15 +#include <lemon/concept_check.h>
   26.16  #include <lemon/core.h>
   26.17  
   26.18  namespace lemon {
   26.19 @@ -31,63 +33,74 @@
   26.20  
   26.21      /// \ingroup graph_concepts
   26.22      ///
   26.23 -    /// \brief Class describing the concept of Undirected Graphs.
   26.24 +    /// \brief Class describing the concept of undirected graphs.
   26.25      ///
   26.26 -    /// This class describes the common interface of all Undirected
   26.27 -    /// Graphs.
   26.28 +    /// This class describes the common interface of all undirected
   26.29 +    /// graphs.
   26.30      ///
   26.31 -    /// As all concept describing classes it provides only interface
   26.32 -    /// without any sensible implementation. So any algorithm for
   26.33 -    /// undirected graph should compile with this class, but it will not
   26.34 +    /// Like all concept classes, it only provides an interface
   26.35 +    /// without any sensible implementation. So any general algorithm for
   26.36 +    /// undirected graphs should compile with this class, but it will not
   26.37      /// run properly, of course.
   26.38 +    /// An actual graph implementation like \ref ListGraph or
   26.39 +    /// \ref SmartGraph may have additional functionality.    
   26.40      ///
   26.41 -    /// The LEMON undirected graphs also fulfill the concept of
   26.42 -    /// directed graphs (\ref lemon::concepts::Digraph "Digraph
   26.43 -    /// Concept"). Each edges can be seen as two opposite
   26.44 -    /// directed arc and consequently the undirected graph can be
   26.45 -    /// seen as the direceted graph of these directed arcs. The
   26.46 -    /// Graph has the Edge inner class for the edges and
   26.47 -    /// the Arc type for the directed arcs. The Arc type is
   26.48 -    /// convertible to Edge or inherited from it so from a directed
   26.49 -    /// arc we can get the represented edge.
   26.50 +    /// The undirected graphs also fulfill the concept of \ref Digraph
   26.51 +    /// "directed graphs", since each edge can also be regarded as two
   26.52 +    /// oppositely directed arcs.
   26.53 +    /// Undirected graphs provide an Edge type for the undirected edges and
   26.54 +    /// an Arc type for the directed arcs. The Arc type is convertible to
   26.55 +    /// Edge or inherited from it, i.e. the corresponding edge can be
   26.56 +    /// obtained from an arc.
   26.57 +    /// EdgeIt and EdgeMap classes can be used for the edges, while ArcIt
   26.58 +    /// and ArcMap classes can be used for the arcs (just like in digraphs).
   26.59 +    /// Both InArcIt and OutArcIt iterates on the same edges but with
   26.60 +    /// opposite direction. IncEdgeIt also iterates on the same edges
   26.61 +    /// as OutArcIt and InArcIt, but it is not convertible to Arc,
   26.62 +    /// only to Edge.
   26.63      ///
   26.64 -    /// In the sense of the LEMON each edge has a default
   26.65 -    /// direction (it should be in every computer implementation,
   26.66 -    /// because the order of edge's nodes defines an
   26.67 -    /// orientation). With the default orientation we can define that
   26.68 -    /// the directed arc is forward or backward directed. With the \c
   26.69 -    /// direction() and \c direct() function we can get the direction
   26.70 -    /// of the directed arc and we can direct an edge.
   26.71 +    /// In LEMON, each undirected edge has an inherent orientation.
   26.72 +    /// Thus it can defined if an arc is forward or backward oriented in
   26.73 +    /// an undirected graph with respect to this default oriantation of
   26.74 +    /// the represented edge.
   26.75 +    /// With the direction() and direct() functions the direction
   26.76 +    /// of an arc can be obtained and set, respectively.
   26.77      ///
   26.78 -    /// The EdgeIt is an iterator for the edges. We can use
   26.79 -    /// the EdgeMap to map values for the edges. The InArcIt and
   26.80 -    /// OutArcIt iterates on the same edges but with opposite
   26.81 -    /// direction. The IncEdgeIt iterates also on the same edges
   26.82 -    /// as the OutArcIt and InArcIt but it is not convertible to Arc just
   26.83 -    /// to Edge.
   26.84 +    /// Only nodes and edges can be added to or removed from an undirected
   26.85 +    /// graph and the corresponding arcs are added or removed automatically.
   26.86 +    ///
   26.87 +    /// \sa Digraph
   26.88      class Graph {
   26.89 +    private:
   26.90 +      /// Graphs are \e not copy constructible. Use DigraphCopy instead.
   26.91 +      Graph(const Graph&) {}
   26.92 +      /// \brief Assignment of a graph to another one is \e not allowed.
   26.93 +      /// Use DigraphCopy instead.
   26.94 +      void operator=(const Graph&) {}
   26.95 +
   26.96      public:
   26.97 -      /// \brief The undirected graph should be tagged by the
   26.98 -      /// UndirectedTag.
   26.99 +      /// Default constructor.
  26.100 +      Graph() {}
  26.101 +
  26.102 +      /// \brief Undirected graphs should be tagged with \c UndirectedTag.
  26.103        ///
  26.104 -      /// The undirected graph should be tagged by the UndirectedTag. This
  26.105 -      /// tag helps the enable_if technics to make compile time
  26.106 +      /// Undirected graphs should be tagged with \c UndirectedTag.
  26.107 +      /// 
  26.108 +      /// This tag helps the \c enable_if technics to make compile time
  26.109        /// specializations for undirected graphs.
  26.110        typedef True UndirectedTag;
  26.111  
  26.112 -      /// \brief The base type of node iterators,
  26.113 -      /// or in other words, the trivial node iterator.
  26.114 -      ///
  26.115 -      /// This is the base type of each node iterator,
  26.116 -      /// thus each kind of node iterator converts to this.
  26.117 -      /// More precisely each kind of node iterator should be inherited
  26.118 -      /// from the trivial node iterator.
  26.119 +      /// The node type of the graph
  26.120 +
  26.121 +      /// This class identifies a node of the graph. It also serves
  26.122 +      /// as a base class of the node iterators,
  26.123 +      /// thus they convert to this type.
  26.124        class Node {
  26.125        public:
  26.126          /// Default constructor
  26.127  
  26.128 -        /// @warning The default constructor sets the iterator
  26.129 -        /// to an undefined value.
  26.130 +        /// Default constructor.
  26.131 +        /// \warning It sets the object to an undefined value.
  26.132          Node() { }
  26.133          /// Copy constructor.
  26.134  
  26.135 @@ -95,40 +108,40 @@
  26.136          ///
  26.137          Node(const Node&) { }
  26.138  
  26.139 -        /// Invalid constructor \& conversion.
  26.140 +        /// %Invalid constructor \& conversion.
  26.141  
  26.142 -        /// This constructor initializes the iterator to be invalid.
  26.143 +        /// Initializes the object to be invalid.
  26.144          /// \sa Invalid for more details.
  26.145          Node(Invalid) { }
  26.146          /// Equality operator
  26.147  
  26.148 +        /// Equality operator.
  26.149 +        ///
  26.150          /// Two iterators are equal if and only if they point to the
  26.151 -        /// same object or both are invalid.
  26.152 +        /// same object or both are \c INVALID.
  26.153          bool operator==(Node) const { return true; }
  26.154  
  26.155          /// Inequality operator
  26.156  
  26.157 -        /// \sa operator==(Node n)
  26.158 -        ///
  26.159 +        /// Inequality operator.
  26.160          bool operator!=(Node) const { return true; }
  26.161  
  26.162          /// Artificial ordering operator.
  26.163  
  26.164 -        /// To allow the use of graph descriptors as key type in std::map or
  26.165 -        /// similar associative container we require this.
  26.166 +        /// Artificial ordering operator.
  26.167          ///
  26.168 -        /// \note This operator only have to define some strict ordering of
  26.169 +        /// \note This operator only has to define some strict ordering of
  26.170          /// the items; this order has nothing to do with the iteration
  26.171          /// ordering of the items.
  26.172          bool operator<(Node) const { return false; }
  26.173  
  26.174        };
  26.175  
  26.176 -      /// This iterator goes through each node.
  26.177 +      /// Iterator class for the nodes.
  26.178  
  26.179 -      /// This iterator goes through each node.
  26.180 +      /// This iterator goes through each node of the graph.
  26.181        /// Its usage is quite simple, for example you can count the number
  26.182 -      /// of nodes in graph \c g of type \c Graph like this:
  26.183 +      /// of nodes in a graph \c g of type \c %Graph like this:
  26.184        ///\code
  26.185        /// int count=0;
  26.186        /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
  26.187 @@ -137,30 +150,28 @@
  26.188        public:
  26.189          /// Default constructor
  26.190  
  26.191 -        /// @warning The default constructor sets the iterator
  26.192 -        /// to an undefined value.
  26.193 +        /// Default constructor.
  26.194 +        /// \warning It sets the iterator to an undefined value.
  26.195          NodeIt() { }
  26.196          /// Copy constructor.
  26.197  
  26.198          /// Copy constructor.
  26.199          ///
  26.200          NodeIt(const NodeIt& n) : Node(n) { }
  26.201 -        /// Invalid constructor \& conversion.
  26.202 +        /// %Invalid constructor \& conversion.
  26.203  
  26.204 -        /// Initialize the iterator to be invalid.
  26.205 +        /// Initializes the iterator to be invalid.
  26.206          /// \sa Invalid for more details.
  26.207          NodeIt(Invalid) { }
  26.208          /// Sets the iterator to the first node.
  26.209  
  26.210 -        /// Sets the iterator to the first node of \c g.
  26.211 +        /// Sets the iterator to the first node of the given digraph.
  26.212          ///
  26.213 -        NodeIt(const Graph&) { }
  26.214 -        /// Node -> NodeIt conversion.
  26.215 +        explicit NodeIt(const Graph&) { }
  26.216 +        /// Sets the iterator to the given node.
  26.217  
  26.218 -        /// Sets the iterator to the node of \c the graph pointed by
  26.219 -        /// the trivial iterator.
  26.220 -        /// This feature necessitates that each time we
  26.221 -        /// iterate the arc-set, the iteration order is the same.
  26.222 +        /// Sets the iterator to the given node of the given digraph.
  26.223 +        ///
  26.224          NodeIt(const Graph&, const Node&) { }
  26.225          /// Next node.
  26.226  
  26.227 @@ -170,54 +181,55 @@
  26.228        };
  26.229  
  26.230  
  26.231 -      /// The base type of the edge iterators.
  26.232 +      /// The edge type of the graph
  26.233  
  26.234 -      /// The base type of the edge iterators.
  26.235 -      ///
  26.236 +      /// This class identifies an edge of the graph. It also serves
  26.237 +      /// as a base class of the edge iterators,
  26.238 +      /// thus they will convert to this type.
  26.239        class Edge {
  26.240        public:
  26.241          /// Default constructor
  26.242  
  26.243 -        /// @warning The default constructor sets the iterator
  26.244 -        /// to an undefined value.
  26.245 +        /// Default constructor.
  26.246 +        /// \warning It sets the object to an undefined value.
  26.247          Edge() { }
  26.248          /// Copy constructor.
  26.249  
  26.250          /// Copy constructor.
  26.251          ///
  26.252          Edge(const Edge&) { }
  26.253 -        /// Initialize the iterator to be invalid.
  26.254 +        /// %Invalid constructor \& conversion.
  26.255  
  26.256 -        /// Initialize the iterator to be invalid.
  26.257 -        ///
  26.258 +        /// Initializes the object to be invalid.
  26.259 +        /// \sa Invalid for more details.
  26.260          Edge(Invalid) { }
  26.261          /// Equality operator
  26.262  
  26.263 +        /// Equality operator.
  26.264 +        ///
  26.265          /// Two iterators are equal if and only if they point to the
  26.266 -        /// same object or both are invalid.
  26.267 +        /// same object or both are \c INVALID.
  26.268          bool operator==(Edge) const { return true; }
  26.269          /// Inequality operator
  26.270  
  26.271 -        /// \sa operator==(Edge n)
  26.272 -        ///
  26.273 +        /// Inequality operator.
  26.274          bool operator!=(Edge) const { return true; }
  26.275  
  26.276          /// Artificial ordering operator.
  26.277  
  26.278 -        /// To allow the use of graph descriptors as key type in std::map or
  26.279 -        /// similar associative container we require this.
  26.280 +        /// Artificial ordering operator.
  26.281          ///
  26.282 -        /// \note This operator only have to define some strict ordering of
  26.283 -        /// the items; this order has nothing to do with the iteration
  26.284 -        /// ordering of the items.
  26.285 +        /// \note This operator only has to define some strict ordering of
  26.286 +        /// the edges; this order has nothing to do with the iteration
  26.287 +        /// ordering of the edges.
  26.288          bool operator<(Edge) const { return false; }
  26.289        };
  26.290  
  26.291 -      /// This iterator goes through each edge.
  26.292 +      /// Iterator class for the edges.
  26.293  
  26.294 -      /// This iterator goes through each edge of a graph.
  26.295 +      /// This iterator goes through each edge of the graph.
  26.296        /// Its usage is quite simple, for example you can count the number
  26.297 -      /// of edges in a graph \c g of type \c Graph as follows:
  26.298 +      /// of edges in a graph \c g of type \c %Graph as follows:
  26.299        ///\code
  26.300        /// int count=0;
  26.301        /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
  26.302 @@ -226,290 +238,285 @@
  26.303        public:
  26.304          /// Default constructor
  26.305  
  26.306 -        /// @warning The default constructor sets the iterator
  26.307 -        /// to an undefined value.
  26.308 +        /// Default constructor.
  26.309 +        /// \warning It sets the iterator to an undefined value.
  26.310          EdgeIt() { }
  26.311          /// Copy constructor.
  26.312  
  26.313          /// Copy constructor.
  26.314          ///
  26.315          EdgeIt(const EdgeIt& e) : Edge(e) { }
  26.316 -        /// Initialize the iterator to be invalid.
  26.317 +        /// %Invalid constructor \& conversion.
  26.318  
  26.319 -        /// Initialize the iterator to be invalid.
  26.320 +        /// Initializes the iterator to be invalid.
  26.321 +        /// \sa Invalid for more details.
  26.322 +        EdgeIt(Invalid) { }
  26.323 +        /// Sets the iterator to the first edge.
  26.324 +
  26.325 +        /// Sets the iterator to the first edge of the given graph.
  26.326          ///
  26.327 -        EdgeIt(Invalid) { }
  26.328 -        /// This constructor sets the iterator to the first edge.
  26.329 +        explicit EdgeIt(const Graph&) { }
  26.330 +        /// Sets the iterator to the given edge.
  26.331  
  26.332 -        /// This constructor sets the iterator to the first edge.
  26.333 -        EdgeIt(const Graph&) { }
  26.334 -        /// Edge -> EdgeIt conversion
  26.335 -
  26.336 -        /// Sets the iterator to the value of the trivial iterator.
  26.337 -        /// This feature necessitates that each time we
  26.338 -        /// iterate the edge-set, the iteration order is the
  26.339 -        /// same.
  26.340 +        /// Sets the iterator to the given edge of the given graph.
  26.341 +        ///
  26.342          EdgeIt(const Graph&, const Edge&) { }
  26.343          /// Next edge
  26.344  
  26.345          /// Assign the iterator to the next edge.
  26.346 +        ///
  26.347          EdgeIt& operator++() { return *this; }
  26.348        };
  26.349  
  26.350 -      /// \brief This iterator goes trough the incident undirected
  26.351 -      /// arcs of a node.
  26.352 -      ///
  26.353 -      /// This iterator goes trough the incident edges
  26.354 -      /// of a certain node of a graph. You should assume that the
  26.355 -      /// loop arcs will be iterated twice.
  26.356 -      ///
  26.357 +      /// Iterator class for the incident edges of a node.
  26.358 +
  26.359 +      /// This iterator goes trough the incident undirected edges
  26.360 +      /// of a certain node of a graph.
  26.361        /// Its usage is quite simple, for example you can compute the
  26.362 -      /// degree (i.e. count the number of incident arcs of a node \c n
  26.363 -      /// in graph \c g of type \c Graph as follows.
  26.364 +      /// degree (i.e. the number of incident edges) of a node \c n
  26.365 +      /// in a graph \c g of type \c %Graph as follows.
  26.366        ///
  26.367        ///\code
  26.368        /// int count=0;
  26.369        /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
  26.370        ///\endcode
  26.371 +      ///
  26.372 +      /// \warning Loop edges will be iterated twice.
  26.373        class IncEdgeIt : public Edge {
  26.374        public:
  26.375          /// Default constructor
  26.376  
  26.377 -        /// @warning The default constructor sets the iterator
  26.378 -        /// to an undefined value.
  26.379 +        /// Default constructor.
  26.380 +        /// \warning It sets the iterator to an undefined value.
  26.381          IncEdgeIt() { }
  26.382          /// Copy constructor.
  26.383  
  26.384          /// Copy constructor.
  26.385          ///
  26.386          IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
  26.387 -        /// Initialize the iterator to be invalid.
  26.388 +        /// %Invalid constructor \& conversion.
  26.389  
  26.390 -        /// Initialize the iterator to be invalid.
  26.391 +        /// Initializes the iterator to be invalid.
  26.392 +        /// \sa Invalid for more details.
  26.393 +        IncEdgeIt(Invalid) { }
  26.394 +        /// Sets the iterator to the first incident edge.
  26.395 +
  26.396 +        /// Sets the iterator to the first incident edge of the given node.
  26.397          ///
  26.398 -        IncEdgeIt(Invalid) { }
  26.399 -        /// This constructor sets the iterator to first incident arc.
  26.400 +        IncEdgeIt(const Graph&, const Node&) { }
  26.401 +        /// Sets the iterator to the given edge.
  26.402  
  26.403 -        /// This constructor set the iterator to the first incident arc of
  26.404 -        /// the node.
  26.405 -        IncEdgeIt(const Graph&, const Node&) { }
  26.406 -        /// Edge -> IncEdgeIt conversion
  26.407 +        /// Sets the iterator to the given edge of the given graph.
  26.408 +        ///
  26.409 +        IncEdgeIt(const Graph&, const Edge&) { }
  26.410 +        /// Next incident edge
  26.411  
  26.412 -        /// Sets the iterator to the value of the trivial iterator \c e.
  26.413 -        /// This feature necessitates that each time we
  26.414 -        /// iterate the arc-set, the iteration order is the same.
  26.415 -        IncEdgeIt(const Graph&, const Edge&) { }
  26.416 -        /// Next incident arc
  26.417 -
  26.418 -        /// Assign the iterator to the next incident arc
  26.419 +        /// Assign the iterator to the next incident edge
  26.420          /// of the corresponding node.
  26.421          IncEdgeIt& operator++() { return *this; }
  26.422        };
  26.423  
  26.424 -      /// The directed arc type.
  26.425 +      /// The arc type of the graph
  26.426  
  26.427 -      /// The directed arc type. It can be converted to the
  26.428 -      /// edge or it should be inherited from the undirected
  26.429 -      /// edge.
  26.430 +      /// This class identifies a directed arc of the graph. It also serves
  26.431 +      /// as a base class of the arc iterators,
  26.432 +      /// thus they will convert to this type.
  26.433        class Arc {
  26.434        public:
  26.435          /// Default constructor
  26.436  
  26.437 -        /// @warning The default constructor sets the iterator
  26.438 -        /// to an undefined value.
  26.439 +        /// Default constructor.
  26.440 +        /// \warning It sets the object to an undefined value.
  26.441          Arc() { }
  26.442          /// Copy constructor.
  26.443  
  26.444          /// Copy constructor.
  26.445          ///
  26.446          Arc(const Arc&) { }
  26.447 -        /// Initialize the iterator to be invalid.
  26.448 +        /// %Invalid constructor \& conversion.
  26.449  
  26.450 -        /// Initialize the iterator to be invalid.
  26.451 -        ///
  26.452 +        /// Initializes the object to be invalid.
  26.453 +        /// \sa Invalid for more details.
  26.454          Arc(Invalid) { }
  26.455          /// Equality operator
  26.456  
  26.457 +        /// Equality operator.
  26.458 +        ///
  26.459          /// Two iterators are equal if and only if they point to the
  26.460 -        /// same object or both are invalid.
  26.461 +        /// same object or both are \c INVALID.
  26.462          bool operator==(Arc) const { return true; }
  26.463          /// Inequality operator
  26.464  
  26.465 -        /// \sa operator==(Arc n)
  26.466 -        ///
  26.467 +        /// Inequality operator.
  26.468          bool operator!=(Arc) const { return true; }
  26.469  
  26.470          /// Artificial ordering operator.
  26.471  
  26.472 -        /// To allow the use of graph descriptors as key type in std::map or
  26.473 -        /// similar associative container we require this.
  26.474 +        /// Artificial ordering operator.
  26.475          ///
  26.476 -        /// \note This operator only have to define some strict ordering of
  26.477 -        /// the items; this order has nothing to do with the iteration
  26.478 -        /// ordering of the items.
  26.479 +        /// \note This operator only has to define some strict ordering of
  26.480 +        /// the arcs; this order has nothing to do with the iteration
  26.481 +        /// ordering of the arcs.
  26.482          bool operator<(Arc) const { return false; }
  26.483  
  26.484 -        /// Converison to Edge
  26.485 +        /// Converison to \c Edge
  26.486 +        
  26.487 +        /// Converison to \c Edge.
  26.488 +        ///
  26.489          operator Edge() const { return Edge(); }
  26.490        };
  26.491 -      /// This iterator goes through each directed arc.
  26.492  
  26.493 -      /// This iterator goes through each arc of a graph.
  26.494 +      /// Iterator class for the arcs.
  26.495 +
  26.496 +      /// This iterator goes through each directed arc of the graph.
  26.497        /// Its usage is quite simple, for example you can count the number
  26.498 -      /// of arcs in a graph \c g of type \c Graph as follows:
  26.499 +      /// of arcs in a graph \c g of type \c %Graph as follows:
  26.500        ///\code
  26.501        /// int count=0;
  26.502 -      /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
  26.503 +      /// for(Graph::ArcIt a(g); a!=INVALID; ++a) ++count;
  26.504        ///\endcode
  26.505        class ArcIt : public Arc {
  26.506        public:
  26.507          /// Default constructor
  26.508  
  26.509 -        /// @warning The default constructor sets the iterator
  26.510 -        /// to an undefined value.
  26.511 +        /// Default constructor.
  26.512 +        /// \warning It sets the iterator to an undefined value.
  26.513          ArcIt() { }
  26.514          /// Copy constructor.
  26.515  
  26.516          /// Copy constructor.
  26.517          ///
  26.518          ArcIt(const ArcIt& e) : Arc(e) { }
  26.519 -        /// Initialize the iterator to be invalid.
  26.520 +        /// %Invalid constructor \& conversion.
  26.521  
  26.522 -        /// Initialize the iterator to be invalid.
  26.523 +        /// Initializes the iterator to be invalid.
  26.524 +        /// \sa Invalid for more details.
  26.525 +        ArcIt(Invalid) { }
  26.526 +        /// Sets the iterator to the first arc.
  26.527 +
  26.528 +        /// Sets the iterator to the first arc of the given graph.
  26.529          ///
  26.530 -        ArcIt(Invalid) { }
  26.531 -        /// This constructor sets the iterator to the first arc.
  26.532 +        explicit ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
  26.533 +        /// Sets the iterator to the given arc.
  26.534  
  26.535 -        /// This constructor sets the iterator to the first arc of \c g.
  26.536 -        ///@param g the graph
  26.537 -        ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
  26.538 -        /// Arc -> ArcIt conversion
  26.539 -
  26.540 -        /// Sets the iterator to the value of the trivial iterator \c e.
  26.541 -        /// This feature necessitates that each time we
  26.542 -        /// iterate the arc-set, the iteration order is the same.
  26.543 +        /// Sets the iterator to the given arc of the given graph.
  26.544 +        ///
  26.545          ArcIt(const Graph&, const Arc&) { }
  26.546 -        ///Next arc
  26.547 +        /// Next arc
  26.548  
  26.549          /// Assign the iterator to the next arc.
  26.550 +        ///
  26.551          ArcIt& operator++() { return *this; }
  26.552        };
  26.553  
  26.554 -      /// This iterator goes trough the outgoing directed arcs of a node.
  26.555 +      /// Iterator class for the outgoing arcs of a node.
  26.556  
  26.557 -      /// This iterator goes trough the \e outgoing arcs of a certain node
  26.558 -      /// of a graph.
  26.559 +      /// This iterator goes trough the \e outgoing directed arcs of a
  26.560 +      /// certain node of a graph.
  26.561        /// Its usage is quite simple, for example you can count the number
  26.562        /// of outgoing arcs of a node \c n
  26.563 -      /// in graph \c g of type \c Graph as follows.
  26.564 +      /// in a graph \c g of type \c %Graph as follows.
  26.565        ///\code
  26.566        /// int count=0;
  26.567 -      /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
  26.568 +      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
  26.569        ///\endcode
  26.570 -
  26.571        class OutArcIt : public Arc {
  26.572        public:
  26.573          /// Default constructor
  26.574  
  26.575 -        /// @warning The default constructor sets the iterator
  26.576 -        /// to an undefined value.
  26.577 +        /// Default constructor.
  26.578 +        /// \warning It sets the iterator to an undefined value.
  26.579          OutArcIt() { }
  26.580          /// Copy constructor.
  26.581  
  26.582          /// Copy constructor.
  26.583          ///
  26.584          OutArcIt(const OutArcIt& e) : Arc(e) { }
  26.585 -        /// Initialize the iterator to be invalid.
  26.586 +        /// %Invalid constructor \& conversion.
  26.587  
  26.588 -        /// Initialize the iterator to be invalid.
  26.589 +        /// Initializes the iterator to be invalid.
  26.590 +        /// \sa Invalid for more details.
  26.591 +        OutArcIt(Invalid) { }
  26.592 +        /// Sets the iterator to the first outgoing arc.
  26.593 +
  26.594 +        /// Sets the iterator to the first outgoing arc of the given node.
  26.595          ///
  26.596 -        OutArcIt(Invalid) { }
  26.597 -        /// This constructor sets the iterator to the first outgoing arc.
  26.598 -
  26.599 -        /// This constructor sets the iterator to the first outgoing arc of
  26.600 -        /// the node.
  26.601 -        ///@param n the node
  26.602 -        ///@param g the graph
  26.603          OutArcIt(const Graph& n, const Node& g) {
  26.604            ignore_unused_variable_warning(n);
  26.605            ignore_unused_variable_warning(g);
  26.606          }
  26.607 -        /// Arc -> OutArcIt conversion
  26.608 +        /// Sets the iterator to the given arc.
  26.609  
  26.610 -        /// Sets the iterator to the value of the trivial iterator.
  26.611 -        /// This feature necessitates that each time we
  26.612 -        /// iterate the arc-set, the iteration order is the same.
  26.613 +        /// Sets the iterator to the given arc of the given graph.
  26.614 +        ///
  26.615          OutArcIt(const Graph&, const Arc&) { }
  26.616 -        ///Next outgoing arc
  26.617 +        /// Next outgoing arc
  26.618  
  26.619          /// Assign the iterator to the next
  26.620          /// outgoing arc of the corresponding node.
  26.621          OutArcIt& operator++() { return *this; }
  26.622        };
  26.623  
  26.624 -      /// This iterator goes trough the incoming directed arcs of a node.
  26.625 +      /// Iterator class for the incoming arcs of a node.
  26.626  
  26.627 -      /// This iterator goes trough the \e incoming arcs of a certain node
  26.628 -      /// of a graph.
  26.629 +      /// This iterator goes trough the \e incoming directed arcs of a
  26.630 +      /// certain node of a graph.
  26.631        /// Its usage is quite simple, for example you can count the number
  26.632 -      /// of outgoing arcs of a node \c n
  26.633 -      /// in graph \c g of type \c Graph as follows.
  26.634 +      /// of incoming arcs of a node \c n
  26.635 +      /// in a graph \c g of type \c %Graph as follows.
  26.636        ///\code
  26.637        /// int count=0;
  26.638 -      /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
  26.639 +      /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
  26.640        ///\endcode
  26.641 -
  26.642        class InArcIt : public Arc {
  26.643        public:
  26.644          /// Default constructor
  26.645  
  26.646 -        /// @warning The default constructor sets the iterator
  26.647 -        /// to an undefined value.
  26.648 +        /// Default constructor.
  26.649 +        /// \warning It sets the iterator to an undefined value.
  26.650          InArcIt() { }
  26.651          /// Copy constructor.
  26.652  
  26.653          /// Copy constructor.
  26.654          ///
  26.655          InArcIt(const InArcIt& e) : Arc(e) { }
  26.656 -        /// Initialize the iterator to be invalid.
  26.657 +        /// %Invalid constructor \& conversion.
  26.658  
  26.659 -        /// Initialize the iterator to be invalid.
  26.660 +        /// Initializes the iterator to be invalid.
  26.661 +        /// \sa Invalid for more details.
  26.662 +        InArcIt(Invalid) { }
  26.663 +        /// Sets the iterator to the first incoming arc.
  26.664 +
  26.665 +        /// Sets the iterator to the first incoming arc of the given node.
  26.666          ///
  26.667 -        InArcIt(Invalid) { }
  26.668 -        /// This constructor sets the iterator to first incoming arc.
  26.669 -
  26.670 -        /// This constructor set the iterator to the first incoming arc of
  26.671 -        /// the node.
  26.672 -        ///@param n the node
  26.673 -        ///@param g the graph
  26.674          InArcIt(const Graph& g, const Node& n) {
  26.675            ignore_unused_variable_warning(n);
  26.676            ignore_unused_variable_warning(g);
  26.677          }
  26.678 -        /// Arc -> InArcIt conversion
  26.679 +        /// Sets the iterator to the given arc.
  26.680  
  26.681 -        /// Sets the iterator to the value of the trivial iterator \c e.
  26.682 -        /// This feature necessitates that each time we
  26.683 -        /// iterate the arc-set, the iteration order is the same.
  26.684 +        /// Sets the iterator to the given arc of the given graph.
  26.685 +        ///
  26.686          InArcIt(const Graph&, const Arc&) { }
  26.687          /// Next incoming arc
  26.688  
  26.689 -        /// Assign the iterator to the next inarc of the corresponding node.
  26.690 -        ///
  26.691 +        /// Assign the iterator to the next
  26.692 +        /// incoming arc of the corresponding node.
  26.693          InArcIt& operator++() { return *this; }
  26.694        };
  26.695  
  26.696 -      /// \brief Reference map of the nodes to type \c T.
  26.697 +      /// \brief Standard graph map type for the nodes.
  26.698        ///
  26.699 -      /// Reference map of the nodes to type \c T.
  26.700 +      /// Standard graph map type for the nodes.
  26.701 +      /// It conforms to the ReferenceMap concept.
  26.702        template<class T>
  26.703        class NodeMap : public ReferenceMap<Node, T, T&, const T&>
  26.704        {
  26.705        public:
  26.706  
  26.707 -        ///\e
  26.708 -        NodeMap(const Graph&) { }
  26.709 -        ///\e
  26.710 +        /// Constructor
  26.711 +        explicit NodeMap(const Graph&) { }
  26.712 +        /// Constructor with given initial value
  26.713          NodeMap(const Graph&, T) { }
  26.714  
  26.715        private:
  26.716 @@ -524,18 +531,20 @@
  26.717          }
  26.718        };
  26.719  
  26.720 -      /// \brief Reference map of the arcs to type \c T.
  26.721 +      /// \brief Standard graph map type for the arcs.
  26.722        ///
  26.723 -      /// Reference map of the arcs to type \c T.
  26.724 +      /// Standard graph map type for the arcs.
  26.725 +      /// It conforms to the ReferenceMap concept.
  26.726        template<class T>
  26.727        class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
  26.728        {
  26.729        public:
  26.730  
  26.731 -        ///\e
  26.732 -        ArcMap(const Graph&) { }
  26.733 -        ///\e
  26.734 +        /// Constructor
  26.735 +        explicit ArcMap(const Graph&) { }
  26.736 +        /// Constructor with given initial value
  26.737          ArcMap(const Graph&, T) { }
  26.738 +
  26.739        private:
  26.740          ///Copy constructor
  26.741          ArcMap(const ArcMap& em) :
  26.742 @@ -548,18 +557,20 @@
  26.743          }
  26.744        };
  26.745  
  26.746 -      /// Reference map of the edges to type \c T.
  26.747 -
  26.748 -      /// Reference map of the edges to type \c T.
  26.749 +      /// \brief Standard graph map type for the edges.
  26.750 +      ///
  26.751 +      /// Standard graph map type for the edges.
  26.752 +      /// It conforms to the ReferenceMap concept.
  26.753        template<class T>
  26.754        class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
  26.755        {
  26.756        public:
  26.757  
  26.758 -        ///\e
  26.759 -        EdgeMap(const Graph&) { }
  26.760 -        ///\e
  26.761 +        /// Constructor
  26.762 +        explicit EdgeMap(const Graph&) { }
  26.763 +        /// Constructor with given initial value
  26.764          EdgeMap(const Graph&, T) { }
  26.765 +
  26.766        private:
  26.767          ///Copy constructor
  26.768          EdgeMap(const EdgeMap& em) :
  26.769 @@ -572,107 +583,124 @@
  26.770          }
  26.771        };
  26.772  
  26.773 -      /// \brief Direct the given edge.
  26.774 +      /// \brief The first node of the edge.
  26.775        ///
  26.776 -      /// Direct the given edge. The returned arc source
  26.777 -      /// will be the given node.
  26.778 -      Arc direct(const Edge&, const Node&) const {
  26.779 -        return INVALID;
  26.780 -      }
  26.781 -
  26.782 -      /// \brief Direct the given edge.
  26.783 +      /// Returns the first node of the given edge.
  26.784        ///
  26.785 -      /// Direct the given edge. The returned arc
  26.786 -      /// represents the given edge and the direction comes
  26.787 -      /// from the bool parameter. The source of the edge and
  26.788 -      /// the directed arc is the same when the given bool is true.
  26.789 -      Arc direct(const Edge&, bool) const {
  26.790 -        return INVALID;
  26.791 -      }
  26.792 -
  26.793 -      /// \brief Returns true if the arc has default orientation.
  26.794 -      ///
  26.795 -      /// Returns whether the given directed arc is same orientation as
  26.796 -      /// the corresponding edge's default orientation.
  26.797 -      bool direction(Arc) const { return true; }
  26.798 -
  26.799 -      /// \brief Returns the opposite directed arc.
  26.800 -      ///
  26.801 -      /// Returns the opposite directed arc.
  26.802 -      Arc oppositeArc(Arc) const { return INVALID; }
  26.803 -
  26.804 -      /// \brief Opposite node on an arc
  26.805 -      ///
  26.806 -      /// \return The opposite of the given node on the given edge.
  26.807 -      Node oppositeNode(Node, Edge) const { return INVALID; }
  26.808 -
  26.809 -      /// \brief First node of the edge.
  26.810 -      ///
  26.811 -      /// \return The first node of the given edge.
  26.812 -      ///
  26.813 -      /// Naturally edges don't have direction and thus
  26.814 -      /// don't have source and target node. However we use \c u() and \c v()
  26.815 -      /// methods to query the two nodes of the arc. The direction of the
  26.816 -      /// arc which arises this way is called the inherent direction of the
  26.817 -      /// edge, and is used to define the "default" direction
  26.818 -      /// of the directed versions of the arcs.
  26.819 +      /// Edges don't have source and target nodes, however methods
  26.820 +      /// u() and v() are used to query the two end-nodes of an edge.
  26.821 +      /// The orientation of an edge that arises this way is called
  26.822 +      /// the inherent direction, it is used to define the default
  26.823 +      /// direction for the corresponding arcs.
  26.824        /// \sa v()
  26.825        /// \sa direction()
  26.826        Node u(Edge) const { return INVALID; }
  26.827  
  26.828 -      /// \brief Second node of the edge.
  26.829 +      /// \brief The second node of the edge.
  26.830        ///
  26.831 -      /// \return The second node of the given edge.
  26.832 +      /// Returns the second node of the given edge.
  26.833        ///
  26.834 -      /// Naturally edges don't have direction and thus
  26.835 -      /// don't have source and target node. However we use \c u() and \c v()
  26.836 -      /// methods to query the two nodes of the arc. The direction of the
  26.837 -      /// arc which arises this way is called the inherent direction of the
  26.838 -      /// edge, and is used to define the "default" direction
  26.839 -      /// of the directed versions of the arcs.
  26.840 +      /// Edges don't have source and target nodes, however methods
  26.841 +      /// u() and v() are used to query the two end-nodes of an edge.
  26.842 +      /// The orientation of an edge that arises this way is called
  26.843 +      /// the inherent direction, it is used to define the default
  26.844 +      /// direction for the corresponding arcs.
  26.845        /// \sa u()
  26.846        /// \sa direction()
  26.847        Node v(Edge) const { return INVALID; }
  26.848  
  26.849 -      /// \brief Source node of the directed arc.
  26.850 +      /// \brief The source node of the arc.
  26.851 +      ///
  26.852 +      /// Returns the source node of the given arc.
  26.853        Node source(Arc) const { return INVALID; }
  26.854  
  26.855 -      /// \brief Target node of the directed arc.
  26.856 +      /// \brief The target node of the arc.
  26.857 +      ///
  26.858 +      /// Returns the target node of the given arc.
  26.859        Node target(Arc) const { return INVALID; }
  26.860  
  26.861 -      /// \brief Returns the id of the node.
  26.862 +      /// \brief The ID of the node.
  26.863 +      ///
  26.864 +      /// Returns the ID of the given node.
  26.865        int id(Node) const { return -1; }
  26.866  
  26.867 -      /// \brief Returns the id of the edge.
  26.868 +      /// \brief The ID of the edge.
  26.869 +      ///
  26.870 +      /// Returns the ID of the given edge.
  26.871        int id(Edge) const { return -1; }
  26.872  
  26.873 -      /// \brief Returns the id of the arc.
  26.874 +      /// \brief The ID of the arc.
  26.875 +      ///
  26.876 +      /// Returns the ID of the given arc.
  26.877        int id(Arc) const { return -1; }
  26.878  
  26.879 -      /// \brief Returns the node with the given id.
  26.880 +      /// \brief The node with the given ID.
  26.881        ///
  26.882 -      /// \pre The argument should be a valid node id in the graph.
  26.883 +      /// Returns the node with the given ID.
  26.884 +      /// \pre The argument should be a valid node ID in the graph.
  26.885        Node nodeFromId(int) const { return INVALID; }
  26.886  
  26.887 -      /// \brief Returns the edge with the given id.
  26.888 +      /// \brief The edge with the given ID.
  26.889        ///
  26.890 -      /// \pre The argument should be a valid edge id in the graph.
  26.891 +      /// Returns the edge with the given ID.
  26.892 +      /// \pre The argument should be a valid edge ID in the graph.
  26.893        Edge edgeFromId(int) const { return INVALID; }
  26.894  
  26.895 -      /// \brief Returns the arc with the given id.
  26.896 +      /// \brief The arc with the given ID.
  26.897        ///
  26.898 -      /// \pre The argument should be a valid arc id in the graph.
  26.899 +      /// Returns the arc with the given ID.
  26.900 +      /// \pre The argument should be a valid arc ID in the graph.
  26.901        Arc arcFromId(int) const { return INVALID; }
  26.902  
  26.903 -      /// \brief Returns an upper bound on the node IDs.
  26.904 +      /// \brief An upper bound on the node IDs.
  26.905 +      ///
  26.906 +      /// Returns an upper bound on the node IDs.
  26.907        int maxNodeId() const { return -1; }
  26.908  
  26.909 -      /// \brief Returns an upper bound on the edge IDs.
  26.910 +      /// \brief An upper bound on the edge IDs.
  26.911 +      ///
  26.912 +      /// Returns an upper bound on the edge IDs.
  26.913        int maxEdgeId() const { return -1; }
  26.914  
  26.915 -      /// \brief Returns an upper bound on the arc IDs.
  26.916 +      /// \brief An upper bound on the arc IDs.
  26.917 +      ///
  26.918 +      /// Returns an upper bound on the arc IDs.
  26.919        int maxArcId() const { return -1; }
  26.920  
  26.921 +      /// \brief The direction of the arc.
  26.922 +      ///
  26.923 +      /// Returns \c true if the direction of the given arc is the same as
  26.924 +      /// the inherent orientation of the represented edge.
  26.925 +      bool direction(Arc) const { return true; }
  26.926 +
  26.927 +      /// \brief Direct the edge.
  26.928 +      ///
  26.929 +      /// Direct the given edge. The returned arc
  26.930 +      /// represents the given edge and its direction comes
  26.931 +      /// from the bool parameter. If it is \c true, then the direction
  26.932 +      /// of the arc is the same as the inherent orientation of the edge.
  26.933 +      Arc direct(Edge, bool) const {
  26.934 +        return INVALID;
  26.935 +      }
  26.936 +
  26.937 +      /// \brief Direct the edge.
  26.938 +      ///
  26.939 +      /// Direct the given edge. The returned arc represents the given
  26.940 +      /// edge and its source node is the given node.
  26.941 +      Arc direct(Edge, Node) const {
  26.942 +        return INVALID;
  26.943 +      }
  26.944 +
  26.945 +      /// \brief The oppositely directed arc.
  26.946 +      ///
  26.947 +      /// Returns the oppositely directed arc representing the same edge.
  26.948 +      Arc oppositeArc(Arc) const { return INVALID; }
  26.949 +
  26.950 +      /// \brief The opposite node on the edge.
  26.951 +      ///
  26.952 +      /// Returns the opposite node on the given edge.
  26.953 +      Node oppositeNode(Node, Edge) const { return INVALID; }
  26.954 +
  26.955        void first(Node&) const {}
  26.956        void next(Node&) const {}
  26.957  
  26.958 @@ -705,47 +733,39 @@
  26.959        // Dummy parameter.
  26.960        int maxId(Arc) const { return -1; }
  26.961  
  26.962 -      /// \brief Base node of the iterator
  26.963 +      /// \brief The base node of the iterator.
  26.964        ///
  26.965 -      /// Returns the base node (the source in this case) of the iterator
  26.966 -      Node baseNode(OutArcIt e) const {
  26.967 -        return source(e);
  26.968 -      }
  26.969 -      /// \brief Running node of the iterator
  26.970 +      /// Returns the base node of the given incident edge iterator.
  26.971 +      Node baseNode(IncEdgeIt) const { return INVALID; }
  26.972 +
  26.973 +      /// \brief The running node of the iterator.
  26.974        ///
  26.975 -      /// Returns the running node (the target in this case) of the
  26.976 -      /// iterator
  26.977 -      Node runningNode(OutArcIt e) const {
  26.978 -        return target(e);
  26.979 -      }
  26.980 +      /// Returns the running node of the given incident edge iterator.
  26.981 +      Node runningNode(IncEdgeIt) const { return INVALID; }
  26.982  
  26.983 -      /// \brief Base node of the iterator
  26.984 +      /// \brief The base node of the iterator.
  26.985        ///
  26.986 -      /// Returns the base node (the target in this case) of the iterator
  26.987 -      Node baseNode(InArcIt e) const {
  26.988 -        return target(e);
  26.989 -      }
  26.990 -      /// \brief Running node of the iterator
  26.991 +      /// Returns the base node of the given outgoing arc iterator
  26.992 +      /// (i.e. the source node of the corresponding arc).
  26.993 +      Node baseNode(OutArcIt) const { return INVALID; }
  26.994 +
  26.995 +      /// \brief The running node of the iterator.
  26.996        ///
  26.997 -      /// Returns the running node (the source in this case) of the
  26.998 -      /// iterator
  26.999 -      Node runningNode(InArcIt e) const {
 26.1000 -        return source(e);
 26.1001 -      }
 26.1002 +      /// Returns the running node of the given outgoing arc iterator
 26.1003 +      /// (i.e. the target node of the corresponding arc).
 26.1004 +      Node runningNode(OutArcIt) const { return INVALID; }
 26.1005  
 26.1006 -      /// \brief Base node of the iterator
 26.1007 +      /// \brief The base node of the iterator.
 26.1008        ///
 26.1009 -      /// Returns the base node of the iterator
 26.1010 -      Node baseNode(IncEdgeIt) const {
 26.1011 -        return INVALID;
 26.1012 -      }
 26.1013 +      /// Returns the base node of the given incomming arc iterator
 26.1014 +      /// (i.e. the target node of the corresponding arc).
 26.1015 +      Node baseNode(InArcIt) const { return INVALID; }
 26.1016  
 26.1017 -      /// \brief Running node of the iterator
 26.1018 +      /// \brief The running node of the iterator.
 26.1019        ///
 26.1020 -      /// Returns the running node of the iterator
 26.1021 -      Node runningNode(IncEdgeIt) const {
 26.1022 -        return INVALID;
 26.1023 -      }
 26.1024 +      /// Returns the running node of the given incomming arc iterator
 26.1025 +      /// (i.e. the source node of the corresponding arc).
 26.1026 +      Node runningNode(InArcIt) const { return INVALID; }
 26.1027  
 26.1028        template <typename _Graph>
 26.1029        struct Constraints {
    27.1 --- a/lemon/concepts/graph_components.h	Tue Aug 18 10:08:28 2009 +0200
    27.2 +++ b/lemon/concepts/graph_components.h	Thu Nov 05 08:39:49 2009 +0100
    27.3 @@ -92,7 +92,7 @@
    27.4        /// It makes possible to use graph item types as key types in 
    27.5        /// associative containers (e.g. \c std::map).
    27.6        ///
    27.7 -      /// \note This operator only have to define some strict ordering of
    27.8 +      /// \note This operator only has to define some strict ordering of
    27.9        /// the items; this order has nothing to do with the iteration
   27.10        /// ordering of the items.
   27.11        bool operator<(const GraphItem&) const { return false; }
    28.1 --- a/lemon/concepts/heap.h	Tue Aug 18 10:08:28 2009 +0200
    28.2 +++ b/lemon/concepts/heap.h	Thu Nov 05 08:39:49 2009 +0100
    28.3 @@ -16,13 +16,13 @@
    28.4   *
    28.5   */
    28.6  
    28.7 +#ifndef LEMON_CONCEPTS_HEAP_H
    28.8 +#define LEMON_CONCEPTS_HEAP_H
    28.9 +
   28.10  ///\ingroup concept
   28.11  ///\file
   28.12  ///\brief The concept of heaps.
   28.13  
   28.14 -#ifndef LEMON_CONCEPTS_HEAP_H
   28.15 -#define LEMON_CONCEPTS_HEAP_H
   28.16 -
   28.17  #include <lemon/core.h>
   28.18  #include <lemon/concept_check.h>
   28.19  
   28.20 @@ -35,21 +35,27 @@
   28.21  
   28.22      /// \brief The heap concept.
   28.23      ///
   28.24 -    /// Concept class describing the main interface of heaps. A \e heap
   28.25 -    /// is a data structure for storing items with specified values called
   28.26 -    /// \e priorities in such a way that finding the item with minimum
   28.27 -    /// priority is efficient. In a heap one can change the priority of an
   28.28 -    /// item, add or erase an item, etc.
   28.29 +    /// This concept class describes the main interface of heaps.
   28.30 +    /// The various \ref heaps "heap structures" are efficient
   28.31 +    /// implementations of the abstract data type \e priority \e queue.
   28.32 +    /// They store items with specified values called \e priorities
   28.33 +    /// in such a way that finding and removing the item with minimum
   28.34 +    /// priority are efficient. The basic operations are adding and
   28.35 +    /// erasing items, changing the priority of an item, etc.
   28.36      ///
   28.37 -    /// \tparam PR Type of the priority of the items.
   28.38 -    /// \tparam IM A read and writable item map with int values, used
   28.39 +    /// Heaps are crucial in several algorithms, such as Dijkstra and Prim.
   28.40 +    /// Any class that conforms to this concept can be used easily in such
   28.41 +    /// algorithms.
   28.42 +    ///
   28.43 +    /// \tparam PR Type of the priorities of the items.
   28.44 +    /// \tparam IM A read-writable item map with \c int values, used
   28.45      /// internally to handle the cross references.
   28.46 -    /// \tparam Comp A functor class for the ordering of the priorities.
   28.47 +    /// \tparam CMP A functor class for comparing the priorities.
   28.48      /// The default is \c std::less<PR>.
   28.49  #ifdef DOXYGEN
   28.50 -    template <typename PR, typename IM, typename Comp = std::less<PR> >
   28.51 +    template <typename PR, typename IM, typename CMP>
   28.52  #else
   28.53 -    template <typename PR, typename IM>
   28.54 +    template <typename PR, typename IM, typename CMP = std::less<PR> >
   28.55  #endif
   28.56      class Heap {
   28.57      public:
   28.58 @@ -64,109 +70,125 @@
   28.59        /// \brief Type to represent the states of the items.
   28.60        ///
   28.61        /// Each item has a state associated to it. It can be "in heap",
   28.62 -      /// "pre heap" or "post heap". The later two are indifferent
   28.63 -      /// from the point of view of the heap, but may be useful for
   28.64 -      /// the user.
   28.65 +      /// "pre-heap" or "post-heap". The latter two are indifferent from the
   28.66 +      /// heap's point of view, but may be useful to the user.
   28.67        ///
   28.68        /// The item-int map must be initialized in such way that it assigns
   28.69        /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap.
   28.70        enum State {
   28.71          IN_HEAP = 0,    ///< = 0. The "in heap" state constant.
   28.72 -        PRE_HEAP = -1,  ///< = -1. The "pre heap" state constant.
   28.73 -        POST_HEAP = -2  ///< = -2. The "post heap" state constant.
   28.74 +        PRE_HEAP = -1,  ///< = -1. The "pre-heap" state constant.
   28.75 +        POST_HEAP = -2  ///< = -2. The "post-heap" state constant.
   28.76        };
   28.77  
   28.78 -      /// \brief The constructor.
   28.79 +      /// \brief Constructor.
   28.80        ///
   28.81 -      /// The constructor.
   28.82 +      /// Constructor.
   28.83        /// \param map A map that assigns \c int values to keys of type
   28.84        /// \c Item. It is used internally by the heap implementations to
   28.85        /// handle the cross references. The assigned value must be
   28.86 -      /// \c PRE_HEAP (<tt>-1</tt>) for every item.
   28.87 +      /// \c PRE_HEAP (<tt>-1</tt>) for each item.
   28.88        explicit Heap(ItemIntMap &map) {}
   28.89  
   28.90 +      /// \brief Constructor.
   28.91 +      ///
   28.92 +      /// Constructor.
   28.93 +      /// \param map A map that assigns \c int values to keys of type
   28.94 +      /// \c Item. It is used internally by the heap implementations to
   28.95 +      /// handle the cross references. The assigned value must be
   28.96 +      /// \c PRE_HEAP (<tt>-1</tt>) for each item.
   28.97 +      /// \param comp The function object used for comparing the priorities.
   28.98 +      explicit Heap(ItemIntMap &map, const CMP &comp) {}
   28.99 +
  28.100        /// \brief The number of items stored in the heap.
  28.101        ///
  28.102 -      /// Returns the number of items stored in the heap.
  28.103 +      /// This function returns the number of items stored in the heap.
  28.104        int size() const { return 0; }
  28.105  
  28.106 -      /// \brief Checks if the heap is empty.
  28.107 +      /// \brief Check if the heap is empty.
  28.108        ///
  28.109 -      /// Returns \c true if the heap is empty.
  28.110 +      /// This function returns \c true if the heap is empty.
  28.111        bool empty() const { return false; }
  28.112  
  28.113 -      /// \brief Makes the heap empty.
  28.114 +      /// \brief Make the heap empty.
  28.115        ///
  28.116 -      /// Makes the heap empty.
  28.117 -      void clear();
  28.118 +      /// This functon makes the heap empty.
  28.119 +      /// It does not change the cross reference map. If you want to reuse
  28.120 +      /// a heap that is not surely empty, you should first clear it and
  28.121 +      /// then you should set the cross reference map to \c PRE_HEAP
  28.122 +      /// for each item.
  28.123 +      void clear() {}
  28.124  
  28.125 -      /// \brief Inserts an item into the heap with the given priority.
  28.126 +      /// \brief Insert an item into the heap with the given priority.
  28.127        ///
  28.128 -      /// Inserts the given item into the heap with the given priority.
  28.129 +      /// This function inserts the given item into the heap with the
  28.130 +      /// given priority.
  28.131        /// \param i The item to insert.
  28.132        /// \param p The priority of the item.
  28.133 +      /// \pre \e i must not be stored in the heap.
  28.134        void push(const Item &i, const Prio &p) {}
  28.135  
  28.136 -      /// \brief Returns the item having minimum priority.
  28.137 +      /// \brief Return the item having minimum priority.
  28.138        ///
  28.139 -      /// Returns the item having minimum priority.
  28.140 +      /// This function returns the item having minimum priority.
  28.141        /// \pre The heap must be non-empty.
  28.142        Item top() const {}
  28.143  
  28.144        /// \brief The minimum priority.
  28.145        ///
  28.146 -      /// Returns the minimum priority.
  28.147 +      /// This function returns the minimum priority.
  28.148        /// \pre The heap must be non-empty.
  28.149        Prio prio() const {}
  28.150  
  28.151 -      /// \brief Removes the item having minimum priority.
  28.152 +      /// \brief Remove the item having minimum priority.
  28.153        ///
  28.154 -      /// Removes the item having minimum priority.
  28.155 +      /// This function removes the item having minimum priority.
  28.156        /// \pre The heap must be non-empty.
  28.157        void pop() {}
  28.158  
  28.159 -      /// \brief Removes an item from the heap.
  28.160 +      /// \brief Remove the given item from the heap.
  28.161        ///
  28.162 -      /// Removes the given item from the heap if it is already stored.
  28.163 +      /// This function removes the given item from the heap if it is
  28.164 +      /// already stored.
  28.165        /// \param i The item to delete.
  28.166 +      /// \pre \e i must be in the heap.
  28.167        void erase(const Item &i) {}
  28.168  
  28.169 -      /// \brief The priority of an item.
  28.170 +      /// \brief The priority of the given item.
  28.171        ///
  28.172 -      /// Returns the priority of the given item.
  28.173 +      /// This function returns the priority of the given item.
  28.174        /// \param i The item.
  28.175 -      /// \pre \c i must be in the heap.
  28.176 +      /// \pre \e i must be in the heap.
  28.177        Prio operator[](const Item &i) const {}
  28.178  
  28.179 -      /// \brief Sets the priority of an item or inserts it, if it is
  28.180 +      /// \brief Set the priority of an item or insert it, if it is
  28.181        /// not stored in the heap.
  28.182        ///
  28.183        /// This method sets the priority of the given item if it is
  28.184 -      /// already stored in the heap.
  28.185 -      /// Otherwise it inserts the given item with the given priority.
  28.186 +      /// already stored in the heap. Otherwise it inserts the given
  28.187 +      /// item into the heap with the given priority.
  28.188        ///
  28.189        /// \param i The item.
  28.190        /// \param p The priority.
  28.191        void set(const Item &i, const Prio &p) {}
  28.192  
  28.193 -      /// \brief Decreases the priority of an item to the given value.
  28.194 +      /// \brief Decrease the priority of an item to the given value.
  28.195        ///
  28.196 -      /// Decreases the priority of an item to the given value.
  28.197 +      /// This function decreases the priority of an item to the given value.
  28.198        /// \param i The item.
  28.199        /// \param p The priority.
  28.200 -      /// \pre \c i must be stored in the heap with priority at least \c p.
  28.201 +      /// \pre \e i must be stored in the heap with priority at least \e p.
  28.202        void decrease(const Item &i, const Prio &p) {}
  28.203  
  28.204 -      /// \brief Increases the priority of an item to the given value.
  28.205 +      /// \brief Increase the priority of an item to the given value.
  28.206        ///
  28.207 -      /// Increases the priority of an item to the given value.
  28.208 +      /// This function increases the priority of an item to the given value.
  28.209        /// \param i The item.
  28.210        /// \param p The priority.
  28.211 -      /// \pre \c i must be stored in the heap with priority at most \c p.
  28.212 +      /// \pre \e i must be stored in the heap with priority at most \e p.
  28.213        void increase(const Item &i, const Prio &p) {}
  28.214  
  28.215 -      /// \brief Returns if an item is in, has already been in, or has
  28.216 -      /// never been in the heap.
  28.217 +      /// \brief Return the state of an item.
  28.218        ///
  28.219        /// This method returns \c PRE_HEAP if the given item has never
  28.220        /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  28.221 @@ -176,11 +198,11 @@
  28.222        /// \param i The item.
  28.223        State state(const Item &i) const {}
  28.224  
  28.225 -      /// \brief Sets the state of an item in the heap.
  28.226 +      /// \brief Set the state of an item in the heap.
  28.227        ///
  28.228 -      /// Sets the state of the given item in the heap. It can be used
  28.229 -      /// to manually clear the heap when it is important to achive the
  28.230 -      /// better time complexity.
  28.231 +      /// This function sets the state of the given item in the heap.
  28.232 +      /// It can be used to manually clear the heap when it is important
  28.233 +      /// to achive better time complexity.
  28.234        /// \param i The item.
  28.235        /// \param st The state. It should not be \c IN_HEAP.
  28.236        void state(const Item& i, State st) {}
    29.1 --- a/lemon/concepts/maps.h	Tue Aug 18 10:08:28 2009 +0200
    29.2 +++ b/lemon/concepts/maps.h	Thu Nov 05 08:39:49 2009 +0100
    29.3 @@ -182,7 +182,8 @@
    29.4  
    29.5        template<typename _ReferenceMap>
    29.6        struct Constraints {
    29.7 -        void constraints() {
    29.8 +        typename enable_if<typename _ReferenceMap::ReferenceMapTag, void>::type
    29.9 +        constraints() {
   29.10            checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
   29.11            ref = m[key];
   29.12            m[key] = val;
    30.1 --- a/lemon/cplex.cc	Tue Aug 18 10:08:28 2009 +0200
    30.2 +++ b/lemon/cplex.cc	Thu Nov 05 08:39:49 2009 +0100
    30.3 @@ -111,6 +111,39 @@
    30.4      return i;
    30.5    }
    30.6  
    30.7 +  int CplexBase::_addRow(Value lb, ExprIterator b, 
    30.8 +                         ExprIterator e, Value ub) {
    30.9 +    int i = CPXgetnumrows(cplexEnv(), _prob);
   30.10 +    if (lb == -INF) {
   30.11 +      const char s = 'L';
   30.12 +      CPXnewrows(cplexEnv(), _prob, 1, &ub, &s, 0, 0);
   30.13 +    } else if (ub == INF) {
   30.14 +      const char s = 'G';
   30.15 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
   30.16 +    } else if (lb == ub){
   30.17 +      const char s = 'E';
   30.18 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, 0, 0);
   30.19 +    } else {
   30.20 +      const char s = 'R';
   30.21 +      double len = ub - lb;
   30.22 +      CPXnewrows(cplexEnv(), _prob, 1, &lb, &s, &len, 0);
   30.23 +    }
   30.24 +
   30.25 +    std::vector<int> indices;
   30.26 +    std::vector<int> rowlist;
   30.27 +    std::vector<Value> values;
   30.28 +
   30.29 +    for(ExprIterator it=b; it!=e; ++it) {
   30.30 +      indices.push_back(it->first);
   30.31 +      values.push_back(it->second);
   30.32 +      rowlist.push_back(i);
   30.33 +    }
   30.34 +
   30.35 +    CPXchgcoeflist(cplexEnv(), _prob, values.size(),
   30.36 +                   &rowlist.front(), &indices.front(), &values.front());
   30.37 +
   30.38 +    return i;
   30.39 +  }
   30.40  
   30.41    void CplexBase::_eraseCol(int i) {
   30.42      CPXdelcols(cplexEnv(), _prob, i, i);
    31.1 --- a/lemon/cplex.h	Tue Aug 18 10:08:28 2009 +0200
    31.2 +++ b/lemon/cplex.h	Thu Nov 05 08:39:49 2009 +0100
    31.3 @@ -93,6 +93,7 @@
    31.4  
    31.5      virtual int _addCol();
    31.6      virtual int _addRow();
    31.7 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    31.8  
    31.9      virtual void _eraseCol(int i);
   31.10      virtual void _eraseRow(int i);
    32.1 --- a/lemon/dfs.h	Tue Aug 18 10:08:28 2009 +0200
    32.2 +++ b/lemon/dfs.h	Thu Nov 05 08:39:49 2009 +0100
    32.3 @@ -47,7 +47,7 @@
    32.4      ///
    32.5      ///The type of the map that stores the predecessor
    32.6      ///arcs of the %DFS paths.
    32.7 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    32.8 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
    32.9      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
   32.10      ///Instantiates a \c PredMap.
   32.11  
   32.12 @@ -62,7 +62,8 @@
   32.13      ///The type of the map that indicates which nodes are processed.
   32.14  
   32.15      ///The type of the map that indicates which nodes are processed.
   32.16 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   32.17 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   32.18 +    ///By default it is a NullMap.
   32.19      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   32.20      ///Instantiates a \c ProcessedMap.
   32.21  
   32.22 @@ -81,7 +82,7 @@
   32.23      ///The type of the map that indicates which nodes are reached.
   32.24  
   32.25      ///The type of the map that indicates which nodes are reached.
   32.26 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   32.27 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   32.28      typedef typename Digraph::template NodeMap<bool> ReachedMap;
   32.29      ///Instantiates a \c ReachedMap.
   32.30  
   32.31 @@ -96,7 +97,7 @@
   32.32      ///The type of the map that stores the distances of the nodes.
   32.33  
   32.34      ///The type of the map that stores the distances of the nodes.
   32.35 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   32.36 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   32.37      typedef typename Digraph::template NodeMap<int> DistMap;
   32.38      ///Instantiates a \c DistMap.
   32.39  
   32.40 @@ -224,7 +225,7 @@
   32.41      ///
   32.42      ///\ref named-templ-param "Named parameter" for setting
   32.43      ///\c PredMap type.
   32.44 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   32.45 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   32.46      template <class T>
   32.47      struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > {
   32.48        typedef Dfs<Digraph, SetPredMapTraits<T> > Create;
   32.49 @@ -244,7 +245,7 @@
   32.50      ///
   32.51      ///\ref named-templ-param "Named parameter" for setting
   32.52      ///\c DistMap type.
   32.53 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   32.54 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   32.55      template <class T>
   32.56      struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > {
   32.57        typedef Dfs<Digraph, SetDistMapTraits<T> > Create;
   32.58 @@ -264,7 +265,7 @@
   32.59      ///
   32.60      ///\ref named-templ-param "Named parameter" for setting
   32.61      ///\c ReachedMap type.
   32.62 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   32.63 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
   32.64      template <class T>
   32.65      struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > {
   32.66        typedef Dfs< Digraph, SetReachedMapTraits<T> > Create;
   32.67 @@ -284,7 +285,7 @@
   32.68      ///
   32.69      ///\ref named-templ-param "Named parameter" for setting
   32.70      ///\c ProcessedMap type.
   32.71 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   32.72 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   32.73      template <class T>
   32.74      struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > {
   32.75        typedef Dfs< Digraph, SetProcessedMapTraits<T> > Create;
   32.76 @@ -411,8 +412,8 @@
   32.77      ///\name Execution Control
   32.78      ///The simplest way to execute the DFS algorithm is to use one of the
   32.79      ///member functions called \ref run(Node) "run()".\n
   32.80 -    ///If you need more control on the execution, first you have to call
   32.81 -    ///\ref init(), then you can add a source node with \ref addSource()
   32.82 +    ///If you need better control on the execution, you have to call
   32.83 +    ///\ref init() first, then you can add a source node with \ref addSource()
   32.84      ///and perform the actual computation with \ref start().
   32.85      ///This procedure can be repeated if there are nodes that have not
   32.86      ///been reached.
   32.87 @@ -669,9 +670,9 @@
   32.88  
   32.89      ///@{
   32.90  
   32.91 -    ///The DFS path to a node.
   32.92 +    ///The DFS path to the given node.
   32.93  
   32.94 -    ///Returns the DFS path to a node.
   32.95 +    ///Returns the DFS path to the given node from the root(s).
   32.96      ///
   32.97      ///\warning \c t should be reached from the root(s).
   32.98      ///
   32.99 @@ -679,9 +680,9 @@
  32.100      ///must be called before using this function.
  32.101      Path path(Node t) const { return Path(*G, *_pred, t); }
  32.102  
  32.103 -    ///The distance of a node from the root(s).
  32.104 +    ///The distance of the given node from the root(s).
  32.105  
  32.106 -    ///Returns the distance of a node from the root(s).
  32.107 +    ///Returns the distance of the given node from the root(s).
  32.108      ///
  32.109      ///\warning If node \c v is not reached from the root(s), then
  32.110      ///the return value of this function is undefined.
  32.111 @@ -690,7 +691,7 @@
  32.112      ///must be called before using this function.
  32.113      int dist(Node v) const { return (*_dist)[v]; }
  32.114  
  32.115 -    ///Returns the 'previous arc' of the %DFS tree for a node.
  32.116 +    ///Returns the 'previous arc' of the %DFS tree for the given node.
  32.117  
  32.118      ///This function returns the 'previous arc' of the %DFS tree for the
  32.119      ///node \c v, i.e. it returns the last arc of a %DFS path from a
  32.120 @@ -698,21 +699,21 @@
  32.121      ///root(s) or if \c v is a root.
  32.122      ///
  32.123      ///The %DFS tree used here is equal to the %DFS tree used in
  32.124 -    ///\ref predNode().
  32.125 +    ///\ref predNode() and \ref predMap().
  32.126      ///
  32.127      ///\pre Either \ref run(Node) "run()" or \ref init()
  32.128      ///must be called before using this function.
  32.129      Arc predArc(Node v) const { return (*_pred)[v];}
  32.130  
  32.131 -    ///Returns the 'previous node' of the %DFS tree.
  32.132 +    ///Returns the 'previous node' of the %DFS tree for the given node.
  32.133  
  32.134      ///This function returns the 'previous node' of the %DFS
  32.135      ///tree for the node \c v, i.e. it returns the last but one node
  32.136 -    ///from a %DFS path from a root to \c v. It is \c INVALID
  32.137 +    ///of a %DFS path from a root to \c v. It is \c INVALID
  32.138      ///if \c v is not reached from the root(s) or if \c v is a root.
  32.139      ///
  32.140      ///The %DFS tree used here is equal to the %DFS tree used in
  32.141 -    ///\ref predArc().
  32.142 +    ///\ref predArc() and \ref predMap().
  32.143      ///
  32.144      ///\pre Either \ref run(Node) "run()" or \ref init()
  32.145      ///must be called before using this function.
  32.146 @@ -733,13 +734,13 @@
  32.147      ///predecessor arcs.
  32.148      ///
  32.149      ///Returns a const reference to the node map that stores the predecessor
  32.150 -    ///arcs, which form the DFS tree.
  32.151 +    ///arcs, which form the DFS tree (forest).
  32.152      ///
  32.153      ///\pre Either \ref run(Node) "run()" or \ref init()
  32.154      ///must be called before using this function.
  32.155      const PredMap &predMap() const { return *_pred;}
  32.156  
  32.157 -    ///Checks if a node is reached from the root(s).
  32.158 +    ///Checks if the given node. node is reached from the root(s).
  32.159  
  32.160      ///Returns \c true if \c v is reached from the root(s).
  32.161      ///
  32.162 @@ -765,7 +766,7 @@
  32.163      ///
  32.164      ///The type of the map that stores the predecessor
  32.165      ///arcs of the %DFS paths.
  32.166 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  32.167 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  32.168      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
  32.169      ///Instantiates a PredMap.
  32.170  
  32.171 @@ -780,7 +781,7 @@
  32.172      ///The type of the map that indicates which nodes are processed.
  32.173  
  32.174      ///The type of the map that indicates which nodes are processed.
  32.175 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  32.176 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  32.177      ///By default it is a NullMap.
  32.178      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
  32.179      ///Instantiates a ProcessedMap.
  32.180 @@ -800,7 +801,7 @@
  32.181      ///The type of the map that indicates which nodes are reached.
  32.182  
  32.183      ///The type of the map that indicates which nodes are reached.
  32.184 -    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  32.185 +    ///It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  32.186      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  32.187      ///Instantiates a ReachedMap.
  32.188  
  32.189 @@ -815,7 +816,7 @@
  32.190      ///The type of the map that stores the distances of the nodes.
  32.191  
  32.192      ///The type of the map that stores the distances of the nodes.
  32.193 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  32.194 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  32.195      typedef typename Digraph::template NodeMap<int> DistMap;
  32.196      ///Instantiates a DistMap.
  32.197  
  32.198 @@ -830,18 +831,14 @@
  32.199      ///The type of the DFS paths.
  32.200  
  32.201      ///The type of the DFS paths.
  32.202 -    ///It must meet the \ref concepts::Path "Path" concept.
  32.203 +    ///It must conform to the \ref concepts::Path "Path" concept.
  32.204      typedef lemon::Path<Digraph> Path;
  32.205    };
  32.206  
  32.207    /// Default traits class used by DfsWizard
  32.208  
  32.209 -  /// To make it easier to use Dfs algorithm
  32.210 -  /// we have created a wizard class.
  32.211 -  /// This \ref DfsWizard class needs default traits,
  32.212 -  /// as well as the \ref Dfs class.
  32.213 -  /// The \ref DfsWizardBase is a class to be the default traits of the
  32.214 -  /// \ref DfsWizard class.
  32.215 +  /// Default traits class used by DfsWizard.
  32.216 +  /// \tparam GR The type of the digraph.
  32.217    template<class GR>
  32.218    class DfsWizardBase : public DfsWizardDefaultTraits<GR>
  32.219    {
  32.220 @@ -869,7 +866,7 @@
  32.221      public:
  32.222      /// Constructor.
  32.223  
  32.224 -    /// This constructor does not require parameters, therefore it initiates
  32.225 +    /// This constructor does not require parameters, it initiates
  32.226      /// all of the attributes to \c 0.
  32.227      DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
  32.228                        _dist(0), _path(0), _di(0) {}
  32.229 @@ -899,7 +896,6 @@
  32.230    {
  32.231      typedef TR Base;
  32.232  
  32.233 -    ///The type of the digraph the algorithm runs on.
  32.234      typedef typename TR::Digraph Digraph;
  32.235  
  32.236      typedef typename Digraph::Node Node;
  32.237 @@ -907,16 +903,10 @@
  32.238      typedef typename Digraph::Arc Arc;
  32.239      typedef typename Digraph::OutArcIt OutArcIt;
  32.240  
  32.241 -    ///\brief The type of the map that stores the predecessor
  32.242 -    ///arcs of the DFS paths.
  32.243      typedef typename TR::PredMap PredMap;
  32.244 -    ///\brief The type of the map that stores the distances of the nodes.
  32.245      typedef typename TR::DistMap DistMap;
  32.246 -    ///\brief The type of the map that indicates which nodes are reached.
  32.247      typedef typename TR::ReachedMap ReachedMap;
  32.248 -    ///\brief The type of the map that indicates which nodes are processed.
  32.249      typedef typename TR::ProcessedMap ProcessedMap;
  32.250 -    ///The type of the DFS paths
  32.251      typedef typename TR::Path Path;
  32.252  
  32.253    public:
  32.254 @@ -999,11 +989,12 @@
  32.255        static PredMap *createPredMap(const Digraph &) { return 0; };
  32.256        SetPredMapBase(const TR &b) : TR(b) {}
  32.257      };
  32.258 -    ///\brief \ref named-func-param "Named parameter"
  32.259 -    ///for setting PredMap object.
  32.260 +
  32.261 +    ///\brief \ref named-templ-param "Named parameter" for setting
  32.262 +    ///the predecessor map.
  32.263      ///
  32.264 -    ///\ref named-func-param "Named parameter"
  32.265 -    ///for setting PredMap object.
  32.266 +    ///\ref named-templ-param "Named parameter" function for setting
  32.267 +    ///the map that stores the predecessor arcs of the nodes.
  32.268      template<class T>
  32.269      DfsWizard<SetPredMapBase<T> > predMap(const T &t)
  32.270      {
  32.271 @@ -1017,11 +1008,12 @@
  32.272        static ReachedMap *createReachedMap(const Digraph &) { return 0; };
  32.273        SetReachedMapBase(const TR &b) : TR(b) {}
  32.274      };
  32.275 -    ///\brief \ref named-func-param "Named parameter"
  32.276 -    ///for setting ReachedMap object.
  32.277 +
  32.278 +    ///\brief \ref named-templ-param "Named parameter" for setting
  32.279 +    ///the reached map.
  32.280      ///
  32.281 -    /// \ref named-func-param "Named parameter"
  32.282 -    ///for setting ReachedMap object.
  32.283 +    ///\ref named-templ-param "Named parameter" function for setting
  32.284 +    ///the map that indicates which nodes are reached.
  32.285      template<class T>
  32.286      DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t)
  32.287      {
  32.288 @@ -1035,11 +1027,13 @@
  32.289        static DistMap *createDistMap(const Digraph &) { return 0; };
  32.290        SetDistMapBase(const TR &b) : TR(b) {}
  32.291      };
  32.292 -    ///\brief \ref named-func-param "Named parameter"
  32.293 -    ///for setting DistMap object.
  32.294 +
  32.295 +    ///\brief \ref named-templ-param "Named parameter" for setting
  32.296 +    ///the distance map.
  32.297      ///
  32.298 -    /// \ref named-func-param "Named parameter"
  32.299 -    ///for setting DistMap object.
  32.300 +    ///\ref named-templ-param "Named parameter" function for setting
  32.301 +    ///the map that stores the distances of the nodes calculated
  32.302 +    ///by the algorithm.
  32.303      template<class T>
  32.304      DfsWizard<SetDistMapBase<T> > distMap(const T &t)
  32.305      {
  32.306 @@ -1053,11 +1047,12 @@
  32.307        static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
  32.308        SetProcessedMapBase(const TR &b) : TR(b) {}
  32.309      };
  32.310 -    ///\brief \ref named-func-param "Named parameter"
  32.311 -    ///for setting ProcessedMap object.
  32.312 +
  32.313 +    ///\brief \ref named-func-param "Named parameter" for setting
  32.314 +    ///the processed map.
  32.315      ///
  32.316 -    /// \ref named-func-param "Named parameter"
  32.317 -    ///for setting ProcessedMap object.
  32.318 +    ///\ref named-templ-param "Named parameter" function for setting
  32.319 +    ///the map that indicates which nodes are processed.
  32.320      template<class T>
  32.321      DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t)
  32.322      {
  32.323 @@ -1208,7 +1203,7 @@
  32.324      /// \brief The type of the map that indicates which nodes are reached.
  32.325      ///
  32.326      /// The type of the map that indicates which nodes are reached.
  32.327 -    /// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  32.328 +    /// It must conform to the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
  32.329      typedef typename Digraph::template NodeMap<bool> ReachedMap;
  32.330  
  32.331      /// \brief Instantiates a ReachedMap.
  32.332 @@ -1369,8 +1364,8 @@
  32.333      /// \name Execution Control
  32.334      /// The simplest way to execute the DFS algorithm is to use one of the
  32.335      /// member functions called \ref run(Node) "run()".\n
  32.336 -    /// If you need more control on the execution, first you have to call
  32.337 -    /// \ref init(), then you can add a source node with \ref addSource()
  32.338 +    /// If you need better control on the execution, you have to call
  32.339 +    /// \ref init() first, then you can add a source node with \ref addSource()
  32.340      /// and perform the actual computation with \ref start().
  32.341      /// This procedure can be repeated if there are nodes that have not
  32.342      /// been reached.
  32.343 @@ -1620,7 +1615,7 @@
  32.344  
  32.345      ///@{
  32.346  
  32.347 -    /// \brief Checks if a node is reached from the root(s).
  32.348 +    /// \brief Checks if the given node is reached from the root(s).
  32.349      ///
  32.350      /// Returns \c true if \c v is reached from the root(s).
  32.351      ///
    33.1 --- a/lemon/dijkstra.h	Tue Aug 18 10:08:28 2009 +0200
    33.2 +++ b/lemon/dijkstra.h	Thu Nov 05 08:39:49 2009 +0100
    33.3 @@ -70,9 +70,9 @@
    33.4      ///The type of the map that stores the arc lengths.
    33.5  
    33.6      ///The type of the map that stores the arc lengths.
    33.7 -    ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
    33.8 +    ///It must conform to the \ref concepts::ReadMap "ReadMap" concept.
    33.9      typedef LEN LengthMap;
   33.10 -    ///The type of the length of the arcs.
   33.11 +    ///The type of the arc lengths.
   33.12      typedef typename LEN::Value Value;
   33.13  
   33.14      /// Operation traits for %Dijkstra algorithm.
   33.15 @@ -116,7 +116,7 @@
   33.16      ///
   33.17      ///The type of the map that stores the predecessor
   33.18      ///arcs of the shortest paths.
   33.19 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   33.20 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   33.21      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
   33.22      ///Instantiates a \c PredMap.
   33.23  
   33.24 @@ -131,7 +131,7 @@
   33.25      ///The type of the map that indicates which nodes are processed.
   33.26  
   33.27      ///The type of the map that indicates which nodes are processed.
   33.28 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   33.29 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   33.30      ///By default it is a NullMap.
   33.31      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
   33.32      ///Instantiates a \c ProcessedMap.
   33.33 @@ -151,7 +151,7 @@
   33.34      ///The type of the map that stores the distances of the nodes.
   33.35  
   33.36      ///The type of the map that stores the distances of the nodes.
   33.37 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   33.38 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   33.39      typedef typename Digraph::template NodeMap<typename LEN::Value> DistMap;
   33.40      ///Instantiates a \c DistMap.
   33.41  
   33.42 @@ -169,6 +169,10 @@
   33.43    /// \ingroup shortest_path
   33.44    ///This class provides an efficient implementation of the %Dijkstra algorithm.
   33.45    ///
   33.46 +  ///The %Dijkstra algorithm solves the single-source shortest path problem
   33.47 +  ///when all arc lengths are non-negative. If there are negative lengths,
   33.48 +  ///the BellmanFord algorithm should be used instead.
   33.49 +  ///
   33.50    ///The arc lengths are passed to the algorithm using a
   33.51    ///\ref concepts::ReadMap "ReadMap",
   33.52    ///so it is easy to change it to any kind of length.
   33.53 @@ -201,7 +205,7 @@
   33.54      ///The type of the digraph the algorithm runs on.
   33.55      typedef typename TR::Digraph Digraph;
   33.56  
   33.57 -    ///The type of the length of the arcs.
   33.58 +    ///The type of the arc lengths.
   33.59      typedef typename TR::LengthMap::Value Value;
   33.60      ///The type of the map that stores the arc lengths.
   33.61      typedef typename TR::LengthMap LengthMap;
   33.62 @@ -304,7 +308,7 @@
   33.63      ///
   33.64      ///\ref named-templ-param "Named parameter" for setting
   33.65      ///\c PredMap type.
   33.66 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   33.67 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   33.68      template <class T>
   33.69      struct SetPredMap
   33.70        : public Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > {
   33.71 @@ -325,7 +329,7 @@
   33.72      ///
   33.73      ///\ref named-templ-param "Named parameter" for setting
   33.74      ///\c DistMap type.
   33.75 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   33.76 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   33.77      template <class T>
   33.78      struct SetDistMap
   33.79        : public Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > {
   33.80 @@ -346,7 +350,7 @@
   33.81      ///
   33.82      ///\ref named-templ-param "Named parameter" for setting
   33.83      ///\c ProcessedMap type.
   33.84 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
   33.85 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
   33.86      template <class T>
   33.87      struct SetProcessedMap
   33.88        : public Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > {
   33.89 @@ -443,6 +447,7 @@
   33.90      ///
   33.91      ///\ref named-templ-param "Named parameter" for setting
   33.92      ///\c OperationTraits type.
   33.93 +    /// For more information see \ref DijkstraDefaultOperationTraits.
   33.94      template <class T>
   33.95      struct SetOperationTraits
   33.96        : public Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> > {
   33.97 @@ -584,8 +589,8 @@
   33.98      ///\name Execution Control
   33.99      ///The simplest way to execute the %Dijkstra algorithm is to use
  33.100      ///one of the member functions called \ref run(Node) "run()".\n
  33.101 -    ///If you need more control on the execution, first you have to call
  33.102 -    ///\ref init(), then you can add several source nodes with
  33.103 +    ///If you need better control on the execution, you have to call
  33.104 +    ///\ref init() first, then you can add several source nodes with
  33.105      ///\ref addSource(). Finally the actual path computation can be
  33.106      ///performed with one of the \ref start() functions.
  33.107  
  33.108 @@ -801,14 +806,14 @@
  33.109      ///\name Query Functions
  33.110      ///The results of the %Dijkstra algorithm can be obtained using these
  33.111      ///functions.\n
  33.112 -    ///Either \ref run(Node) "run()" or \ref start() should be called
  33.113 +    ///Either \ref run(Node) "run()" or \ref init() should be called
  33.114      ///before using them.
  33.115  
  33.116      ///@{
  33.117  
  33.118 -    ///The shortest path to a node.
  33.119 +    ///The shortest path to the given node.
  33.120  
  33.121 -    ///Returns the shortest path to a node.
  33.122 +    ///Returns the shortest path to the given node from the root(s).
  33.123      ///
  33.124      ///\warning \c t should be reached from the root(s).
  33.125      ///
  33.126 @@ -816,9 +821,9 @@
  33.127      ///must be called before using this function.
  33.128      Path path(Node t) const { return Path(*G, *_pred, t); }
  33.129  
  33.130 -    ///The distance of a node from the root(s).
  33.131 +    ///The distance of the given node from the root(s).
  33.132  
  33.133 -    ///Returns the distance of a node from the root(s).
  33.134 +    ///Returns the distance of the given node from the root(s).
  33.135      ///
  33.136      ///\warning If node \c v is not reached from the root(s), then
  33.137      ///the return value of this function is undefined.
  33.138 @@ -827,29 +832,31 @@
  33.139      ///must be called before using this function.
  33.140      Value dist(Node v) const { return (*_dist)[v]; }
  33.141  
  33.142 -    ///Returns the 'previous arc' of the shortest path tree for a node.
  33.143 -
  33.144 +    ///\brief Returns the 'previous arc' of the shortest path tree for
  33.145 +    ///the given node.
  33.146 +    ///
  33.147      ///This function returns the 'previous arc' of the shortest path
  33.148      ///tree for the node \c v, i.e. it returns the last arc of a
  33.149      ///shortest path from a root to \c v. It is \c INVALID if \c v
  33.150      ///is not reached from the root(s) or if \c v is a root.
  33.151      ///
  33.152      ///The shortest path tree used here is equal to the shortest path
  33.153 -    ///tree used in \ref predNode().
  33.154 +    ///tree used in \ref predNode() and \ref predMap().
  33.155      ///
  33.156      ///\pre Either \ref run(Node) "run()" or \ref init()
  33.157      ///must be called before using this function.
  33.158      Arc predArc(Node v) const { return (*_pred)[v]; }
  33.159  
  33.160 -    ///Returns the 'previous node' of the shortest path tree for a node.
  33.161 -
  33.162 +    ///\brief Returns the 'previous node' of the shortest path tree for
  33.163 +    ///the given node.
  33.164 +    ///
  33.165      ///This function returns the 'previous node' of the shortest path
  33.166      ///tree for the node \c v, i.e. it returns the last but one node
  33.167 -    ///from a shortest path from a root to \c v. It is \c INVALID
  33.168 +    ///of a shortest path from a root to \c v. It is \c INVALID
  33.169      ///if \c v is not reached from the root(s) or if \c v is a root.
  33.170      ///
  33.171      ///The shortest path tree used here is equal to the shortest path
  33.172 -    ///tree used in \ref predArc().
  33.173 +    ///tree used in \ref predArc() and \ref predMap().
  33.174      ///
  33.175      ///\pre Either \ref run(Node) "run()" or \ref init()
  33.176      ///must be called before using this function.
  33.177 @@ -870,13 +877,13 @@
  33.178      ///predecessor arcs.
  33.179      ///
  33.180      ///Returns a const reference to the node map that stores the predecessor
  33.181 -    ///arcs, which form the shortest path tree.
  33.182 +    ///arcs, which form the shortest path tree (forest).
  33.183      ///
  33.184      ///\pre Either \ref run(Node) "run()" or \ref init()
  33.185      ///must be called before using this function.
  33.186      const PredMap &predMap() const { return *_pred;}
  33.187  
  33.188 -    ///Checks if a node is reached from the root(s).
  33.189 +    ///Checks if the given node is reached from the root(s).
  33.190  
  33.191      ///Returns \c true if \c v is reached from the root(s).
  33.192      ///
  33.193 @@ -895,9 +902,9 @@
  33.194      bool processed(Node v) const { return (*_heap_cross_ref)[v] ==
  33.195                                            Heap::POST_HEAP; }
  33.196  
  33.197 -    ///The current distance of a node from the root(s).
  33.198 +    ///The current distance of the given node from the root(s).
  33.199  
  33.200 -    ///Returns the current distance of a node from the root(s).
  33.201 +    ///Returns the current distance of the given node from the root(s).
  33.202      ///It may be decreased in the following processes.
  33.203      ///
  33.204      ///\pre Either \ref run(Node) "run()" or \ref init()
  33.205 @@ -924,9 +931,9 @@
  33.206      ///The type of the map that stores the arc lengths.
  33.207  
  33.208      ///The type of the map that stores the arc lengths.
  33.209 -    ///It must meet the \ref concepts::ReadMap "ReadMap" concept.
  33.210 +    ///It must conform to the \ref concepts::ReadMap "ReadMap" concept.
  33.211      typedef LEN LengthMap;
  33.212 -    ///The type of the length of the arcs.
  33.213 +    ///The type of the arc lengths.
  33.214      typedef typename LEN::Value Value;
  33.215  
  33.216      /// Operation traits for Dijkstra algorithm.
  33.217 @@ -973,7 +980,7 @@
  33.218      ///
  33.219      ///The type of the map that stores the predecessor
  33.220      ///arcs of the shortest paths.
  33.221 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  33.222 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  33.223      typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
  33.224      ///Instantiates a PredMap.
  33.225  
  33.226 @@ -988,7 +995,7 @@
  33.227      ///The type of the map that indicates which nodes are processed.
  33.228  
  33.229      ///The type of the map that indicates which nodes are processed.
  33.230 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  33.231 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  33.232      ///By default it is a NullMap.
  33.233      typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
  33.234      ///Instantiates a ProcessedMap.
  33.235 @@ -1008,7 +1015,7 @@
  33.236      ///The type of the map that stores the distances of the nodes.
  33.237  
  33.238      ///The type of the map that stores the distances of the nodes.
  33.239 -    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
  33.240 +    ///It must conform to the \ref concepts::WriteMap "WriteMap" concept.
  33.241      typedef typename Digraph::template NodeMap<typename LEN::Value> DistMap;
  33.242      ///Instantiates a DistMap.
  33.243  
  33.244 @@ -1023,18 +1030,15 @@
  33.245      ///The type of the shortest paths.
  33.246  
  33.247      ///The type of the shortest paths.
  33.248 -    ///It must meet the \ref concepts::Path "Path" concept.
  33.249 +    ///It must conform to the \ref concepts::Path "Path" concept.
  33.250      typedef lemon::Path<Digraph> Path;
  33.251    };
  33.252  
  33.253    /// Default traits class used by DijkstraWizard
  33.254  
  33.255 -  /// To make it easier to use Dijkstra algorithm
  33.256 -  /// we have created a wizard class.
  33.257 -  /// This \ref DijkstraWizard class needs default traits,
  33.258 -  /// as well as the \ref Dijkstra class.
  33.259 -  /// The \ref DijkstraWizardBase is a class to be the default traits of the
  33.260 -  /// \ref DijkstraWizard class.
  33.261 +  /// Default traits class used by DijkstraWizard.
  33.262 +  /// \tparam GR The type of the digraph.
  33.263 +  /// \tparam LEN The type of the length map.
  33.264    template<typename GR, typename LEN>
  33.265    class DijkstraWizardBase : public DijkstraWizardDefaultTraits<GR,LEN>
  33.266    {
  33.267 @@ -1093,7 +1097,6 @@
  33.268    {
  33.269      typedef TR Base;
  33.270  
  33.271 -    ///The type of the digraph the algorithm runs on.
  33.272      typedef typename TR::Digraph Digraph;
  33.273  
  33.274      typedef typename Digraph::Node Node;
  33.275 @@ -1101,20 +1104,12 @@
  33.276      typedef typename Digraph::Arc Arc;
  33.277      typedef typename Digraph::OutArcIt OutArcIt;
  33.278  
  33.279 -    ///The type of the map that stores the arc lengths.
  33.280      typedef typename TR::LengthMap LengthMap;
  33.281 -    ///The type of the length of the arcs.
  33.282      typedef typename LengthMap::Value Value;
  33.283 -    ///\brief The type of the map that stores the predecessor
  33.284 -    ///arcs of the shortest paths.
  33.285      typedef typename TR::PredMap PredMap;
  33.286 -    ///The type of the map that stores the distances of the nodes.
  33.287      typedef typename TR::DistMap DistMap;
  33.288 -    ///The type of the map that indicates which nodes are processed.
  33.289      typedef typename TR::ProcessedMap ProcessedMap;
  33.290 -    ///The type of the shortest paths
  33.291      typedef typename TR::Path Path;
  33.292 -    ///The heap type used by the dijkstra algorithm.
  33.293      typedef typename TR::Heap Heap;
  33.294  
  33.295    public:
  33.296 @@ -1186,11 +1181,12 @@
  33.297        static PredMap *createPredMap(const Digraph &) { return 0; };
  33.298        SetPredMapBase(const TR &b) : TR(b) {}
  33.299      };
  33.300 -    ///\brief \ref named-func-param "Named parameter"
  33.301 -    ///for setting PredMap object.
  33.302 +
  33.303 +    ///\brief \ref named-templ-param "Named parameter" for setting
  33.304 +    ///the predecessor map.
  33.305      ///
  33.306 -    ///\ref named-func-param "Named parameter"
  33.307 -    ///for setting PredMap object.
  33.308 +    ///\ref named-templ-param "Named parameter" function for setting
  33.309 +    ///the map that stores the predecessor arcs of the nodes.
  33.310      template<class T>
  33.311      DijkstraWizard<SetPredMapBase<T> > predMap(const T &t)
  33.312      {
  33.313 @@ -1204,11 +1200,13 @@
  33.314        static DistMap *createDistMap(const Digraph &) { return 0; };
  33.315        SetDistMapBase(const TR &b) : TR(b) {}
  33.316      };
  33.317 -    ///\brief \ref named-func-param "Named parameter"
  33.318 -    ///for setting DistMap object.
  33.319 +
  33.320 +    ///\brief \ref named-templ-param "Named parameter" for setting
  33.321 +    ///the distance map.
  33.322      ///
  33.323 -    ///\ref named-func-param "Named parameter"
  33.324 -    ///for setting DistMap object.
  33.325 +    ///\ref named-templ-param "Named parameter" function for setting
  33.326 +    ///the map that stores the distances of the nodes calculated
  33.327 +    ///by the algorithm.
  33.328      template<class T>
  33.329      DijkstraWizard<SetDistMapBase<T> > distMap(const T &t)
  33.330      {
  33.331 @@ -1222,11 +1220,12 @@
  33.332        static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
  33.333        SetProcessedMapBase(const TR &b) : TR(b) {}
  33.334      };
  33.335 -    ///\brief \ref named-func-param "Named parameter"
  33.336 -    ///for setting ProcessedMap object.
  33.337 +
  33.338 +    ///\brief \ref named-func-param "Named parameter" for setting
  33.339 +    ///the processed map.
  33.340      ///
  33.341 -    /// \ref named-func-param "Named parameter"
  33.342 -    ///for setting ProcessedMap object.
  33.343 +    ///\ref named-templ-param "Named parameter" function for setting
  33.344 +    ///the map that indicates which nodes are processed.
  33.345      template<class T>
  33.346      DijkstraWizard<SetProcessedMapBase<T> > processedMap(const T &t)
  33.347      {
  33.348 @@ -1239,6 +1238,7 @@
  33.349        typedef T Path;
  33.350        SetPathBase(const TR &b) : TR(b) {}
  33.351      };
  33.352 +
  33.353      ///\brief \ref named-func-param "Named parameter"
  33.354      ///for getting the shortest path to the target node.
  33.355      ///
    34.1 --- a/lemon/dim2.h	Tue Aug 18 10:08:28 2009 +0200
    34.2 +++ b/lemon/dim2.h	Thu Nov 05 08:39:49 2009 +0100
    34.3 @@ -21,16 +21,9 @@
    34.4  
    34.5  #include <iostream>
    34.6  
    34.7 -///\ingroup misc
    34.8 +///\ingroup geomdat
    34.9  ///\file
   34.10  ///\brief A simple two dimensional vector and a bounding box implementation
   34.11 -///
   34.12 -/// The class \ref lemon::dim2::Point "dim2::Point" implements
   34.13 -/// a two dimensional vector with the usual operations.
   34.14 -///
   34.15 -/// The class \ref lemon::dim2::Box "dim2::Box" can be used to determine
   34.16 -/// the rectangular bounding box of a set of
   34.17 -/// \ref lemon::dim2::Point "dim2::Point"'s.
   34.18  
   34.19  namespace lemon {
   34.20  
   34.21 @@ -40,7 +33,7 @@
   34.22    ///tools for handling two dimensional coordinates
   34.23    namespace dim2 {
   34.24  
   34.25 -  /// \addtogroup misc
   34.26 +  /// \addtogroup geomdat
   34.27    /// @{
   34.28  
   34.29    /// Two dimensional vector (plain vector)
    35.1 --- a/lemon/fib_heap.h	Tue Aug 18 10:08:28 2009 +0200
    35.2 +++ b/lemon/fib_heap.h	Thu Nov 05 08:39:49 2009 +0100
    35.3 @@ -20,53 +20,49 @@
    35.4  #define LEMON_FIB_HEAP_H
    35.5  
    35.6  ///\file
    35.7 -///\ingroup auxdat
    35.8 -///\brief Fibonacci Heap implementation.
    35.9 +///\ingroup heaps
   35.10 +///\brief Fibonacci heap implementation.
   35.11  
   35.12  #include <vector>
   35.13 +#include <utility>
   35.14  #include <functional>
   35.15  #include <lemon/math.h>
   35.16  
   35.17  namespace lemon {
   35.18  
   35.19 -  /// \ingroup auxdat
   35.20 +  /// \ingroup heaps
   35.21    ///
   35.22 -  ///\brief Fibonacci Heap.
   35.23 +  /// \brief Fibonacci heap data structure.
   35.24    ///
   35.25 -  ///This class implements the \e Fibonacci \e heap data structure. A \e heap
   35.26 -  ///is a data structure for storing items with specified values called \e
   35.27 -  ///priorities in such a way that finding the item with minimum priority is
   35.28 -  ///efficient. \c CMP specifies the ordering of the priorities. In a heap
   35.29 -  ///one can change the priority of an item, add or erase an item, etc.
   35.30 +  /// This class implements the \e Fibonacci \e heap data structure.
   35.31 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   35.32    ///
   35.33 -  ///The methods \ref increase and \ref erase are not efficient in a Fibonacci
   35.34 -  ///heap. In case of many calls to these operations, it is better to use a
   35.35 -  ///\ref BinHeap "binary heap".
   35.36 +  /// The methods \ref increase() and \ref erase() are not efficient in a
   35.37 +  /// Fibonacci heap. In case of many calls of these operations, it is
   35.38 +  /// better to use other heap structure, e.g. \ref BinHeap "binary heap".
   35.39    ///
   35.40 -  ///\param PRIO Type of the priority of the items.
   35.41 -  ///\param IM A read and writable Item int map, used internally
   35.42 -  ///to handle the cross references.
   35.43 -  ///\param CMP A class for the ordering of the priorities. The
   35.44 -  ///default is \c std::less<PRIO>.
   35.45 -  ///
   35.46 -  ///\sa BinHeap
   35.47 -  ///\sa Dijkstra
   35.48 +  /// \tparam PR Type of the priorities of the items.
   35.49 +  /// \tparam IM A read-writable item map with \c int values, used
   35.50 +  /// internally to handle the cross references.
   35.51 +  /// \tparam CMP A functor class for comparing the priorities.
   35.52 +  /// The default is \c std::less<PR>.
   35.53  #ifdef DOXYGEN
   35.54 -  template <typename PRIO, typename IM, typename CMP>
   35.55 +  template <typename PR, typename IM, typename CMP>
   35.56  #else
   35.57 -  template <typename PRIO, typename IM, typename CMP = std::less<PRIO> >
   35.58 +  template <typename PR, typename IM, typename CMP = std::less<PR> >
   35.59  #endif
   35.60    class FibHeap {
   35.61    public:
   35.62 -    ///\e
   35.63 +
   35.64 +    /// Type of the item-int map.
   35.65      typedef IM ItemIntMap;
   35.66 -    ///\e
   35.67 -    typedef PRIO Prio;
   35.68 -    ///\e
   35.69 +    /// Type of the priorities.
   35.70 +    typedef PR Prio;
   35.71 +    /// Type of the items stored in the heap.
   35.72      typedef typename ItemIntMap::Key Item;
   35.73 -    ///\e
   35.74 +    /// Type of the item-priority pairs.
   35.75      typedef std::pair<Item,Prio> Pair;
   35.76 -    ///\e
   35.77 +    /// Functor type for comparing the priorities.
   35.78      typedef CMP Compare;
   35.79  
   35.80    private:
   35.81 @@ -80,10 +76,10 @@
   35.82  
   35.83    public:
   35.84  
   35.85 -    /// \brief Type to represent the items states.
   35.86 +    /// \brief Type to represent the states of the items.
   35.87      ///
   35.88 -    /// Each Item element have a state associated to it. It may be "in heap",
   35.89 -    /// "pre heap" or "post heap". The latter two are indifferent from the
   35.90 +    /// Each item has a state associated to it. It can be "in heap",
   35.91 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   35.92      /// heap's point of view, but may be useful to the user.
   35.93      ///
   35.94      /// The item-int map must be initialized in such way that it assigns
   35.95 @@ -94,60 +90,54 @@
   35.96        POST_HEAP = -2  ///< = -2.
   35.97      };
   35.98  
   35.99 -    /// \brief The constructor
  35.100 +    /// \brief Constructor.
  35.101      ///
  35.102 -    /// \c map should be given to the constructor, since it is
  35.103 -    ///   used internally to handle the cross references.
  35.104 +    /// Constructor.
  35.105 +    /// \param map A map that assigns \c int values to the items.
  35.106 +    /// It is used internally to handle the cross references.
  35.107 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  35.108      explicit FibHeap(ItemIntMap &map)
  35.109        : _minimum(0), _iim(map), _num() {}
  35.110  
  35.111 -    /// \brief The constructor
  35.112 +    /// \brief Constructor.
  35.113      ///
  35.114 -    /// \c map should be given to the constructor, since it is used
  35.115 -    /// internally to handle the cross references. \c comp is an
  35.116 -    /// object for ordering of the priorities.
  35.117 +    /// Constructor.
  35.118 +    /// \param map A map that assigns \c int values to the items.
  35.119 +    /// It is used internally to handle the cross references.
  35.120 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  35.121 +    /// \param comp The function object used for comparing the priorities.
  35.122      FibHeap(ItemIntMap &map, const Compare &comp)
  35.123        : _minimum(0), _iim(map), _comp(comp), _num() {}
  35.124  
  35.125      /// \brief The number of items stored in the heap.
  35.126      ///
  35.127 -    /// Returns the number of items stored in the heap.
  35.128 +    /// This function returns the number of items stored in the heap.
  35.129      int size() const { return _num; }
  35.130  
  35.131 -    /// \brief Checks if the heap stores no items.
  35.132 +    /// \brief Check if the heap is empty.
  35.133      ///
  35.134 -    ///   Returns \c true if and only if the heap stores no items.
  35.135 +    /// This function returns \c true if the heap is empty.
  35.136      bool empty() const { return _num==0; }
  35.137  
  35.138 -    /// \brief Make empty this heap.
  35.139 +    /// \brief Make the heap empty.
  35.140      ///
  35.141 -    /// Make empty this heap. It does not change the cross reference
  35.142 -    /// map.  If you want to reuse a heap what is not surely empty you
  35.143 -    /// should first clear the heap and after that you should set the
  35.144 -    /// cross reference map for each item to \c PRE_HEAP.
  35.145 +    /// This functon makes the heap empty.
  35.146 +    /// It does not change the cross reference map. If you want to reuse
  35.147 +    /// a heap that is not surely empty, you should first clear it and
  35.148 +    /// then you should set the cross reference map to \c PRE_HEAP
  35.149 +    /// for each item.
  35.150      void clear() {
  35.151        _data.clear(); _minimum = 0; _num = 0;
  35.152      }
  35.153  
  35.154 -    /// \brief \c item gets to the heap with priority \c value independently
  35.155 -    /// if \c item was already there.
  35.156 +    /// \brief Insert an item into the heap with the given priority.
  35.157      ///
  35.158 -    /// This method calls \ref push(\c item, \c value) if \c item is not
  35.159 -    /// stored in the heap and it calls \ref decrease(\c item, \c value) or
  35.160 -    /// \ref increase(\c item, \c value) otherwise.
  35.161 -    void set (const Item& item, const Prio& value) {
  35.162 -      int i=_iim[item];
  35.163 -      if ( i >= 0 && _data[i].in ) {
  35.164 -        if ( _comp(value, _data[i].prio) ) decrease(item, value);
  35.165 -        if ( _comp(_data[i].prio, value) ) increase(item, value);
  35.166 -      } else push(item, value);
  35.167 -    }
  35.168 -
  35.169 -    /// \brief Adds \c item to the heap with priority \c value.
  35.170 -    ///
  35.171 -    /// Adds \c item to the heap with priority \c value.
  35.172 -    /// \pre \c item must not be stored in the heap.
  35.173 -    void push (const Item& item, const Prio& value) {
  35.174 +    /// This function inserts the given item into the heap with the
  35.175 +    /// given priority.
  35.176 +    /// \param item The item to insert.
  35.177 +    /// \param prio The priority of the item.
  35.178 +    /// \pre \e item must not be stored in the heap.
  35.179 +    void push (const Item& item, const Prio& prio) {
  35.180        int i=_iim[item];
  35.181        if ( i < 0 ) {
  35.182          int s=_data.size();
  35.183 @@ -168,47 +158,37 @@
  35.184          _data[i].right_neighbor=_data[_minimum].right_neighbor;
  35.185          _data[_minimum].right_neighbor=i;
  35.186          _data[i].left_neighbor=_minimum;
  35.187 -        if ( _comp( value, _data[_minimum].prio) ) _minimum=i;
  35.188 +        if ( _comp( prio, _data[_minimum].prio) ) _minimum=i;
  35.189        } else {
  35.190          _data[i].right_neighbor=_data[i].left_neighbor=i;
  35.191          _minimum=i;
  35.192        }
  35.193 -      _data[i].prio=value;
  35.194 +      _data[i].prio=prio;
  35.195        ++_num;
  35.196      }
  35.197  
  35.198 -    /// \brief Returns the item with minimum priority relative to \c Compare.
  35.199 +    /// \brief Return the item having minimum priority.
  35.200      ///
  35.201 -    /// This method returns the item with minimum priority relative to \c
  35.202 -    /// Compare.
  35.203 -    /// \pre The heap must be nonempty.
  35.204 +    /// This function returns the item having minimum priority.
  35.205 +    /// \pre The heap must be non-empty.
  35.206      Item top() const { return _data[_minimum].name; }
  35.207  
  35.208 -    /// \brief Returns the minimum priority relative to \c Compare.
  35.209 +    /// \brief The minimum priority.
  35.210      ///
  35.211 -    /// It returns the minimum priority relative to \c Compare.
  35.212 -    /// \pre The heap must be nonempty.
  35.213 -    const Prio& prio() const { return _data[_minimum].prio; }
  35.214 +    /// This function returns the minimum priority.
  35.215 +    /// \pre The heap must be non-empty.
  35.216 +    Prio prio() const { return _data[_minimum].prio; }
  35.217  
  35.218 -    /// \brief Returns the priority of \c item.
  35.219 +    /// \brief Remove the item having minimum priority.
  35.220      ///
  35.221 -    /// It returns the priority of \c item.
  35.222 -    /// \pre \c item must be in the heap.
  35.223 -    const Prio& operator[](const Item& item) const {
  35.224 -      return _data[_iim[item]].prio;
  35.225 -    }
  35.226 -
  35.227 -    /// \brief Deletes the item with minimum priority relative to \c Compare.
  35.228 -    ///
  35.229 -    /// This method deletes the item with minimum priority relative to \c
  35.230 -    /// Compare from the heap.
  35.231 +    /// This function removes the item having minimum priority.
  35.232      /// \pre The heap must be non-empty.
  35.233      void pop() {
  35.234        /*The first case is that there are only one root.*/
  35.235        if ( _data[_minimum].left_neighbor==_minimum ) {
  35.236          _data[_minimum].in=false;
  35.237          if ( _data[_minimum].degree!=0 ) {
  35.238 -          makeroot(_data[_minimum].child);
  35.239 +          makeRoot(_data[_minimum].child);
  35.240            _minimum=_data[_minimum].child;
  35.241            balance();
  35.242          }
  35.243 @@ -221,7 +201,7 @@
  35.244            int child=_data[_minimum].child;
  35.245            int last_child=_data[child].left_neighbor;
  35.246  
  35.247 -          makeroot(child);
  35.248 +          makeRoot(child);
  35.249  
  35.250            _data[left].right_neighbor=child;
  35.251            _data[child].left_neighbor=left;
  35.252 @@ -234,10 +214,12 @@
  35.253        --_num;
  35.254      }
  35.255  
  35.256 -    /// \brief Deletes \c item from the heap.
  35.257 +    /// \brief Remove the given item from the heap.
  35.258      ///
  35.259 -    /// This method deletes \c item from the heap, if \c item was already
  35.260 -    /// stored in the heap. It is quite inefficient in Fibonacci heaps.
  35.261 +    /// This function removes the given item from the heap if it is
  35.262 +    /// already stored.
  35.263 +    /// \param item The item to delete.
  35.264 +    /// \pre \e item must be in the heap.
  35.265      void erase (const Item& item) {
  35.266        int i=_iim[item];
  35.267  
  35.268 @@ -252,43 +234,68 @@
  35.269        }
  35.270      }
  35.271  
  35.272 -    /// \brief Decreases the priority of \c item to \c value.
  35.273 +    /// \brief The priority of the given item.
  35.274      ///
  35.275 -    /// This method decreases the priority of \c item to \c value.
  35.276 -    /// \pre \c item must be stored in the heap with priority at least \c
  35.277 -    ///   value relative to \c Compare.
  35.278 -    void decrease (Item item, const Prio& value) {
  35.279 +    /// This function returns the priority of the given item.
  35.280 +    /// \param item The item.
  35.281 +    /// \pre \e item must be in the heap.
  35.282 +    Prio operator[](const Item& item) const {
  35.283 +      return _data[_iim[item]].prio;
  35.284 +    }
  35.285 +
  35.286 +    /// \brief Set the priority of an item or insert it, if it is
  35.287 +    /// not stored in the heap.
  35.288 +    ///
  35.289 +    /// This method sets the priority of the given item if it is
  35.290 +    /// already stored in the heap. Otherwise it inserts the given
  35.291 +    /// item into the heap with the given priority.
  35.292 +    /// \param item The item.
  35.293 +    /// \param prio The priority.
  35.294 +    void set (const Item& item, const Prio& prio) {
  35.295        int i=_iim[item];
  35.296 -      _data[i].prio=value;
  35.297 +      if ( i >= 0 && _data[i].in ) {
  35.298 +        if ( _comp(prio, _data[i].prio) ) decrease(item, prio);
  35.299 +        if ( _comp(_data[i].prio, prio) ) increase(item, prio);
  35.300 +      } else push(item, prio);
  35.301 +    }
  35.302 +
  35.303 +    /// \brief Decrease the priority of an item to the given value.
  35.304 +    ///
  35.305 +    /// This function decreases the priority of an item to the given value.
  35.306 +    /// \param item The item.
  35.307 +    /// \param prio The priority.
  35.308 +    /// \pre \e item must be stored in the heap with priority at least \e prio.
  35.309 +    void decrease (const Item& item, const Prio& prio) {
  35.310 +      int i=_iim[item];
  35.311 +      _data[i].prio=prio;
  35.312        int p=_data[i].parent;
  35.313  
  35.314 -      if ( p!=-1 && _comp(value, _data[p].prio) ) {
  35.315 +      if ( p!=-1 && _comp(prio, _data[p].prio) ) {
  35.316          cut(i,p);
  35.317          cascade(p);
  35.318        }
  35.319 -      if ( _comp(value, _data[_minimum].prio) ) _minimum=i;
  35.320 +      if ( _comp(prio, _data[_minimum].prio) ) _minimum=i;
  35.321      }
  35.322  
  35.323 -    /// \brief Increases the priority of \c item to \c value.
  35.324 +    /// \brief Increase the priority of an item to the given value.
  35.325      ///
  35.326 -    /// This method sets the priority of \c item to \c value. Though
  35.327 -    /// there is no precondition on the priority of \c item, this
  35.328 -    /// method should be used only if it is indeed necessary to increase
  35.329 -    /// (relative to \c Compare) the priority of \c item, because this
  35.330 -    /// method is inefficient.
  35.331 -    void increase (Item item, const Prio& value) {
  35.332 +    /// This function increases the priority of an item to the given value.
  35.333 +    /// \param item The item.
  35.334 +    /// \param prio The priority.
  35.335 +    /// \pre \e item must be stored in the heap with priority at most \e prio.
  35.336 +    void increase (const Item& item, const Prio& prio) {
  35.337        erase(item);
  35.338 -      push(item, value);
  35.339 +      push(item, prio);
  35.340      }
  35.341  
  35.342 -
  35.343 -    /// \brief Returns if \c item is in, has already been in, or has never
  35.344 -    /// been in the heap.
  35.345 +    /// \brief Return the state of an item.
  35.346      ///
  35.347 -    /// This method returns PRE_HEAP if \c item has never been in the
  35.348 -    /// heap, IN_HEAP if it is in the heap at the moment, and POST_HEAP
  35.349 -    /// otherwise. In the latter case it is possible that \c item will
  35.350 -    /// get back to the heap again.
  35.351 +    /// This method returns \c PRE_HEAP if the given item has never
  35.352 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  35.353 +    /// and \c POST_HEAP otherwise.
  35.354 +    /// In the latter case it is possible that the item will get back
  35.355 +    /// to the heap again.
  35.356 +    /// \param item The item.
  35.357      State state(const Item &item) const {
  35.358        int i=_iim[item];
  35.359        if( i>=0 ) {
  35.360 @@ -298,11 +305,11 @@
  35.361        return State(i);
  35.362      }
  35.363  
  35.364 -    /// \brief Sets the state of the \c item in the heap.
  35.365 +    /// \brief Set the state of an item in the heap.
  35.366      ///
  35.367 -    /// Sets the state of the \c item in the heap. It can be used to
  35.368 -    /// manually clear the heap when it is important to achive the
  35.369 -    /// better time _complexity.
  35.370 +    /// This function sets the state of the given item in the heap.
  35.371 +    /// It can be used to manually clear the heap when it is important
  35.372 +    /// to achive better time complexity.
  35.373      /// \param i The item.
  35.374      /// \param st The state. It should not be \c IN_HEAP.
  35.375      void state(const Item& i, State st) {
  35.376 @@ -365,7 +372,7 @@
  35.377        } while ( s != m );
  35.378      }
  35.379  
  35.380 -    void makeroot(int c) {
  35.381 +    void makeRoot(int c) {
  35.382        int s=c;
  35.383        do {
  35.384          _data[s].parent=-1;
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/lemon/fourary_heap.h	Thu Nov 05 08:39:49 2009 +0100
    36.3 @@ -0,0 +1,342 @@
    36.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    36.5 + *
    36.6 + * This file is a part of LEMON, a generic C++ optimization library.
    36.7 + *
    36.8 + * Copyright (C) 2003-2009
    36.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   36.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   36.11 + *
   36.12 + * Permission to use, modify and distribute this software is granted
   36.13 + * provided that this copyright notice appears in all copies. For
   36.14 + * precise terms see the accompanying LICENSE file.
   36.15 + *
   36.16 + * This software is provided "AS IS" with no warranty of any kind,
   36.17 + * express or implied, and with no claim as to its suitability for any
   36.18 + * purpose.
   36.19 + *
   36.20 + */
   36.21 +
   36.22 +#ifndef LEMON_FOURARY_HEAP_H
   36.23 +#define LEMON_FOURARY_HEAP_H
   36.24 +
   36.25 +///\ingroup heaps
   36.26 +///\file
   36.27 +///\brief Fourary heap implementation.
   36.28 +
   36.29 +#include <vector>
   36.30 +#include <utility>
   36.31 +#include <functional>
   36.32 +
   36.33 +namespace lemon {
   36.34 +
   36.35 +  /// \ingroup heaps
   36.36 +  ///
   36.37 +  ///\brief Fourary heap data structure.
   36.38 +  ///
   36.39 +  /// This class implements the \e fourary \e heap data structure.
   36.40 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   36.41 +  ///
   36.42 +  /// The fourary heap is a specialization of the \ref KaryHeap "K-ary heap"
   36.43 +  /// for <tt>K=4</tt>. It is similar to the \ref BinHeap "binary heap",
   36.44 +  /// but its nodes have at most four children, instead of two.
   36.45 +  ///
   36.46 +  /// \tparam PR Type of the priorities of the items.
   36.47 +  /// \tparam IM A read-writable item map with \c int values, used
   36.48 +  /// internally to handle the cross references.
   36.49 +  /// \tparam CMP A functor class for comparing the priorities.
   36.50 +  /// The default is \c std::less<PR>.
   36.51 +  ///
   36.52 +  ///\sa BinHeap
   36.53 +  ///\sa KaryHeap
   36.54 +#ifdef DOXYGEN
   36.55 +  template <typename PR, typename IM, typename CMP>
   36.56 +#else
   36.57 +  template <typename PR, typename IM, typename CMP = std::less<PR> >
   36.58 +#endif
   36.59 +  class FouraryHeap {
   36.60 +  public:
   36.61 +    /// Type of the item-int map.
   36.62 +    typedef IM ItemIntMap;
   36.63 +    /// Type of the priorities.
   36.64 +    typedef PR Prio;
   36.65 +    /// Type of the items stored in the heap.
   36.66 +    typedef typename ItemIntMap::Key Item;
   36.67 +    /// Type of the item-priority pairs.
   36.68 +    typedef std::pair<Item,Prio> Pair;
   36.69 +    /// Functor type for comparing the priorities.
   36.70 +    typedef CMP Compare;
   36.71 +
   36.72 +    /// \brief Type to represent the states of the items.
   36.73 +    ///
   36.74 +    /// Each item has a state associated to it. It can be "in heap",
   36.75 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   36.76 +    /// heap's point of view, but may be useful to the user.
   36.77 +    ///
   36.78 +    /// The item-int map must be initialized in such way that it assigns
   36.79 +    /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap.
   36.80 +    enum State {
   36.81 +      IN_HEAP = 0,    ///< = 0.
   36.82 +      PRE_HEAP = -1,  ///< = -1.
   36.83 +      POST_HEAP = -2  ///< = -2.
   36.84 +    };
   36.85 +
   36.86 +  private:
   36.87 +    std::vector<Pair> _data;
   36.88 +    Compare _comp;
   36.89 +    ItemIntMap &_iim;
   36.90 +
   36.91 +  public:
   36.92 +    /// \brief Constructor.
   36.93 +    ///
   36.94 +    /// Constructor.
   36.95 +    /// \param map A map that assigns \c int values to the items.
   36.96 +    /// It is used internally to handle the cross references.
   36.97 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
   36.98 +    explicit FouraryHeap(ItemIntMap &map) : _iim(map) {}
   36.99 +
  36.100 +    /// \brief Constructor.
  36.101 +    ///
  36.102 +    /// Constructor.
  36.103 +    /// \param map A map that assigns \c int values to the items.
  36.104 +    /// It is used internally to handle the cross references.
  36.105 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  36.106 +    /// \param comp The function object used for comparing the priorities.
  36.107 +    FouraryHeap(ItemIntMap &map, const Compare &comp)
  36.108 +      : _iim(map), _comp(comp) {}
  36.109 +
  36.110 +    /// \brief The number of items stored in the heap.
  36.111 +    ///
  36.112 +    /// This function returns the number of items stored in the heap.
  36.113 +    int size() const { return _data.size(); }
  36.114 +
  36.115 +    /// \brief Check if the heap is empty.
  36.116 +    ///
  36.117 +    /// This function returns \c true if the heap is empty.
  36.118 +    bool empty() const { return _data.empty(); }
  36.119 +
  36.120 +    /// \brief Make the heap empty.
  36.121 +    ///
  36.122 +    /// This functon makes the heap empty.
  36.123 +    /// It does not change the cross reference map. If you want to reuse
  36.124 +    /// a heap that is not surely empty, you should first clear it and
  36.125 +    /// then you should set the cross reference map to \c PRE_HEAP
  36.126 +    /// for each item.
  36.127 +    void clear() { _data.clear(); }
  36.128 +
  36.129 +  private:
  36.130 +    static int parent(int i) { return (i-1)/4; }
  36.131 +    static int firstChild(int i) { return 4*i+1; }
  36.132 +
  36.133 +    bool less(const Pair &p1, const Pair &p2) const {
  36.134 +      return _comp(p1.second, p2.second);
  36.135 +    }
  36.136 +
  36.137 +    void bubbleUp(int hole, Pair p) {
  36.138 +      int par = parent(hole);
  36.139 +      while( hole>0 && less(p,_data[par]) ) {
  36.140 +        move(_data[par],hole);
  36.141 +        hole = par;
  36.142 +        par = parent(hole);
  36.143 +      }
  36.144 +      move(p, hole);
  36.145 +    }
  36.146 +
  36.147 +    void bubbleDown(int hole, Pair p, int length) {
  36.148 +      if( length>1 ) {
  36.149 +        int child = firstChild(hole);
  36.150 +        while( child+3<length ) {
  36.151 +          int min=child;
  36.152 +          if( less(_data[++child], _data[min]) ) min=child;
  36.153 +          if( less(_data[++child], _data[min]) ) min=child;
  36.154 +          if( less(_data[++child], _data[min]) ) min=child;
  36.155 +          if( !less(_data[min], p) )
  36.156 +            goto ok;
  36.157 +          move(_data[min], hole);
  36.158 +          hole = min;
  36.159 +          child = firstChild(hole);
  36.160 +        }
  36.161 +        if ( child<length ) {
  36.162 +          int min = child;
  36.163 +          if( ++child<length && less(_data[child], _data[min]) ) min=child;
  36.164 +          if( ++child<length && less(_data[child], _data[min]) ) min=child;
  36.165 +          if( less(_data[min], p) ) {
  36.166 +            move(_data[min], hole);
  36.167 +            hole = min;
  36.168 +          }
  36.169 +        }
  36.170 +      }
  36.171 +    ok:
  36.172 +      move(p, hole);
  36.173 +    }
  36.174 +
  36.175 +    void move(const Pair &p, int i) {
  36.176 +      _data[i] = p;
  36.177 +      _iim.set(p.first, i);
  36.178 +    }
  36.179 +
  36.180 +  public:
  36.181 +    /// \brief Insert a pair of item and priority into the heap.
  36.182 +    ///
  36.183 +    /// This function inserts \c p.first to the heap with priority
  36.184 +    /// \c p.second.
  36.185 +    /// \param p The pair to insert.
  36.186 +    /// \pre \c p.first must not be stored in the heap.
  36.187 +    void push(const Pair &p) {
  36.188 +      int n = _data.size();
  36.189 +      _data.resize(n+1);
  36.190 +      bubbleUp(n, p);
  36.191 +    }
  36.192 +
  36.193 +    /// \brief Insert an item into the heap with the given priority.
  36.194 +    ///
  36.195 +    /// This function inserts the given item into the heap with the
  36.196 +    /// given priority.
  36.197 +    /// \param i The item to insert.
  36.198 +    /// \param p The priority of the item.
  36.199 +    /// \pre \e i must not be stored in the heap.
  36.200 +    void push(const Item &i, const Prio &p) { push(Pair(i,p)); }
  36.201 +
  36.202 +    /// \brief Return the item having minimum priority.
  36.203 +    ///
  36.204 +    /// This function returns the item having minimum priority.
  36.205 +    /// \pre The heap must be non-empty.
  36.206 +    Item top() const { return _data[0].first; }
  36.207 +
  36.208 +    /// \brief The minimum priority.
  36.209 +    ///
  36.210 +    /// This function returns the minimum priority.
  36.211 +    /// \pre The heap must be non-empty.
  36.212 +    Prio prio() const { return _data[0].second; }
  36.213 +
  36.214 +    /// \brief Remove the item having minimum priority.
  36.215 +    ///
  36.216 +    /// This function removes the item having minimum priority.
  36.217 +    /// \pre The heap must be non-empty.
  36.218 +    void pop() {
  36.219 +      int n = _data.size()-1;
  36.220 +      _iim.set(_data[0].first, POST_HEAP);
  36.221 +      if (n>0) bubbleDown(0, _data[n], n);
  36.222 +      _data.pop_back();
  36.223 +    }
  36.224 +
  36.225 +    /// \brief Remove the given item from the heap.
  36.226 +    ///
  36.227 +    /// This function removes the given item from the heap if it is
  36.228 +    /// already stored.
  36.229 +    /// \param i The item to delete.
  36.230 +    /// \pre \e i must be in the heap.
  36.231 +    void erase(const Item &i) {
  36.232 +      int h = _iim[i];
  36.233 +      int n = _data.size()-1;
  36.234 +      _iim.set(_data[h].first, POST_HEAP);
  36.235 +      if( h<n ) {
  36.236 +        if( less(_data[parent(h)], _data[n]) )
  36.237 +          bubbleDown(h, _data[n], n);
  36.238 +        else
  36.239 +          bubbleUp(h, _data[n]);
  36.240 +      }
  36.241 +      _data.pop_back();
  36.242 +    }
  36.243 +
  36.244 +    /// \brief The priority of the given item.
  36.245 +    ///
  36.246 +    /// This function returns the priority of the given item.
  36.247 +    /// \param i The item.
  36.248 +    /// \pre \e i must be in the heap.
  36.249 +    Prio operator[](const Item &i) const {
  36.250 +      int idx = _iim[i];
  36.251 +      return _data[idx].second;
  36.252 +    }
  36.253 +
  36.254 +    /// \brief Set the priority of an item or insert it, if it is
  36.255 +    /// not stored in the heap.
  36.256 +    ///
  36.257 +    /// This method sets the priority of the given item if it is
  36.258 +    /// already stored in the heap. Otherwise it inserts the given
  36.259 +    /// item into the heap with the given priority.
  36.260 +    /// \param i The item.
  36.261 +    /// \param p The priority.
  36.262 +    void set(const Item &i, const Prio &p) {
  36.263 +      int idx = _iim[i];
  36.264 +      if( idx < 0 )
  36.265 +        push(i,p);
  36.266 +      else if( _comp(p, _data[idx].second) )
  36.267 +        bubbleUp(idx, Pair(i,p));
  36.268 +      else
  36.269 +        bubbleDown(idx, Pair(i,p), _data.size());
  36.270 +    }
  36.271 +
  36.272 +    /// \brief Decrease the priority of an item to the given value.
  36.273 +    ///
  36.274 +    /// This function decreases the priority of an item to the given value.
  36.275 +    /// \param i The item.
  36.276 +    /// \param p The priority.
  36.277 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  36.278 +    void decrease(const Item &i, const Prio &p) {
  36.279 +      int idx = _iim[i];
  36.280 +      bubbleUp(idx, Pair(i,p));
  36.281 +    }
  36.282 +
  36.283 +    /// \brief Increase the priority of an item to the given value.
  36.284 +    ///
  36.285 +    /// This function increases the priority of an item to the given value.
  36.286 +    /// \param i The item.
  36.287 +    /// \param p The priority.
  36.288 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  36.289 +    void increase(const Item &i, const Prio &p) {
  36.290 +      int idx = _iim[i];
  36.291 +      bubbleDown(idx, Pair(i,p), _data.size());
  36.292 +    }
  36.293 +
  36.294 +    /// \brief Return the state of an item.
  36.295 +    ///
  36.296 +    /// This method returns \c PRE_HEAP if the given item has never
  36.297 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  36.298 +    /// and \c POST_HEAP otherwise.
  36.299 +    /// In the latter case it is possible that the item will get back
  36.300 +    /// to the heap again.
  36.301 +    /// \param i The item.
  36.302 +    State state(const Item &i) const {
  36.303 +      int s = _iim[i];
  36.304 +      if (s>=0) s=0;
  36.305 +      return State(s);
  36.306 +    }
  36.307 +
  36.308 +    /// \brief Set the state of an item in the heap.
  36.309 +    ///
  36.310 +    /// This function sets the state of the given item in the heap.
  36.311 +    /// It can be used to manually clear the heap when it is important
  36.312 +    /// to achive better time complexity.
  36.313 +    /// \param i The item.
  36.314 +    /// \param st The state. It should not be \c IN_HEAP.
  36.315 +    void state(const Item& i, State st) {
  36.316 +      switch (st) {
  36.317 +        case POST_HEAP:
  36.318 +        case PRE_HEAP:
  36.319 +          if (state(i) == IN_HEAP) erase(i);
  36.320 +          _iim[i] = st;
  36.321 +          break;
  36.322 +        case IN_HEAP:
  36.323 +          break;
  36.324 +      }
  36.325 +    }
  36.326 +
  36.327 +    /// \brief Replace an item in the heap.
  36.328 +    ///
  36.329 +    /// This function replaces item \c i with item \c j.
  36.330 +    /// Item \c i must be in the heap, while \c j must be out of the heap.
  36.331 +    /// After calling this method, item \c i will be out of the
  36.332 +    /// heap and \c j will be in the heap with the same prioriority
  36.333 +    /// as item \c i had before.
  36.334 +    void replace(const Item& i, const Item& j) {
  36.335 +      int idx = _iim[i];
  36.336 +      _iim.set(i, _iim[j]);
  36.337 +      _iim.set(j, idx);
  36.338 +      _data[idx].first = j;
  36.339 +    }
  36.340 +
  36.341 +  }; // class FouraryHeap
  36.342 +
  36.343 +} // namespace lemon
  36.344 +
  36.345 +#endif // LEMON_FOURARY_HEAP_H
    37.1 --- a/lemon/full_graph.h	Tue Aug 18 10:08:28 2009 +0200
    37.2 +++ b/lemon/full_graph.h	Thu Nov 05 08:39:49 2009 +0100
    37.3 @@ -24,7 +24,7 @@
    37.4  
    37.5  ///\ingroup graphs
    37.6  ///\file
    37.7 -///\brief FullGraph and FullDigraph classes.
    37.8 +///\brief FullDigraph and FullGraph classes.
    37.9  
   37.10  namespace lemon {
   37.11  
   37.12 @@ -148,24 +148,26 @@
   37.13  
   37.14    /// \ingroup graphs
   37.15    ///
   37.16 -  /// \brief A full digraph class.
   37.17 +  /// \brief A directed full graph class.
   37.18    ///
   37.19 -  /// This is a simple and fast directed full graph implementation.
   37.20 -  /// From each node go arcs to each node (including the source node),
   37.21 -  /// therefore the number of the arcs in the digraph is the square of
   37.22 -  /// the node number. This digraph type is completely static, so you
   37.23 -  /// can neither add nor delete either arcs or nodes, and it needs
   37.24 -  /// constant space in memory.
   37.25 +  /// FullDigraph is a simple and fast implmenetation of directed full
   37.26 +  /// (complete) graphs. It contains an arc from each node to each node
   37.27 +  /// (including a loop for each node), therefore the number of arcs
   37.28 +  /// is the square of the number of nodes.
   37.29 +  /// This class is completely static and it needs constant memory space.
   37.30 +  /// Thus you can neither add nor delete nodes or arcs, however
   37.31 +  /// the structure can be resized using resize().
   37.32    ///
   37.33 -  /// This class fully conforms to the \ref concepts::Digraph
   37.34 -  /// "Digraph concept".
   37.35 +  /// This type fully conforms to the \ref concepts::Digraph "Digraph concept".
   37.36 +  /// Most of its member functions and nested classes are documented
   37.37 +  /// only in the concept class.
   37.38    ///
   37.39 -  /// The \c FullDigraph and \c FullGraph classes are very similar,
   37.40 +  /// \note FullDigraph and FullGraph classes are very similar,
   37.41    /// but there are two differences. While this class conforms only
   37.42 -  /// to the \ref concepts::Digraph "Digraph" concept, the \c FullGraph
   37.43 -  /// class conforms to the \ref concepts::Graph "Graph" concept,
   37.44 -  /// moreover \c FullGraph does not contain a loop arc for each
   37.45 -  /// node as \c FullDigraph does.
   37.46 +  /// to the \ref concepts::Digraph "Digraph" concept, FullGraph
   37.47 +  /// conforms to the \ref concepts::Graph "Graph" concept,
   37.48 +  /// moreover FullGraph does not contain a loop for each
   37.49 +  /// node as this class does.
   37.50    ///
   37.51    /// \sa FullGraph
   37.52    class FullDigraph : public ExtendedFullDigraphBase {
   37.53 @@ -173,7 +175,9 @@
   37.54  
   37.55    public:
   37.56  
   37.57 -    /// \brief Constructor
   37.58 +    /// \brief Default constructor.
   37.59 +    ///
   37.60 +    /// Default constructor. The number of nodes and arcs will be zero.
   37.61      FullDigraph() { construct(0); }
   37.62  
   37.63      /// \brief Constructor
   37.64 @@ -184,8 +188,8 @@
   37.65  
   37.66      /// \brief Resizes the digraph
   37.67      ///
   37.68 -    /// Resizes the digraph. The function will fully destroy and
   37.69 -    /// rebuild the digraph. This cause that the maps of the digraph will
   37.70 +    /// This function resizes the digraph. It fully destroys and
   37.71 +    /// rebuilds the structure, therefore the maps of the digraph will be
   37.72      /// reallocated automatically and the previous values will be lost.
   37.73      void resize(int n) {
   37.74        Parent::notifier(Arc()).clear();
   37.75 @@ -197,24 +201,24 @@
   37.76  
   37.77      /// \brief Returns the node with the given index.
   37.78      ///
   37.79 -    /// Returns the node with the given index. Since it is a static
   37.80 -    /// digraph its nodes can be indexed with integers from the range
   37.81 -    /// <tt>[0..nodeNum()-1]</tt>.
   37.82 +    /// Returns the node with the given index. Since this structure is 
   37.83 +    /// completely static, the nodes can be indexed with integers from
   37.84 +    /// the range <tt>[0..nodeNum()-1]</tt>.
   37.85      /// \sa index()
   37.86      Node operator()(int ix) const { return Parent::operator()(ix); }
   37.87  
   37.88      /// \brief Returns the index of the given node.
   37.89      ///
   37.90 -    /// Returns the index of the given node. Since it is a static
   37.91 -    /// digraph its nodes can be indexed with integers from the range
   37.92 -    /// <tt>[0..nodeNum()-1]</tt>.
   37.93 -    /// \sa operator()
   37.94 -    int index(const Node& node) const { return Parent::index(node); }
   37.95 +    /// Returns the index of the given node. Since this structure is 
   37.96 +    /// completely static, the nodes can be indexed with integers from
   37.97 +    /// the range <tt>[0..nodeNum()-1]</tt>.
   37.98 +    /// \sa operator()()
   37.99 +    int index(Node node) const { return Parent::index(node); }
  37.100  
  37.101      /// \brief Returns the arc connecting the given nodes.
  37.102      ///
  37.103      /// Returns the arc connecting the given nodes.
  37.104 -    Arc arc(const Node& u, const Node& v) const {
  37.105 +    Arc arc(Node u, Node v) const {
  37.106        return Parent::arc(u, v);
  37.107      }
  37.108  
  37.109 @@ -520,21 +524,23 @@
  37.110    ///
  37.111    /// \brief An undirected full graph class.
  37.112    ///
  37.113 -  /// This is a simple and fast undirected full graph
  37.114 -  /// implementation. From each node go edge to each other node,
  37.115 -  /// therefore the number of edges in the graph is \f$n(n-1)/2\f$.
  37.116 -  /// This graph type is completely static, so you can neither
  37.117 -  /// add nor delete either edges or nodes, and it needs constant
  37.118 -  /// space in memory.
  37.119 +  /// FullGraph is a simple and fast implmenetation of undirected full
  37.120 +  /// (complete) graphs. It contains an edge between every distinct pair
  37.121 +  /// of nodes, therefore the number of edges is <tt>n(n-1)/2</tt>.
  37.122 +  /// This class is completely static and it needs constant memory space.
  37.123 +  /// Thus you can neither add nor delete nodes or edges, however
  37.124 +  /// the structure can be resized using resize().
  37.125    ///
  37.126 -  /// This class fully conforms to the \ref concepts::Graph "Graph concept".
  37.127 +  /// This type fully conforms to the \ref concepts::Graph "Graph concept".
  37.128 +  /// Most of its member functions and nested classes are documented
  37.129 +  /// only in the concept class.
  37.130    ///
  37.131 -  /// The \c FullGraph and \c FullDigraph classes are very similar,
  37.132 -  /// but there are two differences. While the \c FullDigraph class
  37.133 +  /// \note FullDigraph and FullGraph classes are very similar,
  37.134 +  /// but there are two differences. While FullDigraph
  37.135    /// conforms only to the \ref concepts::Digraph "Digraph" concept,
  37.136    /// this class conforms to the \ref concepts::Graph "Graph" concept,
  37.137 -  /// moreover \c FullGraph does not contain a loop arc for each
  37.138 -  /// node as \c FullDigraph does.
  37.139 +  /// moreover this class does not contain a loop for each
  37.140 +  /// node as FullDigraph does.
  37.141    ///
  37.142    /// \sa FullDigraph
  37.143    class FullGraph : public ExtendedFullGraphBase {
  37.144 @@ -542,7 +548,9 @@
  37.145  
  37.146    public:
  37.147  
  37.148 -    /// \brief Constructor
  37.149 +    /// \brief Default constructor.
  37.150 +    ///
  37.151 +    /// Default constructor. The number of nodes and edges will be zero.
  37.152      FullGraph() { construct(0); }
  37.153  
  37.154      /// \brief Constructor
  37.155 @@ -553,8 +561,8 @@
  37.156  
  37.157      /// \brief Resizes the graph
  37.158      ///
  37.159 -    /// Resizes the graph. The function will fully destroy and
  37.160 -    /// rebuild the graph. This cause that the maps of the graph will
  37.161 +    /// This function resizes the graph. It fully destroys and
  37.162 +    /// rebuilds the structure, therefore the maps of the graph will be
  37.163      /// reallocated automatically and the previous values will be lost.
  37.164      void resize(int n) {
  37.165        Parent::notifier(Arc()).clear();
  37.166 @@ -568,31 +576,31 @@
  37.167  
  37.168      /// \brief Returns the node with the given index.
  37.169      ///
  37.170 -    /// Returns the node with the given index. Since it is a static
  37.171 -    /// graph its nodes can be indexed with integers from the range
  37.172 -    /// <tt>[0..nodeNum()-1]</tt>.
  37.173 +    /// Returns the node with the given index. Since this structure is 
  37.174 +    /// completely static, the nodes can be indexed with integers from
  37.175 +    /// the range <tt>[0..nodeNum()-1]</tt>.
  37.176      /// \sa index()
  37.177      Node operator()(int ix) const { return Parent::operator()(ix); }
  37.178  
  37.179      /// \brief Returns the index of the given node.
  37.180      ///
  37.181 -    /// Returns the index of the given node. Since it is a static
  37.182 -    /// graph its nodes can be indexed with integers from the range
  37.183 -    /// <tt>[0..nodeNum()-1]</tt>.
  37.184 -    /// \sa operator()
  37.185 -    int index(const Node& node) const { return Parent::index(node); }
  37.186 +    /// Returns the index of the given node. Since this structure is 
  37.187 +    /// completely static, the nodes can be indexed with integers from
  37.188 +    /// the range <tt>[0..nodeNum()-1]</tt>.
  37.189 +    /// \sa operator()()
  37.190 +    int index(Node node) const { return Parent::index(node); }
  37.191  
  37.192      /// \brief Returns the arc connecting the given nodes.
  37.193      ///
  37.194      /// Returns the arc connecting the given nodes.
  37.195 -    Arc arc(const Node& s, const Node& t) const {
  37.196 +    Arc arc(Node s, Node t) const {
  37.197        return Parent::arc(s, t);
  37.198      }
  37.199  
  37.200 -    /// \brief Returns the edge connects the given nodes.
  37.201 +    /// \brief Returns the edge connecting the given nodes.
  37.202      ///
  37.203 -    /// Returns the edge connects the given nodes.
  37.204 -    Edge edge(const Node& u, const Node& v) const {
  37.205 +    /// Returns the edge connecting the given nodes.
  37.206 +    Edge edge(Node u, Node v) const {
  37.207        return Parent::edge(u, v);
  37.208      }
  37.209  
    38.1 --- a/lemon/glpk.cc	Tue Aug 18 10:08:28 2009 +0200
    38.2 +++ b/lemon/glpk.cc	Thu Nov 05 08:39:49 2009 +0100
    38.3 @@ -59,6 +59,42 @@
    38.4      return i;
    38.5    }
    38.6  
    38.7 +  int GlpkBase::_addRow(Value lo, ExprIterator b, 
    38.8 +                        ExprIterator e, Value up) {
    38.9 +    int i = glp_add_rows(lp, 1);
   38.10 +
   38.11 +    if (lo == -INF) {
   38.12 +      if (up == INF) {
   38.13 +        glp_set_row_bnds(lp, i, GLP_FR, lo, up);
   38.14 +      } else {
   38.15 +        glp_set_row_bnds(lp, i, GLP_UP, lo, up);
   38.16 +      }    
   38.17 +    } else {
   38.18 +      if (up == INF) {
   38.19 +        glp_set_row_bnds(lp, i, GLP_LO, lo, up);
   38.20 +      } else if (lo != up) {        
   38.21 +        glp_set_row_bnds(lp, i, GLP_DB, lo, up);
   38.22 +      } else {
   38.23 +        glp_set_row_bnds(lp, i, GLP_FX, lo, up);
   38.24 +      }
   38.25 +    }
   38.26 +
   38.27 +    std::vector<int> indexes;
   38.28 +    std::vector<Value> values;
   38.29 +
   38.30 +    indexes.push_back(0);
   38.31 +    values.push_back(0);
   38.32 +
   38.33 +    for(ExprIterator it = b; it != e; ++it) {
   38.34 +      indexes.push_back(it->first);
   38.35 +      values.push_back(it->second);
   38.36 +    }
   38.37 +
   38.38 +    glp_set_mat_row(lp, i, values.size() - 1,
   38.39 +                    &indexes.front(), &values.front());
   38.40 +    return i;
   38.41 +  }
   38.42 +
   38.43    void GlpkBase::_eraseCol(int i) {
   38.44      int ca[2];
   38.45      ca[1] = i;
    39.1 --- a/lemon/glpk.h	Tue Aug 18 10:08:28 2009 +0200
    39.2 +++ b/lemon/glpk.h	Thu Nov 05 08:39:49 2009 +0100
    39.3 @@ -54,6 +54,7 @@
    39.4  
    39.5      virtual int _addCol();
    39.6      virtual int _addRow();
    39.7 +    virtual int _addRow(Value l, ExprIterator b, ExprIterator e, Value u);
    39.8  
    39.9      virtual void _eraseCol(int i);
   39.10      virtual void _eraseRow(int i);
    40.1 --- a/lemon/gomory_hu.h	Tue Aug 18 10:08:28 2009 +0200
    40.2 +++ b/lemon/gomory_hu.h	Thu Nov 05 08:39:49 2009 +0100
    40.3 @@ -359,10 +359,10 @@
    40.4      /// This example counts the nodes in the minimum cut separating \c s from
    40.5      /// \c t.
    40.6      /// \code
    40.7 -    /// GomoruHu<Graph> gom(g, capacities);
    40.8 +    /// GomoryHu<Graph> gom(g, capacities);
    40.9      /// gom.run();
   40.10      /// int cnt=0;
   40.11 -    /// for(GomoruHu<Graph>::MinCutNodeIt n(gom,s,t); n!=INVALID; ++n) ++cnt;
   40.12 +    /// for(GomoryHu<Graph>::MinCutNodeIt n(gom,s,t); n!=INVALID; ++n) ++cnt;
   40.13      /// \endcode
   40.14      class MinCutNodeIt
   40.15      {
   40.16 @@ -456,10 +456,10 @@
   40.17      /// This example computes the value of the minimum cut separating \c s from
   40.18      /// \c t.
   40.19      /// \code
   40.20 -    /// GomoruHu<Graph> gom(g, capacities);
   40.21 +    /// GomoryHu<Graph> gom(g, capacities);
   40.22      /// gom.run();
   40.23      /// int value=0;
   40.24 -    /// for(GomoruHu<Graph>::MinCutEdgeIt e(gom,s,t); e!=INVALID; ++e)
   40.25 +    /// for(GomoryHu<Graph>::MinCutEdgeIt e(gom,s,t); e!=INVALID; ++e)
   40.26      ///   value+=capacities[e];
   40.27      /// \endcode
   40.28      /// The result will be the same as the value returned by
    41.1 --- a/lemon/grid_graph.h	Tue Aug 18 10:08:28 2009 +0200
    41.2 +++ b/lemon/grid_graph.h	Thu Nov 05 08:39:49 2009 +0100
    41.3 @@ -470,18 +470,22 @@
    41.4    ///
    41.5    /// \brief Grid graph class
    41.6    ///
    41.7 -  /// This class implements a special graph type. The nodes of the
    41.8 -  /// graph can be indexed by two integer \c (i,j) value where \c i is
    41.9 -  /// in the \c [0..width()-1] range and j is in the \c
   41.10 -  /// [0..height()-1] range.  Two nodes are connected in the graph if
   41.11 -  /// the indexes differ exactly on one position and exactly one is
   41.12 -  /// the difference. The nodes of the graph can be indexed by position
   41.13 -  /// with the \c operator()() function. The positions of the nodes can be
   41.14 -  /// get with \c pos(), \c col() and \c row() members. The outgoing
   41.15 +  /// GridGraph implements a special graph type. The nodes of the
   41.16 +  /// graph can be indexed by two integer values \c (i,j) where \c i is
   41.17 +  /// in the range <tt>[0..width()-1]</tt> and j is in the range
   41.18 +  /// <tt>[0..height()-1]</tt>. Two nodes are connected in the graph if
   41.19 +  /// the indices differ exactly on one position and the difference is
   41.20 +  /// also exactly one. The nodes of the graph can be obtained by position
   41.21 +  /// using the \c operator()() function and the indices of the nodes can
   41.22 +  /// be obtained using \c pos(), \c col() and \c row() members. The outgoing
   41.23    /// arcs can be retrieved with the \c right(), \c up(), \c left()
   41.24    /// and \c down() functions, where the bottom-left corner is the
   41.25    /// origin.
   41.26    ///
   41.27 +  /// This class is completely static and it needs constant memory space.
   41.28 +  /// Thus you can neither add nor delete nodes or edges, however
   41.29 +  /// the structure can be resized using resize().
   41.30 +  ///
   41.31    /// \image html grid_graph.png
   41.32    /// \image latex grid_graph.eps "Grid graph" width=\textwidth
   41.33    ///
   41.34 @@ -496,16 +500,19 @@
   41.35    /// }
   41.36    ///\endcode
   41.37    ///
   41.38 -  /// This graph type fully conforms to the \ref concepts::Graph
   41.39 -  /// "Graph concept".
   41.40 +  /// This type fully conforms to the \ref concepts::Graph "Graph concept".
   41.41 +  /// Most of its member functions and nested classes are documented
   41.42 +  /// only in the concept class.
   41.43    class GridGraph : public ExtendedGridGraphBase {
   41.44      typedef ExtendedGridGraphBase Parent;
   41.45  
   41.46    public:
   41.47  
   41.48 -    /// \brief Map to get the indices of the nodes as dim2::Point<int>.
   41.49 +    /// \brief Map to get the indices of the nodes as \ref dim2::Point
   41.50 +    /// "dim2::Point<int>".
   41.51      ///
   41.52 -    /// Map to get the indices of the nodes as dim2::Point<int>.
   41.53 +    /// Map to get the indices of the nodes as \ref dim2::Point
   41.54 +    /// "dim2::Point<int>".
   41.55      class IndexMap {
   41.56      public:
   41.57        /// \brief The key type of the map
   41.58 @@ -514,13 +521,9 @@
   41.59        typedef dim2::Point<int> Value;
   41.60  
   41.61        /// \brief Constructor
   41.62 -      ///
   41.63 -      /// Constructor
   41.64        IndexMap(const GridGraph& graph) : _graph(graph) {}
   41.65  
   41.66        /// \brief The subscript operator
   41.67 -      ///
   41.68 -      /// The subscript operator.
   41.69        Value operator[](Key key) const {
   41.70          return _graph.pos(key);
   41.71        }
   41.72 @@ -540,13 +543,9 @@
   41.73        typedef int Value;
   41.74  
   41.75        /// \brief Constructor
   41.76 -      ///
   41.77 -      /// Constructor
   41.78        ColMap(const GridGraph& graph) : _graph(graph) {}
   41.79  
   41.80        /// \brief The subscript operator
   41.81 -      ///
   41.82 -      /// The subscript operator.
   41.83        Value operator[](Key key) const {
   41.84          return _graph.col(key);
   41.85        }
   41.86 @@ -566,13 +565,9 @@
   41.87        typedef int Value;
   41.88  
   41.89        /// \brief Constructor
   41.90 -      ///
   41.91 -      /// Constructor
   41.92        RowMap(const GridGraph& graph) : _graph(graph) {}
   41.93  
   41.94        /// \brief The subscript operator
   41.95 -      ///
   41.96 -      /// The subscript operator.
   41.97        Value operator[](Key key) const {
   41.98          return _graph.row(key);
   41.99        }
  41.100 @@ -583,15 +578,14 @@
  41.101  
  41.102      /// \brief Constructor
  41.103      ///
  41.104 -    /// Construct a grid graph with given size.
  41.105 +    /// Construct a grid graph with the given size.
  41.106      GridGraph(int width, int height) { construct(width, height); }
  41.107  
  41.108 -    /// \brief Resize the graph
  41.109 +    /// \brief Resizes the graph
  41.110      ///
  41.111 -    /// Resize the graph. The function will fully destroy and rebuild
  41.112 -    /// the graph.  This cause that the maps of the graph will
  41.113 -    /// reallocated automatically and the previous values will be
  41.114 -    /// lost.
  41.115 +    /// This function resizes the graph. It fully destroys and
  41.116 +    /// rebuilds the structure, therefore the maps of the graph will be
  41.117 +    /// reallocated automatically and the previous values will be lost.
  41.118      void resize(int width, int height) {
  41.119        Parent::notifier(Arc()).clear();
  41.120        Parent::notifier(Edge()).clear();
  41.121 @@ -609,42 +603,42 @@
  41.122        return Parent::operator()(i, j);
  41.123      }
  41.124  
  41.125 -    /// \brief Gives back the column index of the node.
  41.126 +    /// \brief The column index of the node.
  41.127      ///
  41.128      /// Gives back the column index of the node.
  41.129      int col(Node n) const {
  41.130        return Parent::col(n);
  41.131      }
  41.132  
  41.133 -    /// \brief Gives back the row index of the node.
  41.134 +    /// \brief The row index of the node.
  41.135      ///
  41.136      /// Gives back the row index of the node.
  41.137      int row(Node n) const {
  41.138        return Parent::row(n);
  41.139      }
  41.140  
  41.141 -    /// \brief Gives back the position of the node.
  41.142 +    /// \brief The position of the node.
  41.143      ///
  41.144      /// Gives back the position of the node, ie. the <tt>(col,row)</tt> pair.
  41.145      dim2::Point<int> pos(Node n) const {
  41.146        return Parent::pos(n);
  41.147      }
  41.148  
  41.149 -    /// \brief Gives back the number of the columns.
  41.150 +    /// \brief The number of the columns.
  41.151      ///
  41.152      /// Gives back the number of the columns.
  41.153      int width() const {
  41.154        return Parent::width();
  41.155      }
  41.156  
  41.157 -    /// \brief Gives back the number of the rows.
  41.158 +    /// \brief The number of the rows.
  41.159      ///
  41.160      /// Gives back the number of the rows.
  41.161      int height() const {
  41.162        return Parent::height();
  41.163      }
  41.164  
  41.165 -    /// \brief Gives back the arc goes right from the node.
  41.166 +    /// \brief The arc goes right from the node.
  41.167      ///
  41.168      /// Gives back the arc goes right from the node. If there is not
  41.169      /// outgoing arc then it gives back INVALID.
  41.170 @@ -652,7 +646,7 @@
  41.171        return Parent::right(n);
  41.172      }
  41.173  
  41.174 -    /// \brief Gives back the arc goes left from the node.
  41.175 +    /// \brief The arc goes left from the node.
  41.176      ///
  41.177      /// Gives back the arc goes left from the node. If there is not
  41.178      /// outgoing arc then it gives back INVALID.
  41.179 @@ -660,7 +654,7 @@
  41.180        return Parent::left(n);
  41.181      }
  41.182  
  41.183 -    /// \brief Gives back the arc goes up from the node.
  41.184 +    /// \brief The arc goes up from the node.
  41.185      ///
  41.186      /// Gives back the arc goes up from the node. If there is not
  41.187      /// outgoing arc then it gives back INVALID.
  41.188 @@ -668,7 +662,7 @@
  41.189        return Parent::up(n);
  41.190      }
  41.191  
  41.192 -    /// \brief Gives back the arc goes down from the node.
  41.193 +    /// \brief The arc goes down from the node.
  41.194      ///
  41.195      /// Gives back the arc goes down from the node. If there is not
  41.196      /// outgoing arc then it gives back INVALID.
    42.1 --- a/lemon/hypercube_graph.h	Tue Aug 18 10:08:28 2009 +0200
    42.2 +++ b/lemon/hypercube_graph.h	Thu Nov 05 08:39:49 2009 +0100
    42.3 @@ -282,17 +282,21 @@
    42.4    ///
    42.5    /// \brief Hypercube graph class
    42.6    ///
    42.7 -  /// This class implements a special graph type. The nodes of the graph
    42.8 -  /// are indiced with integers with at most \c dim binary digits.
    42.9 +  /// HypercubeGraph implements a special graph type. The nodes of the
   42.10 +  /// graph are indexed with integers having at most \c dim binary digits.
   42.11    /// Two nodes are connected in the graph if and only if their indices
   42.12    /// differ only on one position in the binary form.
   42.13 +  /// This class is completely static and it needs constant memory space.
   42.14 +  /// Thus you can neither add nor delete nodes or edges, however 
   42.15 +  /// the structure can be resized using resize().
   42.16 +  ///
   42.17 +  /// This type fully conforms to the \ref concepts::Graph "Graph concept".
   42.18 +  /// Most of its member functions and nested classes are documented
   42.19 +  /// only in the concept class.
   42.20    ///
   42.21    /// \note The type of the indices is chosen to \c int for efficiency
   42.22    /// reasons. Thus the maximum dimension of this implementation is 26
   42.23    /// (assuming that the size of \c int is 32 bit).
   42.24 -  ///
   42.25 -  /// This graph type fully conforms to the \ref concepts::Graph
   42.26 -  /// "Graph concept".
   42.27    class HypercubeGraph : public ExtendedHypercubeGraphBase {
   42.28      typedef ExtendedHypercubeGraphBase Parent;
   42.29  
   42.30 @@ -303,6 +307,21 @@
   42.31      /// Constructs a hypercube graph with \c dim dimensions.
   42.32      HypercubeGraph(int dim) { construct(dim); }
   42.33  
   42.34 +    /// \brief Resizes the graph
   42.35 +    ///
   42.36 +    /// This function resizes the graph. It fully destroys and
   42.37 +    /// rebuilds the structure, therefore the maps of the graph will be
   42.38 +    /// reallocated automatically and the previous values will be lost.
   42.39 +    void resize(int dim) {
   42.40 +      Parent::notifier(Arc()).clear();
   42.41 +      Parent::notifier(Edge()).clear();
   42.42 +      Parent::notifier(Node()).clear();
   42.43 +      construct(dim);
   42.44 +      Parent::notifier(Node()).build();
   42.45 +      Parent::notifier(Edge()).build();
   42.46 +      Parent::notifier(Arc()).build();
   42.47 +    }
   42.48 +
   42.49      /// \brief The number of dimensions.
   42.50      ///
   42.51      /// Gives back the number of dimensions.
   42.52 @@ -320,7 +339,7 @@
   42.53      /// \brief The dimension id of an edge.
   42.54      ///
   42.55      /// Gives back the dimension id of the given edge.
   42.56 -    /// It is in the [0..dim-1] range.
   42.57 +    /// It is in the range <tt>[0..dim-1]</tt>.
   42.58      int dimension(Edge edge) const {
   42.59        return Parent::dimension(edge);
   42.60      }
   42.61 @@ -328,7 +347,7 @@
   42.62      /// \brief The dimension id of an arc.
   42.63      ///
   42.64      /// Gives back the dimension id of the given arc.
   42.65 -    /// It is in the [0..dim-1] range.
   42.66 +    /// It is in the range <tt>[0..dim-1]</tt>.
   42.67      int dimension(Arc arc) const {
   42.68        return Parent::dimension(arc);
   42.69      }
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/lemon/kary_heap.h	Thu Nov 05 08:39:49 2009 +0100
    43.3 @@ -0,0 +1,352 @@
    43.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
    43.5 + *
    43.6 + * This file is a part of LEMON, a generic C++ optimization library.
    43.7 + *
    43.8 + * Copyright (C) 2003-2009
    43.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
   43.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
   43.11 + *
   43.12 + * Permission to use, modify and distribute this software is granted
   43.13 + * provided that this copyright notice appears in all copies. For
   43.14 + * precise terms see the accompanying LICENSE file.
   43.15 + *
   43.16 + * This software is provided "AS IS" with no warranty of any kind,
   43.17 + * express or implied, and with no claim as to its suitability for any
   43.18 + * purpose.
   43.19 + *
   43.20 + */
   43.21 +
   43.22 +#ifndef LEMON_KARY_HEAP_H
   43.23 +#define LEMON_KARY_HEAP_H
   43.24 +
   43.25 +///\ingroup heaps
   43.26 +///\file
   43.27 +///\brief Fourary heap implementation.
   43.28 +
   43.29 +#include <vector>
   43.30 +#include <utility>
   43.31 +#include <functional>
   43.32 +
   43.33 +namespace lemon {
   43.34 +
   43.35 +  /// \ingroup heaps
   43.36 +  ///
   43.37 +  ///\brief K-ary heap data structure.
   43.38 +  ///
   43.39 +  /// This class implements the \e K-ary \e heap data structure.
   43.40 +  /// It fully conforms to the \ref concepts::Heap "heap concept".
   43.41 +  ///
   43.42 +  /// The \ref KaryHeap "K-ary heap" is a generalization of the
   43.43 +  /// \ref BinHeap "binary heap" structure, its nodes have at most
   43.44 +  /// \c K children, instead of two.
   43.45 +  /// \ref BinHeap and \ref FouraryHeap are specialized implementations
   43.46 +  /// of this structure for <tt>K=2</tt> and <tt>K=4</tt>, respectively.
   43.47 +  ///
   43.48 +  /// \tparam PR Type of the priorities of the items.
   43.49 +  /// \tparam IM A read-writable item map with \c int values, used
   43.50 +  /// internally to handle the cross references.
   43.51 +  /// \tparam K The degree of the heap, each node have at most \e K
   43.52 +  /// children. The default is 16. Powers of two are suggested to use
   43.53 +  /// so that the multiplications and divisions needed to traverse the
   43.54 +  /// nodes of the heap could be performed faster.
   43.55 +  /// \tparam CMP A functor class for comparing the priorities.
   43.56 +  /// The default is \c std::less<PR>.
   43.57 +  ///
   43.58 +  ///\sa BinHeap
   43.59 +  ///\sa FouraryHeap
   43.60 +#ifdef DOXYGEN
   43.61 +  template <typename PR, typename IM, int K, typename CMP>
   43.62 +#else
   43.63 +  template <typename PR, typename IM, int K = 16,
   43.64 +            typename CMP = std::less<PR> >
   43.65 +#endif
   43.66 +  class KaryHeap {
   43.67 +  public:
   43.68 +    /// Type of the item-int map.
   43.69 +    typedef IM ItemIntMap;
   43.70 +    /// Type of the priorities.
   43.71 +    typedef PR Prio;
   43.72 +    /// Type of the items stored in the heap.
   43.73 +    typedef typename ItemIntMap::Key Item;
   43.74 +    /// Type of the item-priority pairs.
   43.75 +    typedef std::pair<Item,Prio> Pair;
   43.76 +    /// Functor type for comparing the priorities.
   43.77 +    typedef CMP Compare;
   43.78 +
   43.79 +    /// \brief Type to represent the states of the items.
   43.80 +    ///
   43.81 +    /// Each item has a state associated to it. It can be "in heap",
   43.82 +    /// "pre-heap" or "post-heap". The latter two are indifferent from the
   43.83 +    /// heap's point of view, but may be useful to the user.
   43.84 +    ///
   43.85 +    /// The item-int map must be initialized in such way that it assigns
   43.86 +    /// \c PRE_HEAP (<tt>-1</tt>) to any element to be put in the heap.
   43.87 +    enum State {
   43.88 +      IN_HEAP = 0,    ///< = 0.
   43.89 +      PRE_HEAP = -1,  ///< = -1.
   43.90 +      POST_HEAP = -2  ///< = -2.
   43.91 +    };
   43.92 +
   43.93 +  private:
   43.94 +    std::vector<Pair> _data;
   43.95 +    Compare _comp;
   43.96 +    ItemIntMap &_iim;
   43.97 +
   43.98 +  public:
   43.99 +    /// \brief Constructor.
  43.100 +    ///
  43.101 +    /// Constructor.
  43.102 +    /// \param map A map that assigns \c int values to the items.
  43.103 +    /// It is used internally to handle the cross references.
  43.104 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  43.105 +    explicit KaryHeap(ItemIntMap &map) : _iim(map) {}
  43.106 +
  43.107 +    /// \brief Constructor.
  43.108 +    ///
  43.109 +    /// Constructor.
  43.110 +    /// \param map A map that assigns \c int values to the items.
  43.111 +    /// It is used internally to handle the cross references.
  43.112 +    /// The assigned value must be \c PRE_HEAP (<tt>-1</tt>) for each item.
  43.113 +    /// \param comp The function object used for comparing the priorities.
  43.114 +    KaryHeap(ItemIntMap &map, const Compare &comp)
  43.115 +      : _iim(map), _comp(comp) {}
  43.116 +
  43.117 +    /// \brief The number of items stored in the heap.
  43.118 +    ///
  43.119 +    /// This function returns the number of items stored in the heap.
  43.120 +    int size() const { return _data.size(); }
  43.121 +
  43.122 +    /// \brief Check if the heap is empty.
  43.123 +    ///
  43.124 +    /// This function returns \c true if the heap is empty.
  43.125 +    bool empty() const { return _data.empty(); }
  43.126 +
  43.127 +    /// \brief Make the heap empty.
  43.128 +    ///
  43.129 +    /// This functon makes the heap empty.
  43.130 +    /// It does not change the cross reference map. If you want to reuse
  43.131 +    /// a heap that is not surely empty, you should first clear it and
  43.132 +    /// then you should set the cross reference map to \c PRE_HEAP
  43.133 +    /// for each item.
  43.134 +    void clear() { _data.clear(); }
  43.135 +
  43.136 +  private:
  43.137 +    int parent(int i) { return (i-1)/K; }
  43.138 +    int firstChild(int i) { return K*i+1; }
  43.139 +
  43.140 +    bool less(const Pair &p1, const Pair &p2) const {
  43.141 +      return _comp(p1.second, p2.second);
  43.142 +    }
  43.143 +
  43.144 +    void bubbleUp(int hole, Pair p) {
  43.145 +      int par = parent(hole);
  43.146 +      while( hole>0 && less(p,_data[par]) ) {
  43.147 +        move(_data[par],hole);
  43.148 +        hole = par;
  43.149 +        par = parent(hole);
  43.150 +      }
  43.151 +      move(p, hole);
  43.152 +    }
  43.153 +
  43.154 +    void bubbleDown(int hole, Pair p, int length) {
  43.155 +      if( length>1 ) {
  43.156 +        int child = firstChild(hole);
  43.157 +        while( child+K<=length ) {
  43.158 +          int min=child;
  43.159 +          for (int i=1; i<K; ++i) {
  43.160 +            if( less(_data[child+i], _data[min]) )
  43.161 +              min=child+i;
  43.162 +          }
  43.163 +          if( !less(_data[min], p) )
  43.164 +            goto ok;
  43.165 +          move(_data[min], hole);
  43.166 +          hole = min;
  43.167 +          child = firstChild(hole);
  43.168 +        }
  43.169 +        if ( child<length ) {
  43.170 +          int min = child;
  43.171 +          while (++child < length) {
  43.172 +            if( less(_data[child], _data[min]) )
  43.173 +              min=child;
  43.174 +          }
  43.175 +          if( less(_data[min], p) ) {
  43.176 +            move(_data[min], hole);
  43.177 +            hole = min;
  43.178 +          }
  43.179 +        }
  43.180 +      }
  43.181 +    ok:
  43.182 +      move(p, hole);
  43.183 +    }
  43.184 +
  43.185 +    void move(const Pair &p, int i) {
  43.186 +      _data[i] = p;
  43.187 +      _iim.set(p.first, i);
  43.188 +    }
  43.189 +
  43.190 +  public:
  43.191 +    /// \brief Insert a pair of item and priority into the heap.
  43.192 +    ///
  43.193 +    /// This function inserts \c p.first to the heap with priority
  43.194 +    /// \c p.second.
  43.195 +    /// \param p The pair to insert.
  43.196 +    /// \pre \c p.first must not be stored in the heap.
  43.197 +    void push(const Pair &p) {
  43.198 +      int n = _data.size();
  43.199 +      _data.resize(n+1);
  43.200 +      bubbleUp(n, p);
  43.201 +    }
  43.202 +
  43.203 +    /// \brief Insert an item into the heap with the given priority.
  43.204 +    ///
  43.205 +    /// This function inserts the given item into the heap with the
  43.206 +    /// given priority.
  43.207 +    /// \param i The item to insert.
  43.208 +    /// \param p The priority of the item.
  43.209 +    /// \pre \e i must not be stored in the heap.
  43.210 +    void push(const Item &i, const Prio &p) { push(Pair(i,p)); }
  43.211 +
  43.212 +    /// \brief Return the item having minimum priority.
  43.213 +    ///
  43.214 +    /// This function returns the item having minimum priority.
  43.215 +    /// \pre The heap must be non-empty.
  43.216 +    Item top() const { return _data[0].first; }
  43.217 +
  43.218 +    /// \brief The minimum priority.
  43.219 +    ///
  43.220 +    /// This function returns the minimum priority.
  43.221 +    /// \pre The heap must be non-empty.
  43.222 +    Prio prio() const { return _data[0].second; }
  43.223 +
  43.224 +    /// \brief Remove the item having minimum priority.
  43.225 +    ///
  43.226 +    /// This function removes the item having minimum priority.
  43.227 +    /// \pre The heap must be non-empty.
  43.228 +    void pop() {
  43.229 +      int n = _data.size()-1;
  43.230 +      _iim.set(_data[0].first, POST_HEAP);
  43.231 +      if (n>0) bubbleDown(0, _data[n], n);
  43.232 +      _data.pop_back();
  43.233 +    }
  43.234 +
  43.235 +    /// \brief Remove the given item from the heap.
  43.236 +    ///
  43.237 +    /// This function removes the given item from the heap if it is
  43.238 +    /// already stored.
  43.239 +    /// \param i The item to delete.
  43.240 +    /// \pre \e i must be in the heap.
  43.241 +    void erase(const Item &i) {
  43.242 +      int h = _iim[i];
  43.243 +      int n = _data.size()-1;
  43.244 +      _iim.set(_data[h].first, POST_HEAP);
  43.245 +      if( h<n ) {
  43.246 +        if( less(_data[parent(h)], _data[n]) )
  43.247 +          bubbleDown(h, _data[n], n);
  43.248 +        else
  43.249 +          bubbleUp(h, _data[n]);
  43.250 +      }
  43.251 +      _data.pop_back();
  43.252 +    }
  43.253 +
  43.254 +    /// \brief The priority of the given item.
  43.255 +    ///
  43.256 +    /// This function returns the priority of the given item.
  43.257 +    /// \param i The item.
  43.258 +    /// \pre \e i must be in the heap.
  43.259 +    Prio operator[](const Item &i) const {
  43.260 +      int idx = _iim[i];
  43.261 +      return _data[idx].second;
  43.262 +    }
  43.263 +
  43.264 +    /// \brief Set the priority of an item or insert it, if it is
  43.265 +    /// not stored in the heap.
  43.266 +    ///
  43.267 +    /// This method sets the priority of the given item if it is
  43.268 +    /// already stored in the heap. Otherwise it inserts the given
  43.269 +    /// item into the heap with the given priority.
  43.270 +    /// \param i The item.
  43.271 +    /// \param p The priority.
  43.272 +    void set(const Item &i, const Prio &p) {
  43.273 +      int idx = _iim[i];
  43.274 +      if( idx<0 )
  43.275 +        push(i,p);
  43.276 +      else if( _comp(p, _data[idx].second) )
  43.277 +        bubbleUp(idx, Pair(i,p));
  43.278 +      else
  43.279 +        bubbleDown(idx, Pair(i,p), _data.size());
  43.280 +    }
  43.281 +
  43.282 +    /// \brief Decrease the priority of an item to the given value.
  43.283 +    ///
  43.284 +    /// This function decreases the priority of an item to the given value.
  43.285 +    /// \param i The item.
  43.286 +    /// \param p The priority.
  43.287 +    /// \pre \e i must be stored in the heap with priority at least \e p.
  43.288 +    void decrease(const Item &i, const Prio &p) {
  43.289 +      int idx = _iim[i];
  43.290 +      bubbleUp(idx, Pair(i,p));
  43.291 +    }
  43.292 +
  43.293 +    /// \brief Increase the priority of an item to the given value.
  43.294 +    ///
  43.295 +    /// This function increases the priority of an item to the given value.
  43.296 +    /// \param i The item.
  43.297 +    /// \param p The priority.
  43.298 +    /// \pre \e i must be stored in the heap with priority at most \e p.
  43.299 +    void increase(const Item &i, const Prio &p) {
  43.300 +      int idx = _iim[i];
  43.301 +      bubbleDown(idx, Pair(i,p), _data.size());
  43.302 +    }
  43.303 +
  43.304 +    /// \brief Return the state of an item.
  43.305 +    ///
  43.306 +    /// This method returns \c PRE_HEAP if the given item has never
  43.307 +    /// been in the heap, \c IN_HEAP if it is in the heap at the moment,
  43.308 +    /// and \c POST_HEAP otherwise.
  43.309 +    /// In the latter case it is possible that the item will get back
  43.310 +    /// to the heap again.
  43.311 +    /// \param i The item.
  43.312 +    State state(const Item &i) const {
  43.313 +      int s = _iim[i];
  43.314 +      if (s>=0) s=0;
  43.315 +      return State(s);
  43.316 +    }
  43.317 +
  43.318 +    /// \brief Set the state of an item in the heap.
  43.319 +    ///
  43.320 +    /// This function sets the state of the given item in the heap.
  43.321 +    /// It can be used to manually clear the heap when it is important
  43.322 +    /// to achive better time complexity.
  43.323 +    /// \param i The item.
  43.324 +    /// \param st The state. It should not be \c IN_HEAP.
  43.325 +    void state(const Item& i, State st) {
  43.326 +      switch (st) {
  43.327 +        case POST_HEAP:
  43.328 +        case PRE_HEAP:
  43.329 +          if (state(i) == IN_HEAP) erase(i);
  43.330 +          _iim[i] = st;
  43.331 +          break;
  43.332 +        case IN_HEAP:
  43.333 +          break;
  43.334 +      }
  43.335 +    }
  43.336 +
  43.337 +    /// \brief Replace an item in the heap.
  43.338 +    ///
  43.339 +    /// This function replaces item \c i with item \c j.
  43.340 +    /// Item \c i must be in the heap, while \c j must be out of the heap.
  43.341 +    /// After calling this method, item \c i will be out of the
  43.342 +    /// heap and \c j will be in the heap with the same prioriority
  43.343 +    /// as item \c i had before.
  43.344 +    void replace(const Item& i, const Item& j) {
  43.345 +      int idx=_iim[i];
  43.346 +      _iim.set(i, _iim[j]);
  43.347 +      _iim.set(j, idx);
  43.348 +      _data[idx].first=j;
  43.349 +    }
  43.350 +
  43.351 +  }; // class KaryHeap
  43.352 +
  43.353 +} // namespace lemon
  43.354 +
  43.355 +#endif // LEMON_KARY_HEAP_H
    44.1 --- a/lemon/list_graph.h	Tue Aug 18 10:08:28 2009 +0200
    44.2 +++ b/lemon/list_graph.h	Thu Nov 05 08:39:49 2009 +0100
    44.3 @@ -21,7 +21,7 @@
    44.4  
    44.5  ///\ingroup graphs
    44.6  ///\file
    44.7 -///\brief ListDigraph, ListGraph classes.
    44.8 +///\brief ListDigraph and ListGraph classes.
    44.9  
   44.10  #include <lemon/core.h>
   44.11  #include <lemon/error.h>
   44.12 @@ -32,6 +32,8 @@
   44.13  
   44.14  namespace lemon {
   44.15  
   44.16 +  class ListDigraph;
   44.17 +
   44.18    class ListDigraphBase {
   44.19  
   44.20    protected:
   44.21 @@ -62,6 +64,7 @@
   44.22  
   44.23      class Node {
   44.24        friend class ListDigraphBase;
   44.25 +      friend class ListDigraph;
   44.26      protected:
   44.27  
   44.28        int id;
   44.29 @@ -77,6 +80,7 @@
   44.30  
   44.31      class Arc {
   44.32        friend class ListDigraphBase;
   44.33 +      friend class ListDigraph;
   44.34      protected:
   44.35  
   44.36        int id;
   44.37 @@ -116,20 +120,20 @@
   44.38      void first(Arc& arc) const {
   44.39        int n;
   44.40        for(n = first_node;
   44.41 -          n!=-1 && nodes[n].first_in == -1;
   44.42 +          n != -1 && nodes[n].first_out == -1;
   44.43            n = nodes[n].next) {}
   44.44 -      arc.id = (n == -1) ? -1 : nodes[n].first_in;
   44.45 +      arc.id = (n == -1) ? -1 : nodes[n].first_out;
   44.46      }
   44.47  
   44.48      void next(Arc& arc) const {
   44.49 -      if (arcs[arc.id].next_in != -1) {
   44.50 -        arc.id = arcs[arc.id].next_in;
   44.51 +      if (arcs[arc.id].next_out != -1) {
   44.52 +        arc.id = arcs[arc.id].next_out;
   44.53        } else {
   44.54          int n;
   44.55 -        for(n = nodes[arcs[arc.id].target].next;
   44.56 -            n!=-1 && nodes[n].first_in == -1;
   44.57 +        for(n = nodes[arcs[arc.id].source].next;
   44.58 +            n != -1 && nodes[n].first_out == -1;
   44.59              n = nodes[n].next) {}
   44.60 -        arc.id = (n == -1) ? -1 : nodes[n].first_in;
   44.61 +        arc.id = (n == -1) ? -1 : nodes[n].first_out;
   44.62        }
   44.63      }
   44.64  
   44.65 @@ -311,31 +315,25 @@
   44.66  
   44.67    ///A general directed graph structure.
   44.68  
   44.69 -  ///\ref ListDigraph is a simple and fast <em>directed graph</em>
   44.70 -  ///implementation based on static linked lists that are stored in
   44.71 +  ///\ref ListDigraph is a versatile and fast directed graph
   44.72 +  ///implementation based on linked lists that are stored in
   44.73    ///\c std::vector structures.
   44.74    ///
   44.75 -  ///It conforms to the \ref concepts::Digraph "Digraph concept" and it
   44.76 -  ///also provides several useful additional functionalities.
   44.77 -  ///Most of the member functions and nested classes are documented
   44.78 +  ///This type fully conforms to the \ref concepts::Digraph "Digraph concept"
   44.79 +  ///and it also provides several useful additional functionalities.
   44.80 +  ///Most of its member functions and nested classes are documented
   44.81    ///only in the concept class.
   44.82    ///
   44.83    ///\sa concepts::Digraph
   44.84 -
   44.85 +  ///\sa ListGraph
   44.86    class ListDigraph : public ExtendedListDigraphBase {
   44.87      typedef ExtendedListDigraphBase Parent;
   44.88  
   44.89    private:
   44.90 -    ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
   44.91 -