[Lemon-commits] [lemon_svn] alpar: r176 - hugo/trunk/src/work/alpar

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


Author: alpar
Date: Wed Feb 25 16:26:39 2004
New Revision: 176

Modified:
   hugo/trunk/src/work/alpar/smart_graph.h

Log:
setInvalid() functions added.


Modified: hugo/trunk/src/work/alpar/smart_graph.h
==============================================================================
--- hugo/trunk/src/work/alpar/smart_graph.h	(original)
+++ hugo/trunk/src/work/alpar/smart_graph.h	Wed Feb 25 16:26:39 2004
@@ -5,26 +5,29 @@
 
 #include <iostream>
 #include <vector>
+#include <limits.h>
 
 namespace hugo {
 
   class SmartGraph {
 
-    static const int INVALID=-1;
+    static const int INVALID_EDGE=-1;
+    static const int INVALID_NODE=INT_MAX;
 
     struct NodeT 
     {
       int first_in,first_out;      
-      NodeT() : first_in(INVALID), first_out(INVALID) {}
+      NodeT() : first_in(INVALID_EDGE), first_out(INVALID_EDGE) {}
     };
     struct EdgeT 
     {
       int head, tail, next_in, next_out;      
       //FIXME: is this necessary?
-      EdgeT() : next_in(INVALID), next_out(INVALID) {}  
+      EdgeT() : next_in(INVALID_EDGE), next_out(INVALID_EDGE) {}  
     };
 
     std::vector<NodeT> nodes;
+
     std::vector<EdgeT> edges;
     
     template <typename Key> class DynMapBase
@@ -123,10 +126,13 @@
       return e; 
     }
 
-    bool valid(EdgeIt e) const { return e.n!=INVALID; }
+    bool valid(EdgeIt e) const { return e.n!=INVALID_EDGE; }
     bool valid(EachEdgeIt e) const { return e.n<int(edges.size()); }
     bool valid(NodeIt n) const { return n.n<int(nodes.size()); }
     
+    void setInvalid(EdgeIt &e) { e.n=INVALID_EDGE; }
+    void setInvalid(NodeIt &e) { e.n=INVALID_NODE; }
+    
     template <typename It> It next(It it) const
       //    { It tmp(it); return goNext(tmp); }
     { It tmp; tmp.n=it.n+1; return tmp; }



More information about the Lemon-commits mailing list