Changes in / [258:0310c8984732:257:8d76a7bf9961] in lemon-main
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bfs.h
r258 r257 1262 1262 /// the member functions of the \c Visitor class on every BFS event. 1263 1263 /// 1264 /// This interface of the BFS algorithm should be used in special cases1265 /// when extra actions have to be performed in connection with certain1266 /// events of the BFS algorithm. Otherwise consider to use Bfs or bfs()1267 /// instead.1268 ///1269 1264 /// \tparam _Digraph The type of the digraph the algorithm runs on. 1270 1265 /// The default value is -
lemon/bits/base_extender.h
r256 r220 60 60 Arc() {} 61 61 62 // Invalid arc constructor62 /// Invalid arc constructor 63 63 Arc(Invalid i) : Edge(i), forward(true) {} 64 64 … … 75 75 }; 76 76 77 /// First node of the edge 78 Node u(const Edge &e) const { 79 return Parent::source(e); 80 } 81 82 /// Source of the given arc 77 78 79 using Parent::source; 80 81 /// Source of the given Arc. 83 82 Node source(const Arc &e) const { 84 83 return e.forward ? Parent::source(e) : Parent::target(e); 85 84 } 86 85 87 /// Second node of the edge 88 Node v(const Edge &e) const { 89 return Parent::target(e); 90 } 91 92 /// Target of the given arc 86 using Parent::target; 87 88 /// Target of the given Arc. 93 89 Node target(const Arc &e) const { 94 90 return e.forward ? Parent::target(e) : Parent::source(e); … … 97 93 /// \brief Directed arc from an edge. 98 94 /// 99 /// Returns a directed arc corresponding to the specified edge.100 /// If the given bool is true , the first node of the given edge and101 /// the source node of the returned arc are the same.102 static Arc direct(const Edge & e, bool d) {103 return Arc( e, d);104 } 105 106 /// Returns whether the given directed arc has the same orientation107 /// as thecorresponding edge.95 /// Returns a directed arc corresponding to the specified Edge. 96 /// If the given bool is true the given edge and the 97 /// returned arc have the same source node. 98 static Arc direct(const Edge &ue, bool d) { 99 return Arc(ue, d); 100 } 101 102 /// Returns whether the given directed arc is same orientation as the 103 /// corresponding edge. 108 104 /// 109 105 /// \todo reference to the corresponding point of the undirected digraph 110 106 /// concept. "What does the direction of an edge mean?" 111 static bool direction(const Arc &a) { return a.forward; } 107 static bool direction(const Arc &e) { return e.forward; } 108 112 109 113 110 using Parent::first; … … 232 229 return Parent::maxArcId(); 233 230 } 231 234 232 235 233 int arcNum() const { -
lemon/dfs.h
r258 r257 1209 1209 /// the member functions of the \c Visitor class on every DFS event. 1210 1210 /// 1211 /// This interface of the DFS algorithm should be used in special cases1212 /// when extra actions have to be performed in connection with certain1213 /// events of the DFS algorithm. Otherwise consider to use Dfs or dfs()1214 /// instead.1215 ///1216 1211 /// \tparam _Digraph The type of the digraph the algorithm runs on. 1217 1212 /// The default value is -
lemon/dijkstra.h
r258 r257 1068 1068 //Pointer to the length map 1069 1069 void *_length; 1070 //Pointer to the map of processed nodes.1071 void *_processed;1072 1070 //Pointer to the map of predecessors arcs. 1073 1071 void *_pred; … … 1082 1080 /// This constructor does not require parameters, therefore it initiates 1083 1081 /// all of the attributes to default values (0, INVALID). 1084 DijkstraWizardBase() : _g(0), _length(0), _pr ocessed(0), _pred(0),1082 DijkstraWizardBase() : _g(0), _length(0), _pred(0), 1085 1083 _dist(0), _source(INVALID) {} 1086 1084 … … 1096 1094 _g(reinterpret_cast<void*>(const_cast<GR*>(&g))), 1097 1095 _length(reinterpret_cast<void*>(const_cast<LM*>(&l))), 1098 _pr ocessed(0), _pred(0), _dist(0), _source(s) {}1096 _pred(0), _dist(0), _source(s) {} 1099 1097 1100 1098 }; … … 1175 1173 dij(*reinterpret_cast<const Digraph*>(Base::_g), 1176 1174 *reinterpret_cast<const LengthMap*>(Base::_length)); 1177 if(Base::_processed) 1178 dij.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed)); 1179 if(Base::_pred) 1180 dij.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 1181 if(Base::_dist) 1182 dij.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 1175 if(Base::_pred) dij.predMap(*reinterpret_cast<PredMap*>(Base::_pred)); 1176 if(Base::_dist) dij.distMap(*reinterpret_cast<DistMap*>(Base::_dist)); 1183 1177 dij.run(Base::_source); 1184 1178 } -
lemon/dim2.h
r253 r241 29 29 /// a two dimensional vector with the usual operations. 30 30 /// 31 /// The class \ref lemon::dim2::Box "dim2::Box" can be used to determine 31 /// The class \ref lemon::dim2::BoundingBox "dim2::BoundingBox" 32 /// can be used to determine 32 33 /// the rectangular bounding box of a set of 33 34 /// \ref lemon::dim2::Point "dim2::Point"'s. … … 44 45 /// @{ 45 46 46 /// Two dimensional vector (plain vector)47 /// A simple two dimensional vector (plain vector) implementation 47 48 48 49 /// A simple two dimensional vector (plain vector) implementation … … 221 222 inline std::ostream& operator<<(std::ostream &os, const Point<T>& z) 222 223 { 223 os << "(" << z.x << ", " << z.y << ")";224 os << "(" << z.x << ", " << z.y << ")"; 224 225 return os; 225 226 } … … 260 261 261 262 262 /// Bounding box of plain vectors (\ref Point points).263 264 /// A class to calculate or store the bounding box of plain vectors265 /// (\ref Point points).266 template<typename T>267 classBox {263 /// A class to calculate or store the bounding box of plain vectors. 264 265 /// A class to calculate or store the bounding box of plain vectors. 266 /// 267 template<typename T> 268 class BoundingBox { 268 269 Point<T> _bottom_left, _top_right; 269 270 bool _empty; 270 271 public: 271 272 272 ///Default constructor: creates an empty bo x273 Bo x() { _empty = true; }274 275 ///Construct a boxfrom one point276 Bo x(Point<T> a) {273 ///Default constructor: creates an empty bounding box 274 BoundingBox() { _empty = true; } 275 276 ///Construct an instance from one point 277 BoundingBox(Point<T> a) { 277 278 _bottom_left = _top_right = a; 278 279 _empty = false; 279 280 } 280 281 281 ///Construct a boxfrom two points282 283 ///Construct a boxfrom two points.282 ///Construct an instance from two points 283 284 ///Construct an instance from two points. 284 285 ///\param a The bottom left corner. 285 286 ///\param b The top right corner. 286 287 ///\warning The coordinates of the bottom left corner must be no more 287 288 ///than those of the top right one. 288 Bo x(Point<T> a,Point<T> b)289 BoundingBox(Point<T> a,Point<T> b) 289 290 { 290 291 _bottom_left = a; … … 293 294 } 294 295 295 ///Construct a boxfrom four numbers296 297 ///Construct a boxfrom four numbers.296 ///Construct an instance from four numbers 297 298 ///Construct an instance from four numbers. 298 299 ///\param l The left side of the box. 299 300 ///\param b The bottom of the box. … … 302 303 ///\warning The left side must be no more than the right side and 303 304 ///bottom must be no more than the top. 304 Bo x(T l,T b,T r,T t)305 BoundingBox(T l,T b,T r,T t) 305 306 { 306 307 _bottom_left=Point<T>(l,b); … … 309 310 } 310 311 311 ///Return \c true if the bo x is empty.312 313 ///Return \c true if the bo x is empty (i.e. return \c false312 ///Return \c true if the bounding box is empty. 313 314 ///Return \c true if the bounding box is empty (i.e. return \c false 314 315 ///if at least one point was added to the box or the coordinates of 315 316 ///the box were set). 316 317 /// 317 ///The coordinates of an empty bo x are not defined.318 ///The coordinates of an empty bounding box are not defined. 318 319 bool empty() const { 319 320 return _empty; 320 321 } 321 322 322 ///Make the box empty323 ///Make the BoundingBox empty 323 324 void clear() { 324 325 _empty = true; … … 328 329 329 330 ///Give back the bottom left corner of the box. 330 ///If the bo x is empty, then the return value is not defined.331 ///If the bounding box is empty, then the return value is not defined. 331 332 Point<T> bottomLeft() const { 332 333 return _bottom_left; … … 344 345 345 346 ///Give back the top right corner of the box. 346 ///If the bo x is empty, then the return value is not defined.347 ///If the bounding box is empty, then the return value is not defined. 347 348 Point<T> topRight() const { 348 349 return _top_right; … … 360 361 361 362 ///Give back the bottom right corner of the box. 362 ///If the bo x is empty, then the return value is not defined.363 ///If the bounding box is empty, then the return value is not defined. 363 364 Point<T> bottomRight() const { 364 365 return Point<T>(_top_right.x,_bottom_left.y); … … 377 378 378 379 ///Give back the top left corner of the box. 379 ///If the bo x is empty, then the return value is not defined.380 ///If the bounding box is empty, then the return value is not defined. 380 381 Point<T> topLeft() const { 381 382 return Point<T>(_bottom_left.x,_top_right.y); … … 394 395 395 396 ///Give back the bottom of the box. 396 ///If the bo x is empty, then the return value is not defined.397 ///If the bounding box is empty, then the return value is not defined. 397 398 T bottom() const { 398 399 return _bottom_left.y; … … 410 411 411 412 ///Give back the top of the box. 412 ///If the bo x is empty, then the return value is not defined.413 ///If the bounding box is empty, then the return value is not defined. 413 414 T top() const { 414 415 return _top_right.y; … … 426 427 427 428 ///Give back the left side of the box. 428 ///If the bo x is empty, then the return value is not defined.429 ///If the bounding box is empty, then the return value is not defined. 429 430 T left() const { 430 431 return _bottom_left.x; … … 442 443 443 444 /// Give back the right side of the box. 444 ///If the bo x is empty, then the return value is not defined.445 ///If the bounding box is empty, then the return value is not defined. 445 446 T right() const { 446 447 return _top_right.x; … … 458 459 459 460 ///Give back the height of the box. 460 ///If the bo x is empty, then the return value is not defined.461 ///If the bounding box is empty, then the return value is not defined. 461 462 T height() const { 462 463 return _top_right.y-_bottom_left.y; … … 466 467 467 468 ///Give back the width of the box. 468 ///If the bo x is empty, then the return value is not defined.469 ///If the bounding box is empty, then the return value is not defined. 469 470 T width() const { 470 471 return _top_right.x-_bottom_left.x; 471 472 } 472 473 473 ///Checks whether a point is inside thebox474 ///Checks whether a point is inside a bounding box 474 475 bool inside(const Point<T>& u) const { 475 476 if (_empty) … … 481 482 } 482 483 483 ///Increments thebox with a point484 485 ///Increments thebox with a point.484 ///Increments a bounding box with a point 485 486 ///Increments a bounding box with a point. 486 487 /// 487 Bo x& add(const Point<T>& u){488 BoundingBox& add(const Point<T>& u){ 488 489 if (_empty) { 489 490 _bottom_left = _top_right = u; … … 499 500 } 500 501 501 ///Increments the box to contain anotherbox502 503 ///Increments the box to contain anotherbox.502 ///Increments a bounding box to contain another bounding box 503 504 ///Increments a bounding box to contain another bounding box. 504 505 /// 505 Bo x& add(constBox &u){506 BoundingBox& add(const BoundingBox &u){ 506 507 if ( !u.empty() ){ 507 508 add(u._bottom_left); … … 511 512 } 512 513 513 ///Intersection of two bo xes514 515 ///Intersection of two bo xes.514 ///Intersection of two bounding boxes 515 516 ///Intersection of two bounding boxes. 516 517 /// 517 Bo x operator&(constBox& u) const {518 Bo x b;518 BoundingBox operator&(const BoundingBox& u) const { 519 BoundingBox b; 519 520 if (_empty || u._empty) { 520 521 b._empty = true; … … 530 531 } 531 532 532 };//class Box 533 534 535 ///Read a box from a stream 536 537 ///Read a box from a stream. 538 ///\relates Box 539 template<typename T> 540 inline std::istream& operator>>(std::istream &is, Box<T>& b) { 541 char c; 542 Point<T> p; 543 if (is >> c) { 544 if (c != '(') is.putback(c); 545 } else { 546 is.clear(); 547 } 548 if (!(is >> p)) return is; 549 b.bottomLeft(p); 550 if (is >> c) { 551 if (c != ',') is.putback(c); 552 } else { 553 is.clear(); 554 } 555 if (!(is >> p)) return is; 556 b.topRight(p); 557 if (is >> c) { 558 if (c != ')') is.putback(c); 559 } else { 560 is.clear(); 561 } 562 return is; 563 } 564 565 ///Write a box to a stream 566 567 ///Write a box to a stream. 568 ///\relates Box 569 template<typename T> 570 inline std::ostream& operator<<(std::ostream &os, const Box<T>& b) 571 { 572 os << "(" << b.bottomLeft() << "," << b.topRight() << ")"; 573 return os; 574 } 533 };//class Boundingbox 534 575 535 576 536 ///Map of x-coordinates of a \ref Point "Point"-map -
lemon/graph_to_eps.h
r253 r220 726 726 double diag_len = 1; 727 727 if(!(_absoluteNodeSizes&&_absoluteArcWidths)) { 728 dim2::Bo x<double> bb;728 dim2::BoundingBox<double> bb; 729 729 for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]); 730 730 if (bb.empty()) { 731 bb = dim2::Bo x<double>(dim2::Point<double>(0,0));731 bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0)); 732 732 } 733 733 diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare()); … … 737 737 } 738 738 739 dim2::Bo x<double> bb;739 dim2::BoundingBox<double> bb; 740 740 for(NodeIt n(g);n!=INVALID;++n) { 741 741 double ns=_nodeSizes[n]*_nodeScale; … … 759 759 } 760 760 if (bb.empty()) { 761 bb = dim2::Bo x<double>(dim2::Point<double>(0,0));761 bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0)); 762 762 } 763 763 -
test/dim_test.cc
r253 r242 51 51 check(p.x==1 && p.y==2, "Wrong dim2::Point division by a scalar."); 52 52 53 typedef dim2::Bo x<int> Box;54 B oxbox1;55 check(box1.empty(), "Wrong empty() in dim2::Bo x.");53 typedef dim2::BoundingBox<int> BB; 54 BB box1; 55 check(box1.empty(), "Wrong empty() in dim2::BoundingBox."); 56 56 57 57 box1.add(a); 58 check(!box1.empty(), "Wrong empty() in dim2::Bo x.");58 check(!box1.empty(), "Wrong empty() in dim2::BoundingBox."); 59 59 box1.add(b); 60 60 61 61 check(box1.left()==1 && box1.bottom()==2 && 62 62 box1.right()==3 && box1.top()==4, 63 "Wrong addition of points to dim2::Bo x.");63 "Wrong addition of points to dim2::BoundingBox."); 64 64 65 check(box1.inside(Point(2,3)), "Wrong inside() in dim2::Bo x.");66 check(box1.inside(Point(1,3)), "Wrong inside() in dim2::Bo x.");67 check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::Bo x.");65 check(box1.inside(Point(2,3)), "Wrong inside() in dim2::BoundingBox."); 66 check(box1.inside(Point(1,3)), "Wrong inside() in dim2::BoundingBox."); 67 check(!box1.inside(Point(0,3)), "Wrong inside() in dim2::BoundingBox."); 68 68 69 B oxbox2(Point(2,2));70 check(!box2.empty(), "Wrong empty() in dim2::Bo x.");71 69 BB box2(Point(2,2)); 70 check(!box2.empty(), "Wrong empty() in dim2::BoundingBox."); 71 72 72 box2.bottomLeft(Point(2,0)); 73 73 box2.topRight(Point(5,3)); 74 B oxbox3 = box1 & box2;74 BB box3 = box1 & box2; 75 75 check(!box3.empty() && 76 box3.left()==2 && box3.bottom()==2 && 76 box3.left()==2 && box3.bottom()==2 && 77 77 box3.right()==3 && box3.top()==3, 78 "Wrong intersection of two dim2::Bo x objects.");79 78 "Wrong intersection of two dim2::BoundingBox objects."); 79 80 80 box1.add(box2); 81 81 check(!box1.empty() && 82 82 box1.left()==1 && box1.bottom()==0 && 83 83 box1.right()==5 && box1.top()==4, 84 "Wrong addition of two dim2::Bo x objects.");84 "Wrong addition of two dim2::BoundingBox objects."); 85 85 86 86 return 0;
Note: See TracChangeset
for help on using the changeset viewer.