# HG changeset patch # User alpar # Date 1095950445 0 # Node ID 5be029d19c98b9206425d9a816fd82e68fea81de # Parent b40afcf42a4d7fda811947a4460d198a5bb43e4d Some code cleaning in id related stuffs diff -r b40afcf42a4d -r 5be029d19c98 src/benchmark/hcube.cc --- a/src/benchmark/hcube.cc Wed Sep 22 12:42:19 2004 +0000 +++ b/src/benchmark/hcube.cc Thu Sep 23 14:40:45 2004 +0000 @@ -66,10 +66,13 @@ for(int i=0;i friend class EdgeMap; - //template 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 nedges[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 friend class EdgeMap; - - //template 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 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 - /// + protected: int n; - protected: 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 nfirst(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 { diff -r b40afcf42a4d -r 5be029d19c98 src/hugo/smart_graph.h --- a/src/hugo/smart_graph.h Wed Sep 22 12:42:19 2004 +0000 +++ b/src/hugo/smart_graph.h Thu Sep 23 14:40:45 2004 +0000 @@ -217,32 +217,27 @@ friend class SmartGraph; template friend class EdgeMap; - //template 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