0
4
0
... | ... |
@@ -261,48 +261,66 @@ |
261 | 261 |
|
262 | 262 |
/// \brief Set the path structure for storing the found cycle. |
263 | 263 |
/// |
264 | 264 |
/// This function sets an external path structure for storing the |
265 | 265 |
/// found cycle. |
266 | 266 |
/// |
267 | 267 |
/// If you don't call this function before calling \ref run() or |
268 | 268 |
/// \ref findMinMean(), it will allocate a local \ref Path "path" |
269 | 269 |
/// structure. The destuctor deallocates this automatically |
270 | 270 |
/// allocated object, of course. |
271 | 271 |
/// |
272 | 272 |
/// \note The algorithm calls only the \ref lemon::Path::addFront() |
273 | 273 |
/// "addFront()" function of the given path structure. |
274 | 274 |
/// |
275 | 275 |
/// \return <tt>(*this)</tt> |
276 | 276 |
HartmannOrlin& cycle(Path &path) { |
277 | 277 |
if (_local_path) { |
278 | 278 |
delete _cycle_path; |
279 | 279 |
_local_path = false; |
280 | 280 |
} |
281 | 281 |
_cycle_path = &path; |
282 | 282 |
return *this; |
283 | 283 |
} |
284 | 284 |
|
285 |
/// \brief Set the tolerance used by the algorithm. |
|
286 |
/// |
|
287 |
/// This function sets the tolerance object used by the algorithm. |
|
288 |
/// |
|
289 |
/// \return <tt>(*this)</tt> |
|
290 |
HartmannOrlin& tolerance(const Tolerance& tolerance) { |
|
291 |
_tolerance = tolerance; |
|
292 |
return *this; |
|
293 |
} |
|
294 |
|
|
295 |
/// \brief Return a const reference to the tolerance. |
|
296 |
/// |
|
297 |
/// This function returns a const reference to the tolerance object |
|
298 |
/// used by the algorithm. |
|
299 |
const Tolerance& tolerance() const { |
|
300 |
return _tolerance; |
|
301 |
} |
|
302 |
|
|
285 | 303 |
/// \name Execution control |
286 | 304 |
/// The simplest way to execute the algorithm is to call the \ref run() |
287 | 305 |
/// function.\n |
288 | 306 |
/// If you only need the minimum mean length, you may call |
289 | 307 |
/// \ref findMinMean(). |
290 | 308 |
|
291 | 309 |
/// @{ |
292 | 310 |
|
293 | 311 |
/// \brief Run the algorithm. |
294 | 312 |
/// |
295 | 313 |
/// This function runs the algorithm. |
296 | 314 |
/// It can be called more than once (e.g. if the underlying digraph |
297 | 315 |
/// and/or the arc lengths have been modified). |
298 | 316 |
/// |
299 | 317 |
/// \return \c true if a directed cycle exists in the digraph. |
300 | 318 |
/// |
301 | 319 |
/// \note <tt>mmc.run()</tt> is just a shortcut of the following code. |
302 | 320 |
/// \code |
303 | 321 |
/// return mmc.findMinMean() && mmc.findCycle(); |
304 | 322 |
/// \endcode |
305 | 323 |
bool run() { |
306 | 324 |
return findMinMean() && findCycle(); |
307 | 325 |
} |
308 | 326 |
... | ... |
@@ -252,48 +252,66 @@ |
252 | 252 |
|
253 | 253 |
/// \brief Set the path structure for storing the found cycle. |
254 | 254 |
/// |
255 | 255 |
/// This function sets an external path structure for storing the |
256 | 256 |
/// found cycle. |
257 | 257 |
/// |
258 | 258 |
/// If you don't call this function before calling \ref run() or |
259 | 259 |
/// \ref findMinMean(), it will allocate a local \ref Path "path" |
260 | 260 |
/// structure. The destuctor deallocates this automatically |
261 | 261 |
/// allocated object, of course. |
262 | 262 |
/// |
263 | 263 |
/// \note The algorithm calls only the \ref lemon::Path::addBack() |
264 | 264 |
/// "addBack()" function of the given path structure. |
265 | 265 |
/// |
266 | 266 |
/// \return <tt>(*this)</tt> |
267 | 267 |
Howard& cycle(Path &path) { |
268 | 268 |
if (_local_path) { |
269 | 269 |
delete _cycle_path; |
270 | 270 |
_local_path = false; |
271 | 271 |
} |
272 | 272 |
_cycle_path = &path; |
273 | 273 |
return *this; |
274 | 274 |
} |
275 | 275 |
|
276 |
/// \brief Set the tolerance used by the algorithm. |
|
277 |
/// |
|
278 |
/// This function sets the tolerance object used by the algorithm. |
|
279 |
/// |
|
280 |
/// \return <tt>(*this)</tt> |
|
281 |
Howard& tolerance(const Tolerance& tolerance) { |
|
282 |
_tolerance = tolerance; |
|
283 |
return *this; |
|
284 |
} |
|
285 |
|
|
286 |
/// \brief Return a const reference to the tolerance. |
|
287 |
/// |
|
288 |
/// This function returns a const reference to the tolerance object |
|
289 |
/// used by the algorithm. |
|
290 |
const Tolerance& tolerance() const { |
|
291 |
return _tolerance; |
|
292 |
} |
|
293 |
|
|
276 | 294 |
/// \name Execution control |
277 | 295 |
/// The simplest way to execute the algorithm is to call the \ref run() |
278 | 296 |
/// function.\n |
279 | 297 |
/// If you only need the minimum mean length, you may call |
280 | 298 |
/// \ref findMinMean(). |
281 | 299 |
|
282 | 300 |
/// @{ |
283 | 301 |
|
284 | 302 |
/// \brief Run the algorithm. |
285 | 303 |
/// |
286 | 304 |
/// This function runs the algorithm. |
287 | 305 |
/// It can be called more than once (e.g. if the underlying digraph |
288 | 306 |
/// and/or the arc lengths have been modified). |
289 | 307 |
/// |
290 | 308 |
/// \return \c true if a directed cycle exists in the digraph. |
291 | 309 |
/// |
292 | 310 |
/// \note <tt>mmc.run()</tt> is just a shortcut of the following code. |
293 | 311 |
/// \code |
294 | 312 |
/// return mmc.findMinMean() && mmc.findCycle(); |
295 | 313 |
/// \endcode |
296 | 314 |
bool run() { |
297 | 315 |
return findMinMean() && findCycle(); |
298 | 316 |
} |
299 | 317 |
... | ... |
@@ -257,48 +257,66 @@ |
257 | 257 |
|
258 | 258 |
/// \brief Set the path structure for storing the found cycle. |
259 | 259 |
/// |
260 | 260 |
/// This function sets an external path structure for storing the |
261 | 261 |
/// found cycle. |
262 | 262 |
/// |
263 | 263 |
/// If you don't call this function before calling \ref run() or |
264 | 264 |
/// \ref findMinMean(), it will allocate a local \ref Path "path" |
265 | 265 |
/// structure. The destuctor deallocates this automatically |
266 | 266 |
/// allocated object, of course. |
267 | 267 |
/// |
268 | 268 |
/// \note The algorithm calls only the \ref lemon::Path::addFront() |
269 | 269 |
/// "addFront()" function of the given path structure. |
270 | 270 |
/// |
271 | 271 |
/// \return <tt>(*this)</tt> |
272 | 272 |
Karp& cycle(Path &path) { |
273 | 273 |
if (_local_path) { |
274 | 274 |
delete _cycle_path; |
275 | 275 |
_local_path = false; |
276 | 276 |
} |
277 | 277 |
_cycle_path = &path; |
278 | 278 |
return *this; |
279 | 279 |
} |
280 | 280 |
|
281 |
/// \brief Set the tolerance used by the algorithm. |
|
282 |
/// |
|
283 |
/// This function sets the tolerance object used by the algorithm. |
|
284 |
/// |
|
285 |
/// \return <tt>(*this)</tt> |
|
286 |
Karp& tolerance(const Tolerance& tolerance) { |
|
287 |
_tolerance = tolerance; |
|
288 |
return *this; |
|
289 |
} |
|
290 |
|
|
291 |
/// \brief Return a const reference to the tolerance. |
|
292 |
/// |
|
293 |
/// This function returns a const reference to the tolerance object |
|
294 |
/// used by the algorithm. |
|
295 |
const Tolerance& tolerance() const { |
|
296 |
return _tolerance; |
|
297 |
} |
|
298 |
|
|
281 | 299 |
/// \name Execution control |
282 | 300 |
/// The simplest way to execute the algorithm is to call the \ref run() |
283 | 301 |
/// function.\n |
284 | 302 |
/// If you only need the minimum mean length, you may call |
285 | 303 |
/// \ref findMinMean(). |
286 | 304 |
|
287 | 305 |
/// @{ |
288 | 306 |
|
289 | 307 |
/// \brief Run the algorithm. |
290 | 308 |
/// |
291 | 309 |
/// This function runs the algorithm. |
292 | 310 |
/// It can be called more than once (e.g. if the underlying digraph |
293 | 311 |
/// and/or the arc lengths have been modified). |
294 | 312 |
/// |
295 | 313 |
/// \return \c true if a directed cycle exists in the digraph. |
296 | 314 |
/// |
297 | 315 |
/// \note <tt>mmc.run()</tt> is just a shortcut of the following code. |
298 | 316 |
/// \code |
299 | 317 |
/// return mmc.findMinMean() && mmc.findCycle(); |
300 | 318 |
/// \endcode |
301 | 319 |
bool run() { |
302 | 320 |
return findMinMean() && findCycle(); |
303 | 321 |
} |
304 | 322 |
... | ... |
@@ -57,48 +57,51 @@ |
57 | 57 |
"5 2 4 4 4 4 0 0 0 0\n" |
58 | 58 |
"5 6 3 3 3 3 0 1 0 0\n" |
59 | 59 |
"6 5 2 2 2 2 0 1 0 0\n" |
60 | 60 |
"6 4 -1 -1 -1 -1 0 0 0 0\n" |
61 | 61 |
"6 7 1 1 1 1 0 0 0 0\n" |
62 | 62 |
"7 7 4 4 4 -1 0 0 0 1\n"; |
63 | 63 |
|
64 | 64 |
|
65 | 65 |
// Check the interface of an MMC algorithm |
66 | 66 |
template <typename GR, typename Value> |
67 | 67 |
struct MmcClassConcept |
68 | 68 |
{ |
69 | 69 |
template <typename MMC> |
70 | 70 |
struct Constraints { |
71 | 71 |
void constraints() { |
72 | 72 |
const Constraints& me = *this; |
73 | 73 |
|
74 | 74 |
typedef typename MMC |
75 | 75 |
::template SetPath<ListPath<GR> > |
76 | 76 |
::template SetLargeValue<Value> |
77 | 77 |
::Create MmcAlg; |
78 | 78 |
MmcAlg mmc(me.g, me.length); |
79 | 79 |
const MmcAlg& const_mmc = mmc; |
80 | 80 |
|
81 |
typename MmcAlg::Tolerance tol = const_mmc.tolerance(); |
|
82 |
mmc.tolerance(tol); |
|
83 |
|
|
81 | 84 |
b = mmc.cycle(p).run(); |
82 | 85 |
b = mmc.findMinMean(); |
83 | 86 |
b = mmc.findCycle(); |
84 | 87 |
|
85 | 88 |
v = const_mmc.cycleLength(); |
86 | 89 |
i = const_mmc.cycleArcNum(); |
87 | 90 |
d = const_mmc.cycleMean(); |
88 | 91 |
p = const_mmc.cycle(); |
89 | 92 |
} |
90 | 93 |
|
91 | 94 |
typedef concepts::ReadMap<typename GR::Arc, Value> LM; |
92 | 95 |
|
93 | 96 |
GR g; |
94 | 97 |
LM length; |
95 | 98 |
ListPath<GR> p; |
96 | 99 |
Value v; |
97 | 100 |
int i; |
98 | 101 |
double d; |
99 | 102 |
bool b; |
100 | 103 |
}; |
101 | 104 |
}; |
102 | 105 |
|
103 | 106 |
// Perform a test with the given parameters |
104 | 107 |
template <typename MMC> |
0 comments (0 inline)