COIN-OR::LEMON - Graph Library

Changeset 986:e997802b855c in lemon-0.x for src/lemon/full_graph.h


Ignore:
Timestamp:
11/13/04 13:53:28 (15 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/full_graph.h

    r985 r986  
    7979    int maxId(Edge = INVALID) const { return EdgeNum-1; }
    8080
    81     Node tail(Edge e) const { return e.id % NodeNum; }
    82     Node head(Edge e) const { return e.id / NodeNum; }
     81    Node source(Edge e) const { return e.id % NodeNum; }
     82    Node target(Edge e) const { return e.id / NodeNum; }
    8383
    8484
     
    137137     
    138138    protected:
    139       int id;  // NodeNum * head + tail;
     139      int id;  // NodeNum * target + source;
    140140
    141141      Edge(int _id) : id(_id) {}
    142142
    143       Edge(const FullGraphBase& _graph, int tail, int head)
    144         : id(_graph.NodeNum * head+tail) {}
     143      Edge(const FullGraphBase& _graph, int source, int target)
     144        : id(_graph.NodeNum * target+source) {}
    145145    public:
    146146      Edge() { }
     
    251251    int maxId(Edge = INVALID) const { return EdgeNum-1; }
    252252
    253     Node tail(Edge e) const {
     253    Node source(Edge e) const {
    254254      /// \todo we may do it faster
    255255      return ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;
    256256    }
    257257
    258     Node head(Edge e) const {
    259       int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
    260       return e.id - (tail) * (tail - 1) / 2;
     258    Node target(Edge e) const {
     259      int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
     260      return e.id - (source) * (source - 1) / 2;
    261261    }
    262262
     
    316316     
    317317    protected:
    318       int id;  // NodeNum * head + tail;
     318      int id;  // NodeNum * target + source;
    319319
    320320      Edge(int _id) : id(_id) {}
    321321
    322       Edge(const UndirFullGraphBase& _graph, int tail, int head)
    323         : id(_graph.NodeNum * head+tail) {}
     322      Edge(const UndirFullGraphBase& _graph, int source, int target)
     323        : id(_graph.NodeNum * target+source) {}
    324324    public:
    325325      Edge() { }
     
    352352    /// \todo with specialized iterators we can make faster iterating
    353353    void nextOut(Edge& e) const {
    354       int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
    355       int head = e.id - (tail) * (tail - 1) / 2;
    356       ++head;
    357       e.id = head < tail ? tail * (tail - 1) / 2 + head : -1;
     354      int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
     355      int target = e.id - (source) * (source - 1) / 2;
     356      ++target;
     357      e.id = target < source ? source * (source - 1) / 2 + target : -1;
    358358    }
    359359
     
    363363   
    364364    void nextIn(Edge& e) const {
    365       int tail = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
    366       int head = e.id - (tail) * (tail - 1) / 2; ++head;
    367       ++tail;
    368       e.id = tail < NodeNum ? tail * (tail - 1) / 2 + head : -1;
     365      int source = ((int)sqrt((double)(1 + 8 * e.id)) + 1) / 2;;
     366      int target = e.id - (source) * (source - 1) / 2; ++target;
     367      ++source;
     368      e.id = source < NodeNum ? source * (source - 1) / 2 + target : -1;
    369369    }
    370370
Note: See TracChangeset for help on using the changeset viewer.