lemon/dijkstra.h
changeset 2442 27b7c7de9cac
parent 2391 14a343be7a5a
child 2443 14abfa02bf42
equal deleted inserted replaced
31:764d43c03836 32:c74a1f8dbf42
   599     ///
   599     ///
   600     ///\return The next node to be processed or INVALID if the priority heap
   600     ///\return The next node to be processed or INVALID if the priority heap
   601     /// is empty.
   601     /// is empty.
   602     Node nextNode()
   602     Node nextNode()
   603     { 
   603     { 
   604       return _heap->empty()?_heap->top():INVALID;
   604       return !_heap->empty()?_heap->top():INVALID;
   605     }
   605     }
   606  
   606  
   607     ///\brief Returns \c false if there are nodes
   607     ///\brief Returns \c false if there are nodes
   608     ///to be processed in the priority heap
   608     ///to be processed in the priority heap
   609     ///
   609     ///
   662     ///\pre init() must be called and at least one node should be added
   662     ///\pre init() must be called and at least one node should be added
   663     ///with addSource() before using this function.
   663     ///with addSource() before using this function.
   664     ///
   664     ///
   665     ///\param nm must be a bool (or convertible) node map. The algorithm
   665     ///\param nm must be a bool (or convertible) node map. The algorithm
   666     ///will stop when it reaches a node \c v with <tt>nm[v]==true</tt>.
   666     ///will stop when it reaches a node \c v with <tt>nm[v]==true</tt>.
       
   667     ///
       
   668     ///\return The reached node \c v with <tt>nm[v]==true<\tt> or
       
   669     ///\c INVALID if no such node was found.
   667     template<class NodeBoolMap>
   670     template<class NodeBoolMap>
   668     void start(const NodeBoolMap &nm)
   671     Node start(const NodeBoolMap &nm)
   669     {
   672     {
   670       while ( !_heap->empty() && !nm[_heap->top()] ) processNextNode();
   673       while ( !_heap->empty() && !nm[_heap->top()] ) processNextNode();
   671       if ( !_heap->empty() ) finalizeNodeData(_heap->top(),_heap->prio());
   674       if ( _heap->empty() ) return INVALID;
       
   675       finalizeNodeData(_heap->top(),_heap->prio());
       
   676       return _heap->top();
   672     }
   677     }
   673     
   678     
   674     ///Runs %Dijkstra algorithm from node \c s.
   679     ///Runs %Dijkstra algorithm from node \c s.
   675     
   680     
   676     ///This method runs the %Dijkstra algorithm from a root node \c s
   681     ///This method runs the %Dijkstra algorithm from a root node \c s