1.1 --- a/src/hugo/list_graph.h Wed Sep 22 12:42:19 2004 +0000
1.2 +++ b/src/hugo/list_graph.h Thu Sep 23 14:40:45 2004 +0000
1.3 @@ -76,7 +76,7 @@
1.4
1.5 // Create map registries.
1.6 CREATE_MAP_REGISTRIES;
1.7 - /// Create node and edge maps.
1.8 + // Create node and edge maps.
1.9 CREATE_MAPS(ArrayMap);
1.10
1.11 public:
1.12 @@ -321,8 +321,7 @@
1.13 friend class ListGraph;
1.14 template <typename T> friend class EdgeMap;
1.15
1.16 - //template <typename T> friend class SymListGraph::SymEdgeMap;
1.17 - //friend Edge SymListGraph::opposite(Edge) const;
1.18 + friend class SymListGraph;
1.19
1.20 friend class Node;
1.21 friend class NodeIt;
1.22 @@ -342,10 +341,6 @@
1.23 bool operator==(const Edge i) const {return n==i.n;}
1.24 bool operator!=(const Edge i) const {return n!=i.n;}
1.25 bool operator<(const Edge i) const {return n<i.n;}
1.26 - ///\bug This is a workaround until somebody tells me how to
1.27 - ///make class \c SymListGraph::SymEdgeMap friend of Edge
1.28 - int &idref() {return n;}
1.29 - const int &idref() const {return n;}
1.30 // ///Validity check
1.31 // operator bool() { return n!=-1; }
1.32 };
1.33 @@ -363,9 +358,6 @@
1.34 EdgeIt (Invalid i) : Edge(i) { }
1.35 EdgeIt(const ListGraph& _G, Edge e) : Edge(e), G(&_G) { }
1.36 EdgeIt() : Edge() { }
1.37 - ///\bug This is a workaround until somebody tells me how to
1.38 - ///make class \c SymListGraph::SymEdgeMap friend of Edge
1.39 - int &idref() {return n;}
1.40 EdgeIt &operator++() {
1.41 if(G->edges[n].next_in!=-1) n=G->edges[n].next_in;
1.42 else {
1.43 @@ -465,7 +457,7 @@
1.44 static Edge opposite(Edge e)
1.45 {
1.46 Edge f;
1.47 - f.idref() = e.idref() - 2*(e.idref()%2) + 1;
1.48 + f.n = e.n - 2*(e.n%2) + 1;
1.49 return f;
1.50 }
1.51
1.52 @@ -604,7 +596,7 @@
1.53 ///
1.54 /// The ID of the \ref INVALID node is -1.
1.55 ///\return The ID of the node \c v.
1.56 - int id(Node v) const { return v.n; }
1.57 + static int id(Node v) { return v.n; }
1.58 /// Edge ID.
1.59
1.60 /// The ID of a valid Edge is a nonnegative integer not greater than
1.61 @@ -613,7 +605,7 @@
1.62 ///
1.63 /// The ID of the \ref INVALID edge is -1.
1.64 ///\return The ID of the edge \c e.
1.65 - int id(Edge e) const { return -1; }
1.66 + static int id(Edge e) { return -1; }
1.67
1.68 /// Adds a new node to the graph.
1.69
1.70 @@ -683,7 +675,7 @@
1.71
1.72 protected:
1.73 int n;
1.74 - friend int NodeSet::id(Node v) const;
1.75 + friend int NodeSet::id(Node v);
1.76 Node(int nn) {n=nn;}
1.77 public:
1.78 Node() {}
1.79 @@ -708,39 +700,20 @@
1.80 };
1.81
1.82 class Edge {
1.83 - //friend class NodeSet;
1.84 - //template <typename T> friend class EdgeMap;
1.85 -
1.86 - //template <typename T> friend class SymNodeSet::SymEdgeMap;
1.87 - //friend Edge SymNodeSet::opposite(Edge) const;
1.88 -
1.89 - // friend class Node;
1.90 - // friend class NodeIt;
1.91 - protected:
1.92 - //friend int NodeSet::id(Edge e) const;
1.93 - // Edge(int nn) {}
1.94 public:
1.95 Edge() { }
1.96 Edge (Invalid) { }
1.97 bool operator==(const Edge i) const {return true;}
1.98 bool operator!=(const Edge i) const {return false;}
1.99 bool operator<(const Edge i) const {return false;}
1.100 - ///\bug This is a workaround until somebody tells me how to
1.101 - ///make class \c SymNodeSet::SymEdgeMap friend of Edge
1.102 - // int idref() {return -1;}
1.103 - // int idref() const {return -1;}
1.104 };
1.105
1.106 class EdgeIt : public Edge {
1.107 - //friend class NodeSet;
1.108 public:
1.109 EdgeIt(const NodeSet& G) : Edge() { }
1.110 EdgeIt(const NodeSet&, Edge) : Edge() { }
1.111 EdgeIt (Invalid i) : Edge(i) { }
1.112 EdgeIt() : Edge() { }
1.113 - ///\bug This is a workaround until somebody tells me how to
1.114 - ///make class \c SymNodeSet::SymEdgeMap friend of Edge
1.115 - // int idref() {return -1;}
1.116 EdgeIt operator++() { return INVALID; }
1.117 };
1.118
1.119 @@ -810,7 +783,6 @@
1.120
1.121 class Node : public NodeGraphType::Node {
1.122 friend class EdgeSet;
1.123 - // template <typename T> friend class NodeMap;
1.124
1.125 friend class Edge;
1.126 friend class OutEdgeIt;
1.127 @@ -819,7 +791,6 @@
1.128
1.129 public:
1.130 friend int EdgeSet::id(Node v) const;
1.131 - // Node(int nn) {n=nn;}
1.132 public:
1.133 Node() : NodeGraphType::Node() {}
1.134 Node (Invalid i) : NodeGraphType::Node(i) {}
1.135 @@ -946,7 +917,7 @@
1.136 ///
1.137 /// The ID of the \ref INVALID edge is -1.
1.138 ///\return The ID of the edge \c e.
1.139 - int id(Edge e) const { return e.n; }
1.140 + static int id(Edge e) { return e.n; }
1.141
1.142 /// Adds a new node to the graph.
1.143 Node addNode() { return G.addNode(); }
1.144 @@ -1023,13 +994,6 @@
1.145
1.146 public:
1.147
1.148 -// void erase(Node nn) {
1.149 -// int n=nn.n;
1.150 -// int m;
1.151 -// while((m=nodes[n].first_in)!=-1) eraseEdge(m);
1.152 -// while((m=nodes[n].first_out)!=-1) eraseEdge(m);
1.153 -// }
1.154 -
1.155 void erase(Edge e) { eraseEdge(e.n); }
1.156
1.157 ///Clear all edges. (Doesn't clear the nodes!)
1.158 @@ -1047,11 +1011,8 @@
1.159
1.160 friend class Node;
1.161 friend class NodeIt;
1.162 - public:
1.163 - ///\bug It should be at least protected
1.164 - ///
1.165 + protected:
1.166 int n;
1.167 - protected:
1.168 friend int EdgeSet::id(Edge e) const;
1.169
1.170 Edge(int nn) {n=nn;}
1.171 @@ -1061,10 +1022,6 @@
1.172 bool operator==(const Edge i) const {return n==i.n;}
1.173 bool operator!=(const Edge i) const {return n!=i.n;}
1.174 bool operator<(const Edge i) const {return n<i.n;}
1.175 - ///\bug This is a workaround until somebody tells me how to
1.176 - ///make class \c SymEdgeSet::SymEdgeMap friend of Edge
1.177 - int &idref() {return n;}
1.178 - const int &idref() const {return n;}
1.179 };
1.180
1.181 class EdgeIt : public Edge {
1.182 @@ -1074,7 +1031,6 @@
1.183 const EdgeSet *G;
1.184 public:
1.185 EdgeIt(const EdgeSet& _G) : Edge(), G(&_G) {
1.186 - // typename NodeGraphType::Node m;
1.187 NodeIt m;
1.188 for(G->first(m);
1.189 m!=INVALID && G->nodes[m].first_in == -1; ++m);
1.190 @@ -1091,9 +1047,6 @@
1.191 EdgeIt &operator++() {
1.192 return *this;
1.193 }
1.194 - ///\bug This is a workaround until somebody tells me how to
1.195 - ///make class \c SymEdgeSet::SymEdgeMap friend of Edge
1.196 - int &idref() {return this->n;}
1.197 };
1.198
1.199 class OutEdgeIt : public Edge {