COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
11/13/04 13:53:28 (17 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/work/marci/experiment/list_graph.h

    r921 r986  
    123123      //ListGraph* G;
    124124      int id;
    125       node_item* _tail;
    126       node_item* _head;
     125      node_item* _source;
     126      node_item* _target;
    127127      edge_item* _next_out;
    128128      edge_item* _prev_out;
     
    150150    }
    151151
    152     edge_item* _add_edge(node_item* _tail, node_item* _head) {
     152    edge_item* _add_edge(node_item* _source, node_item* _target) {
    153153      edge_item* e=new edge_item;
    154154      e->id=edge_id++;
    155       e->_tail=_tail;
    156       e->_head=_head;
    157      
    158       e->_prev_out=_tail->_last_out_edge;
    159       if (_tail->_last_out_edge) (_tail->_last_out_edge)->_next_out=e;
    160       _tail->_last_out_edge=e;
    161       if (!_tail->_first_out_edge) _tail->_first_out_edge=e;
     155      e->_source=_source;
     156      e->_target=_target;
     157     
     158      e->_prev_out=_source->_last_out_edge;
     159      if (_source->_last_out_edge) (_source->_last_out_edge)->_next_out=e;
     160      _source->_last_out_edge=e;
     161      if (!_source->_first_out_edge) _source->_first_out_edge=e;
    162162      e->_next_out=0;
    163163 
    164       e->_prev_in=_head->_last_in_edge;
    165       if (_head->_last_in_edge) (_head->_last_in_edge)->_next_in=e;
    166       _head->_last_in_edge=e;
    167       if (!_head->_first_in_edge) { _head->_first_in_edge=e; }
     164      e->_prev_in=_target->_last_in_edge;
     165      if (_target->_last_in_edge) (_target->_last_in_edge)->_next_in=e;
     166      _target->_last_in_edge=e;
     167      if (!_target->_first_in_edge) { _target->_first_in_edge=e; }
    168168      e->_next_in=0;
    169169
     
    185185    void _delete_edge(edge_item* e) {
    186186      if (e->_next_out) (e->_next_out)->_prev_out=e->_prev_out; else
    187         (e->_tail)->_last_out_edge=e->_prev_out;
     187        (e->_source)->_last_out_edge=e->_prev_out;
    188188      if (e->_prev_out) (e->_prev_out)->_next_out=e->_next_out; else
    189         (e->_tail)->_first_out_edge=e->_next_out;
     189        (e->_source)->_first_out_edge=e->_next_out;
    190190      if (e->_next_in) (e->_next_in)->_prev_in=e->_prev_in; else
    191         (e->_head)->_last_in_edge=e->_prev_in;
     191        (e->_target)->_last_in_edge=e->_prev_in;
    192192      if (e->_prev_in) (e->_prev_in)->_next_in=e->_next_in; else
    193         (e->_head)->_first_in_edge=e->_next_in;
     193        (e->_target)->_first_in_edge=e->_next_in;
    194194
    195195      delete e;
     
    197197    }
    198198
    199     void _set_tail(edge_item* e, node_item* _tail) {
     199    void _set_source(edge_item* e, node_item* _source) {
    200200      if (e->_next_out) (e->_next_out)->_prev_out=e->_prev_out; else
    201         (e->_tail)->_last_out_edge=e->_prev_out;
     201        (e->_source)->_last_out_edge=e->_prev_out;
    202202      if (e->_prev_out) (e->_prev_out)->_next_out=e->_next_out; else
    203         (e->_tail)->_first_out_edge=e->_next_out;
    204      
    205       e->_tail=_tail;
    206      
    207       e->_prev_out=_tail->_last_out_edge;
    208       if (_tail->_last_out_edge) (_tail->_last_out_edge)->_next_out=e;
    209       _tail->_last_out_edge=e;
    210       if (!_tail->_first_out_edge) _tail->_first_out_edge=e;
     203        (e->_source)->_first_out_edge=e->_next_out;
     204     
     205      e->_source=_source;
     206     
     207      e->_prev_out=_source->_last_out_edge;
     208      if (_source->_last_out_edge) (_source->_last_out_edge)->_next_out=e;
     209      _source->_last_out_edge=e;
     210      if (!_source->_first_out_edge) _source->_first_out_edge=e;
    211211      e->_next_out=0;
    212212    }
    213213
    214     void _set_head(edge_item* e, node_item* _head) {
     214    void _set_target(edge_item* e, node_item* _target) {
    215215      if (e->_next_in) (e->_next_in)->_prev_in=e->_prev_in; else
    216         (e->_head)->_last_in_edge=e->_prev_in;
     216        (e->_target)->_last_in_edge=e->_prev_in;
    217217      if (e->_prev_in) (e->_prev_in)->_next_in=e->_next_in; else
    218         (e->_head)->_first_in_edge=e->_next_in;
    219      
    220       e->_head=_head;
    221      
    222       e->_prev_in=_head->_last_in_edge;
    223       if (_head->_last_in_edge) (_head->_last_in_edge)->_next_in=e;
    224       _head->_last_in_edge=e;
    225       if (!_head->_first_in_edge) { _head->_first_in_edge=e; }
     218        (e->_target)->_first_in_edge=e->_next_in;
     219     
     220      e->_target=_target;
     221     
     222      e->_prev_in=_target->_last_in_edge;
     223      if (_target->_last_in_edge) (_target->_last_in_edge)->_next_in=e;
     224      _target->_last_in_edge=e;
     225      if (!_target->_first_in_edge) { _target->_first_in_edge=e; }
    226226      e->_next_in=0;
    227227    }
     
    248248    //InEdgeIt firstInEdge(const Node v) const { return InEdgeIt(v); }
    249249    //SymEdgeIt firstSymEdge(const Node v) const { return SymEdgeIt(v); }
    250     Node tail(Edge e) const { return e.tailNode(); }
    251     Node head(Edge e) const { return e.headNode(); }
     250    Node source(Edge e) const { return e.sourceNode(); }
     251    Node target(Edge e) const { return e.targetNode(); }
    252252
    253253    Node aNode(const OutEdgeIt& e) const { return e.aNode(); }
     
    278278    SymEdgeIt& /*getF*/first(SymEdgeIt& e, Node v) const {
    279279      e=SymEdgeIt(*this, v); return e; }
    280     //void getTail(Node& n, const Edge& e) const { n=tail(e); }
    281     //void getHead(Node& n, const Edge& e) const { n=head(e); }
     280    //void getSource(Node& n, const Edge& e) const { n=source(e); }
     281    //void getTarget(Node& n, const Edge& e) const { n=target(e); }
    282282
    283283    //void getANode(Node& n, const OutEdgeIt& e) const { n=e.aNode(); }
     
    346346    }
    347347
    348     void setTail(Edge e, Node tail) {
    349       _set_tail(e.edge, tail.node);
    350     }
    351 
    352     void setHead(Edge e, Node head) {
    353       _set_head(e.edge, head.node);
     348    void setSource(Edge e, Node source) {
     349      _set_source(e.edge, source.node);
     350    }
     351
     352    void setTarget(Edge e, Node target) {
     353      _set_target(e.edge, target.node);
    354354    }
    355355
     
    360360    }
    361361    friend std::ostream& operator<<(std::ostream& os, const Edge& i) {
    362       os << "(" << i.edge->_tail->id << "--" << i.edge->id << "->" << i.edge->_head->id << ")";
     362      os << "(" << i.edge->_source->id << "--" << i.edge->id << "->" << i.edge->_target->id << ")";
    363363      return os;
    364364    }
     
    427427      friend bool operator!=(Edge u, Edge v) { return v.edge!=u.edge; }
    428428    protected:
    429       Node tailNode() const { return Node(edge->_tail); }
    430       Node headNode() const { return Node(edge->_head); }
     429      Node sourceNode() const { return Node(edge->_source); }
     430      Node targetNode() const { return Node(edge->_target); }
    431431    public:
    432432      friend std::ostream& operator<<(std::ostream& os, const Edge& i);
     
    448448      EdgeIt(edge_item* _e) : Edge(_e) { }
    449449      EdgeIt& operator++() {
    450         node_item* v=edge->_tail;
     450        node_item* v=edge->_source;
    451451        edge=edge->_next_out;
    452452        while (v && !edge) { v=v->_next_node; if (v) edge=v->_first_out_edge; }
     
    468468      OutEdgeIt& operator++() { edge=edge->_next_out; return *this; }
    469469    protected:
    470       Node aNode() const { return Node(edge->_tail); }
    471       Node bNode() const { return Node(edge->_head); }
     470      Node aNode() const { return Node(edge->_source); }
     471      Node bNode() const { return Node(edge->_target); }
    472472    };
    473473   
     
    485485      InEdgeIt& operator++() { edge=edge->_next_in; return *this; }
    486486    protected:
    487       Node aNode() const { return Node(edge->_head); }
    488       Node bNode() const { return Node(edge->_tail); }
     487      Node aNode() const { return Node(edge->_target); }
     488      Node bNode() const { return Node(edge->_source); }
    489489    };
    490490
     
    511511      SymEdgeIt& operator++() {
    512512        if (out_or_in) {
    513           node_item* v=edge->_tail;
     513          node_item* v=edge->_source;
    514514          edge=edge->_next_out;
    515515          if (!edge) { out_or_in=0; edge=v->_first_in_edge; }
     
    521521    protected:
    522522      Node aNode() const {
    523         return (out_or_in) ? Node(edge->_tail) : Node(edge->_head); }
     523        return (out_or_in) ? Node(edge->_source) : Node(edge->_target); }
    524524      Node bNode() const {
    525         return (out_or_in) ? Node(edge->_head) : Node(edge->_tail); }
     525        return (out_or_in) ? Node(edge->_target) : Node(edge->_source); }
    526526    };
    527527
Note: See TracChangeset for help on using the changeset viewer.