1.1 --- a/src/work/marci/graph_wrapper.h Sat Apr 24 14:25:03 2004 +0000
1.2 +++ b/src/work/marci/graph_wrapper.h Sat Apr 24 15:19:17 2004 +0000
1.3 @@ -918,7 +918,7 @@
1.4 typedef IterableBoolMap< typename Graph::template NodeMap<int> >
1.5 SFalseTTrueMap;
1.6 SFalseTTrueMap* s_false_t_true_map;
1.7 -
1.8 +
1.9 public:
1.10 static const bool S_CLASS=false;
1.11 static const bool T_CLASS=true;
1.12 @@ -930,7 +930,15 @@
1.13 //using GraphWrapper<Graph>::NodeIt;
1.14 typedef typename GraphWrapper<Graph>::Edge Edge;
1.15 //using GraphWrapper<Graph>::EdgeIt;
1.16 + class ClassNodeIt;
1.17 + friend class ClassNodeIt;
1.18 + class OutEdgeIt;
1.19 + friend class OutEdgeIt;
1.20 + class InEdgeIt;
1.21 + friend class InEdgeIt;
1.22 class ClassNodeIt {
1.23 + friend class BipartiteGraphWrapper<Graph>;
1.24 + protected:
1.25 Node n;
1.26 public:
1.27 ClassNodeIt() { }
1.28 @@ -963,8 +971,8 @@
1.29 // operator Node() const { return n; }
1.30 // };
1.31 class OutEdgeIt {
1.32 - public:
1.33 -
1.34 + friend class BipartiteGraphWrapper<Graph>;
1.35 + protected:
1.36 typename Graph::OutEdgeIt e;
1.37 public:
1.38 OutEdgeIt() { }
1.39 @@ -978,7 +986,8 @@
1.40 operator Edge() const { return Edge(typename Graph::Edge(e)); }
1.41 };
1.42 class InEdgeIt {
1.43 - public:
1.44 + friend class BipartiteGraphWrapper<Graph>;
1.45 + protected:
1.46 typename Graph::InEdgeIt e;
1.47 public:
1.48 InEdgeIt() { }
1.49 @@ -994,7 +1003,7 @@
1.50
1.51 using GraphWrapper<Graph>::first;
1.52 ClassNodeIt& first(ClassNodeIt& n, bool _class) const {
1.53 - n=SNodeIt(*this, _class) ; return n; }
1.54 + n=ClassNodeIt(*this, _class) ; return n; }
1.55 // SNodeIt& first(SNodeIt& n) const { n=SNodeIt(*this); return n; }
1.56 // TNodeIt& first(TNodeIt& n) const { n=TNodeIt(*this); return n; }
1.57 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
1.58 @@ -1006,7 +1015,7 @@
1.59
1.60 using GraphWrapper<Graph>::next;
1.61 ClassNodeIt& next(ClassNodeIt& n) const {
1.62 - this->s_false_t_true_map->next(n); return n;
1.63 + this->s_false_t_true_map->next(n.n); return n;
1.64 }
1.65 // SNodeIt& next(SNodeIt& n) const {
1.66 // this->s_false_t_true_map->next(n); return n;
1.67 @@ -1319,9 +1328,10 @@
1.68 return i;
1.69 }
1.70 OutEdgeIt& next(OutEdgeIt& i) const {
1.71 + typename Graph::Node v;
1.72 switch (i.spec) {
1.73 case 0: //normal edge
1.74 - typename Graph::Node v=this->graph->aNode(i.e);
1.75 + this->graph->aNode(i.e);
1.76 this->graph->next(i.e);
1.77 if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
1.78 if (this->graph->inSClass(v)) { //S, nincs kiel
1.79 @@ -1345,9 +1355,10 @@
1.80 return i;
1.81 }
1.82 InEdgeIt& next(InEdgeIt& i) const {
1.83 + typename Graph::Node v;
1.84 switch (i.spec) {
1.85 case 0: //normal edge
1.86 - typename Graph::Node v=this->graph->aNode(i.e);
1.87 + v=this->graph->aNode(i.e);
1.88 this->graph->next(i.e);
1.89 if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
1.90 if (this->graph->inTClass(v)) { //S, nincs beel
1.91 @@ -1403,28 +1414,30 @@
1.92
1.93 Node tail(const Edge& e) const {
1.94 switch (e.spec) {
1.95 - case 0:
1.96 - return Node(this->graph->tail(e));
1.97 - break;
1.98 - case 1:
1.99 - return S_NODE;
1.100 - break;
1.101 - case 2:
1.102 - return Node(e.n);
1.103 - break;
1.104 + case 0:
1.105 + return Node(this->graph->tail(e));
1.106 + break;
1.107 + case 1:
1.108 + return S_NODE;
1.109 + break;
1.110 + case 2:
1.111 + default:
1.112 + return Node(e.n);
1.113 + break;
1.114 }
1.115 }
1.116 Node head(const Edge& e) const {
1.117 switch (e.spec) {
1.118 - case 0:
1.119 - return Node(this->graph->head(e));
1.120 - break;
1.121 - case 1:
1.122 - return Node(e.n);
1.123 - break;
1.124 - case 2:
1.125 - return T_NODE;
1.126 - break;
1.127 + case 0:
1.128 + return Node(this->graph->head(e));
1.129 + break;
1.130 + case 1:
1.131 + return Node(e.n);
1.132 + break;
1.133 + case 2:
1.134 + default:
1.135 + return T_NODE;
1.136 + break;
1.137 }
1.138 }
1.139
1.140 @@ -1458,64 +1471,68 @@
1.141 t_value(a) { }
1.142 T operator[](const Node& n) const {
1.143 switch (n.spec) {
1.144 - case 0:
1.145 - return (*this)[n];
1.146 - break;
1.147 - case 1:
1.148 - return s_value;
1.149 - break;
1.150 - case 2:
1.151 - return t_value;
1.152 - break;
1.153 + case 0:
1.154 + return Parent::operator[](n);
1.155 + break;
1.156 + case 1:
1.157 + return s_value;
1.158 + break;
1.159 + case 2:
1.160 + default:
1.161 + return t_value;
1.162 + break;
1.163 }
1.164 }
1.165 void set(const Node& n, T t) {
1.166 switch (n.spec) {
1.167 - case 0:
1.168 - GraphWrapper<Graph>::template NodeMap<T>::set(n, t);
1.169 - break;
1.170 - case 1:
1.171 - s_value=t;
1.172 - break;
1.173 - case 2:
1.174 - t_value=t;
1.175 - break;
1.176 + case 0:
1.177 + GraphWrapper<Graph>::template NodeMap<T>::set(n, t);
1.178 + break;
1.179 + case 1:
1.180 + s_value=t;
1.181 + break;
1.182 + case 2:
1.183 + default:
1.184 + t_value=t;
1.185 + break;
1.186 }
1.187 }
1.188 };
1.189
1.190 template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> {
1.191 - typedef typename Graph::template NodeMap<T> Parent;
1.192 + typedef typename GraphWrapper<Graph>::template EdgeMap<T> Parent;
1.193 typename GraphWrapper<Graph>::template NodeMap<T> node_value;
1.194 public:
1.195 - EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G),
1.196 - node_value(_G) { }
1.197 + EdgeMap(const stGraphWrapper<Graph>& _G) : Parent(_G),
1.198 + node_value(_G) { }
1.199 EdgeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a),
1.200 node_value(_G, a) { }
1.201 T operator[](const Edge& e) const {
1.202 switch (e.spec) {
1.203 - case 0:
1.204 - return (*this)[e];
1.205 - break;
1.206 - case 1:
1.207 - return node_value[e.n];
1.208 - break;
1.209 - case 2:
1.210 - return node_value[e.n];
1.211 - break;
1.212 + case 0:
1.213 + return Parent::operator[](e);
1.214 + break;
1.215 + case 1:
1.216 + return node_value[e.n];
1.217 + break;
1.218 + case 2:
1.219 + default:
1.220 + return node_value[e.n];
1.221 + break;
1.222 }
1.223 }
1.224 void set(const Edge& e, T t) {
1.225 switch (e.spec) {
1.226 - case 0:
1.227 - GraphWrapper<Graph>::set(e, t);
1.228 - break;
1.229 - case 1:
1.230 - node_value.set(e, t);
1.231 - break;
1.232 - case 2:
1.233 - node_value.set(e, t);
1.234 - break;
1.235 + case 0:
1.236 + GraphWrapper<Graph>::template EdgeMap<T>::set(e, t);
1.237 + break;
1.238 + case 1:
1.239 + node_value.set(e.n, t);
1.240 + break;
1.241 + case 2:
1.242 + default:
1.243 + node_value.set(e.n, t);
1.244 + break;
1.245 }
1.246 }
1.247 };