Changeset 416:76287c8caa26 in lemon1.2 for lemon/bits/graph_adaptor_extender.h
 Timestamp:
 11/30/08 19:18:32 (14 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/bits/graph_adaptor_extender.h
r414 r416 1 /* * C++*1 /* * mode: C++; indenttabsmode: nil; * 2 2 * 3 * This file is a part of LEMON, a generic C++ optimization library 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 20032008 … … 25 25 #include <lemon/bits/default_map.h> 26 26 27 28 ///\ingroup digraphbits29 ///\file30 ///\brief Extenders for the digraph adaptor types31 27 namespace lemon { 32 28 33 /// \ingroup digraphbits34 ///35 /// \brief Extender for the DigraphAdaptors36 29 template <typename _Digraph> 37 30 class DigraphAdaptorExtender : public _Digraph { … … 65 58 Node oppositeNode(const Node &n, const Arc &e) const { 66 59 if (n == Parent::source(e)) 67 60 return Parent::target(e); 68 61 else if(n==Parent::target(e)) 69 62 return Parent::source(e); 70 63 else 71 72 } 73 74 class NodeIt : public Node { 64 return INVALID; 65 } 66 67 class NodeIt : public Node { 75 68 const Adaptor* _adaptor; 76 69 public: … … 81 74 82 75 explicit NodeIt(const Adaptor& adaptor) : _adaptor(&adaptor) { 83 84 } 85 86 NodeIt(const Adaptor& adaptor, const Node& node) 87 88 89 NodeIt& operator++() { 90 91 return *this; 92 } 93 94 }; 95 96 97 class ArcIt : public Arc { 76 _adaptor>first(static_cast<Node&>(*this)); 77 } 78 79 NodeIt(const Adaptor& adaptor, const Node& node) 80 : Node(node), _adaptor(&adaptor) {} 81 82 NodeIt& operator++() { 83 _adaptor>next(*this); 84 return *this; 85 } 86 87 }; 88 89 90 class ArcIt : public Arc { 98 91 const Adaptor* _adaptor; 99 92 public: … … 104 97 105 98 explicit ArcIt(const Adaptor& adaptor) : _adaptor(&adaptor) { 106 107 } 108 109 ArcIt(const Adaptor& adaptor, const Arc& e) : 110 111 112 ArcIt& operator++() { 113 114 return *this; 115 } 116 117 }; 118 119 120 class OutArcIt : public Arc { 99 _adaptor>first(static_cast<Arc&>(*this)); 100 } 101 102 ArcIt(const Adaptor& adaptor, const Arc& e) : 103 Arc(e), _adaptor(&adaptor) { } 104 105 ArcIt& operator++() { 106 _adaptor>next(*this); 107 return *this; 108 } 109 110 }; 111 112 113 class OutArcIt : public Arc { 121 114 const Adaptor* _adaptor; 122 115 public: … … 126 119 OutArcIt(Invalid i) : Arc(i) { } 127 120 128 OutArcIt(const Adaptor& adaptor, const Node& node) 129 130 131 } 132 133 OutArcIt(const Adaptor& adaptor, const Arc& arc) 134 135 136 OutArcIt& operator++() { 137 138 return *this; 139 } 140 141 }; 142 143 144 class InArcIt : public Arc { 121 OutArcIt(const Adaptor& adaptor, const Node& node) 122 : _adaptor(&adaptor) { 123 _adaptor>firstOut(*this, node); 124 } 125 126 OutArcIt(const Adaptor& adaptor, const Arc& arc) 127 : Arc(arc), _adaptor(&adaptor) {} 128 129 OutArcIt& operator++() { 130 _adaptor>nextOut(*this); 131 return *this; 132 } 133 134 }; 135 136 137 class InArcIt : public Arc { 145 138 const Adaptor* _adaptor; 146 139 public: … … 150 143 InArcIt(Invalid i) : Arc(i) { } 151 144 152 InArcIt(const Adaptor& adaptor, const Node& node) 153 : _adaptor(&adaptor) { 154 _adaptor>firstIn(*this, node); 155 } 156 157 InArcIt(const Adaptor& adaptor, const Arc& arc) : 158 Arc(arc), _adaptor(&adaptor) {} 159 160 InArcIt& operator++() { 161 _adaptor>nextIn(*this); 162 return *this; 163 } 164 165 }; 166 167 /// \brief Base node of the iterator 168 /// 169 /// Returns the base node (ie. the source in this case) of the iterator 145 InArcIt(const Adaptor& adaptor, const Node& node) 146 : _adaptor(&adaptor) { 147 _adaptor>firstIn(*this, node); 148 } 149 150 InArcIt(const Adaptor& adaptor, const Arc& arc) : 151 Arc(arc), _adaptor(&adaptor) {} 152 153 InArcIt& operator++() { 154 _adaptor>nextIn(*this); 155 return *this; 156 } 157 158 }; 159 170 160 Node baseNode(const OutArcIt &e) const { 171 161 return Parent::source(e); 172 162 } 173 /// \brief Running node of the iterator174 ///175 /// Returns the running node (ie. the target in this case) of the176 /// iterator177 163 Node runningNode(const OutArcIt &e) const { 178 164 return Parent::target(e); 179 165 } 180 166 181 /// \brief Base node of the iterator182 ///183 /// Returns the base node (ie. the target in this case) of the iterator184 167 Node baseNode(const InArcIt &e) const { 185 168 return Parent::target(e); 186 169 } 187 /// \brief Running node of the iterator188 ///189 /// Returns the running node (ie. the source in this case) of the190 /// iterator191 170 Node runningNode(const InArcIt &e) const { 192 171 return Parent::source(e); … … 199 178 /// 200 179 /// \brief Extender for the GraphAdaptors 201 template <typename _Graph> 180 template <typename _Graph> 202 181 class GraphAdaptorExtender : public _Graph { 203 182 public: 204 183 205 184 typedef _Graph Parent; 206 185 typedef _Graph Graph; … … 211 190 typedef typename Parent::Edge Edge; 212 191 213 // Graph extension 192 // Graph extension 214 193 215 194 int maxId(Node) const { … … 239 218 Node oppositeNode(const Node &n, const Edge &e) const { 240 219 if( n == Parent::u(e)) 241 220 return Parent::v(e); 242 221 else if( n == Parent::v(e)) 243 222 return Parent::u(e); 244 223 else 245 224 return INVALID; 246 225 } 247 226 … … 256 235 257 236 258 class NodeIt : public Node { 237 class NodeIt : public Node { 259 238 const Adaptor* _adaptor; 260 239 public: … … 265 244 266 245 explicit NodeIt(const Adaptor& adaptor) : _adaptor(&adaptor) { 267 268 } 269 270 NodeIt(const Adaptor& adaptor, const Node& node) 271 272 273 NodeIt& operator++() { 274 275 return *this; 276 } 277 278 }; 279 280 281 class ArcIt : public Arc { 246 _adaptor>first(static_cast<Node&>(*this)); 247 } 248 249 NodeIt(const Adaptor& adaptor, const Node& node) 250 : Node(node), _adaptor(&adaptor) {} 251 252 NodeIt& operator++() { 253 _adaptor>next(*this); 254 return *this; 255 } 256 257 }; 258 259 260 class ArcIt : public Arc { 282 261 const Adaptor* _adaptor; 283 262 public: … … 288 267 289 268 explicit ArcIt(const Adaptor& adaptor) : _adaptor(&adaptor) { 290 291 } 292 293 ArcIt(const Adaptor& adaptor, const Arc& e) : 294 295 296 ArcIt& operator++() { 297 298 return *this; 299 } 300 301 }; 302 303 304 class OutArcIt : public Arc { 269 _adaptor>first(static_cast<Arc&>(*this)); 270 } 271 272 ArcIt(const Adaptor& adaptor, const Arc& e) : 273 Arc(e), _adaptor(&adaptor) { } 274 275 ArcIt& operator++() { 276 _adaptor>next(*this); 277 return *this; 278 } 279 280 }; 281 282 283 class OutArcIt : public Arc { 305 284 const Adaptor* _adaptor; 306 285 public: … … 310 289 OutArcIt(Invalid i) : Arc(i) { } 311 290 312 OutArcIt(const Adaptor& adaptor, const Node& node) 313 314 315 } 316 317 OutArcIt(const Adaptor& adaptor, const Arc& arc) 318 319 320 OutArcIt& operator++() { 321 322 return *this; 323 } 324 325 }; 326 327 328 class InArcIt : public Arc { 291 OutArcIt(const Adaptor& adaptor, const Node& node) 292 : _adaptor(&adaptor) { 293 _adaptor>firstOut(*this, node); 294 } 295 296 OutArcIt(const Adaptor& adaptor, const Arc& arc) 297 : Arc(arc), _adaptor(&adaptor) {} 298 299 OutArcIt& operator++() { 300 _adaptor>nextOut(*this); 301 return *this; 302 } 303 304 }; 305 306 307 class InArcIt : public Arc { 329 308 const Adaptor* _adaptor; 330 309 public: … … 334 313 InArcIt(Invalid i) : Arc(i) { } 335 314 336 InArcIt(const Adaptor& adaptor, const Node& node) 337 338 339 } 340 341 InArcIt(const Adaptor& adaptor, const Arc& arc) : 342 343 344 InArcIt& operator++() { 345 346 return *this; 347 } 348 349 }; 350 351 class EdgeIt : public Parent::Edge { 315 InArcIt(const Adaptor& adaptor, const Node& node) 316 : _adaptor(&adaptor) { 317 _adaptor>firstIn(*this, node); 318 } 319 320 InArcIt(const Adaptor& adaptor, const Arc& arc) : 321 Arc(arc), _adaptor(&adaptor) {} 322 323 InArcIt& operator++() { 324 _adaptor>nextIn(*this); 325 return *this; 326 } 327 328 }; 329 330 class EdgeIt : public Parent::Edge { 352 331 const Adaptor* _adaptor; 353 332 public: … … 358 337 359 338 explicit EdgeIt(const Adaptor& adaptor) : _adaptor(&adaptor) { 360 361 } 362 363 EdgeIt(const Adaptor& adaptor, const Edge& e) : 364 365 366 EdgeIt& operator++() { 367 368 return *this; 369 } 370 371 }; 372 373 class IncEdgeIt : public Edge { 339 _adaptor>first(static_cast<Edge&>(*this)); 340 } 341 342 EdgeIt(const Adaptor& adaptor, const Edge& e) : 343 Edge(e), _adaptor(&adaptor) { } 344 345 EdgeIt& operator++() { 346 _adaptor>next(*this); 347 return *this; 348 } 349 350 }; 351 352 class IncEdgeIt : public Edge { 374 353 friend class GraphAdaptorExtender; 375 354 const Adaptor* _adaptor; … … 382 361 383 362 IncEdgeIt(const Adaptor& adaptor, const Node &n) : _adaptor(&adaptor) { 384 363 _adaptor>firstInc(static_cast<Edge&>(*this), direction, n); 385 364 } 386 365 387 366 IncEdgeIt(const Adaptor& adaptor, const Edge &e, const Node &n) 388 389 367 : _adaptor(&adaptor), Edge(e) { 368 direction = (_adaptor>u(e) == n); 390 369 } 391 370 392 371 IncEdgeIt& operator++() { 393 _adaptor>nextInc(*this, direction); 394 return *this; 395 } 396 }; 397 398 /// \brief Base node of the iterator 399 /// 400 /// Returns the base node (ie. the source in this case) of the iterator 372 _adaptor>nextInc(*this, direction); 373 return *this; 374 } 375 }; 376 401 377 Node baseNode(const OutArcIt &a) const { 402 378 return Parent::source(a); 403 379 } 404 /// \brief Running node of the iterator405 ///406 /// Returns the running node (ie. the target in this case) of the407 /// iterator408 380 Node runningNode(const OutArcIt &a) const { 409 381 return Parent::target(a); 410 382 } 411 383 412 /// \brief Base node of the iterator413 ///414 /// Returns the base node (ie. the target in this case) of the iterator415 384 Node baseNode(const InArcIt &a) const { 416 385 return Parent::target(a); 417 386 } 418 /// \brief Running node of the iterator419 ///420 /// Returns the running node (ie. the source in this case) of the421 /// iterator422 387 Node runningNode(const InArcIt &a) const { 423 388 return Parent::source(a); 424 389 } 425 390 426 /// Base node of the iterator427 ///428 /// Returns the base node of the iterator429 391 Node baseNode(const IncEdgeIt &e) const { 430 392 return e.direction ? Parent::u(e) : Parent::v(e); 431 393 } 432 /// Running node of the iterator433 ///434 /// Returns the running node of the iterator435 394 Node runningNode(const IncEdgeIt &e) const { 436 395 return e.direction ? Parent::v(e) : Parent::u(e);
Note: See TracChangeset
for help on using the changeset viewer.