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

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


Author: alpar
Date: Mon Oct 24 10:09:59 2005
New Revision: 2261

Modified:
   hugo/trunk/lemon/dijkstra.h

Log:
- dijkstraZero() added. (Until we conclude how to handle the related problem.)
- processed() query function added.

Modified: hugo/trunk/lemon/dijkstra.h
==============================================================================
--- hugo/trunk/lemon/dijkstra.h	(original)
+++ hugo/trunk/lemon/dijkstra.h	Mon Oct 24 10:09:59 2005
@@ -22,6 +22,7 @@
 ///\brief Dijkstra algorithm.
 ///
 ///\todo getPath() should be implemented! (also for BFS and DFS)
+///\todo dijkstraZero() solution should be revised.
 
 #include <lemon/list_graph.h>
 #include <lemon/bin_heap.h>
@@ -31,7 +32,7 @@
 
 namespace lemon {
 
-
+  template<class T> T dijkstraZero() {return 0;}
   
   ///Default traits class of Dijkstra class.
 
@@ -499,7 +500,7 @@
     ///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)
+    void addSource(Node s,Value dst=dijkstraZero<Value>())
     {
       if(_heap->state(s) != Heap::IN_HEAP) {
 	_heap->push(s,dst);
@@ -659,7 +660,7 @@
       init();
       addSource(s);
       start(t);
-      return (*_pred)[t]==INVALID?0:(*_dist)[t];
+      return (*_pred)[t]==INVALID?dijkstraZero<Value>():(*_dist)[t];
     }
     
     ///@}
@@ -746,6 +747,14 @@
     ///\pre \ref run() must be called before using this function.
     ///
     bool reached(Node v) { return (*_heap_cross_ref)[v] != Heap::PRE_HEAP; }
+
+    ///Checks if a node is processed.
+
+    ///Returns \c true if \c v is processed, i.e. the shortest
+    ///path to \c v has already found.
+    ///\pre \ref run() must be called before using this function.
+    ///
+    bool processed(Node v) { return (*_heap_cross_ref)[v] == Heap::POST_HEAP; }
     
     ///@}
   };



More information about the Lemon-commits mailing list