0
4
0
| 1 | 1 |
LEMON code without an explicit copyright notice is covered by the following |
| 2 | 2 |
copyright/license. |
| 3 | 3 |
|
| 4 |
Copyright (C) 2003- |
|
| 4 |
Copyright (C) 2003-2010 Egervary Jeno Kombinatorikus Optimalizalasi |
|
| 5 | 5 |
Kutatocsoport (Egervary Combinatorial Optimization Research Group, |
| 6 | 6 |
EGRES). |
| 7 | 7 |
|
| 8 | 8 |
=========================================================================== |
| 9 | 9 |
Boost Software License, Version 1.0 |
| 10 | 10 |
=========================================================================== |
| 11 | 11 |
|
| 12 | 12 |
Permission is hereby granted, free of charge, to any person or organization |
| 13 | 13 |
obtaining a copy of the software and accompanying documentation covered by |
| 14 | 14 |
this license (the "Software") to use, reproduce, display, distribute, |
| 15 | 15 |
execute, and transmit the Software, and to prepare derivative works of the |
| 16 | 16 |
Software, and to permit third-parties to whom the Software is furnished to |
| 17 | 17 |
do so, all subject to the following: |
| 18 | 18 |
|
| 19 | 19 |
The copyright notices in the Software and this entire statement, including |
| 20 | 20 |
the above license grant, this restriction and the following disclaimer, |
| ... | ... |
@@ -250,40 +250,32 @@ |
| 250 | 250 |
|
| 251 | 251 |
LEMON provides several heap classes. They are efficient implementations |
| 252 | 252 |
of the abstract data type \e priority \e queue. They store items with |
| 253 | 253 |
specified values called \e priorities in such a way that finding and |
| 254 | 254 |
removing the item with minimum priority are efficient. |
| 255 | 255 |
The basic operations are adding and erasing items, changing the priority |
| 256 | 256 |
of an item, etc. |
| 257 | 257 |
|
| 258 | 258 |
Heaps are crucial in several algorithms, such as Dijkstra and Prim. |
| 259 | 259 |
The heap implementations have the same interface, thus any of them can be |
| 260 | 260 |
used easily in such algorithms. |
| 261 | 261 |
|
| 262 | 262 |
\sa \ref concepts::Heap "Heap concept" |
| 263 | 263 |
*/ |
| 264 | 264 |
|
| 265 | 265 |
/** |
| 266 |
@defgroup matrices Matrices |
|
| 267 |
@ingroup datas |
|
| 268 |
\brief Two dimensional data storages implemented in LEMON. |
|
| 269 |
|
|
| 270 |
This group contains two dimensional data storages implemented in LEMON. |
|
| 271 |
*/ |
|
| 272 |
|
|
| 273 |
/** |
|
| 274 | 266 |
@defgroup auxdat Auxiliary Data Structures |
| 275 | 267 |
@ingroup datas |
| 276 | 268 |
\brief Auxiliary data structures implemented in LEMON. |
| 277 | 269 |
|
| 278 | 270 |
This group contains some data structures implemented in LEMON in |
| 279 | 271 |
order to make it easier to implement combinatorial algorithms. |
| 280 | 272 |
*/ |
| 281 | 273 |
|
| 282 | 274 |
/** |
| 283 | 275 |
@defgroup geomdat Geometric Data Structures |
| 284 | 276 |
@ingroup auxdat |
| 285 | 277 |
\brief Geometric data structures implemented in LEMON. |
| 286 | 278 |
|
| 287 | 279 |
This group contains geometric data structures implemented in LEMON. |
| 288 | 280 |
|
| 289 | 281 |
- \ref lemon::dim2::Point "dim2::Point" implements a two dimensional |
| ... | ... |
@@ -459,45 +451,45 @@ |
| 459 | 451 |
\ref clrs01algorithms, \ref amo93networkflows. |
| 460 | 452 |
|
| 461 | 453 |
The \e minimum \e mean \e cycle \e problem is to find a directed cycle |
| 462 | 454 |
of minimum mean length (cost) in a digraph. |
| 463 | 455 |
The mean length of a cycle is the average length of its arcs, i.e. the |
| 464 | 456 |
ratio between the total length of the cycle and the number of arcs on it. |
| 465 | 457 |
|
| 466 | 458 |
This problem has an important connection to \e conservative \e length |
| 467 | 459 |
\e functions, too. A length function on the arcs of a digraph is called |
| 468 | 460 |
conservative if and only if there is no directed cycle of negative total |
| 469 | 461 |
length. For an arbitrary length function, the negative of the minimum |
| 470 | 462 |
cycle mean is the smallest \f$\epsilon\f$ value so that increasing the |
| 471 | 463 |
arc lengths uniformly by \f$\epsilon\f$ results in a conservative length |
| 472 | 464 |
function. |
| 473 | 465 |
|
| 474 | 466 |
LEMON contains three algorithms for solving the minimum mean cycle problem: |
| 475 |
- \ref |
|
| 467 |
- \ref KarpMmc Karp's original algorithm \ref amo93networkflows, |
|
| 476 | 468 |
\ref dasdan98minmeancycle. |
| 477 |
- \ref |
|
| 469 |
- \ref HartmannOrlinMmc Hartmann-Orlin's algorithm, which is an improved |
|
| 478 | 470 |
version of Karp's algorithm \ref dasdan98minmeancycle. |
| 479 |
- \ref |
|
| 471 |
- \ref HowardMmc Howard's policy iteration algorithm |
|
| 480 | 472 |
\ref dasdan98minmeancycle. |
| 481 | 473 |
|
| 482 |
In practice, the Howard algorithm proved to be by far the most efficient |
|
| 483 |
one, though the best known theoretical bound on its running time is |
|
| 484 |
exponential. |
|
| 485 |
Both Karp and HartmannOrlin algorithms run in time O(ne) and use space |
|
| 486 |
O(n<sup>2</sup>+e), but the latter one is typically faster due to the |
|
| 487 |
applied early termination scheme. |
|
| 474 |
In practice, the \ref HowardMmc "Howard" algorithm proved to be by far the |
|
| 475 |
most efficient one, though the best known theoretical bound on its running |
|
| 476 |
time is exponential. |
|
| 477 |
Both \ref KarpMmc "Karp" and \ref HartmannOrlinMmc "Hartmann-Orlin" algorithms |
|
| 478 |
run in time O(ne) and use space O(n<sup>2</sup>+e), but the latter one is |
|
| 479 |
typically faster due to the applied early termination scheme. |
|
| 488 | 480 |
*/ |
| 489 | 481 |
|
| 490 | 482 |
/** |
| 491 | 483 |
@defgroup matching Matching Algorithms |
| 492 | 484 |
@ingroup algs |
| 493 | 485 |
\brief Algorithms for finding matchings in graphs and bipartite graphs. |
| 494 | 486 |
|
| 495 | 487 |
This group contains the algorithms for calculating |
| 496 | 488 |
matchings in graphs and bipartite graphs. The general matching problem is |
| 497 | 489 |
finding a subset of the edges for which each node has at most one incident |
| 498 | 490 |
edge. |
| 499 | 491 |
|
| 500 | 492 |
There are several different algorithms for calculate matchings in |
| 501 | 493 |
graphs. The matching problems in bipartite graphs are generally |
| 502 | 494 |
easier than in general graphs. The goal of the matching optimization |
| 503 | 495 |
can be finding maximum cardinality, maximum weight or minimum cost |
| ... | ... |
@@ -22,38 +22,45 @@ |
| 22 | 22 |
#include <vector> |
| 23 | 23 |
#include <map> |
| 24 | 24 |
#include <list> |
| 25 | 25 |
#include <string> |
| 26 | 26 |
#include <iostream> |
| 27 | 27 |
#include <sstream> |
| 28 | 28 |
#include <algorithm> |
| 29 | 29 |
#include <lemon/assert.h> |
| 30 | 30 |
|
| 31 | 31 |
///\ingroup misc |
| 32 | 32 |
///\file |
| 33 | 33 |
///\brief A tool to parse command line arguments. |
| 34 | 34 |
|
| 35 | 35 |
namespace lemon {
|
| 36 | 36 |
|
| 37 | 37 |
///Exception used by ArgParser |
| 38 |
|
|
| 39 |
///Exception used by ArgParser. |
|
| 40 |
/// |
|
| 38 | 41 |
class ArgParserException : public Exception {
|
| 39 | 42 |
public: |
| 43 |
/// Reasons for failure |
|
| 44 |
|
|
| 45 |
/// Reasons for failure. |
|
| 46 |
/// |
|
| 40 | 47 |
enum Reason {
|
| 41 |
HELP, /// <tt>--help</tt> option was given |
|
| 42 |
UNKNOWN_OPT, /// Unknown option was given |
|
| 43 |
|
|
| 48 |
HELP, ///< <tt>--help</tt> option was given. |
|
| 49 |
UNKNOWN_OPT, ///< Unknown option was given. |
|
| 50 |
INVALID_OPT ///< Invalid combination of options. |
|
| 44 | 51 |
}; |
| 45 | 52 |
|
| 46 | 53 |
private: |
| 47 | 54 |
Reason _reason; |
| 48 | 55 |
|
| 49 | 56 |
public: |
| 50 | 57 |
///Constructor |
| 51 | 58 |
ArgParserException(Reason r) throw() : _reason(r) {}
|
| 52 | 59 |
///Virtual destructor |
| 53 | 60 |
virtual ~ArgParserException() throw() {}
|
| 54 | 61 |
///A short description of the exception |
| 55 | 62 |
virtual const char* what() const throw() {
|
| 56 | 63 |
switch(_reason) |
| 57 | 64 |
{
|
| 58 | 65 |
case HELP: |
| 59 | 66 |
return "lemon::ArgParseException: ask for help"; |
| ... | ... |
@@ -25,33 +25,33 @@ |
| 25 | 25 |
/// \brief Hartmann-Orlin's algorithm for finding a minimum mean cycle. |
| 26 | 26 |
|
| 27 | 27 |
#include <vector> |
| 28 | 28 |
#include <limits> |
| 29 | 29 |
#include <lemon/core.h> |
| 30 | 30 |
#include <lemon/path.h> |
| 31 | 31 |
#include <lemon/tolerance.h> |
| 32 | 32 |
#include <lemon/connectivity.h> |
| 33 | 33 |
|
| 34 | 34 |
namespace lemon {
|
| 35 | 35 |
|
| 36 | 36 |
/// \brief Default traits class of HartmannOrlinMmc class. |
| 37 | 37 |
/// |
| 38 | 38 |
/// Default traits class of HartmannOrlinMmc class. |
| 39 | 39 |
/// \tparam GR The type of the digraph. |
| 40 | 40 |
/// \tparam CM The type of the cost map. |
| 41 |
/// It must conform to the \ref concepts:: |
|
| 41 |
/// It must conform to the \ref concepts::ReadMap "ReadMap" concept. |
|
| 42 | 42 |
#ifdef DOXYGEN |
| 43 | 43 |
template <typename GR, typename CM> |
| 44 | 44 |
#else |
| 45 | 45 |
template <typename GR, typename CM, |
| 46 | 46 |
bool integer = std::numeric_limits<typename CM::Value>::is_integer> |
| 47 | 47 |
#endif |
| 48 | 48 |
struct HartmannOrlinMmcDefaultTraits |
| 49 | 49 |
{
|
| 50 | 50 |
/// The type of the digraph |
| 51 | 51 |
typedef GR Digraph; |
| 52 | 52 |
/// The type of the cost map |
| 53 | 53 |
typedef CM CostMap; |
| 54 | 54 |
/// The type of the arc costs |
| 55 | 55 |
typedef typename CostMap::Value Cost; |
| 56 | 56 |
|
| 57 | 57 |
/// \brief The large cost type used for internal computations |
| ... | ... |
@@ -86,33 +86,33 @@ |
| 86 | 86 |
typedef long LargeCost; |
| 87 | 87 |
#endif |
| 88 | 88 |
typedef lemon::Tolerance<LargeCost> Tolerance; |
| 89 | 89 |
typedef lemon::Path<Digraph> Path; |
| 90 | 90 |
}; |
| 91 | 91 |
|
| 92 | 92 |
|
| 93 | 93 |
/// \addtogroup min_mean_cycle |
| 94 | 94 |
/// @{
|
| 95 | 95 |
|
| 96 | 96 |
/// \brief Implementation of the Hartmann-Orlin algorithm for finding |
| 97 | 97 |
/// a minimum mean cycle. |
| 98 | 98 |
/// |
| 99 | 99 |
/// This class implements the Hartmann-Orlin algorithm for finding |
| 100 | 100 |
/// a directed cycle of minimum mean cost in a digraph |
| 101 | 101 |
/// \ref amo93networkflows, \ref dasdan98minmeancycle. |
| 102 |
/// It is an improved version of \ref |
|
| 102 |
/// It is an improved version of \ref KarpMmc "Karp"'s original algorithm, |
|
| 103 | 103 |
/// it applies an efficient early termination scheme. |
| 104 | 104 |
/// It runs in time O(ne) and uses space O(n<sup>2</sup>+e). |
| 105 | 105 |
/// |
| 106 | 106 |
/// \tparam GR The type of the digraph the algorithm runs on. |
| 107 | 107 |
/// \tparam CM The type of the cost map. The default |
| 108 | 108 |
/// map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>". |
| 109 | 109 |
/// \tparam TR The traits class that defines various types used by the |
| 110 | 110 |
/// algorithm. By default, it is \ref HartmannOrlinMmcDefaultTraits |
| 111 | 111 |
/// "HartmannOrlinMmcDefaultTraits<GR, CM>". |
| 112 | 112 |
/// In most cases, this parameter should not be set directly, |
| 113 | 113 |
/// consider to use the named template parameters instead. |
| 114 | 114 |
#ifdef DOXYGEN |
| 115 | 115 |
template <typename GR, typename CM, typename TR> |
| 116 | 116 |
#else |
| 117 | 117 |
template < typename GR, |
| 118 | 118 |
typename CM = typename GR::template ArcMap<int>, |
0 comments (0 inline)