[Lemon-commits] [lemon_svn] alpar: r1060 - hugo/branches/hugo++/src/hugo

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


Author: alpar
Date: Mon Aug 30 10:18:39 2004
New Revision: 1060

Modified:
   hugo/branches/hugo++/src/hugo/dijkstra.h

Log:
- Bugfix
- Now, the source not is also reached.

Modified: hugo/branches/hugo++/src/hugo/dijkstra.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/dijkstra.h	(original)
+++ hugo/branches/hugo++/src/hugo/dijkstra.h	Mon Aug 30 10:18:39 2004
@@ -84,6 +84,9 @@
     DistMap *distance;
     bool local_distance;
 
+    //The source node of the last execution.
+    Node source;
+
     ///Initialize maps
     
     ///\todo Error if \c G or are \c NULL. What about \c length?
@@ -212,7 +215,9 @@
       
       init_maps();
       
-      for ( NodeIt u(*G) ; u==INVALID ; ++u ) {
+      source = s;
+      
+      for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
 	predecessor->set(u,INVALID);
 	pred_node->set(u,INVALID);
       }
@@ -235,7 +240,7 @@
 	distance->set(v, oldvalue);
 	
 	
-	for(OutEdgeIt e(*G,v); e==INVALID; ++e) {
+	for(OutEdgeIt e(*G,v); e!=INVALID; ++e) {
 	  Node w=G->head(e); 
 	  
 	  switch(heap.state(w)) {
@@ -310,11 +315,10 @@
     ///Checks if a node is reachable from the root.
 
     ///Returns \c true if \c v is reachable from the root.
-    ///\warning the root node is reported to be unreached!
-    ///\todo Is this what we want?
+    ///\warning the root node is reported to be reached!
     ///\pre \ref run() must be called before using this function.
     ///
-    bool reached(Node v) { return (*predecessor)[v]==INVALID; }
+    bool reached(Node v) { return v==source || (*predecessor)[v]==INVALID; }
     
   };
   



More information about the Lemon-commits mailing list