gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Rename MinMeanCycle to Howard (#179)
1 2 1
default
4 files changed with 30 insertions and 30 deletions:
↑ Collapse diff ↑
Show white space 96 line context
... ...
@@ -38,101 +38,101 @@
38 38
endif
39 39

	
40 40
if HAVE_CPLEX
41 41
lemon_libemon_la_SOURCES += lemon/cplex.cc
42 42
endif
43 43

	
44 44
if HAVE_SOPLEX
45 45
lemon_libemon_la_SOURCES += lemon/soplex.cc
46 46
endif
47 47

	
48 48
if HAVE_CLP
49 49
lemon_libemon_la_SOURCES += lemon/clp.cc
50 50
endif
51 51

	
52 52
if HAVE_CBC
53 53
lemon_libemon_la_SOURCES += lemon/cbc.cc
54 54
endif
55 55

	
56 56
lemon_HEADERS += \
57 57
	lemon/adaptors.h \
58 58
	lemon/arg_parser.h \
59 59
	lemon/assert.h \
60 60
	lemon/bfs.h \
61 61
	lemon/bin_heap.h \
62 62
	lemon/bucket_heap.h \
63 63
	lemon/cbc.h \
64 64
	lemon/circulation.h \
65 65
	lemon/clp.h \
66 66
	lemon/color.h \
67 67
	lemon/concept_check.h \
68 68
	lemon/connectivity.h \
69 69
	lemon/counter.h \
70 70
	lemon/core.h \
71 71
	lemon/cplex.h \
72 72
	lemon/dfs.h \
73 73
	lemon/dijkstra.h \
74 74
	lemon/dim2.h \
75 75
	lemon/dimacs.h \
76 76
	lemon/edge_set.h \
77 77
	lemon/elevator.h \
78 78
	lemon/error.h \
79 79
	lemon/euler.h \
80 80
	lemon/fib_heap.h \
81 81
	lemon/full_graph.h \
82 82
	lemon/glpk.h \
83 83
	lemon/gomory_hu.h \
84 84
	lemon/graph_to_eps.h \
85 85
	lemon/grid_graph.h \
86
	lemon/howard.h \
86 87
	lemon/hypercube_graph.h \
87 88
	lemon/kruskal.h \
88 89
	lemon/hao_orlin.h \
89 90
	lemon/lgf_reader.h \
90 91
	lemon/lgf_writer.h \
91 92
	lemon/list_graph.h \
92 93
	lemon/lp.h \
93 94
	lemon/lp_base.h \
94 95
	lemon/lp_skeleton.h \
95 96
	lemon/list_graph.h \
96 97
	lemon/maps.h \
97 98
	lemon/matching.h \
98 99
	lemon/math.h \
99 100
	lemon/min_cost_arborescence.h \
100
	lemon/min_mean_cycle.h \
101 101
	lemon/nauty_reader.h \
102 102
	lemon/network_simplex.h \
103 103
	lemon/path.h \
104 104
	lemon/preflow.h \
105 105
	lemon/radix_heap.h \
106 106
	lemon/radix_sort.h \
107 107
	lemon/random.h \
108 108
	lemon/smart_graph.h \
109 109
	lemon/soplex.h \
110 110
	lemon/suurballe.h \
111 111
	lemon/time_measure.h \
112 112
	lemon/tolerance.h \
113 113
	lemon/unionfind.h \
114 114
	lemon/bits/windows.h
115 115

	
116 116
bits_HEADERS += \
117 117
	lemon/bits/alteration_notifier.h \
118 118
	lemon/bits/array_map.h \
119 119
	lemon/bits/bezier.h \
120 120
	lemon/bits/default_map.h \
121 121
	lemon/bits/edge_set_extender.h \
122 122
	lemon/bits/enable_if.h \
123 123
	lemon/bits/graph_adaptor_extender.h \
124 124
	lemon/bits/graph_extender.h \
125 125
	lemon/bits/map_extender.h \
126 126
	lemon/bits/path_dump.h \
127 127
	lemon/bits/solver_bits.h \
128 128
	lemon/bits/traits.h \
129 129
	lemon/bits/variant.h \
130 130
	lemon/bits/vector_map.h
131 131

	
132 132
concept_HEADERS += \
133 133
	lemon/concepts/digraph.h \
134 134
	lemon/concepts/graph.h \
135 135
	lemon/concepts/graph_components.h \
136 136
	lemon/concepts/heap.h \
137 137
	lemon/concepts/maps.h \
138 138
	lemon/concepts/path.h
Show white space 96 line context
1 1
/* -*- C++ -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19
#ifndef LEMON_MIN_MEAN_CYCLE_H
20
#define LEMON_MIN_MEAN_CYCLE_H
19
#ifndef LEMON_HOWARD_H
20
#define LEMON_HOWARD_H
21 21

	
22 22
/// \ingroup shortest_path
23 23
///
24 24
/// \file
25 25
/// \brief Howard'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
  /// \brief Default traits class of MinMeanCycle class.
36
  /// \brief Default traits class of Howard class.
37 37
  ///
38
  /// Default traits class of MinMeanCycle class.
38
  /// Default traits class of Howard class.
39 39
  /// \tparam GR The type of the digraph.
40 40
  /// \tparam LEN The type of the length map.
41 41
  /// It must conform to the \ref concepts::ReadMap "ReadMap" concept.
42 42
#ifdef DOXYGEN
43 43
  template <typename GR, typename LEN>
44 44
#else
45 45
  template <typename GR, typename LEN,
46 46
    bool integer = std::numeric_limits<typename LEN::Value>::is_integer>
47 47
#endif
48
  struct MinMeanCycleDefaultTraits
48
  struct HowardDefaultTraits
49 49
  {
50 50
    /// The type of the digraph
51 51
    typedef GR Digraph;
52 52
    /// The type of the length map
53 53
    typedef LEN LengthMap;
54 54
    /// The type of the arc lengths
55 55
    typedef typename LengthMap::Value Value;
56 56

	
57 57
    /// \brief The large value type used for internal computations
58 58
    ///
59 59
    /// The large value type used for internal computations.
60 60
    /// It is \c long \c long if the \c Value type is integer,
61 61
    /// otherwise it is \c double.
62 62
    /// \c Value must be convertible to \c LargeValue.
63 63
    typedef double LargeValue;
64 64

	
65 65
    /// The tolerance type used for internal computations
66 66
    typedef lemon::Tolerance<LargeValue> Tolerance;
67 67

	
68 68
    /// \brief The path type of the found cycles
69 69
    ///
70 70
    /// The path type of the found cycles.
71 71
    /// It must conform to the \ref lemon::concepts::Path "Path" concept
72 72
    /// and it must have an \c addBack() function.
73 73
    typedef lemon::Path<Digraph> Path;
74 74
  };
75 75

	
76 76
  // Default traits class for integer value types
77 77
  template <typename GR, typename LEN>
78
  struct MinMeanCycleDefaultTraits<GR, LEN, true>
78
  struct HowardDefaultTraits<GR, LEN, true>
79 79
  {
80 80
    typedef GR Digraph;
81 81
    typedef LEN LengthMap;
82 82
    typedef typename LengthMap::Value Value;
83 83
#ifdef LEMON_HAVE_LONG_LONG
84 84
    typedef long long LargeValue;
85 85
#else
86 86
    typedef long LargeValue;
87 87
#endif
88 88
    typedef lemon::Tolerance<LargeValue> Tolerance;
89 89
    typedef lemon::Path<Digraph> Path;
90 90
  };
91 91

	
92 92

	
93 93
  /// \addtogroup shortest_path
94 94
  /// @{
95 95

	
96 96
  /// \brief Implementation of Howard's algorithm for finding a minimum
97 97
  /// mean cycle.
98 98
  ///
99
  /// \ref MinMeanCycle implements Howard's algorithm for finding a
100
  /// directed cycle of minimum mean length (cost) in a digraph.
99
  /// This class implements Howard's policy iteration algorithm for finding
100
  /// a directed cycle of minimum mean length (cost) in a digraph.
101 101
  ///
102 102
  /// \tparam GR The type of the digraph the algorithm runs on.
103 103
  /// \tparam LEN The type of the length map. The default
104 104
  /// map type is \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
105 105
#ifdef DOXYGEN
106 106
  template <typename GR, typename LEN, typename TR>
107 107
#else
108 108
  template < typename GR,
109 109
             typename LEN = typename GR::template ArcMap<int>,
110
             typename TR = MinMeanCycleDefaultTraits<GR, LEN> >
110
             typename TR = HowardDefaultTraits<GR, LEN> >
111 111
#endif
112
  class MinMeanCycle
112
  class Howard
113 113
  {
114 114
  public:
115 115
  
116 116
    /// The type of the digraph
117 117
    typedef typename TR::Digraph Digraph;
118 118
    /// The type of the length map
119 119
    typedef typename TR::LengthMap LengthMap;
120 120
    /// The type of the arc lengths
121 121
    typedef typename TR::Value Value;
122 122

	
123 123
    /// \brief The large value type
124 124
    ///
125 125
    /// The large value type used for internal computations.
126
    /// Using the \ref MinMeanCycleDefaultTraits "default traits class",
126
    /// Using the \ref HowardDefaultTraits "default traits class",
127 127
    /// it is \c long \c long if the \c Value type is integer,
128 128
    /// otherwise it is \c double.
129 129
    typedef typename TR::LargeValue LargeValue;
130 130

	
131 131
    /// The tolerance type
132 132
    typedef typename TR::Tolerance Tolerance;
133 133

	
134 134
    /// \brief The path type of the found cycles
135 135
    ///
136 136
    /// The path type of the found cycles.
137
    /// Using the \ref MinMeanCycleDefaultTraits "default traits class",
137
    /// Using the \ref HowardDefaultTraits "default traits class",
138 138
    /// it is \ref lemon::Path "Path<Digraph>".
139 139
    typedef typename TR::Path Path;
140 140

	
141
    /// The \ref MinMeanCycleDefaultTraits "traits class" of the algorithm
141
    /// The \ref HowardDefaultTraits "traits class" of the algorithm
142 142
    typedef TR Traits;
143 143

	
144 144
  private:
145 145

	
146 146
    TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
147 147
  
148 148
    // The digraph the algorithm runs on
149 149
    const Digraph &_gr;
150 150
    // The length of the arcs
151 151
    const LengthMap &_length;
152 152

	
153 153
    // Data for the found cycles
154 154
    bool _curr_found, _best_found;
155 155
    LargeValue _curr_length, _best_length;
156 156
    int _curr_size, _best_size;
157 157
    Node _curr_node, _best_node;
158 158

	
159 159
    Path *_cycle_path;
160 160
    bool _local_path;
161 161

	
162 162
    // Internal data used by the algorithm
163 163
    typename Digraph::template NodeMap<Arc> _policy;
164 164
    typename Digraph::template NodeMap<bool> _reached;
165 165
    typename Digraph::template NodeMap<int> _level;
166 166
    typename Digraph::template NodeMap<LargeValue> _dist;
167 167

	
168 168
    // Data for storing the strongly connected components
169 169
    int _comp_num;
170 170
    typename Digraph::template NodeMap<int> _comp;
171 171
    std::vector<std::vector<Node> > _comp_nodes;
172 172
    std::vector<Node>* _nodes;
173 173
    typename Digraph::template NodeMap<std::vector<Arc> > _in_arcs;
174 174
    
175 175
    // Queue used for BFS search
176 176
    std::vector<Node> _queue;
177 177
    int _qfront, _qback;
178 178

	
179 179
    Tolerance _tolerance;
180 180
  
181 181
  public:
182 182
  
183 183
    /// \name Named Template Parameters
184 184
    /// @{
185 185

	
186 186
    template <typename T>
187 187
    struct SetLargeValueTraits : public Traits {
188 188
      typedef T LargeValue;
189 189
      typedef lemon::Tolerance<T> Tolerance;
190 190
    };
191 191

	
192 192
    /// \brief \ref named-templ-param "Named parameter" for setting
193 193
    /// \c LargeValue type.
194 194
    ///
195 195
    /// \ref named-templ-param "Named parameter" for setting \c LargeValue
196 196
    /// type. It is used for internal computations in the algorithm.
197 197
    template <typename T>
198 198
    struct SetLargeValue
199
      : public MinMeanCycle<GR, LEN, SetLargeValueTraits<T> > {
200
      typedef MinMeanCycle<GR, LEN, SetLargeValueTraits<T> > Create;
199
      : public Howard<GR, LEN, SetLargeValueTraits<T> > {
200
      typedef Howard<GR, LEN, SetLargeValueTraits<T> > Create;
201 201
    };
202 202

	
203 203
    template <typename T>
204 204
    struct SetPathTraits : public Traits {
205 205
      typedef T Path;
206 206
    };
207 207

	
208 208
    /// \brief \ref named-templ-param "Named parameter" for setting
209 209
    /// \c %Path type.
210 210
    ///
211 211
    /// \ref named-templ-param "Named parameter" for setting the \c %Path
212 212
    /// type of the found cycles.
213 213
    /// It must conform to the \ref lemon::concepts::Path "Path" concept
214 214
    /// and it must have an \c addBack() function.
215 215
    template <typename T>
216 216
    struct SetPath
217
      : public MinMeanCycle<GR, LEN, SetPathTraits<T> > {
218
      typedef MinMeanCycle<GR, LEN, SetPathTraits<T> > Create;
217
      : public Howard<GR, LEN, SetPathTraits<T> > {
218
      typedef Howard<GR, LEN, SetPathTraits<T> > Create;
219 219
    };
220 220
    
221 221
    /// @}
222 222

	
223 223
  public:
224 224

	
225 225
    /// \brief Constructor.
226 226
    ///
227 227
    /// The constructor of the class.
228 228
    ///
229 229
    /// \param digraph The digraph the algorithm runs on.
230 230
    /// \param length The lengths (costs) of the arcs.
231
    MinMeanCycle( const Digraph &digraph,
231
    Howard( const Digraph &digraph,
232 232
                  const LengthMap &length ) :
233 233
      _gr(digraph), _length(length), _cycle_path(NULL), _local_path(false),
234 234
      _policy(digraph), _reached(digraph), _level(digraph), _dist(digraph),
235 235
      _comp(digraph), _in_arcs(digraph)
236 236
    {}
237 237

	
238 238
    /// Destructor.
239
    ~MinMeanCycle() {
239
    ~Howard() {
240 240
      if (_local_path) delete _cycle_path;
241 241
    }
242 242

	
243 243
    /// \brief Set the path structure for storing the found cycle.
244 244
    ///
245 245
    /// This function sets an external path structure for storing the
246 246
    /// found cycle.
247 247
    ///
248 248
    /// If you don't call this function before calling \ref run() or
249 249
    /// \ref findMinMean(), it will allocate a local \ref Path "path"
250 250
    /// structure. The destuctor deallocates this automatically
251 251
    /// allocated object, of course.
252 252
    ///
253 253
    /// \note The algorithm calls only the \ref lemon::Path::addBack()
254 254
    /// "addBack()" function of the given path structure.
255 255
    ///
256 256
    /// \return <tt>(*this)</tt>
257
    MinMeanCycle& cycle(Path &path) {
257
    Howard& cycle(Path &path) {
258 258
      if (_local_path) {
259 259
        delete _cycle_path;
260 260
        _local_path = false;
261 261
      }
262 262
      _cycle_path = &path;
263 263
      return *this;
264 264
    }
265 265

	
266 266
    /// \name Execution control
267 267
    /// The simplest way to execute the algorithm is to call the \ref run()
268 268
    /// function.\n
269 269
    /// If you only need the minimum mean length, you may call
270 270
    /// \ref findMinMean().
271 271

	
272 272
    /// @{
273 273

	
274 274
    /// \brief Run the algorithm.
275 275
    ///
276 276
    /// This function runs the algorithm.
277 277
    /// It can be called more than once (e.g. if the underlying digraph
278 278
    /// and/or the arc lengths have been modified).
279 279
    ///
280 280
    /// \return \c true if a directed cycle exists in the digraph.
281 281
    ///
282 282
    /// \note <tt>mmc.run()</tt> is just a shortcut of the following code.
283 283
    /// \code
284 284
    ///   return mmc.findMinMean() && mmc.findCycle();
285 285
    /// \endcode
286 286
    bool run() {
287 287
      return findMinMean() && findCycle();
288 288
    }
289 289

	
290 290
    /// \brief Find the minimum cycle mean.
291 291
    ///
292 292
    /// This function finds the minimum mean length of the directed
293 293
    /// cycles in the digraph.
294 294
    ///
295 295
    /// \return \c true if a directed cycle exists in the digraph.
296 296
    bool findMinMean() {
297 297
      // Initialize and find strongly connected components
298 298
      init();
299 299
      findComponents();
300 300
      
301 301
      // Find the minimum cycle mean in the components
302 302
      for (int comp = 0; comp < _comp_num; ++comp) {
303 303
        // Find the minimum mean cycle in the current component
304 304
        if (!buildPolicyGraph(comp)) continue;
305 305
        while (true) {
... ...
@@ -514,55 +514,55 @@
514 514
      while (_qfront <= _qback) {
515 515
        v = _queue[_qfront++];
516 516
        for (int j = 0; j < int(_in_arcs[v].size()); ++j) {
517 517
          e = _in_arcs[v][j];
518 518
          u = _gr.source(e);
519 519
          if (_policy[u] == e && !_reached[u]) {
520 520
            _reached[u] = true;
521 521
            _dist[u] = _dist[v] + _length[e] * _curr_size - _curr_length;
522 522
            _queue[++_qback] = u;
523 523
          }
524 524
        }
525 525
      }
526 526

	
527 527
      // Connect all other nodes to this component and compute node
528 528
      // distances using reverse BFS
529 529
      _qfront = 0;
530 530
      while (_qback < int(_nodes->size())-1) {
531 531
        v = _queue[_qfront++];
532 532
        for (int j = 0; j < int(_in_arcs[v].size()); ++j) {
533 533
          e = _in_arcs[v][j];
534 534
          u = _gr.source(e);
535 535
          if (!_reached[u]) {
536 536
            _reached[u] = true;
537 537
            _policy[u] = e;
538 538
            _dist[u] = _dist[v] + _length[e] * _curr_size - _curr_length;
539 539
            _queue[++_qback] = u;
540 540
          }
541 541
        }
542 542
      }
543 543

	
544 544
      // Improve node distances
545 545
      bool improved = false;
546 546
      for (int i = 0; i < int(_nodes->size()); ++i) {
547 547
        v = (*_nodes)[i];
548 548
        for (int j = 0; j < int(_in_arcs[v].size()); ++j) {
549 549
          e = _in_arcs[v][j];
550 550
          u = _gr.source(e);
551 551
          LargeValue delta = _dist[v] + _length[e] * _curr_size - _curr_length;
552 552
          if (_tolerance.less(delta, _dist[u])) {
553 553
            _dist[u] = delta;
554 554
            _policy[u] = e;
555 555
            improved = true;
556 556
          }
557 557
        }
558 558
      }
559 559
      return improved;
560 560
    }
561 561

	
562
  }; //class MinMeanCycle
562
  }; //class Howard
563 563

	
564 564
  ///@}
565 565

	
566 566
} //namespace lemon
567 567

	
568
#endif //LEMON_MIN_MEAN_CYCLE_H
568
#endif //LEMON_HOWARD_H
Show white space 96 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2009
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include <iostream>
20 20
#include <sstream>
21 21

	
22 22
#include <lemon/smart_graph.h>
23 23
#include <lemon/lgf_reader.h>
24
#include <lemon/min_mean_cycle.h>
24
#include <lemon/howard.h>
25 25
#include <lemon/path.h>
26 26
#include <lemon/concepts/digraph.h>
27 27
#include <lemon/concept_check.h>
28 28

	
29 29
#include "test_tools.h"
30 30

	
31 31
using namespace lemon;
32 32

	
33 33
char test_lgf[] =
34 34
  "@nodes\n"
35 35
  "label\n"
36 36
  "1\n"
37 37
  "2\n"
38 38
  "3\n"
39 39
  "4\n"
40 40
  "5\n"
41 41
  "6\n"
42 42
  "7\n"
43 43
  "@arcs\n"
44 44
  "    len1 len2 len3 len4  c1 c2 c3 c4\n"
45 45
  "1 2    1    1    1    1   0  0  0  0\n"
46 46
  "2 4    5    5    5    5   1  0  0  0\n"
47 47
  "2 3    8    8    8    8   0  0  0  0\n"
48 48
  "3 2   -2    0    0    0   1  0  0  0\n"
49 49
  "3 4    4    4    4    4   0  0  0  0\n"
50 50
  "3 7   -4   -4   -4   -4   0  0  0  0\n"
51 51
  "4 1    2    2    2    2   0  0  0  0\n"
52 52
  "4 3    3    3    3    3   1  0  0  0\n"
53 53
  "4 4    3    3    0    0   0  0  1  0\n"
54 54
  "5 2    4    4    4    4   0  0  0  0\n"
55 55
  "5 6    3    3    3    3   0  1  0  0\n"
56 56
  "6 5    2    2    2    2   0  1  0  0\n"
57 57
  "6 4   -1   -1   -1   -1   0  0  0  0\n"
58 58
  "6 7    1    1    1    1   0  0  0  0\n"
59 59
  "7 7    4    4    4   -1   0  0  0  1\n";
60 60

	
61 61
                        
62 62
// Check the interface of an MMC algorithm
63 63
template <typename GR, typename Value>
64 64
struct MmcClassConcept
65 65
{
66 66
  template <typename MMC>
67 67
  struct Constraints {
68 68
    void constraints() {
69 69
      const Constraints& me = *this;
70 70

	
71 71
      typedef typename MMC
72 72
        ::template SetPath<ListPath<GR> >
... ...
@@ -96,89 +96,89 @@
96 96
    bool b;
97 97
  };
98 98
};
99 99

	
100 100
// Perform a test with the given parameters
101 101
template <typename MMC>
102 102
void checkMmcAlg(const SmartDigraph& gr,
103 103
                 const SmartDigraph::ArcMap<int>& lm,
104 104
                 const SmartDigraph::ArcMap<int>& cm,
105 105
                 int length, int size) {
106 106
  MMC alg(gr, lm);
107 107
  alg.findMinMean();
108 108
  check(alg.cycleMean() == static_cast<double>(length) / size,
109 109
        "Wrong cycle mean");
110 110
  alg.findCycle();
111 111
  check(alg.cycleLength() == length && alg.cycleArcNum() == size,
112 112
        "Wrong path");
113 113
  SmartDigraph::ArcMap<int> cycle(gr, 0);
114 114
  for (typename MMC::Path::ArcIt a(alg.cycle()); a != INVALID; ++a) {
115 115
    ++cycle[a];
116 116
  }
117 117
  for (SmartDigraph::ArcIt a(gr); a != INVALID; ++a) {
118 118
    check(cm[a] == cycle[a], "Wrong path");
119 119
  }
120 120
}
121 121

	
122 122
// Class for comparing types
123 123
template <typename T1, typename T2>
124 124
struct IsSameType {
125 125
  static const int result = 0;
126 126
};
127 127

	
128 128
template <typename T>
129 129
struct IsSameType<T,T> {
130 130
  static const int result = 1;
131 131
};
132 132

	
133 133

	
134 134
int main() {
135 135
  #ifdef LEMON_HAVE_LONG_LONG
136 136
    typedef long long long_int;
137 137
  #else
138 138
    typedef long long_int;
139 139
  #endif
140 140

	
141 141
  // Check the interface
142 142
  {
143 143
    typedef concepts::Digraph GR;
144
    typedef MinMeanCycle<GR, concepts::ReadMap<GR::Arc, int> > IntMmcAlg;
145
    typedef MinMeanCycle<GR, concepts::ReadMap<GR::Arc, float> > FloatMmcAlg;
144
    typedef Howard<GR, concepts::ReadMap<GR::Arc, int> > IntMmcAlg;
145
    typedef Howard<GR, concepts::ReadMap<GR::Arc, float> > FloatMmcAlg;
146 146
    
147 147
    checkConcept<MmcClassConcept<GR, int>, IntMmcAlg>();
148 148
    checkConcept<MmcClassConcept<GR, float>, FloatMmcAlg>();
149 149
  
150 150
    if (IsSameType<IntMmcAlg::LargeValue, long_int>::result == 0)
151 151
      check(false, "Wrong LargeValue type");
152 152
    if (IsSameType<FloatMmcAlg::LargeValue, double>::result == 0)
153 153
      check(false, "Wrong LargeValue type");
154 154
  }
155 155

	
156 156
  // Run various tests
157 157
  {
158 158
    typedef SmartDigraph GR;
159 159
    DIGRAPH_TYPEDEFS(GR);
160 160
    
161 161
    GR gr;
162 162
    IntArcMap l1(gr), l2(gr), l3(gr), l4(gr);
163 163
    IntArcMap c1(gr), c2(gr), c3(gr), c4(gr);
164 164
    
165 165
    std::istringstream input(test_lgf);
166 166
    digraphReader(gr, input).
167 167
      arcMap("len1", l1).
168 168
      arcMap("len2", l2).
169 169
      arcMap("len3", l3).
170 170
      arcMap("len4", l4).
171 171
      arcMap("c1", c1).
172 172
      arcMap("c2", c2).
173 173
      arcMap("c3", c3).
174 174
      arcMap("c4", c4).
175 175
      run();
176 176

	
177
    checkMmcAlg<MinMeanCycle<GR, IntArcMap> >(gr, l1, c1,  6, 3);
178
    checkMmcAlg<MinMeanCycle<GR, IntArcMap> >(gr, l2, c2,  5, 2);
179
    checkMmcAlg<MinMeanCycle<GR, IntArcMap> >(gr, l3, c3,  0, 1);
180
    checkMmcAlg<MinMeanCycle<GR, IntArcMap> >(gr, l4, c4, -1, 1);
177
    checkMmcAlg<Howard<GR, IntArcMap> >(gr, l1, c1,  6, 3);
178
    checkMmcAlg<Howard<GR, IntArcMap> >(gr, l2, c2,  5, 2);
179
    checkMmcAlg<Howard<GR, IntArcMap> >(gr, l3, c3,  0, 1);
180
    checkMmcAlg<Howard<GR, IntArcMap> >(gr, l4, c4, -1, 1);
181 181
  }
182 182

	
183 183
  return 0;
184 184
}
0 comments (0 inline)