[Lemon-commits] [lemon_svn] alpar: r1215 - in hugo/trunk/src: benchmark hugo

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


Author: alpar
Date: Thu Sep 23 16:40:45 2004
New Revision: 1215

Modified:
   hugo/trunk/src/benchmark/hcube.cc
   hugo/trunk/src/hugo/list_graph.h
   hugo/trunk/src/hugo/smart_graph.h

Log:
Some code cleaning in id related stuffs


Modified: hugo/trunk/src/benchmark/hcube.cc
==============================================================================
--- hugo/trunk/src/benchmark/hcube.cc	(original)
+++ hugo/trunk/src/benchmark/hcube.cc	Thu Sep 23 16:40:45 2004
@@ -66,10 +66,13 @@
     for(int i=0;i<dim*(1<<dim);i++) P();
     
     //  for(EdgeIt e(G);G.valid(e);G.next(e)) map[e]=P();
-    for(int i=0;i<dim*(1<<dim);i++)
+    Edge te;
+    for(int i=0;i<dim*(1<<dim);i++) {
+      te.setToId(((long long int)(i)*93505)%(dim*(1<<dim)));
       //    map[Edge(((long long int)(i)*2987)%(dim*(1<<dim)))]=P();
-      map[Edge(((long long int)(i)*93505)%(dim*(1<<dim)))]=P();
-  
+      map[te]=P();
+    }
+    
 //     for(int i=0;i<(1<<dim);i++) {
 //       int mul= (1<<(numOfZeros(i,dim)/4));
 //       for(OutEdgeIt e(G,nodes[i]);G.valid(e);G.next(e))

Modified: hugo/trunk/src/hugo/list_graph.h
==============================================================================
--- hugo/trunk/src/hugo/list_graph.h	(original)
+++ hugo/trunk/src/hugo/list_graph.h	Thu Sep 23 16:40:45 2004
@@ -76,7 +76,7 @@
 
     // Create map registries.
     CREATE_MAP_REGISTRIES;
-    /// Create node and edge maps.
+    // Create node and edge maps.
     CREATE_MAPS(ArrayMap);
 
   public:
@@ -321,8 +321,7 @@
       friend class ListGraph;
       template <typename T> friend class EdgeMap;
 
-      //template <typename T> friend class SymListGraph::SymEdgeMap;      
-      //friend Edge SymListGraph::opposite(Edge) const;
+      friend class SymListGraph;
       
       friend class Node;
       friend class NodeIt;
@@ -342,10 +341,6 @@
       bool operator==(const Edge i) const {return n==i.n;}
       bool operator!=(const Edge i) const {return n!=i.n;}
       bool operator<(const Edge i) const {return n<i.n;}
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymListGraph::SymEdgeMap friend of Edge
-      int &idref() {return n;}
-      const int &idref() const {return n;} 
       //      ///Validity check
       //      operator bool() { return n!=-1; }
    };
@@ -363,9 +358,6 @@
       EdgeIt (Invalid i) : Edge(i) { }
       EdgeIt(const ListGraph& _G, Edge e) : Edge(e), G(&_G) { }
       EdgeIt() : Edge() { }
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymListGraph::SymEdgeMap friend of Edge
-      int &idref() {return n;}
       EdgeIt &operator++() {
 	if(G->edges[n].next_in!=-1) n=G->edges[n].next_in;
 	else {
@@ -465,7 +457,7 @@
     static Edge opposite(Edge e)
     {
       Edge f;
-      f.idref() = e.idref() - 2*(e.idref()%2) + 1;
+      f.n = e.n - 2*(e.n%2) + 1;
       return f;
     }
     
@@ -604,7 +596,7 @@
     ///
     /// The ID of the \ref INVALID node is -1.
     ///\return The ID of the node \c v. 
-    int id(Node v) const { return v.n; }
+    static int id(Node v) { return v.n; }
     /// Edge ID.
     
     /// The ID of a valid Edge is a nonnegative integer not greater than
@@ -613,7 +605,7 @@
     ///
     /// The ID of the \ref INVALID edge is -1.
     ///\return The ID of the edge \c e. 
-    int id(Edge e) const { return -1; }
+    static int id(Edge e) { return -1; }
 
     /// Adds a new node to the graph.
 
@@ -683,7 +675,7 @@
 
     protected:
       int n;
-      friend int NodeSet::id(Node v) const; 
+      friend int NodeSet::id(Node v); 
       Node(int nn) {n=nn;}
     public:
       Node() {}
@@ -708,39 +700,20 @@
     };
 
     class Edge {
-      //friend class NodeSet;
-      //template <typename T> friend class EdgeMap;
-
-      //template <typename T> friend class SymNodeSet::SymEdgeMap;      
-      //friend Edge SymNodeSet::opposite(Edge) const;
-      
-      //      friend class Node;
-      //      friend class NodeIt;
-    protected:
-      //friend int NodeSet::id(Edge e) const;
-      //      Edge(int nn) {}
     public:
       Edge() { }
       Edge (Invalid) { }
       bool operator==(const Edge i) const {return true;}
       bool operator!=(const Edge i) const {return false;}
       bool operator<(const Edge i) const {return false;}
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymNodeSet::SymEdgeMap friend of Edge
-      //      int idref() {return -1;}
-      //      int idref() const {return -1;}
     };
     
     class EdgeIt : public Edge {
-      //friend class NodeSet;
     public:
       EdgeIt(const NodeSet& G) : Edge() { }
       EdgeIt(const NodeSet&, Edge) : Edge() { }
       EdgeIt (Invalid i) : Edge(i) { }
       EdgeIt() : Edge() { }
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymNodeSet::SymEdgeMap friend of Edge
-      //      int idref() {return -1;}
       EdgeIt operator++() { return INVALID; }
     };
     
@@ -810,7 +783,6 @@
 
     class Node : public NodeGraphType::Node {
       friend class EdgeSet;
-      //      template <typename T> friend class NodeMap;
       
       friend class Edge;
       friend class OutEdgeIt;
@@ -819,7 +791,6 @@
 
     public:
       friend int EdgeSet::id(Node v) const; 
-      //      Node(int nn) {n=nn;}
     public:
       Node() : NodeGraphType::Node() {}
       Node (Invalid i) : NodeGraphType::Node(i) {}
@@ -946,7 +917,7 @@
     ///
     /// The ID of the \ref INVALID edge is -1.
     ///\return The ID of the edge \c e. 
-    int id(Edge e) const { return e.n; }
+    static int id(Edge e) { return e.n; }
 
     /// Adds a new node to the graph.
     Node addNode() { return G.addNode(); }
@@ -1023,13 +994,6 @@
       
   public:
 
-//     void erase(Node nn) {
-//       int n=nn.n;
-//       int m;
-//       while((m=nodes[n].first_in)!=-1) eraseEdge(m);
-//       while((m=nodes[n].first_out)!=-1) eraseEdge(m);
-//     }
-    
     void erase(Edge e) { eraseEdge(e.n); }
 
     ///Clear all edges. (Doesn't clear the nodes!)
@@ -1047,11 +1011,8 @@
 
       friend class Node;
       friend class NodeIt;
-    public:
-      ///\bug It should be at least protected
-      ///
-      int n;
     protected:
+      int n;
       friend int EdgeSet::id(Edge e) const;
 
       Edge(int nn) {n=nn;}
@@ -1061,10 +1022,6 @@
       bool operator==(const Edge i) const {return n==i.n;}
       bool operator!=(const Edge i) const {return n!=i.n;}
       bool operator<(const Edge i) const {return n<i.n;}
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymEdgeSet::SymEdgeMap friend of Edge
-      int &idref() {return n;}
-      const int &idref() const {return n;}
     };
     
     class EdgeIt : public Edge {
@@ -1074,7 +1031,6 @@
       const EdgeSet *G;
     public:
       EdgeIt(const EdgeSet& _G) : Edge(), G(&_G) {
-	//      	typename NodeGraphType::Node m;
         NodeIt m;
 	for(G->first(m);
 	    m!=INVALID && G->nodes[m].first_in == -1;  ++m);
@@ -1091,9 +1047,6 @@
       EdgeIt &operator++() {
 	return *this;
       }
-       ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymEdgeSet::SymEdgeMap friend of Edge
-      int &idref() {return this->n;}
     };
     
     class OutEdgeIt : public Edge {

Modified: hugo/trunk/src/hugo/smart_graph.h
==============================================================================
--- hugo/trunk/src/hugo/smart_graph.h	(original)
+++ hugo/trunk/src/hugo/smart_graph.h	Thu Sep 23 16:40:45 2004
@@ -217,32 +217,27 @@
       friend class SmartGraph;
       template <typename T> friend class EdgeMap;
 
-      //template <typename T> friend class SymSmartGraph::SymEdgeMap;      
-      //friend Edge SymSmartGraph::opposite(Edge) const;
+      friend class SymSmartGraph;
       
       friend class Node;
       friend class NodeIt;
     protected:
       int n;
       friend int SmartGraph::id(Edge e);
-
+      Edge(int nn) {n=nn;}
     public:
       /// An Edge with id \c n.
 
-      /// \bug It should be
-      /// obtained by a member function of the Graph.
-      Edge(int nn) {n=nn;}
       Edge() { }
       Edge (Invalid) { n=-1; }
       bool operator==(const Edge i) const {return n==i.n;}
       bool operator!=(const Edge i) const {return n!=i.n;}
       bool operator<(const Edge i) const {return n<i.n;}
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymSmartGraph::SymEdgeMap friend of Edge
-      int &idref() {return n;}
-      const int &idref() const {return n;} 
 //       ///Validity check
 //       operator bool() { return n!=-1; }
+
+      ///Set the edge to that have ID \c ID.
+      void setToId(int id) { n=id; }
    };
     
     class EdgeIt : public Edge {
@@ -253,9 +248,6 @@
       EdgeIt(const SmartGraph& _G, Edge e) : Edge(e), G(&_G) { }
       EdgeIt (Invalid i) : Edge(i) { }
       EdgeIt() : Edge() { }
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymSmartGraph::SymEdgeMap friend of Edge
-      int &idref() {return n;}
       EdgeIt &operator++() { --n; return *this; }
 //       ///Validity check
 //       operator bool() { return Edge::operator bool(); }      
@@ -342,7 +334,7 @@
     static Edge opposite(Edge e)
     {
       Edge f;
-      f.idref() = e.idref() - 2*(e.idref()%2) + 1;
+      f.n = e.n - 2*(e.n%2) + 1;
       return f;
     }
     



More information about the Lemon-commits mailing list