[Lemon-commits] [lemon_svn] alpar: r1038 - in hugo/branches/hugo++/src: hugo test

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


Author: alpar
Date: Tue Aug 24 19:01:23 2004
New Revision: 1038

Modified:
   hugo/branches/hugo++/src/hugo/full_graph.h
   hugo/branches/hugo++/src/hugo/list_graph.h
   hugo/branches/hugo++/src/test/graph_test.cc

Log:
- full_graph conversion finished
- bug fixes in list_graph.h
- src/test/graph_test.cc compiles (with graphskeleton checks commented out)

Modified: hugo/branches/hugo++/src/hugo/full_graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/full_graph.h	(original)
+++ hugo/branches/hugo++/src/hugo/full_graph.h	Tue Aug 24 19:01:23 2004
@@ -63,12 +63,6 @@
     Node tail(Edge e) const { return e.n%NodeNum; }
     Node head(Edge e) const { return e.n/NodeNum; }
 
-    Node aNode(OutEdgeIt e) const { return tail(e); }
-    Node aNode(InEdgeIt e) const { return head(e); }
-
-    Node bNode(OutEdgeIt e) const { return head(e); }
-    Node bNode(InEdgeIt e) const { return tail(e); }
-
     NodeIt& first(NodeIt& v) const {
       v=NodeIt(*this); return v; }
     EdgeIt& first(EdgeIt& e) const { 
@@ -78,22 +72,6 @@
     InEdgeIt& first(InEdgeIt& e, const Node v) const { 
       e=InEdgeIt(*this,v); return e; }
 
-    static bool valid(Edge e) { return e.n!=-1; }
-    static bool valid(Node n) { return n.n!=-1; }
-    
-    template <typename It> It getNext(It it) const
-    { It tmp(it); return next(tmp); }
-
-    NodeIt& next(NodeIt& it) const { 
-      it.n=(it.n+2)%(NodeNum+1)-1; 
-      return it; 
-    }
-    OutEdgeIt& next(OutEdgeIt& it) const
-    { it.n+=NodeNum; if(it.n>=EdgeNum) it.n=-1; return it; }
-    InEdgeIt& next(InEdgeIt& it) const
-    { if(!((++it.n)%NodeNum)) it.n=-1; return it; }
-    static EdgeIt& next(EdgeIt& it) { --it.n; return it; }
-
     static int id(Node v) { return v.n; }
     static int id(Edge e) { return e.n; }
 
@@ -119,13 +97,15 @@
     };
     
     class NodeIt : public Node {
+      const FullGraph *G;
       friend class FullGraph;
     public:
       NodeIt() : Node() { }
       NodeIt(Invalid i) : Node(i) { }
-      NodeIt(const FullGraph& G) : Node(G.NodeNum?0:-1) { }
+      NodeIt(const FullGraph& _G) : Node(_G.NodeNum?0:-1), G(&_G) { }
       ///\todo Undocumented conversion Node -\> NodeIt.
-      NodeIt(const FullGraph& G, const Node &n) : Node(n) { }
+      NodeIt(const FullGraph& _G, const Node &n) : Node(n), G(&_G) { }
+      NodeIt& operator++() { n=(n+2)%(G->NodeNum+1)-1;return *this; }
     };
 
     class Edge {
@@ -154,30 +134,39 @@
     class EdgeIt : public Edge {
       friend class FullGraph;
     public:
-      EdgeIt(const FullGraph& G) : Edge(G.EdgeNum-1) { }
+      EdgeIt(const FullGraph& _G) : Edge(_G.EdgeNum-1) { }
       EdgeIt (Invalid i) : Edge(i) { }
       EdgeIt() : Edge() { }
+      EdgeIt& operator++() { --n; return *this; }
+
       ///\bug This is a workaround until somebody tells me how to
       ///make class \c SymFullGraph::SymEdgeMap friend of Edge
       int &idref() {return n;}
     };
     
     class OutEdgeIt : public Edge {
+      const FullGraph *G;
       friend class FullGraph;
     public: 
       OutEdgeIt() : Edge() { }
       OutEdgeIt (Invalid i) : Edge(i) { }
 
-      OutEdgeIt(const FullGraph& G,const Node v)
-	: Edge(v.n) {}
+      OutEdgeIt(const FullGraph& _G,const Node v) : Edge(v.n), G(&_G) {}
+      
+      OutEdgeIt& operator++()
+      { n+=G->NodeNum; if(n>=G->EdgeNum) n=-1; return *this; }
+
     };
     
     class InEdgeIt : public Edge {
+      const FullGraph *G;
       friend class FullGraph;
     public: 
       InEdgeIt() : Edge() { }
       InEdgeIt (Invalid i) : Edge(i) { }
-      InEdgeIt(const FullGraph& G,Node v) :Edge(v.n*G.NodeNum){}
+      InEdgeIt(const FullGraph& _G,Node v) : Edge(v.n*_G.NodeNum), G(&_G) {}
+      InEdgeIt& operator++()
+      { if(!((++n)%G->NodeNum)) n=-1; return *this; }
     };
 
     template <typename T> class NodeMap

Modified: hugo/branches/hugo++/src/hugo/list_graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/list_graph.h	(original)
+++ hugo/branches/hugo++/src/hugo/list_graph.h	Tue Aug 24 19:01:23 2004
@@ -917,13 +917,14 @@
     };
     
     class NodeIt : public Node {
+      const NodeSet *G;
       friend class NodeSet;
     public:
       NodeIt() : Node() { }
       NodeIt(Invalid i) : Node(i) { }
-      NodeIt(const NodeSet& G) : Node(G.first_node) { }
+      NodeIt(const NodeSet& _G) : Node(_G.first_node), G(&_G) { }
       ///\todo Undocumented conversion Node -\> NodeIt.
-      NodeIt(const NodeSet& G, const Node &n) : Node(n) { }
+      NodeIt(const NodeSet& _G, const Node &n) : Node(n), G(&_G) { }
       NodeIt &operator++() {
 	n=G->nodes[n].next; 
 	return *this; 
@@ -1176,8 +1177,8 @@
 	: NodeGraphType::NodeIt(_G.G,n) { }
 
       operator Node() { return Node(*this);}
-      NodeIt &operator++() { return this->NodeGraphType::NodeIt::operator++();} 
-      }
+      NodeIt &operator++()
+      { this->NodeGraphType::NodeIt::operator++(); return *this;} 
     };
 
   private:
@@ -1419,7 +1420,7 @@
 	//      	typename NodeGraphType::Node m;
         NodeIt m;
 	for(G.first(m);
-	    m!=INVALID && G.nodes[m].first_in == -1;  G.next(m));
+	    m!=INVALID && G.nodes[m].first_in == -1;  ++m);
 	///\bug AJJAJ! This is a non sense!!!!!!!
 	this->n = m!=INVALID?-1:G.nodes[m].first_in;
       }
@@ -1438,21 +1439,25 @@
     };
     
     class OutEdgeIt : public Edge {
+      const EdgeSet *G;
       friend class EdgeSet;
     public: 
       OutEdgeIt() : Edge() { }
       OutEdgeIt (Invalid i) : Edge(i) { }
 
-      OutEdgeIt(const EdgeSet& G,const Node v) : Edge(G.nodes[v].first_out) { }
+      OutEdgeIt(const EdgeSet& _G,const Node v) :
+	Edge(_G.nodes[v].first_out), G(&_G) { }
       OutEdgeIt &operator++() { n=G->edges[n].next_out; return *this; }
     };
     
     class InEdgeIt : public Edge {
+      const EdgeSet *G;
       friend class EdgeSet;
     public: 
       InEdgeIt() : Edge() { }
       InEdgeIt (Invalid i) : Edge(i) { }
-      InEdgeIt(const EdgeSet& G,Node v) :Edge(G.nodes[v].first_in) { }
+      InEdgeIt(const EdgeSet& _G,Node v)
+	: Edge(_G.nodes[v].first_in), G(&_G) { }
       InEdgeIt &operator++() { n=G->edges[n].next_in; return *this; }
     };
 

Modified: hugo/branches/hugo++/src/test/graph_test.cc
==============================================================================
--- hugo/branches/hugo++/src/test/graph_test.cc	(original)
+++ hugo/branches/hugo++/src/test/graph_test.cc	Tue Aug 24 19:01:23 2004
@@ -1,6 +1,6 @@
 #include<iostream>
 #include<hugo/smart_graph.h>
-#include<hugo/skeletons/graph.h>
+//#include<hugo/skeletons/graph.h>
 #include<hugo/list_graph.h>
 #include<hugo/full_graph.h>
 
@@ -18,7 +18,7 @@
 */
 
 using namespace hugo;
-using namespace hugo::skeleton;
+//using namespace hugo::skeleton;
 
 template<class Graph> void checkCompileStaticGraph(Graph &G) 
 {
@@ -278,9 +278,9 @@
   }  
 }
 
-template
-void checkCompileStaticGraph<StaticGraphSkeleton>(StaticGraphSkeleton &);
-template void checkCompile<GraphSkeleton>(GraphSkeleton &);
+// template
+// void checkCompileStaticGraph<StaticGraphSkeleton>(StaticGraphSkeleton &);
+// template void checkCompile<GraphSkeleton>(GraphSkeleton &);
 
 template void checkCompile<SmartGraph>(SmartGraph &);
 template void checkCompile<SymSmartGraph>(SymSmartGraph &);



More information about the Lemon-commits mailing list