[Lemon-commits] [lemon_svn] alpar: r1556 - hugo/trunk/src/lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:46:11 CET 2006


Author: alpar
Date: Fri Feb 18 15:46:04 2005
New Revision: 1556

Modified:
   hugo/trunk/src/lemon/dijkstra.h

Log:
- Better addSource()
- More docs

Modified: hugo/trunk/src/lemon/dijkstra.h
==============================================================================
--- hugo/trunk/src/lemon/dijkstra.h	(original)
+++ hugo/trunk/src/lemon/dijkstra.h	Fri Feb 18 15:46:04 2005
@@ -483,18 +483,28 @@
     
     ///Adds a new source node.
 
-    ///Adds a new source node the the priority heap.
-    ///It checks if the node has already been added to the heap.
+    ///Adds a new source node to the priority heap.
     ///
     ///The optional second parameter is the initial distance of the node.
     ///
-    ///\todo Do we really want to check it?
+    ///It checks if the node has already been added to the heap and
+    ///It is pushed to the heap only if either it was not in the heap
+    ///or the shortest path found till then is longer then \c dst.
     void addSource(Node s,Value dst=0)
     {
       source = s;
       if(_heap.state(s) != Heap::IN_HEAP) _heap.push(s,dst);
+      else if(_heap[s]<dst) {
+	_heap.push(s,dst);
+	_pred->set(s,INVALID);
+      }
     }
     
+    ///Processes the next node in the priority heap
+
+    ///Processes the next node in the priority heap.
+    ///
+    ///\warning The priority heap must not be empty!
     void processNextNode()
     {
       Node v=_heap.top(); 
@@ -523,6 +533,17 @@
       }
     }
 
+    ///Returns \c false if there are nodes to be processed in the priority heap
+
+    ///Returns \c false if there are nodes to be processed in the priority heap
+    ///
+    bool emptyHeap() { return heap.empty(); }
+    ///Returns the number of the nodes to be processed in the priority heap
+
+    ///Returns the number of the nodes to be processed in the priority heap
+    ///
+    int heapSize() { return heap.size(); }
+    
     ///Executes the algorithm.
 
     ///Executes the algorithm.



More information about the Lemon-commits mailing list