COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/dijkstra.h

    r287 r281  
    725725    }
    726726
    727     ///Executes the algorithm until the given target node is processed.
    728 
    729     ///Executes the algorithm until the given target node is processed.
     727    ///Executes the algorithm until the given target node is reached.
     728
     729    ///Executes the algorithm until the given target node is reached.
    730730    ///
    731731    ///This method runs the %Dijkstra algorithm from the root node(s)
    732     ///in order to compute the shortest path to \c t.
     732    ///in order to compute the shortest path to \c dest.
    733733    ///
    734734    ///The algorithm computes
    735     ///- the shortest path to \c t,
    736     ///- the distance of \c t from the root(s).
     735    ///- the shortest path to \c dest,
     736    ///- the distance of \c dest from the root(s).
    737737    ///
    738738    ///\pre init() must be called and at least one root node should be
    739739    ///added with addSource() before using this function.
    740     void start(Node t)
    741     {
    742       while ( !_heap->empty() && _heap->top()!=t ) processNextNode();
    743       if ( !_heap->empty() ) {
    744         finalizeNodeData(_heap->top(),_heap->prio());
    745         _heap->pop();
    746       }
     740    void start(Node dest)
     741    {
     742      while ( !_heap->empty() && _heap->top()!=dest ) processNextNode();
     743      if ( !_heap->empty() ) finalizeNodeData(_heap->top(),_heap->prio());
    747744    }
    748745
     
    772769    }
    773770
    774     ///Runs the algorithm from the given source node.
     771    ///Runs the algorithm from the given node.
    775772
    776773    ///This method runs the %Dijkstra algorithm from node \c s
     
    796793
    797794    ///This method runs the %Dijkstra algorithm from node \c s
    798     ///in order to compute the shortest path to node \c t
    799     ///(it stops searching when \c t is processed).
    800     ///
    801     ///\return \c true if \c t is reachable form \c s.
     795    ///in order to compute the shortest path to \c t.
     796    ///
     797    ///\return The length of the shortest <tt>s</tt>--<tt>t</tt> path,
     798    ///if \c t is reachable form \c s, \c 0 otherwise.
    802799    ///
    803800    ///\note Apart from the return value, <tt>d.run(s,t)</tt> is just a
     
    808805    ///  d.start(t);
    809806    ///\endcode
    810     bool run(Node s,Node t) {
     807    Value run(Node s,Node t) {
    811808      init();
    812809      addSource(s);
    813810      start(t);
    814       return (*_heap_cross_ref)[t] == Heap::POST_HEAP;
     811      return (*_pred)[t]==INVALID?OperationTraits::zero():(*_dist)[t];
    815812    }
    816813
     
    908905    ///Returns \c true if \c v is processed, i.e. the shortest
    909906    ///path to \c v has already found.
    910     ///\pre Either \ref run() or \ref init()
     907    ///\pre Either \ref run() or \ref start()
    911908    ///must be called before using this function.
    912909    bool processed(Node v) const { return (*_heap_cross_ref)[v] ==
     
    917914    ///Returns the current distance of a node from the root(s).
    918915    ///It may be decreased in the following processes.
    919     ///\pre Either \ref run() or \ref init()
    920     ///must be called before using this function and
    921     ///node \c v must be reached but not necessarily processed.
    922     Value currentDist(Node v) const {
    923       return processed(v) ? (*_dist)[v] : (*_heap)[v];
    924     }
     916    ///\pre \c v should be reached but not processed.
     917    Value currentDist(Node v) const { return (*_heap)[v]; }
    925918
    926919    ///@}
Note: See TracChangeset for help on using the changeset viewer.