339 /// \brief Resets the internal data structures. |
343 /// \brief Resets the internal data structures. |
340 /// |
344 /// |
341 /// Resets the internal data structures so that \ref findMinMean() |
345 /// Resets the internal data structures so that \ref findMinMean() |
342 /// and \ref findCycle() can be called again (e.g. when the |
346 /// and \ref findCycle() can be called again (e.g. when the |
343 /// underlaying graph has been modified). |
347 /// underlaying graph has been modified). |
|
348 /// |
|
349 /// \sa init() |
344 void reset() { |
350 void reset() { |
345 for (NodeIt u(graph); u != INVALID; ++u) |
351 for (NodeIt u(graph); u != INVALID; ++u) |
346 dmap[u].clear(); |
352 dmap[u].clear(); |
347 cycle_node = INVALID; |
353 cycle_node = INVALID; |
348 if (cycle_path) cycle_path->clear(); |
354 if (cycle_path) cycle_path->clear(); |
351 |
357 |
352 /// \brief Returns the total length of the found cycle. |
358 /// \brief Returns the total length of the found cycle. |
353 /// |
359 /// |
354 /// Returns the total length of the found cycle. |
360 /// Returns the total length of the found cycle. |
355 /// |
361 /// |
356 /// \pre \ref run() must be called before using this function. |
362 /// \pre \ref run() or \ref findCycle() must be called before |
|
363 /// using this function. If only \ref findMinMean() is called, |
|
364 /// the return value is not valid. |
357 Length cycleLength() const { |
365 Length cycleLength() const { |
358 return cycle_length; |
366 return cycle_length; |
359 } |
367 } |
360 |
368 |
361 /// \brief Returns the number of edges in the found cycle. |
369 /// \brief Returns the number of edges in the found cycle. |
362 /// |
370 /// |
363 /// Returns the number of edges in the found cycle. |
371 /// Returns the number of edges in the found cycle. |
364 /// |
372 /// |
365 /// \pre \ref run() must be called before using this function. |
373 /// \pre \ref run() or \ref findCycle() must be called before |
|
374 /// using this function. If only \ref findMinMean() is called, |
|
375 /// the return value is not valid. |
366 int cycleEdgeNum() const { |
376 int cycleEdgeNum() const { |
367 return cycle_size; |
377 return cycle_size; |
368 } |
378 } |
369 |
379 |
370 /// \brief Returns the mean length of the found cycle. |
380 /// \brief Returns the mean length of the found cycle. |
371 /// |
381 /// |
372 /// Returns the mean length of the found cycle. |
382 /// Returns the mean length of the found cycle. |
373 /// |
383 /// |
374 /// \pre \ref run() must be called before using this function. |
384 /// \pre \ref run() or \ref findMinMean() must be called before |
|
385 /// using this function. |
375 /// |
386 /// |
376 /// \warning LengthMap::Value must be convertible to double. |
387 /// \warning LengthMap::Value must be convertible to double. |
377 /// |
388 /// |
378 /// \note m.minMean() is just a shortcut of the following code. |
389 /// \note <tt>m.minMean()</tt> is just a shortcut of the following |
|
390 /// code. |
379 /// \code |
391 /// \code |
380 /// return m.cycleEdgeNum() / double(m.cycleLength()); |
392 /// return m.cycleLength() / double(m.cycleEdgeNum()); |
381 /// \endcode |
393 /// \endcode |
|
394 /// However if only \ref findMinMean() is called before using this |
|
395 /// function, <tt>m.cycleLength()</tt> and <tt>m.cycleEdgeNum()</tt> |
|
396 /// are not valid alone, only their ratio is valid. |
382 double minMean() const { |
397 double minMean() const { |
383 return cycle_length / (double)cycle_size; |
398 return cycle_length / (double)cycle_size; |
384 } |
399 } |
385 |
400 |
386 /// \brief Returns a const reference to the \ref lemon::Path "Path" |
401 /// \brief Returns a const reference to the \ref lemon::Path "Path" |