COIN-OR::LEMON - Graph Library

Changeset 656:cb38ccedd2c1 in lemon-main


Ignore:
Timestamp:
05/07/09 10:46:49 (15 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Children:
657:bf7928412136, 658:ebdcc68fe79e
Phase:
public
Message:

Change Undirector::Edge -> Undirector::Arc inheritance to conversion (#283)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/adaptors.h

    r617 r656  
    18401840    typedef typename Digraph::Node Node;
    18411841
    1842     class Arc : public Edge {
     1842    class Arc {
    18431843      friend class UndirectorBase;
    18441844    protected:
     1845      Edge _edge;
    18451846      bool _forward;
    18461847
    1847       Arc(const Edge& edge, bool forward) :
    1848         Edge(edge), _forward(forward) {}
     1848      Arc(const Edge& edge, bool forward)
     1849        : _edge(edge), _forward(forward) {}
    18491850
    18501851    public:
    18511852      Arc() {}
    18521853
    1853       Arc(Invalid) : Edge(INVALID), _forward(true) {}
     1854      Arc(Invalid) : _edge(INVALID), _forward(true) {}
     1855
     1856      operator const Edge&() const { return _edge; }
    18541857
    18551858      bool operator==(const Arc &other) const {
    1856         return _forward == other._forward &&
    1857           static_cast<const Edge&>(*this) == static_cast<const Edge&>(other);
     1859        return _forward == other._forward && _edge == other._edge;
    18581860      }
    18591861      bool operator!=(const Arc &other) const {
    1860         return _forward != other._forward ||
    1861           static_cast<const Edge&>(*this) != static_cast<const Edge&>(other);
     1862        return _forward != other._forward || _edge != other._edge;
    18621863      }
    18631864      bool operator<(const Arc &other) const {
    18641865        return _forward < other._forward ||
    1865           (_forward == other._forward &&
    1866            static_cast<const Edge&>(*this) < static_cast<const Edge&>(other));
     1866          (_forward == other._forward && _edge < other._edge);
    18671867      }
    18681868    };
     
    18771877
    18781878    void first(Arc& a) const {
    1879       _digraph->first(a);
     1879      _digraph->first(a._edge);
    18801880      a._forward = true;
    18811881    }
     
    18851885        a._forward = false;
    18861886      } else {
    1887         _digraph->next(a);
     1887        _digraph->next(a._edge);
    18881888        a._forward = true;
    18891889      }
     
    18991899
    19001900    void firstOut(Arc& a, const Node& n) const {
    1901       _digraph->firstIn(a, n);
    1902       if( static_cast<const Edge&>(a) != INVALID ) {
     1901      _digraph->firstIn(a._edge, n);
     1902      if (a._edge != INVALID ) {
    19031903        a._forward = false;
    19041904      } else {
    1905         _digraph->firstOut(a, n);
     1905        _digraph->firstOut(a._edge, n);
    19061906        a._forward = true;
    19071907      }
     
    19091909    void nextOut(Arc &a) const {
    19101910      if (!a._forward) {
    1911         Node n = _digraph->target(a);
    1912         _digraph->nextIn(a);
    1913         if (static_cast<const Edge&>(a) == INVALID ) {
    1914           _digraph->firstOut(a, n);
     1911        Node n = _digraph->target(a._edge);
     1912        _digraph->nextIn(a._edge);
     1913        if (a._edge == INVALID) {
     1914          _digraph->firstOut(a._edge, n);
    19151915          a._forward = true;
    19161916        }
    19171917      }
    19181918      else {
    1919         _digraph->nextOut(a);
     1919        _digraph->nextOut(a._edge);
    19201920      }
    19211921    }
    19221922
    19231923    void firstIn(Arc &a, const Node &n) const {
    1924       _digraph->firstOut(a, n);
    1925       if (static_cast<const Edge&>(a) != INVALID ) {
     1924      _digraph->firstOut(a._edge, n);
     1925      if (a._edge != INVALID ) {
    19261926        a._forward = false;
    19271927      } else {
    1928         _digraph->firstIn(a, n);
     1928        _digraph->firstIn(a._edge, n);
    19291929        a._forward = true;
    19301930      }
     
    19321932    void nextIn(Arc &a) const {
    19331933      if (!a._forward) {
    1934         Node n = _digraph->source(a);
    1935         _digraph->nextOut(a);
    1936         if( static_cast<const Edge&>(a) == INVALID ) {
    1937           _digraph->firstIn(a, n);
     1934        Node n = _digraph->source(a._edge);
     1935        _digraph->nextOut(a._edge);
     1936        if (a._edge == INVALID ) {
     1937          _digraph->firstIn(a._edge, n);
    19381938          a._forward = true;
    19391939        }
    19401940      }
    19411941      else {
    1942         _digraph->nextIn(a);
     1942        _digraph->nextIn(a._edge);
    19431943      }
    19441944    }
     
    19731973
    19741974    Node source(const Arc &a) const {
    1975       return a._forward ? _digraph->source(a) : _digraph->target(a);
     1975      return a._forward ? _digraph->source(a._edge) : _digraph->target(a._edge);
    19761976    }
    19771977
    19781978    Node target(const Arc &a) const {
    1979       return a._forward ? _digraph->target(a) : _digraph->source(a);
     1979      return a._forward ? _digraph->target(a._edge) : _digraph->source(a._edge);
    19801980    }
    19811981
    19821982    static Arc direct(const Edge &e, bool d) {
    19831983      return Arc(e, d);
    1984     }
    1985     Arc direct(const Edge &e, const Node& n) const {
    1986       return Arc(e, _digraph->source(e) == n);
    19871984    }
    19881985
Note: See TracChangeset for help on using the changeset viewer.