COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/dijkstra.h

    r440 r397  
    33 * This file is a part of LEMON, a generic C++ optimization library.
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2008
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    180180  ///
    181181  ///\tparam GR The type of the digraph the algorithm runs on.
    182   ///The default type is \ref ListDigraph.
    183   ///\tparam LM A \ref concepts::ReadMap "readable" arc map that specifies
    184   ///the lengths of the arcs.
    185   ///It is read once for each arc, so the map may involve in
     182  ///The default value is \ref ListDigraph.
     183  ///The value of GR is not used directly by \ref Dijkstra, it is only
     184  ///passed to \ref DijkstraDefaultTraits.
     185  ///\tparam LM A readable arc map that determines the lengths of the
     186  ///arcs. It is read once for each arc, so the map may involve in
    186187  ///relatively time consuming process to compute the arc lengths if
    187188  ///it is necessary. The default map type is \ref
    188   ///concepts::Digraph::ArcMap "GR::ArcMap<int>".
     189  ///concepts::Digraph::ArcMap "Digraph::ArcMap<int>".
     190  ///The value of LM is not used directly by \ref Dijkstra, it is only
     191  ///passed to \ref DijkstraDefaultTraits.
     192  ///\tparam TR Traits class to set various data types used by the algorithm.
     193  ///The default traits class is \ref DijkstraDefaultTraits
     194  ///"DijkstraDefaultTraits<GR,LM>". See \ref DijkstraDefaultTraits
     195  ///for the documentation of a Dijkstra traits class.
    189196#ifdef DOXYGEN
    190197  template <typename GR, typename LM, typename TR>
     
    220227    typedef typename TR::OperationTraits OperationTraits;
    221228
    222     ///The \ref DijkstraDefaultTraits "traits class" of the algorithm.
     229    ///The traits class.
    223230    typedef TR Traits;
    224231
     
    302309    ///\ref named-templ-param "Named parameter" for setting
    303310    ///PredMap type.
    304     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    305311    template <class T>
    306312    struct SetPredMap
     
    323329    ///\ref named-templ-param "Named parameter" for setting
    324330    ///DistMap type.
    325     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    326331    template <class T>
    327332    struct SetDistMap
     
    344349    ///\ref named-templ-param "Named parameter" for setting
    345350    ///ProcessedMap type.
    346     ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
    347351    template <class T>
    348352    struct SetProcessedMap
     
    385389    };
    386390    ///\brief \ref named-templ-param "Named parameter" for setting
    387     ///heap and cross reference types
     391    ///heap and cross reference type
    388392    ///
    389393    ///\ref named-templ-param "Named parameter" for setting heap and cross
    390     ///reference types. If this named parameter is used, then external
    391     ///heap and cross reference objects must be passed to the algorithm
    392     ///using the \ref heap() function before calling \ref run(Node) "run()"
    393     ///or \ref init().
    394     ///\sa SetStandardHeap
     394    ///reference type.
    395395    template <class H, class CR = typename Digraph::template NodeMap<int> >
    396396    struct SetHeap
     
    412412    };
    413413    ///\brief \ref named-templ-param "Named parameter" for setting
    414     ///heap and cross reference types with automatic allocation
     414    ///heap and cross reference type with automatic allocation
    415415    ///
    416416    ///\ref named-templ-param "Named parameter" for setting heap and cross
    417     ///reference types with automatic allocation.
    418     ///They should have standard constructor interfaces to be able to
    419     ///automatically created by the algorithm (i.e. the digraph should be
    420     ///passed to the constructor of the cross reference and the cross
    421     ///reference should be passed to the constructor of the heap).
    422     ///However external heap and cross reference objects could also be
    423     ///passed to the algorithm using the \ref heap() function before
    424     ///calling \ref run(Node) "run()" or \ref init().
    425     ///\sa SetHeap
     417    ///reference type. It can allocate the heap and the cross reference
     418    ///object if the cross reference's constructor waits for the digraph as
     419    ///parameter and the heap's constructor waits for the cross reference.
    426420    template <class H, class CR = typename Digraph::template NodeMap<int> >
    427421    struct SetStandardHeap
     
    493487
    494488    ///Sets the map that stores the predecessor arcs.
    495     ///If you don't use this function before calling \ref run(Node) "run()"
    496     ///or \ref init(), an instance will be allocated automatically.
    497     ///The destructor deallocates this automatically allocated map,
    498     ///of course.
     489    ///If you don't use this function before calling \ref run(),
     490    ///it will allocate one. The destructor deallocates this
     491    ///automatically allocated map, of course.
    499492    ///\return <tt> (*this) </tt>
    500493    Dijkstra &predMap(PredMap &m)
     
    511504
    512505    ///Sets the map that indicates which nodes are processed.
    513     ///If you don't use this function before calling \ref run(Node) "run()"
    514     ///or \ref init(), an instance will be allocated automatically.
    515     ///The destructor deallocates this automatically allocated map,
    516     ///of course.
     506    ///If you don't use this function before calling \ref run(),
     507    ///it will allocate one. The destructor deallocates this
     508    ///automatically allocated map, of course.
    517509    ///\return <tt> (*this) </tt>
    518510    Dijkstra &processedMap(ProcessedMap &m)
     
    530522    ///Sets the map that stores the distances of the nodes calculated by the
    531523    ///algorithm.
    532     ///If you don't use this function before calling \ref run(Node) "run()"
    533     ///or \ref init(), an instance will be allocated automatically.
    534     ///The destructor deallocates this automatically allocated map,
    535     ///of course.
     524    ///If you don't use this function before calling \ref run(),
     525    ///it will allocate one. The destructor deallocates this
     526    ///automatically allocated map, of course.
    536527    ///\return <tt> (*this) </tt>
    537528    Dijkstra &distMap(DistMap &m)
     
    548539
    549540    ///Sets the heap and the cross reference used by algorithm.
    550     ///If you don't use this function before calling \ref run(Node) "run()"
    551     ///or \ref init(), heap and cross reference instances will be
    552     ///allocated automatically.
    553     ///The destructor deallocates these automatically allocated objects,
    554     ///of course.
     541    ///If you don't use this function before calling \ref run(),
     542    ///it will allocate one. The destructor deallocates this
     543    ///automatically allocated heap and cross reference, of course.
    555544    ///\return <tt> (*this) </tt>
    556545    Dijkstra &heap(Heap& hp, HeapCrossRef &cr)
     
    579568  public:
    580569
    581     ///\name Execution Control
    582     ///The simplest way to execute the %Dijkstra algorithm is to use
    583     ///one of the member functions called \ref run(Node) "run()".\n
    584     ///If you need more control on the execution, first you have to call
    585     ///\ref init(), then you can add several source nodes with
    586     ///\ref addSource(). Finally the actual path computation can be
    587     ///performed with one of the \ref start() functions.
     570    ///\name Execution control
     571    ///The simplest way to execute the algorithm is to use one of the
     572    ///member functions called \ref lemon::Dijkstra::run() "run()".
     573    ///\n
     574    ///If you need more control on the execution, first you must call
     575    ///\ref lemon::Dijkstra::init() "init()", then you can add several
     576    ///source nodes with \ref lemon::Dijkstra::addSource() "addSource()".
     577    ///Finally \ref lemon::Dijkstra::start() "start()" will perform the
     578    ///actual path computation.
    588579
    589580    ///@{
    590581
    591     ///\brief Initializes the internal data structures.
    592     ///
    593582    ///Initializes the internal data structures.
     583
     584    ///Initializes the internal data structures.
     585    ///
    594586    void init()
    595587    {
     
    667659    }
    668660
    669     ///Returns \c false if there are nodes to be processed.
    670 
    671     ///Returns \c false if there are nodes to be processed
    672     ///in the priority heap.
     661    ///\brief Returns \c false if there are nodes
     662    ///to be processed.
     663    ///
     664    ///Returns \c false if there are nodes
     665    ///to be processed in the priority heap.
    673666    bool emptyQueue() const { return _heap->empty(); }
    674667
    675     ///Returns the number of the nodes to be processed.
    676 
    677     ///Returns the number of the nodes to be processed
    678     ///in the priority heap.
     668    ///Returns the number of the nodes to be processed in the priority heap
     669
     670    ///Returns the number of the nodes to be processed in the priority heap.
     671    ///
    679672    int queueSize() const { return _heap->size(); }
    680673
     
    797790
    798791    ///\name Query Functions
    799     ///The results of the %Dijkstra algorithm can be obtained using these
     792    ///The result of the %Dijkstra algorithm can be obtained using these
    800793    ///functions.\n
    801     ///Either \ref run(Node) "run()" or \ref start() should be called
    802     ///before using them.
     794    ///Either \ref lemon::Dijkstra::run() "run()" or
     795    ///\ref lemon::Dijkstra::start() "start()" must be called before
     796    ///using them.
    803797
    804798    ///@{
     
    808802    ///Returns the shortest path to a node.
    809803    ///
    810     ///\warning \c t should be reached from the root(s).
    811     ///
    812     ///\pre Either \ref run(Node) "run()" or \ref init()
    813     ///must be called before using this function.
     804    ///\warning \c t should be reachable from the root(s).
     805    ///
     806    ///\pre Either \ref run() or \ref start() must be called before
     807    ///using this function.
    814808    Path path(Node t) const { return Path(*G, *_pred, t); }
    815809
     
    818812    ///Returns the distance of a node from the root(s).
    819813    ///
    820     ///\warning If node \c v is not reached from the root(s), then
     814    ///\warning If node \c v is not reachable from the root(s), then
    821815    ///the return value of this function is undefined.
    822816    ///
    823     ///\pre Either \ref run(Node) "run()" or \ref init()
    824     ///must be called before using this function.
     817    ///\pre Either \ref run() or \ref start() must be called before
     818    ///using this function.
    825819    Value dist(Node v) const { return (*_dist)[v]; }
    826820
     
    829823    ///This function returns the 'previous arc' of the shortest path
    830824    ///tree for the node \c v, i.e. it returns the last arc of a
    831     ///shortest path from a root to \c v. It is \c INVALID if \c v
    832     ///is not reached from the root(s) or if \c v is a root.
     825    ///shortest path from the root(s) to \c v. It is \c INVALID if \c v
     826    ///is not reachable from the root(s) or if \c v is a root.
    833827    ///
    834828    ///The shortest path tree used here is equal to the shortest path
    835829    ///tree used in \ref predNode().
    836830    ///
    837     ///\pre Either \ref run(Node) "run()" or \ref init()
    838     ///must be called before using this function.
     831    ///\pre Either \ref run() or \ref start() must be called before
     832    ///using this function.
    839833    Arc predArc(Node v) const { return (*_pred)[v]; }
    840834
     
    843837    ///This function returns the 'previous node' of the shortest path
    844838    ///tree for the node \c v, i.e. it returns the last but one node
    845     ///from a shortest path from a root to \c v. It is \c INVALID
    846     ///if \c v is not reached from the root(s) or if \c v is a root.
     839    ///from a shortest path from the root(s) to \c v. It is \c INVALID
     840    ///if \c v is not reachable from the root(s) or if \c v is a root.
    847841    ///
    848842    ///The shortest path tree used here is equal to the shortest path
    849843    ///tree used in \ref predArc().
    850844    ///
    851     ///\pre Either \ref run(Node) "run()" or \ref init()
    852     ///must be called before using this function.
     845    ///\pre Either \ref run() or \ref start() must be called before
     846    ///using this function.
    853847    Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
    854848                                  G->source((*_pred)[v]); }
     
    860854    ///of the nodes calculated by the algorithm.
    861855    ///
    862     ///\pre Either \ref run(Node) "run()" or \ref init()
     856    ///\pre Either \ref run() or \ref init()
    863857    ///must be called before using this function.
    864858    const DistMap &distMap() const { return *_dist;}
     
    870864    ///arcs, which form the shortest path tree.
    871865    ///
    872     ///\pre Either \ref run(Node) "run()" or \ref init()
     866    ///\pre Either \ref run() or \ref init()
    873867    ///must be called before using this function.
    874868    const PredMap &predMap() const { return *_pred;}
    875869
    876     ///Checks if a node is reached from the root(s).
    877 
    878     ///Returns \c true if \c v is reached from the root(s).
    879     ///
    880     ///\pre Either \ref run(Node) "run()" or \ref init()
     870    ///Checks if a node is reachable from the root(s).
     871
     872    ///Returns \c true if \c v is reachable from the root(s).
     873    ///\pre Either \ref run() or \ref start()
    881874    ///must be called before using this function.
    882875    bool reached(Node v) const { return (*_heap_cross_ref)[v] !=
     
    887880    ///Returns \c true if \c v is processed, i.e. the shortest
    888881    ///path to \c v has already found.
    889     ///
    890     ///\pre Either \ref run(Node) "run()" or \ref init()
     882    ///\pre Either \ref run() or \ref init()
    891883    ///must be called before using this function.
    892884    bool processed(Node v) const { return (*_heap_cross_ref)[v] ==
     
    897889    ///Returns the current distance of a node from the root(s).
    898890    ///It may be decreased in the following processes.
    899     ///
    900     ///\pre Either \ref run(Node) "run()" or \ref init()
     891    ///\pre Either \ref run() or \ref init()
    901892    ///must be called before using this function and
    902893    ///node \c v must be reached but not necessarily processed.
     
    10811072  /// This auxiliary class is created to implement the
    10821073  /// \ref dijkstra() "function-type interface" of \ref Dijkstra algorithm.
    1083   /// It does not have own \ref run(Node) "run()" method, it uses the
    1084   /// functions and features of the plain \ref Dijkstra.
     1074  /// It does not have own \ref run() method, it uses the functions
     1075  /// and features of the plain \ref Dijkstra.
    10851076  ///
    10861077  /// This class should only be used through the \ref dijkstra() function,
     
    12771268  ///  bool reached = dijkstra(g,length).path(p).dist(d).run(s,t);
    12781269  ///\endcode
    1279   ///\warning Don't forget to put the \ref DijkstraWizard::run(Node) "run()"
     1270  ///\warning Don't forget to put the \ref DijkstraWizard::run() "run()"
    12801271  ///to the end of the parameter list.
    12811272  ///\sa DijkstraWizard
Note: See TracChangeset for help on using the changeset viewer.