COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
11/25/04 15:48:24 (19 years ago)
Author:
Mihaly Barasz
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1411
Message:

Advances in UndirGraph?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/undir_graph_extender.h

    r986 r1021  
    7171    }
    7272
    73     /// Source of the given Edge.
    74     Node source(const Edge &e) const {
     73  protected:
     74
     75    template <typename E>
     76    Node _dirSource(const E &e) const {
    7577      return e.forward ? Parent::source(e) : Parent::target(e);
    7678    }
    7779
     80    template <typename E>
     81    Node _dirTarget(const E &e) const {
     82      return e.forward ? Parent::target(e) : Parent::source(e);
     83    }
     84
     85  public:
    7886    /// \todo Shouldn't the "source" of an undirected edge be called "aNode"
    7987    /// or something???
    8088    using Parent::source;
    8189
    82     /// Target of the given Edge.
    83     Node target(const Edge &e) const {
    84       return e.forward ? Parent::target(e) : Parent::source(e);
     90    /// Source of the given Edge.
     91    Node source(const Edge &e) const {
     92      return _dirSource(e);
    8593    }
    8694
     
    8896    /// or something???
    8997    using Parent::target;
     98
     99    /// Target of the given Edge.
     100    Node target(const Edge &e) const {
     101      return _dirTarget(e);
     102    }
    90103
    91104    /// Returns whether the given directed edge is same orientation as the
     
    123136    }
    124137
    125     void firstOut(Edge &e, const Node &n) const {
     138   
     139  protected:
     140
     141    template <typename E>
     142    void _dirFirstOut(E &e, const Node &n) const {
    126143      Parent::firstOut(e,n);
    127144      if( UndirEdge(e) != INVALID ) {
     
    133150      }
    134151    }
    135     void firstIn(Edge &e, const Node &n) const {
     152    template <typename E>
     153    void _dirFirstIn(E &e, const Node &n) const {
    136154      Parent::firstIn(e,n);
    137155      if( UndirEdge(e) != INVALID ) {
     
    144162    }
    145163
    146     void nextOut(Edge &e) const {
     164    template <typename E>
     165    void _dirNextOut(E &e) const {
    147166      if( e.forward ) {
    148167        Parent::nextOut(e);
     
    156175      }
    157176    }
    158     void nextIn(Edge &e) const {
     177    template <typename E>
     178    void _dirNextIn(E &e) const {
    159179      if( e.forward ) {
    160180        Parent::nextIn(e);
     
    169189    }
    170190
     191  public:
     192
     193    void firstOut(Edge &e, const Node &n) const {
     194      _dirFirstOut(e, n);
     195    }
     196    void firstIn(Edge &e, const Node &n) const {
     197      _dirFirstIn(e, n);
     198    }
     199
     200    void nextOut(Edge &e) const {
     201      _dirNextOut(e);
     202    }
     203    void nextIn(Edge &e) const {
     204      _dirNextIn(e);
     205    }
     206
    171207    // Miscellaneous stuff:
    172208
     
    174210    /// Extender
    175211
    176     using Parent::id;
     212    // using Parent::id;
     213    // Using "using" is not a good idea, cause it could be that there is
     214    // no "id" in Parent...
     215
     216    int id(const Node &n) const {
     217      return Parent::id(n);
     218    }
     219
     220    int id(const UndirEdge &e) const {
     221      return Parent::id(e);
     222    }
    177223
    178224    int id(const Edge &e) const {
     
    180226    }
    181227
    182     int maxId(Edge = INVALID) const {
     228
     229    int maxId(Node n) const {
     230      return Parent::maxId(Node());
     231    }
     232
     233    int maxId(Edge) const {
    183234      return 2 * Parent::maxId(typename Parent::Edge()) + 1;
    184235    }
    185     int maxId(UndirEdge = INVALID) const {
     236    int maxId(UndirEdge) const {
    186237      return Parent::maxId(typename Parent::Edge());
    187238    }
Note: See TracChangeset for help on using the changeset viewer.