lemon/suurballe.h
author Alpar Juttner <alpar@cs.elte.hu>
Fri, 21 Nov 2008 14:42:47 +0000
changeset 399 5a7dbeaed70e
parent 345 2f64c4a692a8
child 425 cace3206223b
permissions -rw-r--r--
Port Circulation from svn -r3516 (#175)
Namely,
- port the files
- apply the migrate script
- apply the unify script
- fix the compilation
- strip the demo input file
- break long lines
alpar@345
     1
/* -*- C++ -*-
alpar@345
     2
 *
alpar@345
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@345
     4
 *
alpar@345
     5
 * Copyright (C) 2003-2008
alpar@345
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@345
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@345
     8
 *
alpar@345
     9
 * Permission to use, modify and distribute this software is granted
alpar@345
    10
 * provided that this copyright notice appears in all copies. For
alpar@345
    11
 * precise terms see the accompanying LICENSE file.
alpar@345
    12
 *
alpar@345
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@345
    14
 * express or implied, and with no claim as to its suitability for any
alpar@345
    15
 * purpose.
alpar@345
    16
 *
alpar@345
    17
 */
alpar@345
    18
alpar@345
    19
#ifndef LEMON_SUURBALLE_H
alpar@345
    20
#define LEMON_SUURBALLE_H
alpar@345
    21
alpar@345
    22
///\ingroup shortest_path
alpar@345
    23
///\file
alpar@345
    24
///\brief An algorithm for finding arc-disjoint paths between two
alpar@345
    25
/// nodes having minimum total length.
alpar@345
    26
alpar@345
    27
#include <vector>
alpar@345
    28
#include <lemon/bin_heap.h>
alpar@345
    29
#include <lemon/path.h>
alpar@345
    30
alpar@345
    31
namespace lemon {
alpar@345
    32
alpar@345
    33
  /// \addtogroup shortest_path
alpar@345
    34
  /// @{
alpar@345
    35
kpeter@346
    36
  /// \brief Algorithm for finding arc-disjoint paths between two nodes
kpeter@346
    37
  /// having minimum total length.
alpar@345
    38
  ///
alpar@345
    39
  /// \ref lemon::Suurballe "Suurballe" implements an algorithm for
alpar@345
    40
  /// finding arc-disjoint paths having minimum total length (cost)
kpeter@346
    41
  /// from a given source node to a given target node in a digraph.
alpar@345
    42
  ///
alpar@345
    43
  /// In fact, this implementation is the specialization of the
alpar@345
    44
  /// \ref CapacityScaling "successive shortest path" algorithm.
alpar@345
    45
  ///
kpeter@346
    46
  /// \tparam Digraph The digraph type the algorithm runs on.
kpeter@346
    47
  /// The default value is \c ListDigraph.
alpar@345
    48
  /// \tparam LengthMap The type of the length (cost) map.
kpeter@346
    49
  /// The default value is <tt>Digraph::ArcMap<int></tt>.
alpar@345
    50
  ///
alpar@345
    51
  /// \warning Length values should be \e non-negative \e integers.
alpar@345
    52
  ///
alpar@345
    53
  /// \note For finding node-disjoint paths this algorithm can be used
alpar@345
    54
  /// with \ref SplitDigraphAdaptor.
kpeter@346
    55
#ifdef DOXYGEN
kpeter@346
    56
  template <typename Digraph, typename LengthMap>
kpeter@346
    57
#else
kpeter@346
    58
  template < typename Digraph = ListDigraph,
alpar@345
    59
             typename LengthMap = typename Digraph::template ArcMap<int> >
kpeter@346
    60
#endif
alpar@345
    61
  class Suurballe
alpar@345
    62
  {
alpar@345
    63
    TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
alpar@345
    64
alpar@345
    65
    typedef typename LengthMap::Value Length;
alpar@345
    66
    typedef ConstMap<Arc, int> ConstArcMap;
alpar@345
    67
    typedef typename Digraph::template NodeMap<Arc> PredMap;
alpar@345
    68
alpar@345
    69
  public:
alpar@345
    70
alpar@345
    71
    /// The type of the flow map.
alpar@345
    72
    typedef typename Digraph::template ArcMap<int> FlowMap;
alpar@345
    73
    /// The type of the potential map.
alpar@345
    74
    typedef typename Digraph::template NodeMap<Length> PotentialMap;
alpar@345
    75
    /// The type of the path structures.
alpar@345
    76
    typedef SimplePath<Digraph> Path;
alpar@345
    77
alpar@345
    78
  private:
alpar@345
    79
  
kpeter@346
    80
    /// \brief Special implementation of the Dijkstra algorithm
alpar@345
    81
    /// for finding shortest paths in the residual network.
alpar@345
    82
    ///
alpar@345
    83
    /// \ref ResidualDijkstra is a special implementation of the
alpar@345
    84
    /// \ref Dijkstra algorithm for finding shortest paths in the
alpar@345
    85
    /// residual network of the digraph with respect to the reduced arc
alpar@345
    86
    /// lengths and modifying the node potentials according to the
alpar@345
    87
    /// distance of the nodes.
alpar@345
    88
    class ResidualDijkstra
alpar@345
    89
    {
alpar@345
    90
      typedef typename Digraph::template NodeMap<int> HeapCrossRef;
alpar@345
    91
      typedef BinHeap<Length, HeapCrossRef> Heap;
alpar@345
    92
alpar@345
    93
    private:
alpar@345
    94
kpeter@346
    95
      // The digraph the algorithm runs on
alpar@345
    96
      const Digraph &_graph;
alpar@345
    97
alpar@345
    98
      // The main maps
alpar@345
    99
      const FlowMap &_flow;
alpar@345
   100
      const LengthMap &_length;
alpar@345
   101
      PotentialMap &_potential;
alpar@345
   102
alpar@345
   103
      // The distance map
alpar@345
   104
      PotentialMap _dist;
alpar@345
   105
      // The pred arc map
alpar@345
   106
      PredMap &_pred;
alpar@345
   107
      // The processed (i.e. permanently labeled) nodes
alpar@345
   108
      std::vector<Node> _proc_nodes;
alpar@345
   109
      
alpar@345
   110
      Node _s;
alpar@345
   111
      Node _t;
alpar@345
   112
alpar@345
   113
    public:
alpar@345
   114
alpar@345
   115
      /// Constructor.
alpar@345
   116
      ResidualDijkstra( const Digraph &digraph,
alpar@345
   117
                        const FlowMap &flow,
alpar@345
   118
                        const LengthMap &length,
alpar@345
   119
                        PotentialMap &potential,
alpar@345
   120
                        PredMap &pred,
alpar@345
   121
                        Node s, Node t ) :
alpar@345
   122
        _graph(digraph), _flow(flow), _length(length), _potential(potential),
alpar@345
   123
        _dist(digraph), _pred(pred), _s(s), _t(t) {}
alpar@345
   124
kpeter@346
   125
      /// \brief Run the algorithm. It returns \c true if a path is found
alpar@345
   126
      /// from the source node to the target node.
alpar@345
   127
      bool run() {
alpar@345
   128
        HeapCrossRef heap_cross_ref(_graph, Heap::PRE_HEAP);
alpar@345
   129
        Heap heap(heap_cross_ref);
alpar@345
   130
        heap.push(_s, 0);
alpar@345
   131
        _pred[_s] = INVALID;
alpar@345
   132
        _proc_nodes.clear();
alpar@345
   133
kpeter@346
   134
        // Process nodes
alpar@345
   135
        while (!heap.empty() && heap.top() != _t) {
alpar@345
   136
          Node u = heap.top(), v;
alpar@345
   137
          Length d = heap.prio() + _potential[u], nd;
alpar@345
   138
          _dist[u] = heap.prio();
alpar@345
   139
          heap.pop();
alpar@345
   140
          _proc_nodes.push_back(u);
alpar@345
   141
kpeter@346
   142
          // Traverse outgoing arcs
alpar@345
   143
          for (OutArcIt e(_graph, u); e != INVALID; ++e) {
alpar@345
   144
            if (_flow[e] == 0) {
alpar@345
   145
              v = _graph.target(e);
alpar@345
   146
              switch(heap.state(v)) {
alpar@345
   147
              case Heap::PRE_HEAP:
alpar@345
   148
                heap.push(v, d + _length[e] - _potential[v]);
alpar@345
   149
                _pred[v] = e;
alpar@345
   150
                break;
alpar@345
   151
              case Heap::IN_HEAP:
alpar@345
   152
                nd = d + _length[e] - _potential[v];
alpar@345
   153
                if (nd < heap[v]) {
alpar@345
   154
                  heap.decrease(v, nd);
alpar@345
   155
                  _pred[v] = e;
alpar@345
   156
                }
alpar@345
   157
                break;
alpar@345
   158
              case Heap::POST_HEAP:
alpar@345
   159
                break;
alpar@345
   160
              }
alpar@345
   161
            }
alpar@345
   162
          }
alpar@345
   163
kpeter@346
   164
          // Traverse incoming arcs
alpar@345
   165
          for (InArcIt e(_graph, u); e != INVALID; ++e) {
alpar@345
   166
            if (_flow[e] == 1) {
alpar@345
   167
              v = _graph.source(e);
alpar@345
   168
              switch(heap.state(v)) {
alpar@345
   169
              case Heap::PRE_HEAP:
alpar@345
   170
                heap.push(v, d - _length[e] - _potential[v]);
alpar@345
   171
                _pred[v] = e;
alpar@345
   172
                break;
alpar@345
   173
              case Heap::IN_HEAP:
alpar@345
   174
                nd = d - _length[e] - _potential[v];
alpar@345
   175
                if (nd < heap[v]) {
alpar@345
   176
                  heap.decrease(v, nd);
alpar@345
   177
                  _pred[v] = e;
alpar@345
   178
                }
alpar@345
   179
                break;
alpar@345
   180
              case Heap::POST_HEAP:
alpar@345
   181
                break;
alpar@345
   182
              }
alpar@345
   183
            }
alpar@345
   184
          }
alpar@345
   185
        }
alpar@345
   186
        if (heap.empty()) return false;
alpar@345
   187
kpeter@346
   188
        // Update potentials of processed nodes
alpar@345
   189
        Length t_dist = heap.prio();
alpar@345
   190
        for (int i = 0; i < int(_proc_nodes.size()); ++i)
alpar@345
   191
          _potential[_proc_nodes[i]] += _dist[_proc_nodes[i]] - t_dist;
alpar@345
   192
        return true;
alpar@345
   193
      }
alpar@345
   194
alpar@345
   195
    }; //class ResidualDijkstra
alpar@345
   196
alpar@345
   197
  private:
alpar@345
   198
kpeter@346
   199
    // The digraph the algorithm runs on
alpar@345
   200
    const Digraph &_graph;
alpar@345
   201
    // The length map
alpar@345
   202
    const LengthMap &_length;
alpar@345
   203
    
alpar@345
   204
    // Arc map of the current flow
alpar@345
   205
    FlowMap *_flow;
alpar@345
   206
    bool _local_flow;
alpar@345
   207
    // Node map of the current potentials
alpar@345
   208
    PotentialMap *_potential;
alpar@345
   209
    bool _local_potential;
alpar@345
   210
alpar@345
   211
    // The source node
alpar@345
   212
    Node _source;
alpar@345
   213
    // The target node
alpar@345
   214
    Node _target;
alpar@345
   215
alpar@345
   216
    // Container to store the found paths
alpar@345
   217
    std::vector< SimplePath<Digraph> > paths;
alpar@345
   218
    int _path_num;
alpar@345
   219
alpar@345
   220
    // The pred arc map
alpar@345
   221
    PredMap _pred;
alpar@345
   222
    // Implementation of the Dijkstra algorithm for finding augmenting
alpar@345
   223
    // shortest paths in the residual network
alpar@345
   224
    ResidualDijkstra *_dijkstra;
alpar@345
   225
alpar@345
   226
  public:
alpar@345
   227
alpar@345
   228
    /// \brief Constructor.
alpar@345
   229
    ///
alpar@345
   230
    /// Constructor.
alpar@345
   231
    ///
kpeter@346
   232
    /// \param digraph The digraph the algorithm runs on.
alpar@345
   233
    /// \param length The length (cost) values of the arcs.
alpar@345
   234
    /// \param s The source node.
alpar@345
   235
    /// \param t The target node.
alpar@345
   236
    Suurballe( const Digraph &digraph,
alpar@345
   237
               const LengthMap &length,
alpar@345
   238
               Node s, Node t ) :
alpar@345
   239
      _graph(digraph), _length(length), _flow(0), _local_flow(false),
alpar@345
   240
      _potential(0), _local_potential(false), _source(s), _target(t),
alpar@345
   241
      _pred(digraph) {}
alpar@345
   242
alpar@345
   243
    /// Destructor.
alpar@345
   244
    ~Suurballe() {
alpar@345
   245
      if (_local_flow) delete _flow;
alpar@345
   246
      if (_local_potential) delete _potential;
alpar@345
   247
      delete _dijkstra;
alpar@345
   248
    }
alpar@345
   249
kpeter@346
   250
    /// \brief Set the flow map.
alpar@345
   251
    ///
kpeter@346
   252
    /// This function sets the flow map.
alpar@345
   253
    ///
alpar@345
   254
    /// The found flow contains only 0 and 1 values. It is the union of
alpar@345
   255
    /// the found arc-disjoint paths.
alpar@345
   256
    ///
alpar@345
   257
    /// \return \c (*this)
alpar@345
   258
    Suurballe& flowMap(FlowMap &map) {
alpar@345
   259
      if (_local_flow) {
alpar@345
   260
        delete _flow;
alpar@345
   261
        _local_flow = false;
alpar@345
   262
      }
alpar@345
   263
      _flow = &map;
alpar@345
   264
      return *this;
alpar@345
   265
    }
alpar@345
   266
kpeter@346
   267
    /// \brief Set the potential map.
alpar@345
   268
    ///
kpeter@346
   269
    /// This function sets the potential map.
alpar@345
   270
    ///
alpar@345
   271
    /// The potentials provide the dual solution of the underlying 
alpar@345
   272
    /// minimum cost flow problem.
alpar@345
   273
    ///
alpar@345
   274
    /// \return \c (*this)
alpar@345
   275
    Suurballe& potentialMap(PotentialMap &map) {
alpar@345
   276
      if (_local_potential) {
alpar@345
   277
        delete _potential;
alpar@345
   278
        _local_potential = false;
alpar@345
   279
      }
alpar@345
   280
      _potential = &map;
alpar@345
   281
      return *this;
alpar@345
   282
    }
alpar@345
   283
alpar@345
   284
    /// \name Execution control
alpar@345
   285
    /// The simplest way to execute the algorithm is to call the run()
alpar@345
   286
    /// function.
alpar@345
   287
    /// \n
alpar@345
   288
    /// If you only need the flow that is the union of the found
alpar@345
   289
    /// arc-disjoint paths, you may call init() and findFlow().
alpar@345
   290
alpar@345
   291
    /// @{
alpar@345
   292
kpeter@346
   293
    /// \brief Run the algorithm.
alpar@345
   294
    ///
kpeter@346
   295
    /// This function runs the algorithm.
alpar@345
   296
    ///
alpar@345
   297
    /// \param k The number of paths to be found.
alpar@345
   298
    ///
kpeter@346
   299
    /// \return \c k if there are at least \c k arc-disjoint paths from
kpeter@346
   300
    /// \c s to \c t in the digraph. Otherwise it returns the number of
alpar@345
   301
    /// arc-disjoint paths found.
alpar@345
   302
    ///
alpar@345
   303
    /// \note Apart from the return value, <tt>s.run(k)</tt> is just a
alpar@345
   304
    /// shortcut of the following code.
alpar@345
   305
    /// \code
alpar@345
   306
    ///   s.init();
alpar@345
   307
    ///   s.findFlow(k);
alpar@345
   308
    ///   s.findPaths();
alpar@345
   309
    /// \endcode
alpar@345
   310
    int run(int k = 2) {
alpar@345
   311
      init();
alpar@345
   312
      findFlow(k);
alpar@345
   313
      findPaths();
alpar@345
   314
      return _path_num;
alpar@345
   315
    }
alpar@345
   316
kpeter@346
   317
    /// \brief Initialize the algorithm.
alpar@345
   318
    ///
kpeter@346
   319
    /// This function initializes the algorithm.
alpar@345
   320
    void init() {
kpeter@346
   321
      // Initialize maps
alpar@345
   322
      if (!_flow) {
alpar@345
   323
        _flow = new FlowMap(_graph);
alpar@345
   324
        _local_flow = true;
alpar@345
   325
      }
alpar@345
   326
      if (!_potential) {
alpar@345
   327
        _potential = new PotentialMap(_graph);
alpar@345
   328
        _local_potential = true;
alpar@345
   329
      }
alpar@345
   330
      for (ArcIt e(_graph); e != INVALID; ++e) (*_flow)[e] = 0;
alpar@345
   331
      for (NodeIt n(_graph); n != INVALID; ++n) (*_potential)[n] = 0;
alpar@345
   332
alpar@345
   333
      _dijkstra = new ResidualDijkstra( _graph, *_flow, _length, 
alpar@345
   334
                                        *_potential, _pred,
alpar@345
   335
                                        _source, _target );
alpar@345
   336
    }
alpar@345
   337
kpeter@346
   338
    /// \brief Execute the successive shortest path algorithm to find
alpar@345
   339
    /// an optimal flow.
alpar@345
   340
    ///
kpeter@346
   341
    /// This function executes the successive shortest path algorithm to
kpeter@346
   342
    /// find a minimum cost flow, which is the union of \c k or less
alpar@345
   343
    /// arc-disjoint paths.
alpar@345
   344
    ///
kpeter@346
   345
    /// \return \c k if there are at least \c k arc-disjoint paths from
kpeter@346
   346
    /// \c s to \c t in the digraph. Otherwise it returns the number of
alpar@345
   347
    /// arc-disjoint paths found.
alpar@345
   348
    ///
alpar@345
   349
    /// \pre \ref init() must be called before using this function.
alpar@345
   350
    int findFlow(int k = 2) {
kpeter@346
   351
      // Find shortest paths
alpar@345
   352
      _path_num = 0;
alpar@345
   353
      while (_path_num < k) {
kpeter@346
   354
        // Run Dijkstra
alpar@345
   355
        if (!_dijkstra->run()) break;
alpar@345
   356
        ++_path_num;
alpar@345
   357
kpeter@346
   358
        // Set the flow along the found shortest path
alpar@345
   359
        Node u = _target;
alpar@345
   360
        Arc e;
alpar@345
   361
        while ((e = _pred[u]) != INVALID) {
alpar@345
   362
          if (u == _graph.target(e)) {
alpar@345
   363
            (*_flow)[e] = 1;
alpar@345
   364
            u = _graph.source(e);
alpar@345
   365
          } else {
alpar@345
   366
            (*_flow)[e] = 0;
alpar@345
   367
            u = _graph.target(e);
alpar@345
   368
          }
alpar@345
   369
        }
alpar@345
   370
      }
alpar@345
   371
      return _path_num;
alpar@345
   372
    }
alpar@345
   373
    
kpeter@346
   374
    /// \brief Compute the paths from the flow.
alpar@345
   375
    ///
kpeter@346
   376
    /// This function computes the paths from the flow.
alpar@345
   377
    ///
alpar@345
   378
    /// \pre \ref init() and \ref findFlow() must be called before using
alpar@345
   379
    /// this function.
alpar@345
   380
    void findPaths() {
kpeter@346
   381
      // Create the residual flow map (the union of the paths not found
kpeter@346
   382
      // so far)
alpar@345
   383
      FlowMap res_flow(_graph);
kpeter@346
   384
      for(ArcIt a(_graph); a != INVALID; ++a) res_flow[a] = (*_flow)[a];
alpar@345
   385
alpar@345
   386
      paths.clear();
alpar@345
   387
      paths.resize(_path_num);
alpar@345
   388
      for (int i = 0; i < _path_num; ++i) {
alpar@345
   389
        Node n = _source;
alpar@345
   390
        while (n != _target) {
alpar@345
   391
          OutArcIt e(_graph, n);
alpar@345
   392
          for ( ; res_flow[e] == 0; ++e) ;
alpar@345
   393
          n = _graph.target(e);
alpar@345
   394
          paths[i].addBack(e);
alpar@345
   395
          res_flow[e] = 0;
alpar@345
   396
        }
alpar@345
   397
      }
alpar@345
   398
    }
alpar@345
   399
alpar@345
   400
    /// @}
alpar@345
   401
alpar@345
   402
    /// \name Query Functions
kpeter@346
   403
    /// The results of the algorithm can be obtained using these
alpar@345
   404
    /// functions.
alpar@345
   405
    /// \n The algorithm should be executed before using them.
alpar@345
   406
alpar@345
   407
    /// @{
alpar@345
   408
kpeter@346
   409
    /// \brief Return a const reference to the arc map storing the
alpar@345
   410
    /// found flow.
alpar@345
   411
    ///
kpeter@346
   412
    /// This function returns a const reference to the arc map storing
kpeter@346
   413
    /// the flow that is the union of the found arc-disjoint paths.
alpar@345
   414
    ///
kpeter@346
   415
    /// \pre \ref run() or \ref findFlow() must be called before using
kpeter@346
   416
    /// this function.
alpar@345
   417
    const FlowMap& flowMap() const {
alpar@345
   418
      return *_flow;
alpar@345
   419
    }
alpar@345
   420
kpeter@346
   421
    /// \brief Return a const reference to the node map storing the
alpar@345
   422
    /// found potentials (the dual solution).
alpar@345
   423
    ///
kpeter@346
   424
    /// This function returns a const reference to the node map storing
kpeter@346
   425
    /// the found potentials that provide the dual solution of the
kpeter@346
   426
    /// underlying minimum cost flow problem.
alpar@345
   427
    ///
kpeter@346
   428
    /// \pre \ref run() or \ref findFlow() must be called before using
kpeter@346
   429
    /// this function.
alpar@345
   430
    const PotentialMap& potentialMap() const {
alpar@345
   431
      return *_potential;
alpar@345
   432
    }
alpar@345
   433
kpeter@346
   434
    /// \brief Return the flow on the given arc.
alpar@345
   435
    ///
kpeter@346
   436
    /// This function returns the flow on the given arc.
alpar@345
   437
    /// It is \c 1 if the arc is involved in one of the found paths,
alpar@345
   438
    /// otherwise it is \c 0.
alpar@345
   439
    ///
kpeter@346
   440
    /// \pre \ref run() or \ref findFlow() must be called before using
kpeter@346
   441
    /// this function.
alpar@345
   442
    int flow(const Arc& arc) const {
alpar@345
   443
      return (*_flow)[arc];
alpar@345
   444
    }
alpar@345
   445
kpeter@346
   446
    /// \brief Return the potential of the given node.
alpar@345
   447
    ///
kpeter@346
   448
    /// This function returns the potential of the given node.
alpar@345
   449
    ///
kpeter@346
   450
    /// \pre \ref run() or \ref findFlow() must be called before using
kpeter@346
   451
    /// this function.
alpar@345
   452
    Length potential(const Node& node) const {
alpar@345
   453
      return (*_potential)[node];
alpar@345
   454
    }
alpar@345
   455
kpeter@346
   456
    /// \brief Return the total length (cost) of the found paths (flow).
alpar@345
   457
    ///
kpeter@346
   458
    /// This function returns the total length (cost) of the found paths
kpeter@346
   459
    /// (flow). The complexity of the function is \f$ O(e) \f$.
alpar@345
   460
    ///
kpeter@346
   461
    /// \pre \ref run() or \ref findFlow() must be called before using
kpeter@346
   462
    /// this function.
alpar@345
   463
    Length totalLength() const {
alpar@345
   464
      Length c = 0;
alpar@345
   465
      for (ArcIt e(_graph); e != INVALID; ++e)
alpar@345
   466
        c += (*_flow)[e] * _length[e];
alpar@345
   467
      return c;
alpar@345
   468
    }
alpar@345
   469
kpeter@346
   470
    /// \brief Return the number of the found paths.
alpar@345
   471
    ///
kpeter@346
   472
    /// This function returns the number of the found paths.
alpar@345
   473
    ///
kpeter@346
   474
    /// \pre \ref run() or \ref findFlow() must be called before using
kpeter@346
   475
    /// this function.
alpar@345
   476
    int pathNum() const {
alpar@345
   477
      return _path_num;
alpar@345
   478
    }
alpar@345
   479
kpeter@346
   480
    /// \brief Return a const reference to the specified path.
alpar@345
   481
    ///
kpeter@346
   482
    /// This function returns a const reference to the specified path.
alpar@345
   483
    ///
alpar@345
   484
    /// \param i The function returns the \c i-th path.
alpar@345
   485
    /// \c i must be between \c 0 and <tt>%pathNum()-1</tt>.
alpar@345
   486
    ///
kpeter@346
   487
    /// \pre \ref run() or \ref findPaths() must be called before using
kpeter@346
   488
    /// this function.
alpar@345
   489
    Path path(int i) const {
alpar@345
   490
      return paths[i];
alpar@345
   491
    }
alpar@345
   492
alpar@345
   493
    /// @}
alpar@345
   494
alpar@345
   495
  }; //class Suurballe
alpar@345
   496
alpar@345
   497
  ///@}
alpar@345
   498
alpar@345
   499
} //namespace lemon
alpar@345
   500
alpar@345
   501
#endif //LEMON_SUURBALLE_H