COIN-OR::LEMON - Graph Library

Changeset 986:e997802b855c in lemon-0.x for src/work/peter/path


Ignore:
Timestamp:
11/13/04 13:53:28 (19 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1376
Message:

Naming changes:

  • head -> target
  • tail -> source
Location:
src/work/peter/path
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/work/peter/path/path.h

    r959 r986  
    109109    /// Returns INVALID if the path is empty.
    110110    GraphNode from() const {
    111       return empty() ? INVALID : gr->tail(edges[0]);
     111      return empty() ? INVALID : gr->source(edges[0]);
    112112    }
    113113    /// \brief End point of the path.
     
    116116    /// Returns INVALID if the path is empty.
    117117    GraphNode to() const {
    118       return empty() ? INVALID : gr->head(edges[length()-1]);
     118      return empty() ? INVALID : gr->target(edges[length()-1]);
    119119    }
    120120
     
    154154    }
    155155
    156     /// \brief Returns node iterator pointing to the head node of the
     156    /// \brief Returns node iterator pointing to the target node of the
    157157    /// given edge iterator.
    158     NodeIt head(const EdgeIt& e) const {
     158    NodeIt target(const EdgeIt& e) const {
    159159      if( DM::range_check && !e.valid() )
    160         fault("DirPath::head() on invalid iterator");
     160        fault("DirPath::target() on invalid iterator");
    161161      return NodeIt(*this, e.idx+1);
    162162    }
    163163
    164     /// \brief Returns node iterator pointing to the tail node of the
     164    /// \brief Returns node iterator pointing to the source node of the
    165165    /// given edge iterator.
    166     NodeIt tail(const EdgeIt& e) const {
     166    NodeIt source(const EdgeIt& e) const {
    167167      if( DM::range_check && !e.valid() )
    168         fault("DirPath::tail() on invalid iterator");
     168        fault("DirPath::source() on invalid iterator");
    169169      return NodeIt(*this, e.idx);
    170170    }
     
    255255          return p->to();
    256256        else if(idx >= 0)
    257           return p->gr->tail(p->edges[idx]);
     257          return p->gr->source(p->edges[idx]);
    258258        else
    259259          return INVALID;
     
    313313      ///\sa setStartNode
    314314      void pushFront(const GraphEdge& e) {
    315         if( DM::consistensy_check && !empty() && P.gr->head(e)!=from() ) {
     315        if( DM::consistensy_check && !empty() && P.gr->target(e)!=from() ) {
    316316          fault("DirPath::Builder::pushFront: nonincident edge");
    317317        }
     
    324324      ///\sa setStartNode
    325325      void pushBack(const GraphEdge& e) {
    326         if( DM::consistensy_check && !empty() && P.gr->tail(e)!=to() ) {
     326        if( DM::consistensy_check && !empty() && P.gr->source(e)!=to() ) {
    327327          fault("DirPath::Builder::pushBack: nonincident edge");
    328328        }
     
    363363      GraphNode from() const {
    364364        if( ! front.empty() )
    365           return P.gr->tail(front[front.size()-1]);
     365          return P.gr->source(front[front.size()-1]);
    366366        else if( ! P.empty() )
    367           return P.gr->tail(P.edges[0]);
     367          return P.gr->source(P.edges[0]);
    368368        else if( ! back.empty() )
    369           return P.gr->tail(back[0]);
     369          return P.gr->source(back[0]);
    370370        else
    371371          return INVALID;
     
    373373      GraphNode to() const {
    374374        if( ! back.empty() )
    375           return P.gr->head(back[back.size()-1]);
     375          return P.gr->target(back[back.size()-1]);
    376376        else if( ! P.empty() )
    377           return P.gr->head(P.edges[P.length()-1]);
     377          return P.gr->target(P.edges[P.length()-1]);
    378378        else if( ! front.empty() )
    379           return P.gr->head(front[0]);
     379          return P.gr->target(front[0]);
    380380        else
    381381          return INVALID;
     
    472472    /// Returns INVALID if the path is empty.
    473473    GraphNode from() const {
    474       return empty() ? INVALID : gr->tail(edges[0]);
     474      return empty() ? INVALID : gr->source(edges[0]);
    475475    }
    476476    /// \brief End point of the path.
     
    479479    /// Returns INVALID if the path is empty.
    480480    GraphNode to() const {
    481       return empty() ? INVALID : gr->head(edges[length()-1]);
     481      return empty() ? INVALID : gr->target(edges[length()-1]);
    482482    }
    483483
     
    517517    }
    518518
    519     /// \brief Returns node iterator pointing to the head node of the
     519    /// \brief Returns node iterator pointing to the target node of the
    520520    /// given edge iterator.
    521     NodeIt head(const EdgeIt& e) const {
     521    NodeIt target(const EdgeIt& e) const {
    522522      if( DM::range_check && !e.valid() )
    523         fault("UndirPath::head() on invalid iterator");
     523        fault("UndirPath::target() on invalid iterator");
    524524      return NodeIt(*this, e.idx+1);
    525525    }
    526526
    527     /// \brief Returns node iterator pointing to the tail node of the
     527    /// \brief Returns node iterator pointing to the source node of the
    528528    /// given edge iterator.
    529     NodeIt tail(const EdgeIt& e) const {
     529    NodeIt source(const EdgeIt& e) const {
    530530      if( DM::range_check && !e.valid() )
    531         fault("UndirPath::tail() on invalid iterator");
     531        fault("UndirPath::source() on invalid iterator");
    532532      return NodeIt(*this, e.idx);
    533533    }
     
    616616          return p->to();
    617617        else if(idx >= 0)
    618           return p->gr->tail(p->edges[idx]);
     618          return p->gr->source(p->edges[idx]);
    619619        else
    620620          return INVALID;
     
    674674      ///\sa setStartNode
    675675      void pushFront(const GraphEdge& e) {
    676         if( DM::consistensy_check && !empty() && P.gr->head(e)!=from() ) {
     676        if( DM::consistensy_check && !empty() && P.gr->target(e)!=from() ) {
    677677          fault("UndirPath::Builder::pushFront: nonincident edge");
    678678        }
     
    685685      ///\sa setStartNode
    686686      void pushBack(const GraphEdge& e) {
    687         if( DM::consistensy_check && !empty() && P.gr->tail(e)!=to() ) {
     687        if( DM::consistensy_check && !empty() && P.gr->source(e)!=to() ) {
    688688          fault("UndirPath::Builder::pushBack: nonincident edge");
    689689        }
     
    724724      GraphNode from() const {
    725725        if( ! front.empty() )
    726           return P.gr->tail(front[front.size()-1]);
     726          return P.gr->source(front[front.size()-1]);
    727727        else if( ! P.empty() )
    728           return P.gr->tail(P.edges[0]);
     728          return P.gr->source(P.edges[0]);
    729729        else if( ! back.empty() )
    730           return P.gr->tail(back[0]);
     730          return P.gr->source(back[0]);
    731731        else
    732732          return INVALID;
     
    734734      GraphNode to() const {
    735735        if( ! back.empty() )
    736           return P.gr->head(back[back.size()-1]);
     736          return P.gr->target(back[back.size()-1]);
    737737        else if( ! P.empty() )
    738           return P.gr->head(P.edges[P.length()-1]);
     738          return P.gr->target(P.edges[P.length()-1]);
    739739        else if( ! front.empty() )
    740           return P.gr->head(front[0]);
     740          return P.gr->target(front[0]);
    741741        else
    742742          return INVALID;
     
    841841    bool setTo(const GraphNode &n);
    842842
    843     // WARNING: these two functions return the head/tail of an edge with
     843    // WARNING: these two functions return the target/source of an edge with
    844844    // respect to the direction of the path!
    845     // So G.head(P.graphEdge(e)) == P.graphNode(P.head(e)) holds only if
     845    // So G.target(P.graphEdge(e)) == P.graphNode(P.target(e)) holds only if
    846846    // P.forward(e) is true (or the edge is a loop)!
    847     NodeIt head(const EdgeIt& e) const;
    848     NodeIt tail(const EdgeIt& e) const;
     847    NodeIt target(const EdgeIt& e) const;
     848    NodeIt source(const EdgeIt& e) const;
    849849
    850850    // FIXME: ezeknek valami jobb nev kellene!!!
     
    874874
    875875      size_t idx;
    876       bool tail;  // Is this node the tail of the edge with same idx?
     876      bool source;  // Is this node the source of the edge with same idx?
    877877
    878878    public:
     
    897897      return e;
    898898
    899     GraphNode common_node = ( e.forw ? G.head(*e.it) : G.tail(*e.it) );
     899    GraphNode common_node = ( e.forw ? G.target(*e.it) : G.source(*e.it) );
    900900    ++e.it;
    901901
     
    906906    }
    907907
    908     e.forw = ( G.tail(*e.it) == common_node );
     908    e.forw = ( G.source(*e.it) == common_node );
    909909    return e;
    910910  }
     
    919919
    920920   
    921     GraphNode next_node = ( n.tail ? G.head(edges[n.idx]) :
    922                               G.tail(edges[n.idx]) );
     921    GraphNode next_node = ( n.source ? G.target(edges[n.idx]) :
     922                              G.source(edges[n.idx]) );
    923923    ++n.idx;
    924924    if( n.idx < length() ) {
    925       n.tail = ( next_node == G.tail(edges[n.idx]) );
     925      n.source = ( next_node == G.source(edges[n.idx]) );
    926926    }
    927927    else {
    928       n.tail = true;
     928      n.source = true;
    929929    }
    930930
     
    935935  bool DynamicPath<Gr>::edgeIncident(const GraphEdge &e, const GraphNode &a,
    936936                          GraphNode &b) {
    937     if( G.tail(e) == a ) {
    938       b=G.head(e);
     937    if( G.source(e) == a ) {
     938      b=G.target(e);
    939939      return true;
    940940    }
    941     if( G.head(e) == a ) {
    942       b=G.tail(e);
     941    if( G.target(e) == a ) {
     942      b=G.source(e);
    943943      return true;
    944944    }
     
    949949  bool DynamicPath<Gr>::connectTwoEdges(const GraphEdge &e,
    950950                             const GraphEdge &f) {
    951     if( edgeIncident(f, G.tail(e), _last) ) {
    952       _first = G.head(e);
     951    if( edgeIncident(f, G.source(e), _last) ) {
     952      _first = G.target(e);
    953953      return true;
    954954    }
    955     if( edgeIncident(f, G.head(e), _last) ) {
    956       _first = G.tail(e);
     955    if( edgeIncident(f, G.target(e), _last) ) {
     956      _first = G.source(e);
    957957      return true;
    958958    }
     
    10401040  template<typename Gr>
    10411041  typename DynamicPath<Gr>::NodeIt
    1042   DynamicPath<Gr>::tail(const EdgeIt& e) const {
     1042  DynamicPath<Gr>::source(const EdgeIt& e) const {
    10431043    NodeIt n;
    10441044
     
    10461046      // FIXME: invalid-> invalid
    10471047      n.idx = length() + 1;
    1048       n.tail = true;
     1048      n.source = true;
    10491049      return n;
    10501050    }
    10511051
    10521052    n.idx = e.it-edges.begin();
    1053     n.tail = e.forw;
     1053    n.source = e.forw;
    10541054    return n;
    10551055  }
     
    10571057  template<typename Gr>
    10581058  typename DynamicPath<Gr>::NodeIt
    1059   DynamicPath<Gr>::head(const EdgeIt& e) const {
     1059  DynamicPath<Gr>::target(const EdgeIt& e) const {
    10601060    if( e.it == edges.end()-1 ) {
    10611061      return _last;
     
    10641064    EdgeIt next_edge = e;
    10651065    next(next_edge);
    1066     return tail(next_edge);
     1066    return source(next_edge);
    10671067  }
    10681068     
     
    10821082  DynamicPath<Gr>::graphNode(const NodeIt& n) const {
    10831083    if( n.idx < length() ) {
    1084       return n.tail ? G.tail(edges[n.idx]) : G.head(edges[n.idx]);
     1084      return n.source ? G.source(edges[n.idx]) : G.target(edges[n.idx]);
    10851085    }
    10861086    else if( n.idx == length() ) {
     
    11041104    e.it = edges.begin()+k;
    11051105    if(k==0) {
    1106       e.forw = ( G.tail(*e.it) == _first );
     1106      e.forw = ( G.source(*e.it) == _first );
    11071107    }
    11081108    else {
    1109       e.forw = ( G.tail(*e.it) == G.tail(edges[k-1]) ||
    1110                  G.tail(*e.it) == G.head(edges[k-1]) );
     1109      e.forw = ( G.source(*e.it) == G.source(edges[k-1]) ||
     1110                 G.source(*e.it) == G.target(edges[k-1]) );
    11111111    }
    11121112    return e;
     
    11191119      // FIXME: invalid NodeIt
    11201120      n.idx = length()+1;
    1121       n.tail = true;
     1121      n.source = true;
    11221122      return n;
    11231123    }
    11241124    if( k==length() ) {
    11251125      n.idx = length();
    1126       n.tail = true;
     1126      n.source = true;
    11271127      return n;
    11281128    }
    1129     n = tail(nth<EdgeIt>(k));
     1129    n = source(nth<EdgeIt>(k));
    11301130    return n;
    11311131  }
     
    11401140  {
    11411141    if( G.valid(P._first) && a.it < P.edges.end() ) {
    1142       _first = ( a.forw ? G.tail(*a.it) : G.head(*a.it) );
     1142      _first = ( a.forw ? G.source(*a.it) : G.target(*a.it) );
    11431143      if( b.it < P.edges.end() ) {
    1144         _last = ( b.forw ? G.tail(*b.it) : G.head(*b.it) );
     1144        _last = ( b.forw ? G.source(*b.it) : G.target(*b.it) );
    11451145      }
    11461146      else {
  • src/work/peter/path/path_skeleton.h

    r959 r986  
    5454      /// Starting point of the path.
    5555      /// Returns INVALID if the path is empty.
    56       GraphNode head() const {}
     56      GraphNode target() const {}
    5757      /// \brief End point of the path.
    5858      ///
    5959      /// End point of the path.
    6060      /// Returns INVALID if the path is empty.
    61       GraphNode tail() const {}
     61      GraphNode source() const {}
    6262
    6363      /// \brief First NodeIt/EdgeIt.
     
    6868      It& first(It &i) const { return i=It(*this); }
    6969
    70       /// \brief The head of an edge.
    71       ///
    72       /// Returns node iterator pointing to the head node of the
     70      /// \brief The target of an edge.
     71      ///
     72      /// Returns node iterator pointing to the target node of the
    7373      /// given edge iterator.
    74       NodeIt head(const EdgeIt& e) const {}
    75 
    76       /// \brief The tail of an edge.
    77       ///
    78       /// Returns node iterator pointing to the tail node of the
     74      NodeIt target(const EdgeIt& e) const {}
     75
     76      /// \brief The source of an edge.
     77      ///
     78      /// Returns node iterator pointing to the source node of the
    7979      /// given edge iterator.
    80       NodeIt tail(const EdgeIt& e) const {}
     80      NodeIt source(const EdgeIt& e) const {}
    8181
    8282
  • src/work/peter/path/path_test.cc

    r959 r986  
    6767
    6868#ifdef SKELETON
    69       cout << "P.tail() valid? " << (P.tail()!=INVALID) << endl;
    70       check(! (P.tail()!=INVALID));
     69      cout << "P.source() valid? " << (P.source()!=INVALID) << endl;
     70      check(! (P.source()!=INVALID));
    7171#else
    72       cout << "P.tail() valid? " << (P.from()!=INVALID) << endl;
     72      cout << "P.source() valid? " << (P.from()!=INVALID) << endl;
    7373      check(! (P.to()!=INVALID));
    7474#endif
     
    9090
    9191#ifdef SKELETON
    92         cout << "P.tail() valid? " << (P.tail()!=INVALID) << endl;
    93         check(P.tail()!=INVALID);
    94         cout << "P.tail()==v1 ? " << (P.tail()==v1) << endl;
    95         check(P.tail() == v1);
     92        cout << "P.source() valid? " << (P.source()!=INVALID) << endl;
     93        check(P.source()!=INVALID);
     94        cout << "P.source()==v1 ? " << (P.source()==v1) << endl;
     95        check(P.source() == v1);
    9696#else
    97         cout << "P.tail() valid? " << (P.from()!=INVALID) << endl;
     97        cout << "P.source() valid? " << (P.from()!=INVALID) << endl;
    9898        check(P.from()!=INVALID);
    99         cout << "P.tail()==v1 ? " << (P.from()==v1) << endl;
     99        cout << "P.source()==v1 ? " << (P.from()==v1) << endl;
    100100        check(P.from() == v1);
    101101#endif
     
    129129
    130130#ifdef SKELETON
    131       cout << "P.head()==v3 ? " << (P.head()==v3) << endl;
    132       check(P.head() == v3);
     131      cout << "P.target()==v3 ? " << (P.target()==v3) << endl;
     132      check(P.target() == v3);
    133133#else
    134       cout << "P.head()==v3 ? " << (P.to()==v3) << endl;
     134      cout << "P.target()==v3 ? " << (P.to()==v3) << endl;
    135135      check(P.to() == v3);
    136136#endif
Note: See TracChangeset for help on using the changeset viewer.