COIN-OR::LEMON - Graph Library

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


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/sage_graph.h

    r921 r986  
    9797    struct edge_item {
    9898      int id;
    99       node_item* _tail;
    100       node_item* _head;
     99      node_item* _source;
     100      node_item* _target;
    101101      edge_item* _next_out;
    102102      edge_item* _prev_out;
     
    122122    }
    123123
    124     edge_item* _add_edge(node_item* _tail, node_item* _head) {
     124    edge_item* _add_edge(node_item* _source, node_item* _target) {
    125125      edge_item* e=new edge_item;
    126126      e->id=edge_id++;
    127       e->_tail=_tail;
    128       e->_head=_head;
     127      e->_source=_source;
     128      e->_target=_target;
    129129     
    130       e->_prev_out=_tail->_last_out_edge;
    131       if (_tail->_last_out_edge) (_tail->_last_out_edge)->_next_out=e;
    132       _tail->_last_out_edge=e;
    133       if (!_tail->_first_out_edge) _tail->_first_out_edge=e;
     130      e->_prev_out=_source->_last_out_edge;
     131      if (_source->_last_out_edge) (_source->_last_out_edge)->_next_out=e;
     132      _source->_last_out_edge=e;
     133      if (!_source->_first_out_edge) _source->_first_out_edge=e;
    134134      e->_next_out=0;
    135135 
    136       e->_prev_in=_head->_last_in_edge;
    137       if (_head->_last_in_edge) (_head->_last_in_edge)->_next_in=e;
    138       _head->_last_in_edge=e;
    139       if (!_head->_first_in_edge) { _head->_first_in_edge=e; }
     136      e->_prev_in=_target->_last_in_edge;
     137      if (_target->_last_in_edge) (_target->_last_in_edge)->_next_in=e;
     138      _target->_last_in_edge=e;
     139      if (!_target->_first_in_edge) { _target->_first_in_edge=e; }
    140140      e->_next_in=0;
    141141
     
    157157    void _delete_edge(edge_item* e) {
    158158      if (e->_next_out) (e->_next_out)->_prev_out=e->_prev_out; else
    159         (e->_tail)->_last_out_edge=e->_prev_out;
     159        (e->_source)->_last_out_edge=e->_prev_out;
    160160      if (e->_prev_out) (e->_prev_out)->_next_out=e->_next_out; else
    161         (e->_tail)->_first_out_edge=e->_next_out;
     161        (e->_source)->_first_out_edge=e->_next_out;
    162162      if (e->_next_in) (e->_next_in)->_prev_in=e->_prev_in; else
    163         (e->_head)->_last_in_edge=e->_prev_in;
     163        (e->_target)->_last_in_edge=e->_prev_in;
    164164      if (e->_prev_in) (e->_prev_in)->_next_in=e->_next_in; else
    165         (e->_head)->_first_in_edge=e->_next_in;
     165        (e->_target)->_first_in_edge=e->_next_in;
    166166
    167167      delete e;
     
    169169    }
    170170
    171     void _set_tail(edge_item* e, node_item* _tail) {
     171    void _set_source(edge_item* e, node_item* _source) {
    172172      if (e->_next_out) (e->_next_out)->_prev_out=e->_prev_out; else
    173         (e->_tail)->_last_out_edge=e->_prev_out;
     173        (e->_source)->_last_out_edge=e->_prev_out;
    174174      if (e->_prev_out) (e->_prev_out)->_next_out=e->_next_out; else
    175         (e->_tail)->_first_out_edge=e->_next_out;
     175        (e->_source)->_first_out_edge=e->_next_out;
    176176     
    177       e->_tail=_tail;
     177      e->_source=_source;
    178178     
    179       e->_prev_out=_tail->_last_out_edge;
    180       if (_tail->_last_out_edge) (_tail->_last_out_edge)->_next_out=e;
    181       _tail->_last_out_edge=e;
    182       if (!_tail->_first_out_edge) _tail->_first_out_edge=e;
     179      e->_prev_out=_source->_last_out_edge;
     180      if (_source->_last_out_edge) (_source->_last_out_edge)->_next_out=e;
     181      _source->_last_out_edge=e;
     182      if (!_source->_first_out_edge) _source->_first_out_edge=e;
    183183      e->_next_out=0;
    184184    }
    185185
    186     void _set_head(edge_item* e, node_item* _head) {
     186    void _set_target(edge_item* e, node_item* _target) {
    187187      if (e->_next_in) (e->_next_in)->_prev_in=e->_prev_in; else
    188         (e->_head)->_last_in_edge=e->_prev_in;
     188        (e->_target)->_last_in_edge=e->_prev_in;
    189189      if (e->_prev_in) (e->_prev_in)->_next_in=e->_next_in; else
    190         (e->_head)->_first_in_edge=e->_next_in;
     190        (e->_target)->_first_in_edge=e->_next_in;
    191191     
    192       e->_head=_head;
     192      e->_target=_target;
    193193     
    194       e->_prev_in=_head->_last_in_edge;
    195       if (_head->_last_in_edge) (_head->_last_in_edge)->_next_in=e;
    196       _head->_last_in_edge=e;
    197       if (!_head->_first_in_edge) { _head->_first_in_edge=e; }
     194      e->_prev_in=_target->_last_in_edge;
     195      if (_target->_last_in_edge) (_target->_last_in_edge)->_next_in=e;
     196      _target->_last_in_edge=e;
     197      if (!_target->_first_in_edge) { _target->_first_in_edge=e; }
    198198      e->_next_in=0;
    199199    }
     
    222222    //InEdgeIt firstInEdge(const Node v) const { return InEdgeIt(v); }
    223223    //SymEdgeIt firstSymEdge(const Node v) const { return SymEdgeIt(v); }
    224     Node tail(Edge e) const { return e.tailNode(); }
    225     Node head(Edge e) const { return e.headNode(); }
     224    Node source(Edge e) const { return e.sourceNode(); }
     225    Node target(Edge e) const { return e.targetNode(); }
    226226
    227227    Node aNode(const OutEdgeIt& e) const { return e.aNode(); }
     
    252252    SymEdgeIt& first(SymEdgeIt& e, Node v) const {
    253253      e=SymEdgeIt(*this, v); return e; }
    254     //void getTail(Node& n, const Edge& e) const { n=tail(e); }
    255     //void getHead(Node& n, const Edge& e) const { n=head(e); }
     254    //void getSource(Node& n, const Edge& e) const { n=source(e); }
     255    //void getTarget(Node& n, const Edge& e) const { n=target(e); }
    256256
    257257    //void getANode(Node& n, const OutEdgeIt& e) const { n=e.aNode(); }
     
    330330    }
    331331
    332     void setTail(Edge e, Node tail) {
    333       _set_tail(e.edge, tail.node);
    334     }
    335 
    336     void setHead(Edge e, Node head) {
    337       _set_head(e.edge, head.node);
     332    void setSource(Edge e, Node source) {
     333      _set_source(e.edge, source.node);
     334    }
     335
     336    void setTarget(Edge e, Node target) {
     337      _set_target(e.edge, target.node);
    338338    }
    339339
     
    349349//     friend std::ostream& operator<<(std::ostream& os, const Edge& i) {
    350350//       if (i.valid())
    351 //      os << "(" << i.edge->_tail->id << "--" << i.edge->id << "->" << i.edge->_head->id << ")";
     351//      os << "(" << i.edge->_source->id << "--" << i.edge->id << "->" << i.edge->_target->id << ")";
    352352//       else
    353353//      os << "invalid";
     
    420420      friend bool operator!=(Edge u, Edge v) { return v.edge!=u.edge; }
    421421    protected:
    422       Node tailNode() const { return Node(edge->_tail); }
    423       Node headNode() const { return Node(edge->_head); }
     422      Node sourceNode() const { return Node(edge->_source); }
     423      Node targetNode() const { return Node(edge->_target); }
    424424    public:
    425425      friend std::ostream& operator<<(std::ostream& os, const Edge& i);
     
    441441    public:
    442442      EdgeIt& operator++() {
    443         node_item* v=edge->_tail;
     443        node_item* v=edge->_source;
    444444        edge=edge->_next_out;
    445445        while (v && !edge) { v=v->_next_node; if (v) edge=v->_first_out_edge; }
     
    457457      OutEdgeIt& operator++() { edge=edge->_next_out; return *this; }
    458458    protected:
    459       Node aNode() const { return Node(edge->_tail); }
    460       Node bNode() const { return Node(edge->_head); }
     459      Node aNode() const { return Node(edge->_source); }
     460      Node bNode() const { return Node(edge->_target); }
    461461    };
    462462   
     
    470470      InEdgeIt& operator++() { edge=edge->_next_in; return *this; }
    471471    protected:
    472       Node aNode() const { return Node(edge->_head); }
    473       Node bNode() const { return Node(edge->_tail); }
     472      Node aNode() const { return Node(edge->_target); }
     473      Node bNode() const { return Node(edge->_source); }
    474474    };
    475475
     
    496496      SymEdgeIt& operator++() {
    497497        if (out_or_in) {
    498           node_item* v=edge->_tail;
     498          node_item* v=edge->_source;
    499499          edge=edge->_next_out;
    500500          if (!edge) { out_or_in=0; edge=v->_first_in_edge; }
     
    506506    protected:
    507507      Node aNode() const {
    508         return (out_or_in) ? Node(edge->_tail) : Node(edge->_head); }
     508        return (out_or_in) ? Node(edge->_source) : Node(edge->_target); }
    509509      Node bNode() const {
    510         return (out_or_in) ? Node(edge->_head) : Node(edge->_tail); }
     510        return (out_or_in) ? Node(edge->_target) : Node(edge->_source); }
    511511    };
    512512  };
     
    524524  std::ostream& operator<<(std::ostream& os, const SageGraph::Edge& i) {
    525525    if (i.valid())
    526       os << "(" << i.tailNode() << "--" << i.edge->id << "->"
    527          << i.headNode() << ")";
     526      os << "(" << i.sourceNode() << "--" << i.edge->id << "->"
     527         << i.targetNode() << ")";
    528528    else
    529529      os << "invalid";
Note: See TracChangeset for help on using the changeset viewer.