COIN-OR::LEMON - Graph Library

Changes in / [22:45f8b617339e:21:40d6f625e549] in lemon-main


Ignore:
Files:
3 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • .hgignore

    r9 r3  
    66*.o
    77.#.*
    8 *.log
    9 *.lo
    10 *.tar.*
    118Makefile.in
    129aclocal.m4
     
    2320lemon/stamp-h2
    2421doc/Doxyfile
    25 .dirstamp
    26 .libs/*
    27 .deps/*
     22lemon/.dirstamp
     23lemon/.libs/*
    2824
    2925syntax: regexp
    30 ^doc/html/.*
    31 ^autom4te.cache/.*
    32 ^build-aux/.*
    33 ^objs.*/.*
    34 ^test/[a-z_]*$
     26html/.*
     27autom4te.cache/.*
     28build-aux/.*
     29objs.*/.*
  • lemon/Makefile.am

    r10 r8  
    88
    99lemon_libemon_la_SOURCES = \
    10         lemon/base.cc \
    11         lemon/random.cc
    12 
     10        lemon/base.cc
    1311
    1412lemon_libemon_la_CXXFLAGS = $(GLPK_CFLAGS) $(CPLEX_CFLAGS) $(SOPLEX_CXXFLAGS)
     
    1715lemon_HEADERS += \
    1816        lemon/dim2.h \
    19         lemon/random.h \
    2017        lemon/list_graph.h \
    2118        lemon/tolerance.h
  • lemon/bits/invalid.h

    r13 r7  
    2525namespace lemon {
    2626
    27   /// \brief Dummy type to make it easier to create invalid iterators.
     27  /// \brief Dummy type to make it easier to make invalid iterators.
    2828  ///
    2929  /// See \ref INVALID for the usage.
     
    3535  };
    3636 
    37   /// \brief Invalid iterators.
    38   ///
     37  /// Invalid iterators.
     38 
    3939  /// \ref Invalid is a global type that converts to each iterator
    4040  /// in such a way that the value of the target iterator will be invalid.
  • lemon/dim2.h

    r15 r8  
    3535/// the rectangular bounding box of a set of
    3636/// \ref lemon::dim2::Point "dim2::Point"'s.
     37///
     38///\author Attila Bernath
     39
    3740
    3841namespace lemon {
     
    6063      typedef T Value;
    6164
    62       ///First coordinate
     65      ///First co-ordinate
    6366      T x;
    64       ///Second coordinate
     67      ///Second co-ordinate
    6568      T y;     
    6669     
     
    7376      ///The dimension of the vector.
    7477
    75       ///The dimension of the vector.
    76       ///This function always returns 2.
     78      ///This class give back always 2.
     79      ///
    7780      int size() const { return 2; }
    7881
     
    136139      }
    137140
    138       ///Return the negative of the vector
     141      ///Return the neg of the vectors
    139142      Point<T> operator-() const {
    140143        Point<T> b=*this;
     
    173176    };
    174177
    175   ///Return a Point
    176 
    177   ///Return a Point.
     178  ///Return an Point
     179
     180  ///Return an Point
    178181  ///\relates Point
    179182  template <typename T>
     
    184187  ///Return a vector multiplied by a scalar
    185188
    186   ///Return a vector multiplied by a scalar.
     189  ///Return a vector multiplied by a scalar
    187190  ///\relates Point
    188191  template<typename T> Point<T> operator*(const T &u,const Point<T> &x) {
     
    192195  ///Read a plainvector from a stream
    193196
    194   ///Read a plainvector from a stream.
     197  ///Read a plainvector from a stream
    195198  ///\relates Point
    196199  ///
     
    220223  ///Write a plainvector to a stream
    221224
    222   ///Write a plainvector to a stream.
     225  ///Write a plainvector to a stream
    223226  ///\relates Point
    224227  ///
     
    232235  ///Rotate by 90 degrees
    233236
    234   ///Returns the parameter rotated by 90 degrees in positive direction.
     237  ///Returns its parameter rotated by 90 degrees in positive direction.
    235238  ///\relates Point
    236239  ///
     
    243246  ///Rotate by 180 degrees
    244247
    245   ///Returns the parameter rotated by 180 degrees.
     248  ///Returns its parameter rotated by 180 degrees.
    246249  ///\relates Point
    247250  ///
     
    254257  ///Rotate by 270 degrees
    255258
    256   ///Returns the parameter rotated by 90 degrees in negative direction.
     259  ///Returns its parameter rotated by 90 degrees in negative direction.
    257260  ///\relates Point
    258261  ///
     
    269272  /// A class to calculate or store the bounding box of plainvectors.
    270273  ///
     274  ///\author Attila Bernath
    271275    template<typename T>
    272276    class BoundingBox {
     
    283287      ///Construct an instance from two points
    284288     
    285       ///Construct an instance from two points.
    286       ///\param a The bottom left corner.
    287       ///\param b The top right corner.
    288       ///\warning The coordinates of the bottom left corner must be no more
    289       ///than those of the top right one.
     289      ///Construct an instance from two points
     290      ///\warning The coordinates of the bottom-left corner must be no more
     291      ///than those of the top-right one
    290292      BoundingBox(Point<T> a,Point<T> b)
    291293      {
     
    297299      ///Construct an instance from four numbers
    298300
    299       ///Construct an instance from four numbers.
    300       ///\param l The left side of the box.
    301       ///\param b The bottom of the box.
    302       ///\param r The right side of the box.
    303       ///\param t The top of the box.
    304       ///\warning The left side must be no more than the right side and
    305       ///bottom must be no more than the top.
     301      ///Construct an instance from four numbers
     302      ///\warning The coordinates of the bottom-left corner must be no more
     303      ///than those of the top-right one
    306304      BoundingBox(T l,T b,T r,T t)
    307305      {
     
    311309      }
    312310     
    313       ///Return \c true if the bounding box is empty.
    314      
    315       ///Return \c true if the bounding box is empty (i.e. return \c false
    316       ///if at least one point was added to the box or the coordinates of
    317       ///the box were set).
    318       ///The coordinates of an empty bounding box are not defined.
     311      ///Were any points added?
    319312      bool empty() const {
    320313        return _empty;
     
    337330
    338331      ///Set the bottom left corner.
    339       ///It should only be used for non-empty box.
     332      ///It should only bee used for non-empty box.
    340333      void bottomLeft(Point<T> p) {
    341334        bottom_left = p;
     
    353346
    354347      ///Set the top right corner.
    355       ///It should only be used for non-empty box.
     348      ///It should only bee used for non-empty box.
    356349      void topRight(Point<T> p) {
    357350        top_right = p;
     
    369362
    370363      ///Set the bottom right corner.
    371       ///It should only be used for non-empty box.
     364      ///It should only bee used for non-empty box.
    372365      void bottomRight(Point<T> p) {
    373366        top_right.x = p.x;
     
    386379
    387380      ///Set the top left corner.
    388       ///It should only be used for non-empty box.
     381      ///It should only bee used for non-empty box.
    389382      void topLeft(Point<T> p) {
    390383        top_right.y = p.y;
     
    403396
    404397      ///Set the bottom of the box.
    405       ///It should only be used for non-empty box.
     398      ///It should only bee used for non-empty box.
    406399      void bottom(T t) {
    407400        bottom_left.y = t;
     
    419412
    420413      ///Set the top of the box.
    421       ///It should only be used for non-empty box.
     414      ///It should only bee used for non-empty box.
    422415      void top(T t) {
    423416        top_right.y = t;
     
    435428
    436429      ///Set the left side of the box.
    437       ///It should only be used for non-empty box.
     430      ///It should only bee used for non-empty box
    438431      void left(T t) {
    439432        bottom_left.x = t;
     
    451444
    452445      ///Set the right side of the box.
    453       ///It should only be used for non-empty box.
     446      ///It should only bee used for non-empty box
    454447      void right(T t) {
    455448        top_right.x = t;
     
    473466
    474467      ///Checks whether a point is inside a bounding box
    475       bool inside(const Point<T>& u) const {
     468      bool inside(const Point<T>& u){
    476469        if (_empty)
    477470          return false;
     
    483476 
    484477      ///Increments a bounding box with a point
    485 
    486       ///Increments a bounding box with a point.
    487       ///
    488478      BoundingBox& add(const Point<T>& u){
    489479        if (_empty){
     
    500490      }
    501491   
    502       ///Increments a bounding box to contain another bounding box
    503      
    504       ///Increments a bounding box to contain another bounding box.
    505       ///
     492      ///Increments a bounding to contain another bounding box
    506493      BoundingBox& add(const BoundingBox &u){
    507494        if ( !u.empty() ){
     
    513500 
    514501      ///Intersection of two bounding boxes
    515 
    516       ///Intersection of two bounding boxes.
    517       ///
    518       BoundingBox operator&(const BoundingBox& u) const {
     502      BoundingBox operator &(const BoundingBox& u){
    519503        BoundingBox b;
    520         if (this->_empty || u._empty) {
    521           b._empty = true;
    522         } else {
    523           b.bottom_left.x = std::max(this->bottom_left.x,u.bottom_left.x);
    524           b.bottom_left.y = std::max(this->bottom_left.y,u.bottom_left.y);
    525           b.top_right.x = std::min(this->top_right.x,u.top_right.x);
    526           b.top_right.y = std::min(this->top_right.y,u.top_right.y);
    527           b._empty = b.bottom_left.x > b.top_right.x ||
    528                      b.bottom_left.y > b.top_right.y;
    529         }
     504        b.bottom_left.x=std::max(this->bottom_left.x,u.bottom_left.x);
     505        b.bottom_left.y=std::max(this->bottom_left.y,u.bottom_left.y);
     506        b.top_right.x=std::min(this->top_right.x,u.top_right.x);
     507        b.top_right.y=std::min(this->top_right.y,u.top_right.y);
     508        b._empty = this->_empty || u._empty ||
     509          b.bottom_left.x>top_right.x && b.bottom_left.y>top_right.y;
    530510        return b;
    531511      }
     
    534514
    535515
    536   ///Map of x-coordinates of a \ref Point "Point"-map
    537 
    538   ///\ingroup maps
    539   ///Map of x-coordinates of a \ref Point "Point"-map.
     516  ///Map of x-coordinates of a dim2::Point<>-map
     517
     518  ///\ingroup maps
     519  ///Map of x-coordinates of a dim2::Point<>-map
    540520  ///
    541521  template<class M>
     
    591571  ///Returns a \ref ConstXMap class
    592572
    593   ///This function just returns a \ref ConstXMap class.
     573  ///This function just returns an \ref ConstXMap class.
    594574  ///
    595575  ///\ingroup maps
     
    601581  }
    602582
    603   ///Map of y-coordinates of a \ref Point "Point"-map
     583  ///Map of y-coordinates of a dim2::Point<>-map
    604584   
    605585  ///\ingroup maps
    606   ///Map of y-coordinates of a \ref Point "Point"-map.
     586  ///Map of y-coordinates of a dim2::Point<>-map
    607587  ///
    608588  template<class M>
     
    620600  };
    621601
    622   ///Returns a \ref YMap class
    623 
    624   ///This function just returns a \ref YMap class.
     602  ///Returns an \ref YMap class
     603
     604  ///This function just returns an \ref YMap class.
    625605  ///
    626606  ///\ingroup maps
     
    658638  ///Returns a \ref ConstYMap class
    659639
    660   ///This function just returns a \ref ConstYMap class.
     640  ///This function just returns an \ref ConstYMap class.
    661641  ///
    662642  ///\ingroup maps
     
    670650
    671651    ///\brief Map of the \ref Point::normSquare() "normSquare()"
    672     ///of a \ref Point "Point"-map
     652    ///of an \ref Point "Point"-map
    673653    ///
    674654    ///Map of the \ref Point::normSquare() "normSquare()"
    675     ///of a \ref Point "Point"-map.
     655    ///of an \ref Point "Point"-map
    676656    ///\ingroup maps
    677657    ///
     
    691671  ///Returns a \ref NormSquareMap class
    692672
    693   ///This function just returns a \ref NormSquareMap class.
     673  ///This function just returns an \ref NormSquareMap class.
    694674  ///
    695675  ///\ingroup maps
  • lemon/tolerance.h

    r16 r7  
    4949  ///\sa Tolerance<long double>
    5050  ///\sa Tolerance<int>
    51 #if defined __GNUC__ && !defined __STRICT_ANSI__ 
    5251  ///\sa Tolerance<long long int>
    53 #endif
    5452  ///\sa Tolerance<unsigned int>
    55 #if defined __GNUC__ && !defined __STRICT_ANSI__ 
    5653  ///\sa Tolerance<unsigned long long int>
    57 #endif
    5854
    5955  template<class T>
     
    135131    bool negative(Value a) const { return -_epsilon>a; }
    136132    ///Returns \c true if \c a is \e surely non-zero
    137     bool nonZero(Value a) const { return positive(a)||negative(a); }
     133    bool nonZero(Value a) const { return positive(a)||negative(a); };
    138134
    139135    ///@}
     
    186182    bool negative(Value a) const { return -_epsilon>a; }
    187183    ///Returns \c true if \c a is \e surely non-zero
    188     bool nonZero(Value a) const { return positive(a)||negative(a); }
     184    bool nonZero(Value a) const { return positive(a)||negative(a); };
    189185
    190186    ///@}
     
    237233    bool negative(Value a) const { return -_epsilon>a; }
    238234    ///Returns \c true if \c a is \e surely non-zero
    239     bool nonZero(Value a) const { return positive(a)||negative(a); }
     235    bool nonZero(Value a) const { return positive(a)||negative(a); };
    240236
    241237    ///@}
     
    270266    static bool negative(Value a) { return 0>a; }
    271267    ///Returns \c true if \c a is \e surely non-zero
    272     static bool nonZero(Value a) { return a!=0; }
     268    static bool nonZero(Value a) { return a!=0; };
    273269
    274270    ///@}
     
    303299    static bool negative(Value) { return false; }
    304300    ///Returns \c true if \c a is \e surely non-zero
    305     static bool nonZero(Value a) { return a!=0; }
     301    static bool nonZero(Value a) { return a!=0; };
    306302
    307303    ///@}
     
    337333    static bool negative(Value a) { return 0>a; }
    338334    ///Returns \c true if \c a is \e surely non-zero
    339     static bool nonZero(Value a) { return a!=0;}
     335    static bool nonZero(Value a) { return a!=0;};
    340336
    341337    ///@}
     
    370366    static bool negative(Value) { return false; }
    371367    ///Returns \c true if \c a is \e surely non-zero
    372     static bool nonZero(Value a) { return a!=0;}
     368    static bool nonZero(Value a) { return a!=0;};
    373369
    374370    ///@}
     
    407403    static bool negative(Value a) { return 0>a; }
    408404    ///Returns \c true if \c a is \e surely non-zero
    409     static bool nonZero(Value a) { return a!=0;}
     405    static bool nonZero(Value a) { return a!=0;};
    410406
    411407    ///@}
     
    442438    static bool negative(Value) { return false; }
    443439    ///Returns \c true if \c a is \e surely non-zero
    444     static bool nonZero(Value a) { return a!=0;}
     440    static bool nonZero(Value a) { return a!=0;};
    445441
    446442    ///@}
  • test/Makefile.am

    r10 r8  
    44noinst_HEADERS += \
    55        test/test_tools.h
    6 
     6 
    77check_PROGRAMS += \
    88        test/dim_test \
    9         test/random_test \
    109        test/test_tools_fail \
    1110        test/test_tools_pass
    12 
     11 
    1312TESTS += $(check_PROGRAMS)
    1413XFAIL_TESTS += test/test_tools_fail$(EXEEXT)
    1514
    1615test_dim_test_SOURCES = test/dim_test.cc
    17 test_random_test_SOURCES = test/random_test.cc
    1816test_test_tools_fail_SOURCES = test/test_tools_fail.cc
    1917test_test_tools_pass_SOURCES = test/test_tools_pass.cc
  • test/dim_test.cc

    r14 r8  
    2323using namespace std;
    2424using namespace lemon;
    25 
    2625int main()
    2726{
    28   cout << "Testing classes 'dim2::Point' and 'dim2::BoundingBox'." << endl;
     27
     28  cout << "Testing classes `dim2::Point' and `dim2::BoundingBox'." << endl;
    2929
    3030  typedef dim2::Point<int> Point;
    31 
    32   Point p;
    33   check(p.size()==2, "Wrong vector initialization.");
     31       
     32  Point seged;
     33  check(seged.size()==2, "Wrong vector addition");
    3434
    3535  Point a(1,2);
    3636  Point b(3,4);
    37   check(a[0]==1 && a[1]==2, "Wrong vector initialization.");
    3837
    39   p = a+b;
    40   check(p.x==4 && p.y==6, "Wrong vector addition.");
     38  check(a[0]==1 && a[1]==2, "Wrong vector addition");
    4139
    42   p = a-b;
    43   check(p.x==-2 && p.y==-2, "Wrong vector subtraction.");
     40  seged = a+b;
     41  check(seged.x==4 && seged.y==6, "Wrong vector addition");
    4442
    45   check(a.normSquare()==5,"Wrong vector norm calculation.");
    46   check(a*b==11, "Wrong vector scalar product.");
     43  seged = a-b;
     44  check(seged.x==-2 && seged.y==-2, "a-b");
     45
     46  check(a.normSquare()==5,"Wrong norm calculation");
     47  check(a*b==11, "a*b");
    4748
    4849  int l=2;
    49   p = a*l;
    50   check(p.x==2 && p.y==4, "Wrong vector multiplication by a scalar.");
     50  seged = a*l;
     51  check(seged.x==2 && seged.y==4, "a*l");
    5152
    52   p = b/l;
    53   check(p.x==1 && p.y==2, "Wrong vector division by a scalar.");
     53  seged = b/l;
     54  check(seged.x==1 && seged.y==2, "b/l");
    5455
    5556  typedef dim2::BoundingBox<int> BB;
    56   BB box1;
    57   check(box1.empty(), "It should be empty.");
     57  BB doboz1;
     58  check(doboz1.empty(), "It should be empty.");
     59       
     60  doboz1.add(a);
     61  check(!doboz1.empty(), "It should not be empty.");
     62  doboz1.add(b);
    5863
    59   box1.add(a);
    60   check(!box1.empty(), "It should not be empty.");
    61   box1.add(b);
     64  check(doboz1.bottomLeft().x==1 &&
     65        doboz1.bottomLeft().y==2 &&
     66        doboz1.topRight().x==3 &&
     67        doboz1.topRight().y==4, 
     68        "added points to box");
    6269
    63   check(box1.bottomLeft().x==1 &&
    64         box1.bottomLeft().y==2 &&
    65         box1.topRight().x==3 &&
    66         box1.topRight().y==4,
    67         "Wrong addition of points to box.");
     70  seged.x=2;seged.y=3;
     71  check(doboz1.inside(seged),"It should be inside.");
    6872
    69   p.x=2; p.y=3;
    70   check(box1.inside(p), "It should be inside.");
     73  seged.x=1;seged.y=3;
     74  check(doboz1.inside(seged),"It should be inside.");
    7175
    72   p.x=1; p.y=3;
    73   check(box1.inside(p), "It should be inside.");
     76  seged.x=0;seged.y=3;
     77  check(!doboz1.inside(seged),"It should not be inside.");
    7478
    75   p.x=0; p.y=3;
    76   check(!box1.inside(p), "It should not be inside.");
    77 
    78   BB box2(p);
    79   check(!box2.empty(),
     79  BB doboz2(seged);
     80  check(!doboz2.empty(),
    8081        "It should not be empty. Constructed from 1 point.");
    8182
    82   box2.add(box1);
    83   check(box2.inside(p),
     83  doboz2.add(doboz1);
     84  check(doboz2.inside(seged),
    8485        "It should be inside. Incremented a box with another one.");
    85 
    86   return 0;
    8786}
Note: See TracChangeset for help on using the changeset viewer.