lemon/dijkstra.h
changeset 1992 6e1b62d42d94
parent 1981 81c8efe92706
child 1993 2115143eceea
equal deleted inserted replaced
16:c50dd8c6ae5b 17:4c249b88b545
   541     ///Adds a new source node to the priority heap.
   541     ///Adds a new source node to the priority heap.
   542     ///
   542     ///
   543     ///The optional second parameter is the initial distance of the node.
   543     ///The optional second parameter is the initial distance of the node.
   544     ///
   544     ///
   545     ///It checks if the node has already been added to the heap and
   545     ///It checks if the node has already been added to the heap and
   546     ///It is pushed to the heap only if either it was not in the heap
   546     ///it is pushed to the heap only if either it was not in the heap
   547     ///or the shortest path found till then is longer then \c dst.
   547     ///or the shortest path found till then is shorter than \c dst.
   548     void addSource(Node s,Value dst=dijkstraZero<Value>())
   548     void addSource(Node s,Value dst=dijkstraZero<Value>())
   549     {
   549     {
   550       if(_heap->state(s) != Heap::IN_HEAP) {
   550       if(_heap->state(s) != Heap::IN_HEAP) {
   551 	_heap->push(s,dst);
   551 	_heap->push(s,dst);
   552       } else if((*_heap)[s]<dst) {
   552       } else if((*_heap)[s]<dst) {
   553 	_heap->push(s,dst);
   553 	_heap->set(s,dst);
   554 	_pred->set(s,INVALID);
   554 	_pred->set(s,INVALID);
   555       }
   555       }
   556     }
   556     }
   557     
   557     
   558     ///Processes the next node in the priority heap
   558     ///Processes the next node in the priority heap