COIN-OR::LEMON - Graph Library

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


Ignore:
Timestamp:
11/13/04 13:53:28 (20 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
Files:
66 edited

Legend:

Unmodified
Added
Removed
  • src/work/alpar/bfs-named-param.cc

    r945 r986  
    1111struct _BFS_CUSTOM_VIS {};
    1212
    13 template<class GT,class VT,class DVT,class PNT,class PET,class PT >
    14 class _BFS
     13
     14class _Bfs_Traits
     15{
     16  typedef ListGraph Graph;
     17}
     18
     19template<class T>
     20class _Bfs
    1521{
    1622 public:
    17   typedef GT Graph;
    18   typedef VT Visited;
    19   typedef PNT PredNode;
    20   typedef PET PredEdge;
    21   typedef PT Priority;
    22   //  typedef QDT QueueData;
     23  typedef typename T::Graph Graph;
     24  typedef typename T::Reached Reached;
     25  typedef typename T::PredNode PredNode;
     26  typedef typename T::PredEdge PredEdge;
     27  typedef typename T::Priority Priority;
     28 
     29  typedef typename T::DefaultReachedTag DefaultReachedTag;
    2330 
    2431  typedef typename Graph::Node Node;
    2532  typedef typename Graph::OutEdgeIt OutEdgeIt;
    2633
    27   typedef DVT DefaultVisitedTag;
    28  
    2934  const Graph &_graph;
    3035
    3136  Node _source;
    3237 
    33   Visited *_visited;
     38  Reached *_visited;
    3439  PredNode _predNode;
    3540  PredEdge _predEdge;
    3641  Priority _priority;
    3742
    38   _BFS(const Graph &g,
     43  _Bfs(const Graph &g,
    3944       Node s,
    40        Visited *v,
     45       Reached *v,
    4146       PredNode &pn,
    4247       PredEdge &pe,
     
    4651
    4752 
    48   int run(const _BFS_CUSTOM_VIS &)
     53  int run(const _Bfs_CUSTOM_VIS &)
    4954  {
    5055    using namespace std;
     
    6469      Node n=Q[Qt++];
    6570      for(OutEdgeIt e(_graph,n);e!=INVALID;++e)
    66         if(!(*_visited)[m=_graph.head(e)]) {
     71        if(!(*_visited)[m=_graph.target(e)]) {
    6772          Q[Qh++]=m;
    6873          _visited->set(m,true);
     
    7681  int run(const _BFS_DEFAULT_VIS &)
    7782  {
    78     _visited= new Visited(_graph);
     83    _visited= new Reached(_graph);
    7984    int r = run(_BFS_CUSTOM_VIS());
    8085    delete _visited;
    8186    return r;
    8287  }
    83   int run() { return run(DefaultVisitedTag());}
    84 
    85   template<class T> _BFS<Graph,T,_BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>
     88  int run() { return run(DefaultReachedTag());}
     89
     90  template<class T> _Bfs<Graph,T,_BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>
    8691  setVisitMap(T &t)
    8792  {
    88     return _BFS<Graph,T,_BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>
     93    return _Bfs<Graph,T,_BFS_CUSTOM_VIS,PredNode,PredEdge,Priority>
    8994      (_graph,_source,&t,_predNode,_predEdge,_priority);
    9095  }
    9196
    9297  template<class T>
    93   _BFS<Graph,Visited,DefaultVisitedTag,T,PredEdge,Priority>
     98  _Bfs<Graph,Reached,DefaultReachedTag,T,PredEdge,Priority>
    9499  setPredNodeMap(T &t)
    95100  {
    96     return _BFS<Graph,Visited,DefaultVisitedTag,T,PredEdge,Priority>
     101    return _BFS<Graph,Reached,DefaultReachedTag,T,PredEdge,Priority>
    97102      (_graph,_source,
    98103       _visited,
     
    101106
    102107  template<class T>
    103   _BFS<Graph,Visited,DefaultVisitedTag,PredNode,T,Priority>
     108  _BFS<Graph,Reached,DefaultReachedTag,PredNode,T,Priority>
    104109  setPredEdgeMap(T &t)
    105110  {
    106     return _BFS<Graph,Visited,DefaultVisitedTag,PredNode,T,Priority>
     111    return _BFS<Graph,Reached,DefaultReachedTag,PredNode,T,Priority>
    107112      (_graph,_source,
    108113       _visited,
     
    110115  }
    111116
    112   _BFS<Graph,Visited,DefaultVisitedTag,PredNode,PredEdge,Priority>
     117  _Bfs<Graph,Reached,DefaultReachedTag,PredNode,PredEdge,Priority>
    113118  setNothing()
    114119  {
    115     return _BFS<Graph,Visited,DefaultVisitedTag,PredNode,PredEdge,Priority>
     120    return _Bfs<Graph,Reached,DefaultReachedTag,PredNode,PredEdge,Priority>
    116121      (_graph,_source,
    117122       _visited,
     
    122127
    123128template<class G>
    124 _BFS<G,
     129_Bfs<G,
    125130     typename G::template NodeMap<bool>,
    126131     _BFS_DEFAULT_VIS,
     
    132137  //  typename G::template NodeMap<bool> v(g);
    133138
    134   return _BFS < G,
     139  return _Bfs < G,
    135140    typename G::template NodeMap<bool>,
    136141    _BFS_DEFAULT_VIS,
     
    147152
    148153
    149 class MyVisitedMap : public SmartGraph::NodeMap<bool>
     154class MyReachedMap : public SmartGraph::NodeMap<bool>
    150155{
    151156  const SmartGraph &_G;
    152157public:
    153   MyVisitedMap(const SmartGraph &G) : SmartGraph::NodeMap<bool>(G), _G(G) {}
     158  MyReachedMap(const SmartGraph &G) : SmartGraph::NodeMap<bool>(G), _G(G) {}
    154159  void set(SmartGraph::Node n,bool b)
    155160  {
     
    181186  SmartGraph::NodeMap<SmartGraph::Edge> em(G);
    182187
    183   MyVisitedMap vm(G);
     188  MyReachedMap vm(G);
    184189
    185190
  • src/work/alpar/boolmap_iter.cc

    r921 r986  
    120120
    121121  for(EdgeIt e(G);G.valid(e);G.next(e))
    122     std::cout << G.id(G.tail(e)) << "->" << G.id(G.head(e))
     122    std::cout << G.id(G.source(e)) << "->" << G.id(G.target(e))
    123123      << ": " << map[e] << '\n';
    124124  std::cout << "True Edges:\n";
    125125  for(BoolIterEdgeMap<Graph>::TrueIterator i(map);i;++i)
    126     std::cout << G.id(G.tail(i)) << "->" << G.id(G.head(i)) << '\n';
     126    std::cout << G.id(G.source(i)) << "->" << G.id(G.target(i)) << '\n';
    127127  std::cout << "False Edges:\n";
    128128  for(BoolIterEdgeMap<Graph>::FalseIterator i(map);i;++i)
    129     std::cout << G.id(G.tail(i)) << "->" << G.id(G.head(i)) << '\n';
     129    std::cout << G.id(G.source(i)) << "->" << G.id(G.target(i)) << '\n';
    130130}
    131131
  • src/work/alpar/dijkstra.h

    r967 r986  
    394394       
    395395        for(OutEdgeIt e(*G,v); e!=INVALID; ++e) {
    396           Node w=G->head(e);
     396          Node w=G->target(e);
    397397          switch(heap.state(w)) {
    398398          case Heap::PRE_HEAP:
  • src/work/alpar/f_ed_ka.h

    r921 r986  
    8585      c.get(tree.get(t))-f.get(tree.get(t)) : f.get(tree.get(t));
    8686    //FIXME: I would need 'G.opposite(e,n)'
    87     gn = visited.get(t)==1 ? G.tail(tree.get(t)) : G.head(tree.get(t));
     87    gn = visited.get(t)==1 ? G.source(tree.get(t)) : G.target(tree.get(t));
    8888    while(gn!=s) if(visited.get(gn)==1)
    8989      {
    9090        //FIXME: nonstandard gcc extension!
    9191        aug_val <?= c.get(tree.get(gn))-f.get(tree.get(gn));
    92         gn=G.tail(tree.get(gn));
     92        gn=G.source(tree.get(gn));
    9393      }
    9494    else {
    9595      //FIXME: nonstandard gcc extension!
    9696      aug_val <?= f.get(tree.get(gn));
    97       gn=G.head(tree.get(gn));
     97      gn=G.target(tree.get(gn));
    9898    }
    9999       
     
    103103      {
    104104        f.set(tree.get(gn),f.get(tree.get(gn))+aug_val);
    105         gn=G.tail(tree.get(gn));
     105        gn=G.source(tree.get(gn));
    106106      }
    107107    else {
    108108      f.set(tree.get(gn),f.get(tree.get(gn))-aug_val);
    109       gn=G.head(tree.get(gn));
     109      gn=G.target(tree.get(gn));
    110110    }
    111111
  • src/work/alpar/f_ed_ka_demo.cc

    r921 r986  
    4242  //std::cout << "maximum flow: "<< std::endl;
    4343  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    44   //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     44  //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    4545  //}
    4646  //std::cout<<std::endl;
  • src/work/alpar/graph.h

    r253 r986  
    107107      // Lehet, hogy ez a ketto nem kell!!!
    108108     
    109       NodeIterator tail() const {NodeIterator i;i.G=G;i.n=e->From();return i;}
    110       NodeIterator head() const {NodeIterator i;i.G=G;i.n=e->To();return i;}
     109      NodeIterator source() const {NodeIterator i;i.G=G;i.n=e->From();return i;}
     110      NodeIterator target() const {NodeIterator i;i.G=G;i.n=e->To();return i;}
    111111      NodeIterator opposite(const NodeIterator &n) const
    112       {return n==tail()?head():tail();}
     112      {return n==source()?target():source();}
    113113     
    114114      bool valid() {return e;}
     
    191191      {OutEdgeIterator tmp(*this); goNext(); return tmp;}
    192192     
    193       NodeIterator aNode() const {return tail();}
    194       NodeIterator bNode() const {return head();}
     193      NodeIterator aNode() const {return source();}
     194      NodeIterator bNode() const {return target();}
    195195     
    196196      operator const InEdgeIterator ()
     
    219219     
    220220      NodeIterator aNode() const {return n;}
    221       NodeIterator bNode() const {return n.n==tail().n?head():tail();}
     221      NodeIterator bNode() const {return n.n==source().n?target():source();}
    222222     
    223223      operator const InEdgeIterator ()
     
    255255     
    256256      NodeIterator aNode() const {return n;}
    257       NodeIterator bNode() const {return n.n==tail().n?head():tail();}
     257      NodeIterator bNode() const {return n.n==source().n?target():source();}
    258258     
    259259      operator const EdgeIterator ()
     
    464464    {
    465465      return n?
    466         reversed[n-1]?path[n-1].tail():path[n-1].head():
    467         reversed[0]?path[0].head():path[0].tail();
     466        reversed[n-1]?path[n-1].source():path[n-1].target():
     467        reversed[0]?path[0].target():path[0].source();
    468468    }
    469469    void setRevert(int n,bool r=true) {reversed[n]=r;}
     
    471471    {
    472472      path[n]=i;
    473       reversed[n] = i.head()==i.aNode();
     473      reversed[n] = i.target()==i.aNode();
    474474    }
    475475    void setEdge(int n,EdgeIterator i,bool r)
     
    479479    }
    480480
    481     NodeIterator tail() { return getNode(0); }
    482     NodeIterator head() { return getNode(getLength()); }
     481    NodeIterator source() { return getNode(0); }
     482    NodeIterator target() { return getNode(getLength()); }
    483483  };
    484484 
  • src/work/alpar/gwrapper.h

    r921 r986  
    2828  template<typename I> I &goNext(I &i); { return graph->goNext(i); }
    2929
    30   NodeIt head(const EdgeIt &e);
    31   { return graph->head(e); }
    32   NodeIt tail(const EdgeIt &e);
    33   { return graph->tail(e); }
     30  NodeIt target(const EdgeIt &e);
     31  { return graph->target(e); }
     32  NodeIt source(const EdgeIt &e);
     33  { return graph->source(e); }
    3434 
    3535  template<typename I> NodeIt aNode(const I e);
     
    8484  template<typename I> I &goNext(I &i); { return graph->goNext(i); }
    8585
    86   NodeIt head(const EdgeIt &e);
    87   { return graph->tail(e); }
    88   NodeIt tail(const EdgeIt &e);
    89   { return graph->head(e); }
     86  NodeIt target(const EdgeIt &e);
     87  { return graph->source(e); }
     88  NodeIt source(const EdgeIt &e);
     89  { return graph->target(e); }
    9090 
    9191  template<typename I> NodeIt aNode(const I e);
     
    138138//   template<typename I> I &goNext(I &i); { return graph->goNext(i); }
    139139
    140   NodeIt head(const EdgeIt &e);
    141   { return G::tail(e); }
    142   NodeIt tail(const EdgeIt &e);
    143   { return G::head(e); }
     140  NodeIt target(const EdgeIt &e);
     141  { return G::source(e); }
     142  NodeIt source(const EdgeIt &e);
     143  { return G::target(e); }
    144144 
    145145//   template<typename I> NodeIt aNode(const I e);
     
    195195  template<typename I> I &goNext(I &i); { return graph->goNext(i); }
    196196
    197   NodeIt head(const EdgeIt &e);
    198   { return graph->head(e); }
    199   NodeIt tail(const EdgeIt &e);
    200   { return graph->tail(e); }
     197  NodeIt target(const EdgeIt &e);
     198  { return graph->target(e); }
     199  NodeIt source(const EdgeIt &e);
     200  { return graph->source(e); }
    201201 
    202202  template<typename I> NodeIt aNode(const I e);
     
    344344  template<typename I> I next(const I i); { return graph->goNext(i); }
    345345
    346   NodeIt head(const EdgeIt &e);
    347   { return graph->head(e); }
    348   NodeIt tail(const EdgeIt &e);
    349   { return graph->tail(e); }
     346  NodeIt target(const EdgeIt &e);
     347  { return graph->target(e); }
     348  NodeIt source(const EdgeIt &e);
     349  { return graph->source(e); }
    350350 
    351351  template<typename I> NodeIt aNode(const I e);
  • src/work/alpar/list_graph_demo.cc

    r959 r986  
    112112    for(EdgeIt e(G);G.valid(e);G.next(e)) em[e]=G.id(e);
    113113    for(EdgeIt e(G);G.valid(e);G.next(e))
    114       if(G.tail(e)<G.head(e)) sm[e]=G.id(e);
     114      if(G.source(e)<G.target(e)) sm[e]=G.id(e);
    115115   
    116116    for(EdgeIt e(G);G.valid(e);G.next(e))
    117       std::cout << G.id(G.tail(e)) << "->" << G.id(G.head(e))
     117      std::cout << G.id(G.source(e)) << "->" << G.id(G.target(e))
    118118                << ": id=" << G.id(e) << " oppid=" << G.id(G.opposite(e))
    119119                << " em=" << em[e]
  • src/work/alpar/rw_nonref_map.cc

    r921 r986  
    2424    {
    2525      ValueType tmp;
    26       std::cout << G.id(G.tail(e)) << "->"
    27                 << G.id(G.head(e)) << ": ";
     26      std::cout << G.id(G.source(e)) << "->"
     27                << G.id(G.target(e)) << ": ";
    2828      std::cin  >> tmp;
    2929      return tmp;
     
    3131    ValueType operator = (ValueType v) const
    3232    {
    33       std::cout << G.id(G.tail(e)) << "->"
    34                 << G.id(G.head(e)) << ": " << v << '\n';
     33      std::cout << G.id(G.source(e)) << "->"
     34                << G.id(G.target(e)) << ": " << v << '\n';
    3535      return v;
    3636    }
  • src/work/alpar/smart_graph_demo.cc

    r921 r986  
    112112    for(EdgeIt e(G);G.valid(e);G.next(e)) em[e]=G.id(e);
    113113    for(EdgeIt e(G);G.valid(e);G.next(e))
    114       if(G.tail(e)<G.head(e)) sm[e]=G.id(e);
     114      if(G.source(e)<G.target(e)) sm[e]=G.id(e);
    115115   
    116116    for(EdgeIt e(G);G.valid(e);G.next(e))
    117       std::cout << G.id(G.tail(e)) << "->" << G.id(G.head(e))
     117      std::cout << G.id(G.source(e)) << "->" << G.id(G.target(e))
    118118                << ": id=" << G.id(e) << " oppid=" << G.id(G.opposite(e))
    119119                << " em=" << em[e]
  • src/work/athos/bfs_test.cc

    r921 r986  
    4242      OutEdgeIt e;
    4343      for(g.first(e,v); g.valid(e); g.next(e)) {
    44         Node w=g.head(e);
     44        Node w=g.target(e);
    4545        if (!reached[w]) {
    4646          bfs_queue.push(w);
  • src/work/athos/dijkstra_demo.cc

    r921 r986  
    130130    std::cout << "out edges: ";
    131131    for(out_edge_iterator j=flow_test.first_out_edge(i); j.valid(); ++j)
    132       std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " ";
     132      std::cout << node_name.get(flow_test.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.target(j)) << " ";
    133133    std::cout << "in edges: ";
    134134    for(in_edge_iterator j=flow_test.first_in_edge(i); j.valid(); ++j)
    135       std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " ";
     135      std::cout << node_name.get(flow_test.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.target(j)) << " ";
    136136    std::cout << std::endl;
    137137  }
  • src/work/athos/mincostflow.h

    r921 r986  
    7474      ValueType operator[](typename ResGraph::Edge e) const {     
    7575        if (res_graph.forward(e))
    76           return  ol[e]-(pot[res_graph.head(e)]-pot[res_graph.tail(e)]);   
     76          return  ol[e]-(pot[res_graph.target(e)]-pot[res_graph.source(e)]);   
    7777        else
    78           return -ol[e]-(pot[res_graph.head(e)]-pot[res_graph.tail(e)]);   
     78          return -ol[e]-(pot[res_graph.target(e)]-pot[res_graph.source(e)]);   
    7979      }     
    8080       
     
    259259          while ( i != nonabundant_arcs.end() ){
    260260            if (flow[*i]>=buf){
    261               Node a = abundant_components.find(res_graph.head(*i));
    262               Node b = abundant_components.find(res_graph.tail(*i));
     261              Node a = abundant_components.find(res_graph.target(*i));
     262              Node b = abundant_components.find(res_graph.source(*i));
    263263              //Merge
    264264              if (a != b){
     
    285285                  while (n!=non_root){
    286286                    e = bfs_pred[n];
    287                     n = res_graph.tail(e);
     287                    n = res_graph.source(e);
    288288                    res_graph.augment(e,qty_to_augment);
    289289                  }
     
    455455      FOR_EACH_LOC(typename Graph::EdgeIt, e, graph){
    456456        //C^{\Pi}_{i,j}
    457         mod_pot = cost[e]-potential[graph.head(e)]+potential[graph.tail(e)];
     457        mod_pot = cost[e]-potential[graph.target(e)]+potential[graph.source(e)];
    458458        fl_e = flow[e];
    459459        //      std::cout << fl_e << std::endl;
     
    484484          return false;
    485485        }
    486         supdem[graph.tail(e)] += flow[e];
    487         supdem[graph.head(e)] -= flow[e];
     486        supdem[graph.source(e)] += flow[e];
     487        supdem[graph.target(e)] -= flow[e];
    488488      }
    489489      //write_property_vector(supdem, "supdem");
  • src/work/athos/old/minlengthpaths.h

    r921 r986  
    5454       
    5555      ValueType operator[](typename ResGraphType::Edge e) const {     
    56         //if ( (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)] ) <0 ){
     56        //if ( (1-2*rev[e])*ol[e]-(pot[G.target(e)]-pot[G.source(e)] ) <0 ){
    5757        //  std::cout<<"Negative length!!"<<std::endl;
    5858        //}
    59         return (1-2*rev[e])*ol[e]-(pot[G.head(e)]-pot[G.tail(e)]);   
     59        return (1-2*rev[e])*ol[e]-(pot[G.target(e)]-pot[G.source(e)]);   
    6060      }     
    6161       
     
    162162            G.next(e);
    163163          }
    164           n = G.head(e);
     164          n = G.target(e);
    165165          paths[j].push_back(e);
    166166          total_length += length[e];
  • src/work/athos/preflow_push_wogw.h

    r921 r986  
    140140    //This private procedure is supposed to modify the preflow on edge j
    141141    //by value v (which can be positive or negative as well)
    142     //and maintain the excess on the head and tail
     142    //and maintain the excess on the target and source
    143143    //Here we do not check whether this is possible or not
    144144    void modify_preflow(Edge j, const T& v){
     
    148148
    149149
    150       //Modifiyng the head
    151       modify_excess(G.head(j),v);
    152        
    153       //Modifiyng the tail
    154       modify_excess(G.tail(j),-v);
     150      //Modifiyng the target
     151      modify_excess(G.target(j),v);
     152       
     153      //Modifiyng the source
     154      modify_excess(G.source(j),-v);
    155155
    156156    }
     
    273273        InEdgeIt e;
    274274        for(G.first(e,v); G.valid(e); G.next(e)) {
    275           Node w=G.tail(e);
     275          Node w=G.source(e);
    276276          if ( level[w] == number_of_nodes && w != s ) {
    277277            bfs_queue.push(w);
     
    311311      for(OutEdgeIt j=G.template first<OutEdgeIt>(s); G.valid(j); G.next(j)){
    312312        modify_preflow(j,capacity[j] );
    313         make_active(G.head(j));
    314         int lev=level[G.head(j)];
     313        make_active(G.target(j));
     314        int lev=level[G.target(j)];
    315315        if(highest_active<lev){
    316316          highest_active=lev;
     
    326326
    327327      if (capacity[j]>preflow[j]){
    328         if(level[G.tail(j)]==level[G.head(j)]+1){
     328        if(level[G.source(j)]==level[G.target(j)]+1){
    329329          return true;
    330330        }
    331331        else{
    332           if (level[G.head(j)] < new_level)
    333             new_level=level[G.head(j)];
     332          if (level[G.target(j)] < new_level)
     333            new_level=level[G.target(j)];
    334334        }
    335335      }
     
    342342     
    343343      if (0<preflow[j]){
    344         if(level[G.tail(j)]==level[G.head(j)]-1){
     344        if(level[G.source(j)]==level[G.target(j)]-1){
    345345         
    346346          return true;
    347347        }
    348348        else{
    349           if (level[G.tail(j)] < new_level)
    350             new_level=level[G.tail(j)];
     349          if (level[G.source(j)] < new_level)
     350            new_level=level[G.source(j)];
    351351        }
    352352       
     
    389389              e -= v;
    390390              //New node might become active
    391               if (excess[G.head(j)]==0){
    392                 make_active(G.head(j));
     391              if (excess[G.target(j)]==0){
     392                make_active(G.target(j));
    393393              }
    394394              modify_preflow(j,v);
     
    405405              e -= v;
    406406              //New node might become active
    407               if (excess[G.tail(j)]==0){
    408                 make_active(G.tail(j));
     407              if (excess[G.source(j)]==0){
     408                make_active(G.source(j));
    409409              }
    410410              modify_preflow(j,-v);
  • src/work/deba/list_graph.h

    r921 r986  
    4444    struct EdgeT
    4545    {
    46       int head, tail;
     46      int target, source;
    4747      int prev_in, prev_out;
    4848      int next_in, next_out;
     
    105105    int maxEdgeId() const { return edges.size(); }  //FIXME: What is this?
    106106
    107     Node tail(Edge e) const { return edges[e.n].tail; }
    108     Node head(Edge e) const { return edges[e.n].head; }
    109 
    110     Node aNode(OutEdgeIt e) const { return edges[e.n].tail; }
    111     Node aNode(InEdgeIt e) const { return edges[e.n].head; }
    112 
    113     Node bNode(OutEdgeIt e) const { return edges[e.n].head; }
    114     Node bNode(InEdgeIt e) const { return edges[e.n].tail; }
     107    Node source(Edge e) const { return edges[e.n].source; }
     108    Node target(Edge e) const { return edges[e.n].target; }
     109
     110    Node aNode(OutEdgeIt e) const { return edges[e.n].source; }
     111    Node aNode(InEdgeIt e) const { return edges[e.n].target; }
     112
     113    Node bNode(OutEdgeIt e) const { return edges[e.n].target; }
     114    Node bNode(InEdgeIt e) const { return edges[e.n].source; }
    115115
    116116    NodeIt& first(NodeIt& v) const {
     
    152152      else {
    153153        int n;
    154         for(n=nodes[edges[it.n].head].next;
     154        for(n=nodes[edges[it.n].target].next;
    155155            n!=-1 && nodes[n].first_in == -1;
    156156            n = nodes[n].next) ;
     
    208208      }
    209209     
    210       edges[n].tail = u.n; edges[n].head = v.n;
     210      edges[n].source = u.n; edges[n].target = v.n;
    211211
    212212      edges[n].next_out = nodes[u.n].first_out;
     
    233233      if(edges[n].prev_in!=-1)
    234234        edges[edges[n].prev_in].next_in = edges[n].next_in;
    235       else nodes[edges[n].head].first_in = edges[n].next_in;
     235      else nodes[edges[n].target].first_in = edges[n].next_in;
    236236     
    237237      if(edges[n].next_out!=-1)
     
    239239      if(edges[n].prev_out!=-1)
    240240        edges[edges[n].prev_out].next_out = edges[n].next_out;
    241       else nodes[edges[n].tail].first_out = edges[n].next_out;
     241      else nodes[edges[n].source].first_out = edges[n].next_out;
    242242     
    243243      edges[n].next_in = first_free_edge;
  • src/work/jacint/max_flow.h

    r921 r986  
    327327        OutEdgeIt e;
    328328        for(g->first(e,w) ; g->valid(e); g->next(e)) {
    329           Node v=g->head(e);
     329          Node v=g->target(e);
    330330          if (!M[v] && (*flow)[e] < (*capacity)[e] ) {
    331331            queue.push(v);
     
    336336        InEdgeIt f;
    337337        for(g->first(f,w) ; g->valid(f); g->next(f)) {
    338           Node v=g->tail(f);
     338          Node v=g->source(f);
    339339          if (!M[v] && (*flow)[f] > 0 ) {
    340340            queue.push(v);
     
    371371        InEdgeIt e;
    372372        for(g->first(e,w) ; g->valid(e); g->next(e)) {
    373           Node v=g->tail(e);
     373          Node v=g->source(e);
    374374          if (M[v] && (*flow)[e] < (*capacity)[e] ) {
    375375            queue.push(v);
     
    380380        OutEdgeIt f;
    381381        for(g->first(f,w) ; g->valid(f); g->next(f)) {
    382           Node v=g->head(f);
     382          Node v=g->target(f);
    383383          if (M[v] && (*flow)[f] > 0 ) {
    384384            queue.push(v);
     
    434434
    435435        if ( (*flow)[e] >= (*capacity)[e] ) continue;
    436         Node v=g->head(e);
     436        Node v=g->target(e);
    437437
    438438        if( lev > level[v] ) { //Push is allowed now
     
    467467
    468468          if( (*flow)[e] <= 0 ) continue;
    469           Node v=g->tail(e);
     469          Node v=g->source(e);
    470470
    471471          if( lev > level[v] ) { //Push is allowed now
     
    522522            InEdgeIt e;
    523523            for(g->first(e,v); g->valid(e); g->next(e)) {
    524               Node w=g->tail(e);
     524              Node w=g->source(e);
    525525              if ( level[w] == n && w != s ) {
    526526                bfs_queue.push(w);
     
    540540              Num c=(*capacity)[e];
    541541              if ( c <= 0 ) continue;
    542               Node w=g->head(e);
     542              Node w=g->target(e);
    543543              if ( level[w] < n ) {
    544544                if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
     
    567567            for(g->first(e,v); g->valid(e); g->next(e)) {
    568568              if ( (*capacity)[e] <= (*flow)[e] ) continue;
    569               Node w=g->tail(e);
     569              Node w=g->source(e);
    570570              if ( level[w] == n && w != s ) {
    571571                bfs_queue.push(w);
     
    581581            for(g->first(f,v); g->valid(f); g->next(f)) {
    582582              if ( 0 >= (*flow)[f] ) continue;
    583               Node w=g->head(f);
     583              Node w=g->target(f);
    584584              if ( level[w] == n && w != s ) {
    585585                bfs_queue.push(w);
     
    600600              Num rem=(*capacity)[e]-(*flow)[e];
    601601              if ( rem <= 0 ) continue;
    602               Node w=g->head(e);
     602              Node w=g->target(e);
    603603              if ( level[w] < n ) {
    604604                if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
     
    612612            {
    613613              if ( (*flow)[f] <= 0 ) continue;
    614               Node w=g->tail(f);
     614              Node w=g->source(f);
    615615              if ( level[w] < n ) {
    616616                if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
     
    711711      //        return dist[n]; }
    712712      //       bool get(const typename MapGraphWrapper::Edge& e) const {
    713       //        return (dist.get(g->tail(e))<dist.get(g->head(e))); }
     713      //        return (dist.get(g->source(e))<dist.get(g->target(e))); }
    714714      bool operator[](const typename MapGraphWrapper::Edge& e) const {
    715         return (dist[g->tail(e)]<dist[g->head(e)]);
     715        return (dist[g->source(e)]<dist[g->target(e)]);
    716716      }
    717717    };
     
    861861      for(g->first(e,v); g->valid(e); g->next(e)) {
    862862        if ( (*capacity)[e] <= (*flow)[e] ) continue;
    863         Node u=g->tail(e);
     863        Node u=g->source(e);
    864864        if ( level[u] >= n ) {
    865865          bfs_queue.push(u);
     
    872872      for(g->first(f,v); g->valid(f); g->next(f)) {
    873873        if ( 0 >= (*flow)[f] ) continue;
    874         Node u=g->head(f);
     874        Node u=g->target(f);
    875875        if ( level[u] >= n ) {
    876876          bfs_queue.push(u);
     
    926926      ResGWOutEdgeIt e=bfs;
    927927      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    928         Node v=res_graph.tail(e);
    929         Node w=res_graph.head(e);
     928        Node v=res_graph.source(e);
     929        Node w=res_graph.target(e);
    930930        pred.set(w, e);
    931931        if (res_graph.valid(pred[v])) {
     
    934934          free.set(w, res_graph.resCap(e));
    935935        }
    936         if (res_graph.head(e)==t) { _augment=true; break; }
     936        if (res_graph.target(e)==t) { _augment=true; break; }
    937937      }
    938938
     
    946946        ResGWEdge e=pred[n];
    947947        res_graph.augment(e, augment_value);
    948         n=res_graph.tail(e);
     948        n=res_graph.source(e);
    949949      }
    950950    }
     
    984984      ResGWOutEdgeIt e=bfs;
    985985      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    986         Node v=res_graph.tail(e);
    987         Node w=res_graph.head(e);
     986        Node v=res_graph.source(e);
     987        Node w=res_graph.target(e);
    988988        pred.set(w, e);
    989989        if (res_graph.valid(pred[v])) {
     
    992992          free.set(w, res_graph.resCap(e));
    993993        }
    994         if (res_graph.head(e)==t) { _augment=true; break; }
     994        if (res_graph.target(e)==t) { _augment=true; break; }
    995995      }
    996996
     
    10041004        ResGWEdge e=pred[n];
    10051005        res_graph.augment(e, augment_value);
    1006         n=res_graph.tail(e);
     1006        n=res_graph.source(e);
    10071007      }
    10081008    }
     
    10511051      if (res_graph.valid(e)) {
    10521052        if (bfs.isBNodeNewlyReached()) {
    1053           dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
    1054           typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)],
    1055                                         res_graph_to_F[res_graph.head(e)]);
     1053          dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
     1054          typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)],
     1055                                        res_graph_to_F[res_graph.target(e)]);
    10561056          original_edge.update();
    10571057          original_edge.set(f, e);
     
    10591059          residual_capacity.set(f, res_graph.resCap(e));
    10601060        } else {
    1061           if (dist[res_graph.head(e)]==(dist[res_graph.tail(e)]+1)) {
    1062             typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)],
    1063                                           res_graph_to_F[res_graph.head(e)]);
     1061          if (dist[res_graph.target(e)]==(dist[res_graph.source(e)]+1)) {
     1062            typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)],
     1063                                          res_graph_to_F[res_graph.target(e)]);
    10641064            original_edge.update();
    10651065            original_edge.set(f, e);
     
    11151115          typename MG::Edge e=pred[n];
    11161116          res_graph.augment(original_edge[e], augment_value);
    1117           n=F.tail(e);
     1117          n=F.source(e);
    11181118          if (residual_capacity[e]==augment_value)
    11191119            F.erase(e);
     
    11481148      ResGWOutEdgeIt e=bfs;
    11491149      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    1150         dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
     1150        dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
    11511151      }
    11521152      ++bfs;
     
    12481248          typename ErasingResGW::OutEdgeIt e=pred[n];
    12491249          res_graph.augment(e, augment_value);
    1250           n=erasing_res_graph.tail(e);
     1250          n=erasing_res_graph.source(e);
    12511251          if (res_graph.resCap(e)==0)
    12521252            erasing_res_graph.erase(e);
  • src/work/jacint/max_flow_bug.cc

    r921 r986  
    4343  EdgeIt e;
    4444  for(G.first(e); G.valid(e); G.next(e)) {
    45     if (mincut[G.tail(e)] && !mincut[G.head(e)]) min_min_cut_value+=cap[e];
     45    if (mincut[G.source(e)] && !mincut[G.target(e)]) min_min_cut_value+=cap[e];
    4646  }
    4747
     
    5050  int min_cut_value=0;
    5151  for(G.first(e); G.valid(e); G.next(e)) {
    52     if (cut[G.tail(e)] && !cut[G.head(e)])
     52    if (cut[G.source(e)] && !cut[G.target(e)])
    5353      min_cut_value+=cap[e];
    5454  }
     
    5858  int max_min_cut_value=0;
    5959  for(G.first(e); G.valid(e); G.next(e)) {
    60     if (maxcut[G.tail(e)] && !maxcut[G.head(e)])
     60    if (maxcut[G.source(e)] && !maxcut[G.target(e)])
    6161      max_min_cut_value+=cap[e];
    6262      }
     
    8989  int min_min_cut_value2=0;
    9090    for(G.first(e); G.valid(e); G.next(e)) {
    91     if (mincut2[G.tail(e)] && !mincut2[G.head(e)]) min_min_cut_value2+=cap[e];
     91    if (mincut2[G.source(e)] && !mincut2[G.target(e)]) min_min_cut_value2+=cap[e];
    9292  }
    9393
     
    9696  int min_cut_value2=0;
    9797  for(G.first(e); G.valid(e); G.next(e)) {
    98     if (cut2[G.tail(e)] && !cut2[G.head(e)])
     98    if (cut2[G.source(e)] && !cut2[G.target(e)])
    9999      min_cut_value2+=cap[e];
    100100  }
     
    104104  int max_min_cut_value2=0;
    105105  for(G.first(e); G.valid(e); G.next(e)) {
    106     if (maxcut2[G.tail(e)] && !maxcut2[G.head(e)])
     106    if (maxcut2[G.source(e)] && !maxcut2[G.target(e)])
    107107      max_min_cut_value2+=cap[e];
    108108      }
     
    128128  int min_min_cut_value3=0;
    129129  for(G.first(e); G.valid(e); G.next(e)) {
    130     if (mincut3[G.tail(e)] && !mincut3[G.head(e)]) min_min_cut_value3+=cap[e];
     130    if (mincut3[G.source(e)] && !mincut3[G.target(e)]) min_min_cut_value3+=cap[e];
    131131  }
    132132
     
    135135  int min_cut_value3=0;
    136136  for(G.first(e); G.valid(e); G.next(e)) {
    137     if (cut3[G.tail(e)] && !cut3[G.head(e)])
     137    if (cut3[G.source(e)] && !cut3[G.target(e)])
    138138      min_cut_value3+=cap[e];
    139139  }
     
    143143  int max_min_cut_value3=0;
    144144  for(G.first(e); G.valid(e); G.next(e)) {
    145     if (maxcut3[G.tail(e)] && !maxcut3[G.head(e)])
     145    if (maxcut3[G.source(e)] && !maxcut3[G.target(e)])
    146146      max_min_cut_value3+=cap[e];
    147147  }
  • src/work/jacint/max_flow_test.cc

    r921 r986  
    4646  EdgeIt e;
    4747  for(G.first(e); G.valid(e); G.next(e)) {
    48     if (mincut[G.tail(e)] && !mincut[G.head(e)]) min_min_cut_value+=cap[e];
     48    if (mincut[G.source(e)] && !mincut[G.target(e)]) min_min_cut_value+=cap[e];
    4949  }
    5050
     
    5353  int min_cut_value=0;
    5454  for(G.first(e); G.valid(e); G.next(e)) {
    55     if (cut[G.tail(e)] && !cut[G.head(e)])
     55    if (cut[G.source(e)] && !cut[G.target(e)])
    5656      min_cut_value+=cap[e];
    5757  }
     
    6161  int max_min_cut_value=0;
    6262  for(G.first(e); G.valid(e); G.next(e)) {
    63     if (maxcut[G.tail(e)] && !maxcut[G.head(e)])
     63    if (maxcut[G.source(e)] && !maxcut[G.target(e)])
    6464      max_min_cut_value+=cap[e];
    6565      }
     
    9292  int min_min_cut_value2=0;
    9393    for(G.first(e); G.valid(e); G.next(e)) {
    94     if (mincut2[G.tail(e)] && !mincut2[G.head(e)]) min_min_cut_value2+=cap[e];
     94    if (mincut2[G.source(e)] && !mincut2[G.target(e)]) min_min_cut_value2+=cap[e];
    9595  }
    9696
     
    9999  int min_cut_value2=0;
    100100  for(G.first(e); G.valid(e); G.next(e)) {
    101     if (cut2[G.tail(e)] && !cut2[G.head(e)])
     101    if (cut2[G.source(e)] && !cut2[G.target(e)])
    102102      min_cut_value2+=cap[e];
    103103  }
     
    107107  int max_min_cut_value2=0;
    108108  for(G.first(e); G.valid(e); G.next(e)) {
    109     if (maxcut2[G.tail(e)] && !maxcut2[G.head(e)])
     109    if (maxcut2[G.source(e)] && !maxcut2[G.target(e)])
    110110      max_min_cut_value2+=cap[e];
    111111      }
     
    131131  int min_min_cut_value3=0;
    132132  for(G.first(e); G.valid(e); G.next(e)) {
    133     if (mincut3[G.tail(e)] && !mincut3[G.head(e)]) min_min_cut_value3+=cap[e];
     133    if (mincut3[G.source(e)] && !mincut3[G.target(e)]) min_min_cut_value3+=cap[e];
    134134  }
    135135
     
    138138  int min_cut_value3=0;
    139139  for(G.first(e); G.valid(e); G.next(e)) {
    140     if (cut3[G.tail(e)] && !cut3[G.head(e)])
     140    if (cut3[G.source(e)] && !cut3[G.target(e)])
    141141      min_cut_value3+=cap[e];
    142142  }
     
    146146  int max_min_cut_value3=0;
    147147  for(G.first(e); G.valid(e); G.next(e)) {
    148     if (maxcut3[G.tail(e)] && !maxcut3[G.head(e)])
     148    if (maxcut3[G.source(e)] && !maxcut3[G.target(e)])
    149149      max_min_cut_value3+=cap[e];
    150150  }
  • src/work/jacint/max_matching.cc

    r921 r986  
    191191  EdgeIt e;
    192192  for(G.first(e); G.valid(e); G.next(e) ) {
    193     if ( (pos[G.head(e)]==max_matching.C && pos[G.tail(e)]==max_matching.D) ||
    194          (pos[G.head(e)]==max_matching.D && pos[G.tail(e)]==max_matching.C) )
     193    if ( (pos[G.target(e)]==max_matching.C && pos[G.source(e)]==max_matching.D) ||
     194         (pos[G.target(e)]==max_matching.D && pos[G.source(e)]==max_matching.C) )
    195195      noedge=false;
    196196  }
  • src/work/jacint/max_matching.h

    r921 r986  
    154154        Edge e=map[v];
    155155        if ( G.valid(e) )
    156           G.tail(e) == v ? mate.set(v,G.head(e)) : mate.set(v,G.tail(e));
     156          G.source(e) == v ? mate.set(v,G.target(e)) : mate.set(v,G.source(e));
    157157      }
    158158    }
     
    173173      NodeIt e;
    174174      for( G.first(e); G.valid(e); G.next(e)) {
    175         if ( todo[G.head(e)] && todo[G.tail(e)] ) {
    176           Node u=G.tail(e);
    177           Node v=G.head(e);
     175        if ( todo[G.target(e)] && todo[G.source(e)] ) {
     176          Node u=G.source(e);
     177          Node v=G.target(e);
    178178          if ( mate[u]=v && mate[v]=u ) {
    179179            map.set(u,e);
     
    197197      for( G.first(e); G.valid(e); G.next(e)) {
    198198        if ( G.valid(e) ) {
    199           Node u=G.tail(e);       
    200           Node v=G.head(e);
     199          Node u=G.source(e);     
     200          Node v=G.target(e);
    201201          mate.set(u,v);
    202202          mate.set(v,u);
     
    223223      for( G.first(e); G.valid(e); G.next(e)) {
    224224        map.set(e,false);
    225         if ( todo[G.head(e)] && todo[G.tail(e)] ) {
    226           Node u=G.tail(e);
    227           Node v=G.head(e);
     225        if ( todo[G.target(e)] && todo[G.source(e)] ) {
     226          Node u=G.source(e);
     227          Node v=G.target(e);
    228228          if ( mate[u]=v && mate[v]=u ) {
    229229            map.set(e,true);
  • src/work/jacint/max_save.h

    r921 r986  
    259259        OutEdgeIt e;
    260260        for(g->first(e,w) ; g->valid(e); g->next(e)) {
    261           Node v=g->head(e);
     261          Node v=g->target(e);
    262262          if (!M[v] && (*flow)[e] < (*capacity)[e] ) {
    263263            queue.push(v);
     
    268268        InEdgeIt f;
    269269        for(g->first(f,w) ; g->valid(f); g->next(f)) {
    270           Node v=g->tail(f);
     270          Node v=g->source(f);
    271271          if (!M[v] && (*flow)[f] > 0 ) {
    272272            queue.push(v);
     
    305305        InEdgeIt e;
    306306        for(g->first(e,w) ; g->valid(e); g->next(e)) {
    307           Node v=g->tail(e);
     307          Node v=g->source(e);
    308308          if (M[v] && (*flow)[e] < (*capacity)[e] ) {
    309309            queue.push(v);
     
    314314        OutEdgeIt f;
    315315        for(g->first(f,w) ; g->valid(f); g->next(f)) {
    316           Node v=g->head(f);
     316          Node v=g->target(f);
    317317          if (M[v] && (*flow)[f] > 0 ) {
    318318            queue.push(v);
     
    370370           
    371371        if ( (*flow)[e] >= (*capacity)[e] ) continue;
    372         Node v=g->head(e);           
     372        Node v=g->target(e);           
    373373           
    374374        if( lev > level[v] ) { //Push is allowed now
     
    403403         
    404404          if( (*flow)[e] <= 0 ) continue;
    405           Node v=g->tail(e);
     405          Node v=g->source(e);
    406406         
    407407          if( lev > level[v] ) { //Push is allowed now
     
    457457                                  InEdgeIt e;
    458458                                  for(g->first(e,v); g->valid(e); g->next(e)) {
    459                                     Node w=g->tail(e);
     459                                    Node w=g->source(e);
    460460                                    if ( level[w] == n && w != s ) {
    461461                                      bfs_queue.push(w);
     
    475475                                    Num c=(*capacity)[e];
    476476                                    if ( c <= 0 ) continue;
    477                                     Node w=g->head(e);
     477                                    Node w=g->target(e);
    478478                                    if ( level[w] < n ) {         
    479479                                      if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
     
    502502                                  for(g->first(e,v); g->valid(e); g->next(e)) {
    503503                                    if ( (*capacity)[e] <= (*flow)[e] ) continue;
    504                                     Node w=g->tail(e);
     504                                    Node w=g->source(e);
    505505                                    if ( level[w] == n && w != s ) {
    506506                                      bfs_queue.push(w);
     
    516516                                  for(g->first(f,v); g->valid(f); g->next(f)) {
    517517                                    if ( 0 >= (*flow)[f] ) continue;
    518                                     Node w=g->head(f);
     518                                    Node w=g->target(f);
    519519                                    if ( level[w] == n && w != s ) {
    520520                                      bfs_queue.push(w);
     
    535535                                    Num rem=(*capacity)[e]-(*flow)[e];
    536536                                    if ( rem <= 0 ) continue;
    537                                     Node w=g->head(e);
     537                                    Node w=g->target(e);
    538538                                    if ( level[w] < n ) {         
    539539                                      if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
     
    547547                                  {
    548548                                    if ( (*flow)[f] <= 0 ) continue;
    549                                     Node w=g->tail(f);
     549                                    Node w=g->source(f);
    550550                                    if ( level[w] < n ) {         
    551551                                      if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
     
    645645      //        return dist[n]; }
    646646      //       bool get(const typename MapGraphWrapper::Edge& e) const {
    647       //        return (dist.get(g->tail(e))<dist.get(g->head(e))); }
     647      //        return (dist.get(g->source(e))<dist.get(g->target(e))); }
    648648      bool operator[](const typename MapGraphWrapper::Edge& e) const {
    649         return (dist[g->tail(e)]<dist[g->head(e)]);
     649        return (dist[g->source(e)]<dist[g->target(e)]);
    650650      }
    651651    };
     
    784784      for(g->first(e,v); g->valid(e); g->next(e)) {
    785785        if ( (*capacity)[e] <= (*flow)[e] ) continue;
    786         Node u=g->tail(e);
     786        Node u=g->source(e);
    787787        if ( level[u] >= n ) {
    788788          bfs_queue.push(u);
     
    795795      for(g->first(f,v); g->valid(f); g->next(f)) {
    796796        if ( 0 >= (*flow)[f] ) continue;
    797         Node u=g->head(f);
     797        Node u=g->target(f);
    798798        if ( level[u] >= n ) {
    799799          bfs_queue.push(u);
     
    847847      ResGWOutEdgeIt e=bfs;
    848848      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    849         Node v=res_graph.tail(e);
    850         Node w=res_graph.head(e);
     849        Node v=res_graph.source(e);
     850        Node w=res_graph.target(e);
    851851        pred.set(w, e);
    852852        if (res_graph.valid(pred[v])) {
     
    855855          free.set(w, res_graph.resCap(e));
    856856        }
    857         if (res_graph.head(e)==t) { _augment=true; break; }
     857        if (res_graph.target(e)==t) { _augment=true; break; }
    858858      }
    859859       
     
    867867        ResGWEdge e=pred[n];
    868868        res_graph.augment(e, augment_value);
    869         n=res_graph.tail(e);
     869        n=res_graph.source(e);
    870870      }
    871871    }
     
    920920      if (res_graph.valid(e)) {
    921921        if (bfs.isBNodeNewlyReached()) {
    922           dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
    923           typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)], res_graph_to_F[res_graph.head(e)]);
     922          dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
     923          typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)], res_graph_to_F[res_graph.target(e)]);
    924924          original_edge.update();
    925925          original_edge.set(f, e);
     
    927927          residual_capacity.set(f, res_graph.resCap(e));
    928928        } else {
    929           if (dist[res_graph.head(e)]==(dist[res_graph.tail(e)]+1)) {
    930             typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)], res_graph_to_F[res_graph.head(e)]);
     929          if (dist[res_graph.target(e)]==(dist[res_graph.source(e)]+1)) {
     930            typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)], res_graph_to_F[res_graph.target(e)]);
    931931            original_edge.update();
    932932            original_edge.set(f, e);
     
    982982          typename MG::Edge e=pred[n];
    983983          res_graph.augment(original_edge[e], augment_value);
    984           n=F.tail(e);
     984          n=F.source(e);
    985985          if (residual_capacity[e]==augment_value)
    986986            F.erase(e);
     
    10161016      ResGWOutEdgeIt e=bfs;
    10171017      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    1018         dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
     1018        dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
    10191019      }
    10201020      ++bfs;
     
    11131113          typename ErasingResGW::OutEdgeIt e=pred[n];
    11141114          res_graph.augment(e, augment_value);
    1115           n=erasing_res_graph.tail(e);
     1115          n=erasing_res_graph.source(e);
    11161116          if (res_graph.resCap(e)==0)
    11171117            erasing_res_graph.erase(e);
  • src/work/jacint/preflow.cc

    r921 r986  
    4747  for(G.first(e); G.valid(e); G.next(e)) {
    4848    int c=cap[e];
    49     if (mincut[G.tail(e)] && !mincut[G.head(e)]) min_min_cut_value+=c;
    50     if (cut[G.tail(e)] && !cut[G.head(e)]) min_cut_value+=c;
    51     if (maxcut[G.tail(e)] && !maxcut[G.head(e)]) max_min_cut_value+=c;
     49    if (mincut[G.source(e)] && !mincut[G.target(e)]) min_min_cut_value+=c;
     50    if (cut[G.source(e)] && !cut[G.target(e)]) min_cut_value+=c;
     51    if (maxcut[G.source(e)] && !maxcut[G.target(e)]) max_min_cut_value+=c;
    5252  }
    5353
     
    8787  for(G.first(e); G.valid(e); G.next(e)) {
    8888    int c=cap[e];
    89     if (mincut2[G.tail(e)] && !mincut2[G.head(e)]) min_min_cut2_value+=c;
    90     if (cut2[G.tail(e)] && !cut2[G.head(e)]) min_cut2_value+=c;
    91     if (maxcut2[G.tail(e)] && !maxcut2[G.head(e)]) max_min_cut2_value+=c;
     89    if (mincut2[G.source(e)] && !mincut2[G.target(e)]) min_min_cut2_value+=c;
     90    if (cut2[G.source(e)] && !cut2[G.target(e)]) min_cut2_value+=c;
     91    if (maxcut2[G.source(e)] && !maxcut2[G.target(e)]) max_min_cut2_value+=c;
    9292  }
    9393
     
    139139  for(G.first(e); G.valid(e); G.next(e)) {
    140140    int c=cap[e];
    141     if (mincut3[G.tail(e)] && !mincut3[G.head(e)]) min_min_cut3_value+=c;
    142     if (cut3[G.tail(e)] && !cut3[G.head(e)]) min_cut3_value+=c;
    143     if (maxcut3[G.tail(e)] && !maxcut3[G.head(e)]) max_min_cut3_value+=c;
    144     if (actcut3[G.tail(e)] && !actcut3[G.head(e)]) act_min_cut3_value+=c;
     141    if (mincut3[G.source(e)] && !mincut3[G.target(e)]) min_min_cut3_value+=c;
     142    if (cut3[G.source(e)] && !cut3[G.target(e)]) min_cut3_value+=c;
     143    if (maxcut3[G.source(e)] && !maxcut3[G.target(e)]) max_min_cut3_value+=c;
     144    if (actcut3[G.source(e)] && !actcut3[G.target(e)]) act_min_cut3_value+=c;
    145145  }
    146146
     
    196196  for(G.first(e); G.valid(e); G.next(e)) {
    197197    int c=cap[e];
    198     if (mincut4[G.tail(e)] && !mincut4[G.head(e)]) min_min_cut4_value+=c;
    199     if (cut4[G.tail(e)] && !cut4[G.head(e)]) min_cut4_value+=c;
    200     if (maxcut4[G.tail(e)] && !maxcut4[G.head(e)]) max_min_cut4_value+=c;
     198    if (mincut4[G.source(e)] && !mincut4[G.target(e)]) min_min_cut4_value+=c;
     199    if (cut4[G.source(e)] && !cut4[G.target(e)]) min_cut4_value+=c;
     200    if (maxcut4[G.source(e)] && !maxcut4[G.target(e)]) max_min_cut4_value+=c;
    201201  }
    202202
     
    239239  for(G.first(e); G.valid(e); G.next(e)) {
    240240    int c=cap[e];
    241     if (mincut5[G.tail(e)] && !mincut5[G.head(e)]) min_min_cut5_value+=c;
    242     if (cut5[G.tail(e)] && !cut5[G.head(e)]) min_cut5_value+=c;
    243     if (maxcut5[G.tail(e)] && !maxcut5[G.head(e)]) max_min_cut5_value+=c;
     241    if (mincut5[G.source(e)] && !mincut5[G.target(e)]) min_min_cut5_value+=c;
     242    if (cut5[G.source(e)] && !cut5[G.target(e)]) min_cut5_value+=c;
     243    if (maxcut5[G.source(e)] && !maxcut5[G.target(e)]) max_min_cut5_value+=c;
    244244  }
    245245
  • src/work/jacint/preflow_excess.h

    r921 r986  
    137137          InEdgeIt e;
    138138          for(G.first(e,v); G.valid(e); G.next(e)) {
    139             Node w=G.tail(e);
     139            Node w=G.source(e);
    140140            if ( level[w] == n && w != s ) {
    141141              bfs_queue.push(w);
     
    155155          T c=capacity[e];
    156156          if ( c == 0 ) continue;
    157           Node w=G.head(e);
     157          Node w=G.target(e);
    158158          if ( level[w] < n ) {   
    159159            if ( excess[w] == 0 && w!=t ) active[level[w]].push(w);
     
    183183          for(G.first(e,v); G.valid(e); G.next(e)) {
    184184            if ( capacity[e] == flow[e] ) continue;
    185             Node w=G.tail(e);
     185            Node w=G.source(e);
    186186            if ( level[w] == n && w != s ) {
    187187              bfs_queue.push(w);
     
    197197          for(G.first(f,v); G.valid(f); G.next(f)) {
    198198            if ( 0 == flow[f] ) continue;
    199             Node w=G.head(f);
     199            Node w=G.target(f);
    200200            if ( level[w] == n && w != s ) {
    201201              bfs_queue.push(w);
     
    248248          T rem=capacity[e]-flow[e];
    249249          if ( rem == 0 ) continue;
    250           Node w=G.head(e);
     250          Node w=G.target(e);
    251251          if ( level[w] < n ) {   
    252252            if ( excess[w] == 0 && w!=t ) active[level[w]].push(w);
     
    260260        {
    261261          if ( flow[f] == 0 ) continue;
    262           Node w=G.tail(f);
     262          Node w=G.source(f);
    263263          if ( level[w] < n ) {   
    264264            if ( excess[w] == 0 && w!=t ) active[level[w]].push(w);
     
    304304              for(G.first(e,v); G.valid(e); G.next(e)) {
    305305                if ( capacity[e] == flow[e] ) continue;
    306                 Node u=G.tail(e);
     306                Node u=G.source(e);
    307307                if ( level[u] >= n ) {
    308308                  bfs_queue.push(u);
     
    315315              for(G.first(f,v); G.valid(f); G.next(f)) {
    316316                if ( 0 == flow[f] ) continue;
    317                 Node u=G.head(f);
     317                Node u=G.target(f);
    318318                if ( level[u] >= n ) {
    319319                  bfs_queue.push(u);
     
    344344           
    345345            if ( flow[e] == capacity[e] ) continue;
    346             Node v=G.head(e);           
     346            Node v=G.target(e);           
    347347            //e=wv         
    348348           
     
    386386           
    387387            if( flow[e] == 0 ) continue;
    388             Node v=G.tail(e); 
     388            Node v=G.source(e); 
    389389            //e=vw
    390390           
     
    570570        OutEdgeIt e;
    571571        for(G.first(e,w) ; G.valid(e); G.next(e)) {
    572           Node v=G.head(e);
     572          Node v=G.target(e);
    573573          if (!M[v] && flow[e] < capacity[e] ) {
    574574            queue.push(v);
     
    579579        InEdgeIt f;
    580580        for(G.first(f,w) ; G.valid(f); G.next(f)) {
    581           Node v=G.tail(f);
     581          Node v=G.source(f);
    582582          if (!M[v] && flow[f] > 0 ) {
    583583            queue.push(v);
     
    610610        InEdgeIt e;
    611611        for(G.first(e,w) ; G.valid(e); G.next(e)) {
    612           Node v=G.tail(e);
     612          Node v=G.source(e);
    613613          if (!M[v] && flow[e] < capacity[e] ) {
    614614            queue.push(v);
     
    619619        OutEdgeIt f;
    620620        for(G.first(f,w) ; G.valid(f); G.next(f)) {
    621           Node v=G.head(f);
     621          Node v=G.target(f);
    622622          if (!M[v] && flow[f] > 0 ) {
    623623            queue.push(v);
  • src/work/jacint/preflow_excess_test.cc

    r921 r986  
    5353  EdgeIt e;
    5454  for(G.first(e); G.valid(e); G.next(e)) {
    55     if (mincut[G.tail(e)] && !mincut[G.head(e)]) min_min_cut_value+=cap[e];
     55    if (mincut[G.source(e)] && !mincut[G.target(e)]) min_min_cut_value+=cap[e];
    5656  }
    5757
     
    6060  int min_cut_value=0;
    6161  for(G.first(e); G.valid(e); G.next(e)) {
    62     if (cut[G.tail(e)] && !cut[G.head(e)])
     62    if (cut[G.source(e)] && !cut[G.target(e)])
    6363      min_cut_value+=cap[e];
    6464  }
     
    6868  int max_min_cut_value=0;
    6969  for(G.first(e); G.valid(e); G.next(e)) {
    70     if (maxcut[G.tail(e)] && !maxcut[G.head(e)])
     70    if (maxcut[G.source(e)] && !maxcut[G.target(e)])
    7171      max_min_cut_value+=cap[e];
    7272      }
     
    100100  int min_min_cut_value2=0;
    101101    for(G.first(e); G.valid(e); G.next(e)) {
    102     if (mincut2[G.tail(e)] && !mincut2[G.head(e)]) min_min_cut_value2+=cap[e];
     102    if (mincut2[G.source(e)] && !mincut2[G.target(e)]) min_min_cut_value2+=cap[e];
    103103  }
    104104
     
    107107  int min_cut_value2=0;
    108108  for(G.first(e); G.valid(e); G.next(e)) {
    109     if (cut2[G.tail(e)] && !cut2[G.head(e)])
     109    if (cut2[G.source(e)] && !cut2[G.target(e)])
    110110      min_cut_value2+=cap[e];
    111111  }
     
    115115  int max_min_cut_value2=0;
    116116  for(G.first(e); G.valid(e); G.next(e)) {
    117     if (maxcut2[G.tail(e)] && !maxcut2[G.head(e)])
     117    if (maxcut2[G.source(e)] && !maxcut2[G.target(e)])
    118118      max_min_cut_value2+=cap[e];
    119119      }
     
    145145  int min_min_cut_value3=0;
    146146  for(G.first(e); G.valid(e); G.next(e)) {
    147     if (mincut3[G.tail(e)] && !mincut3[G.head(e)]) min_min_cut_value3+=cap[e];
     147    if (mincut3[G.source(e)] && !mincut3[G.target(e)]) min_min_cut_value3+=cap[e];
    148148  }
    149149
     
    152152  int min_cut_value3=0;
    153153  for(G.first(e); G.valid(e); G.next(e)) {
    154     if (cut3[G.tail(e)] && !cut3[G.head(e)])
     154    if (cut3[G.source(e)] && !cut3[G.target(e)])
    155155      min_cut_value3+=cap[e];
    156156  }
     
    160160  int max_min_cut_value3=0;
    161161  for(G.first(e); G.valid(e); G.next(e)) {
    162     if (maxcut3[G.tail(e)] && !maxcut3[G.head(e)])
     162    if (maxcut3[G.source(e)] && !maxcut3[G.target(e)])
    163163      max_min_cut_value3+=cap[e];
    164164      }
  • src/work/jacint/preflow_res.h

    r921 r986  
    103103        for(res_graph.first(e,v); res_graph.valid(e);
    104104            res_graph.next(e)) {
    105           Node w=res_graph.tail(e);
     105          Node w=res_graph.source(e);
    106106          if ( level[w] == n && w != s ) {
    107107            bfs_queue.push(w);
     
    146146      for(res_graph.first(e,s); res_graph.valid(e);
    147147          res_graph.next(e)) {
    148           Node w=res_graph.head(e);
     148          Node w=res_graph.target(e);
    149149          if ( level[w] < n ) {   
    150150            if ( excess[w] == 0 && w!=t ) {
     
    191191              for(res_graph.first(e,v);
    192192                  res_graph.valid(e); res_graph.next(e)) {
    193                 Node u=res_graph.tail(e);
     193                Node u=res_graph.source(e);
    194194                if ( level[u] >= n ) {
    195195                  bfs_queue.push(u);
     
    222222          for(res_graph.first(e,w); res_graph.valid(e); res_graph.next(e)) {
    223223           
    224             Node v=res_graph.head(e);           
     224            Node v=res_graph.target(e);           
    225225            if( lev > level[v] ) {     
    226226              /*Push is allowed now*/
     
    401401        OutEdgeIt e;
    402402        for(G.first(e,w) ; G.valid(e); G.next(e)) {
    403           Node v=G.head(e);
     403          Node v=G.target(e);
    404404          if (!M[v] && flow[e] < capacity[e] ) {
    405405            queue.push(v);
     
    410410        InEdgeIt f;
    411411        for(G.first(f,w) ; G.valid(f); G.next(f)) {
    412           Node v=G.tail(f);
     412          Node v=G.source(f);
    413413          if (!M[v] && flow[f] > 0 ) {
    414414            queue.push(v);
     
    441441        InEdgeIt e;
    442442        for(G.first(e,w) ; G.valid(e); G.next(e)) {
    443           Node v=G.tail(e);
     443          Node v=G.source(e);
    444444          if (!M[v] && flow[e] < capacity[e] ) {
    445445            queue.push(v);
     
    450450        OutEdgeIt f;
    451451        for(G.first(f,w) ; G.valid(f); G.next(f)) {
    452           Node v=G.head(f);
     452          Node v=G.target(f);
    453453          if (!M[v] && flow[f] > 0 ) {
    454454            queue.push(v);
  • src/work/jacint/prim.h

    r921 r986  
    9696          OutEdgeIt e;
    9797          for( G.first(e,v); G.valid(e); G.next(e)) {
    98             Node w=G.head(e);
     98            Node w=G.target(e);
    9999           
    100100            if ( !scanned[w] ) {
     
    112112          InEdgeIt f;
    113113          for( G.first(f,v); G.valid(f); G.next(f)) {
    114             Node w=G.tail(f);
     114            Node w=G.source(f);
    115115           
    116116            if ( !scanned[w] ) {
  • src/work/johanna/ma_order.h

    r921 r986  
    5858          G.first(e,a);
    5959          for (;G.valid(e);G.next(e)) {
    60             Node v = G.head(e); // hmm
     60            Node v = G.target(e); // hmm
    6161            if (heap.state(v) == Heap::IN_HEAP ) {
    6262              heap.decrease(v, heap[v]+1);
  • src/work/marci/augmenting_flow.h

    r970 r986  
    211211        OutEdgeIt e;
    212212        for(g->first(e,w) ; e!=INVALID; ++e) {
    213           Node v=g->head(e);
     213          Node v=g->target(e);
    214214          if (!M[v] && (*flow)[e] < (*capacity)[e] ) {
    215215            queue.push(v);
     
    220220        InEdgeIt f;
    221221        for(g->first(f,w) ; f!=INVALID; ++f) {
    222           Node v=g->tail(f);
     222          Node v=g->source(f);
    223223          if (!M[v] && (*flow)[f] > 0 ) {
    224224            queue.push(v);
     
    271271      ResGWEdge e=bfs;
    272272      if (e!=INVALID && bfs.isBNodeNewlyReached()) {
    273         Node v=res_graph.tail(e);
    274         Node w=res_graph.head(e);
     273        Node v=res_graph.source(e);
     274        Node w=res_graph.target(e);
    275275        pred.set(w, e);
    276276        if (pred[v]!=INVALID) {
     
    279279          free.set(w, res_cap[e]);
    280280        }
    281         if (res_graph.head(e)==t) { _augment=true; break; }
     281        if (res_graph.target(e)==t) { _augment=true; break; }
    282282      }
    283283
     
    291291        ResGWEdge e=pred[n];
    292292        res_graph.augment(e, augment_value);
    293         n=res_graph.tail(e);
     293        n=res_graph.source(e);
    294294      }
    295295    }
     
    330330      ResGWEdge e=bfs;
    331331      if (e!=INVALID && bfs.isBNodeNewlyReached()) {
    332         Node v=res_graph.tail(e);
    333         Node w=res_graph.head(e);
     332        Node v=res_graph.source(e);
     333        Node w=res_graph.target(e);
    334334        pred.set(w, e);
    335335        if (pred[v]!=INVALID) {
     
    338338          free.set(w, res_cap[e]);
    339339        }
    340         if (res_graph.head(e)==t) { _augment=true; break; }
     340        if (res_graph.target(e)==t) { _augment=true; break; }
    341341      }
    342342
     
    350350        ResGWEdge e=pred[n];
    351351        res_graph.augment(e, augment_value);
    352         n=res_graph.tail(e);
     352        n=res_graph.source(e);
    353353      }
    354354    }
     
    396396      if (e!=INVALID) {
    397397        if (bfs.isBNodeNewlyReached()) {
    398           dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
    399           typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)],
    400                                         res_graph_to_F[res_graph.head(e)]);
     398          dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
     399          typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)],
     400                                        res_graph_to_F[res_graph.target(e)]);
    401401          //original_edge.update();
    402402          original_edge.set(f, e);
     
    404404          residual_capacity.set(f, res_cap[e]);
    405405        } else {
    406           if (dist[res_graph.head(e)]==(dist[res_graph.tail(e)]+1)) {
    407             typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)],
    408                                           res_graph_to_F[res_graph.head(e)]);
     406          if (dist[res_graph.target(e)]==(dist[res_graph.source(e)]+1)) {
     407            typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)],
     408                                          res_graph_to_F[res_graph.target(e)]);
    409409            //original_edge.update();
    410410            original_edge.set(f, e);
     
    434434        if (typename MG::Edge(dfs)!=INVALID) {
    435435          if (dfs.isBNodeNewlyReached()) {
    436             typename MG::Node v=F.tail(dfs);
    437             typename MG::Node w=F.head(dfs);
     436            typename MG::Node v=F.source(dfs);
     437            typename MG::Node w=F.target(dfs);
    438438            pred.set(w, dfs);
    439439            if (pred[v]!=INVALID) {
     
    460460          typename MG::Edge e=pred[n];
    461461          res_graph.augment(original_edge[e], augment_value);
    462           n=F.tail(e);
     462          n=F.source(e);
    463463          if (residual_capacity[e]==augment_value)
    464464            F.erase(e);
     
    499499      ResGWEdge e=bfs;
    500500      if (e!=INVALID && bfs.isBNodeNewlyReached())
    501         potential.set(res_graph.head(e), potential[res_graph.tail(e)]+1);
     501        potential.set(res_graph.target(e), potential[res_graph.source(e)]+1);
    502502      ++bfs;
    503503    }
     
    554554          if (dfs.isBNodeNewlyReached()) {
    555555           
    556             typename ErasingResGW::Node v=erasing_res_graph.tail(dfs);
    557             typename ErasingResGW::Node w=erasing_res_graph.head(dfs);
     556            typename ErasingResGW::Node v=erasing_res_graph.source(dfs);
     557            typename ErasingResGW::Node w=erasing_res_graph.target(dfs);
    558558
    559559            pred.set(w, typename ErasingResGW::Edge(dfs));
     
    586586          typename ErasingResGW::Edge e=pred[n];
    587587          res_graph.augment(e, augment_value);
    588           n=erasing_res_graph.tail(e);
     588          n=erasing_res_graph.source(e);
    589589          if (res_cap[e]==0)
    590590            erasing_res_graph.erase(e);
  • src/work/marci/bfs_dfs.h

    r921 r986  
    6464        //graph->first(actual_edge, s);
    6565        if (actual_edge!=INVALID) {
    66           Node w=graph->head(actual_edge);
     66          Node w=graph->target(actual_edge);
    6767          if (!reached[w]) {
    6868            bfs_queue.push(w);
     
    8686        //++actual_edge;
    8787        if (actual_edge!=INVALID) {
    88           Node w=graph->head(actual_edge);
     88          Node w=graph->target(actual_edge);
    8989          if (!reached[w]) {
    9090            bfs_queue.push(w);
     
    101101          //graph->first(actual_edge, bfs_queue.front());
    102102          if (actual_edge!=INVALID) {
    103             Node w=graph->head(actual_edge);
     103            Node w=graph->target(actual_edge);
    104104            if (!reached[w]) {
    105105              bfs_queue.push(w);
     
    125125    bool isANodeExamined() const { return actual_edge==INVALID; }
    126126    /// Returns a-node of the actual edge, so does if the edge is invalid.
    127     Node tail() const { return bfs_queue.front(); }
     127    Node source() const { return bfs_queue.front(); }
    128128    /// \pre The actual edge have to be valid.
    129     Node head() const { return graph->head(actual_edge); }
     129    Node target() const { return graph->target(actual_edge); }
    130130    /// Guess what?
    131131    /// \deprecated
     
    187187      if (this->graph->valid(this->actual_edge) && this->b_node_newly_reached)
    188188      {
    189         pred.set(this->head(), this->actual_edge);
    190         dist.set(this->head(), dist[this->tail()]);
     189        pred.set(this->target(), this->actual_edge);
     190        dist.set(this->target(), dist[this->source()]);
    191191      }
    192192      return *this;
     
    247247      actual_edge=dfs_stack.top();
    248248      if (actual_edge!=INVALID/*.valid()*/) {
    249         Node w=graph->head(actual_edge);
     249        Node w=graph->target(actual_edge);
    250250        actual_node=w;
    251251        if (!reached[w]) {
     
    256256          b_node_newly_reached=true;
    257257        } else {
    258           actual_node=graph->tail(actual_edge);
     258          actual_node=graph->source(actual_edge);
    259259          ++dfs_stack.top();
    260260          b_node_newly_reached=false;
     
    277277    bool isANodeExamined() const { return actual_edge==INVALID; }
    278278    /// Returns a-node of the actual edge, so does if the edge is invalid.
    279     Node tail() const { return actual_node; /*FIXME*/}
     279    Node source() const { return actual_node; /*FIXME*/}
    280280    /// Returns b-node of the actual edge.
    281281    /// \pre The actual edge have to be valid.
    282     Node head() const { return graph->head(actual_edge); }
     282    Node target() const { return graph->target(actual_edge); }
    283283    /// Guess what?
    284284    /// \deprecated
     
    334334      if (this->graph->valid(this->actual_edge) && this->b_node_newly_reached)
    335335      {
    336         pred.set(this->head(), this->actual_edge);
     336        pred.set(this->target(), this->actual_edge);
    337337      }
    338338      return *this;
  • src/work/marci/bfs_mm.h

    r944 r986  
    7272        //graph->first(actual_edge, s);
    7373        if (actual_edge!=INVALID) {
    74           Node w=graph->head(actual_edge);
     74          Node w=graph->target(actual_edge);
    7575          if (!(*reached_map)[w]) {
    7676            bfs_queue.push(w);
     
    9494        //++actual_edge;
    9595        if (actual_edge!=INVALID) {
    96           Node w=graph->head(actual_edge);
     96          Node w=graph->target(actual_edge);
    9797          if (!(*reached_map)[w]) {
    9898            bfs_queue.push(w);
     
    109109          //graph->first(actual_edge, bfs_queue.front());
    110110          if (actual_edge!=INVALID) {
    111             Node w=graph->head(actual_edge);
     111            Node w=graph->target(actual_edge);
    112112            if (!(*reached_map)[w]) {
    113113              bfs_queue.push(w);
     
    133133    bool isANodeExamined() const { return actual_edge==INVALID; }
    134134    /// Returns a-node of the actual edge, so does if the edge is invalid.
    135     Node tail() const { return bfs_queue.front(); }
     135    Node source() const { return bfs_queue.front(); }
    136136    /// \pre The actual edge have to be valid.
    137     Node head() const { return graph->head(actual_edge); }
     137    Node target() const { return graph->target(actual_edge); }
    138138    /// Guess what?
    139139    /// \deprecated
     
    232232      if ((this->actual_edge)!=INVALID && this->b_node_newly_reached)
    233233      {
    234         pred_map->set(this->head(), this->actual_edge);
    235         pred_node_map->set(this->head(), this->tail());
    236         dist_map->set(this->head(), (*dist_map)[this->tail()]);
     234        pred_map->set(this->target(), this->actual_edge);
     235        pred_node_map->set(this->target(), this->source());
     236        dist_map->set(this->target(), (*dist_map)[this->source()]);
    237237      }
    238238      return *this;
     
    458458      actual_edge=dfs_stack.top();
    459459      if (actual_edge!=INVALID/*.valid()*/) {
    460         Node w=graph->head(actual_edge);
     460        Node w=graph->target(actual_edge);
    461461        actual_node=w;
    462462        if (!reached[w]) {
     
    467467          b_node_newly_reached=true;
    468468        } else {
    469           actual_node=graph->tail(actual_edge);
     469          actual_node=graph->source(actual_edge);
    470470          ++dfs_stack.top();
    471471          b_node_newly_reached=false;
     
    488488    bool isANodeExamined() const { return actual_edge==INVALID; }
    489489    /// Returns a-node of the actual edge, so does if the edge is invalid.
    490     Node tail() const { return actual_node; /*FIXME*/}
     490    Node source() const { return actual_node; /*FIXME*/}
    491491    /// Returns b-node of the actual edge.
    492492    /// \pre The actual edge have to be valid.
    493     Node head() const { return graph->head(actual_edge); }
     493    Node target() const { return graph->target(actual_edge); }
    494494    /// Guess what?
    495495    /// \deprecated
     
    545545      if (this->graph->valid(this->actual_edge) && this->b_node_newly_reached)
    546546      {
    547         pred.set(this->head(), this->actual_edge);
     547        pred.set(this->target(), this->actual_edge);
    548548      }
    549549      return *this;
  • src/work/marci/bfs_mm_test.cc

    r959 r986  
    9292
    9393//   for(EdgeIt e(G); e==INVALID; ++e) {
    94 //     Node u=G.tail(e);
    95 //     Node v=G.head(e);
     94//     Node u=G.source(e);
     95//     Node v=G.target(e);
    9696//     check( !bfs_test.reached(u) ||
    9797//         (bfs_test.dist(v) > bfs_test.dist(u)+1),
     
    103103//     if ( bfs_test.pred(v)!=INVALID ) {
    104104//       Edge e=bfs_test.pred(v);
    105 //       Node u=G.tail(e);
     105//       Node u=G.source(e);
    106106//       check(u==bfs_test.predNode(v),"Wrong tree.");
    107107//       check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
  • src/work/marci/bfsit_vs_byhand.cc

    r944 r986  
    4949      bfs_queue.pop();
    5050      for(OutEdgeIt e(g,v); e!=INVALID; ++e) {
    51         Node w=g.head(e);
     51        Node w=g.target(e);
    5252        if (!reached[w]) {
    5353          bfs_queue.push(w);
     
    7171      ++bfs;
    7272      if (Graph::Edge(bfs)!=INVALID && bfs.isBNodeNewlyReached())
    73         pred.set(bfs.head(), Graph::Edge(bfs));
     73        pred.set(bfs.target(), Graph::Edge(bfs));
    7474    }
    7575  }
  • src/work/marci/bipartite_graph_wrapper.h

    r921 r986  
    168168//     InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }
    169169
    170 //     Node tail(const Edge& e) {
    171 //       if (!(*(this->s_false_t_true_map))[this->graph->tail(e)])
    172 //      return Node(this->graph->tail(e));
     170//     Node source(const Edge& e) {
     171//       if (!(*(this->s_false_t_true_map))[this->graph->source(e)])
     172//      return Node(this->graph->source(e));
    173173//       else
    174 //      return Node(this->graph->head(e));     
    175 //     }
    176 //     Node head(const Edge& e) {
    177 //       if (!(*(this->s_false_t_true_map))[this->graph->tail(e)])
    178 //      return Node(this->graph->head(e));
     174//      return Node(this->graph->target(e));   
     175//     }
     176//     Node target(const Edge& e) {
     177//       if (!(*(this->s_false_t_true_map))[this->graph->source(e)])
     178//      return Node(this->graph->target(e));
    179179//       else
    180 //      return Node(this->graph->tail(e));     
     180//      return Node(this->graph->source(e));   
    181181//     }
    182182
     
    253253
    254254    /// A new edge is inserted.
    255     ///\pre \c tail have to be in \c S_Class and \c head in \c T_Class.
    256     Edge addEdge(const Node& tail, const Node& head) {
    257       return Parent::graph->addEdge(tail, head);
     255    ///\pre \c source have to be in \c S_Class and \c target in \c T_Class.
     256    Edge addEdge(const Node& source, const Node& target) {
     257      return Parent::graph->addEdge(source, target);
    258258    }
    259259
     
    696696    }   
    697697
    698     Node tail(const Edge& e) const {
     698    Node source(const Edge& e) const {
    699699      switch (e.spec) {
    700700      case 0:
    701         return Node(this->graph->tail(e));
     701        return Node(this->graph->source(e));
    702702        break;
    703703      case 1:
     
    710710      }
    711711    }
    712     Node head(const Edge& e) const {
     712    Node target(const Edge& e) const {
    713713      switch (e.spec) {
    714714      case 0:
    715         return Node(this->graph->head(e));
     715        return Node(this->graph->target(e));
    716716        break;
    717717      case 1:
     
    733733    }
    734734 
    735     Node aNode(const OutEdgeIt& e) const { return tail(e); }
    736     Node aNode(const InEdgeIt& e) const { return head(e); }
    737     Node bNode(const OutEdgeIt& e) const { return head(e); }
    738     Node bNode(const InEdgeIt& e) const { return tail(e); }
     735    Node aNode(const OutEdgeIt& e) const { return source(e); }
     736    Node aNode(const InEdgeIt& e) const { return target(e); }
     737    Node bNode(const OutEdgeIt& e) const { return target(e); }
     738    Node bNode(const InEdgeIt& e) const { return source(e); }
    739739
    740740    void addNode() const { }
     
    742742   
    743743//    Node addNode() const { return Node(this->graph->addNode()); }
    744 //    Edge addEdge(const Node& tail, const Node& head) const {
    745 //      return Edge(this->graph->addEdge(tail, head)); }
     744//    Edge addEdge(const Node& source, const Node& target) const {
     745//      return Edge(this->graph->addEdge(source, target)); }
    746746
    747747//    void erase(const Node& i) const { this->graph->erase(i); }
  • src/work/marci/bipartite_graph_wrapper_test.cc

    r921 r986  
    8888  cout << "Edges of the bipartite graph:" << endl;
    8989  for (BGW::EdgeIt e(bgw); e!=INVALID; ++e)
    90     cout << g.id(bgw.tail(e)) << "->" << g.id(bgw.head(e)) << endl;
     90    cout << g.id(bgw.source(e)) << "->" << g.id(bgw.target(e)) << endl;
    9191
    9292  BGW::NodeMap<int> dbyj(bgw);
  • src/work/marci/experiment/edmonds_karp.h

    r921 r986  
    4141      //Edge(const Edge& e) : resG(e.resG), sym(e.sym) { }
    4242      Number free() const {
    43         if (resG->G.aNode(sym)==resG->G.tail(sym)) {
     43        if (resG->G.aNode(sym)==resG->G.source(sym)) {
    4444          return (resG->capacity.get(sym)-resG->flow.get(sym));
    4545        } else {
     
    4949      bool valid() const { return sym.valid(); }
    5050      void augment(Number a) const {
    51         if (resG->G.aNode(sym)==resG->G.tail(sym)) {
     51        if (resG->G.aNode(sym)==resG->G.source(sym)) {
    5252          resG->flow.set(sym, resG->flow.get(sym)+a);
    5353          //resG->flow[sym]+=a;
     
    9797    }
    9898
    99     Node tail(Edge e) const { return G.aNode(e.sym); }
    100     Node head(Edge e) const { return G.bNode(e.sym); }
     99    Node source(Edge e) const { return G.aNode(e.sym); }
     100    Node target(Edge e) const { return G.bNode(e.sym); }
    101101
    102102    Node aNode(OutEdgeIt e) const { return G.aNode(e.sym); }
     
    224224    }
    225225
    226     Node tail(Edge e) const {
     226    Node source(Edge e) const {
    227227      return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
    228     Node head(Edge e) const {
     228    Node target(Edge e) const {
    229229      return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
    230230
     
    288288        ResGWOutEdgeIt e=bfs;
    289289        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    290           Node v=res_graph.tail(e);
    291           Node w=res_graph.head(e);
     290          Node v=res_graph.source(e);
     291          Node w=res_graph.target(e);
    292292          pred.set(w, e);
    293293          if (res_graph.valid(pred.get(v))) {
     
    296296            free.set(w, res_graph.resCap(e));
    297297          }
    298           if (res_graph.head(e)==t) { _augment=true; break; }
     298          if (res_graph.target(e)==t) { _augment=true; break; }
    299299        }
    300300       
     
    308308          ResGWEdge e=pred.get(n);
    309309          res_graph.augment(e, augment_value);
    310           n=res_graph.tail(e);
     310          n=res_graph.source(e);
    311311        }
    312312      }
     
    325325      int get(const typename MapGraphWrapper::Node& n) const { return dist[n]; }
    326326      bool get(const typename MapGraphWrapper::Edge& e) const {
    327         return (dist.get(gw.tail(e))<dist.get(gw.head(e)));
     327        return (dist.get(gw.source(e))<dist.get(gw.target(e)));
    328328      }
    329329    };
     
    344344        ResGWOutEdgeIt e=bfs;
    345345        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    346           dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     346          dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    347347        }
    348348        ++bfs;
     
    370370        typename FilterResGW::EdgeIt e;
    371371        for(filter_res_graph.first(e); filter_res_graph.valid(e); filter_res_graph.next(e)) {
    372           //if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    373           typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     372          //if (dist.get(res_graph.target(e))==dist.get(res_graph.source(e))+1) {
     373          typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    374374          original_edge.update();
    375375          original_edge.set(f, e);
     
    424424            typename MG::Edge e=pred.get(n);
    425425            res_graph.augment(original_edge.get(e), augment_value);
    426             n=F.tail(e);
     426            n=F.source(e);
    427427            if (residual_capacity.get(e)==augment_value)
    428428              F.erase(e);
     
    469469        if (res_graph.valid(e)) {
    470470          if (bfs.isBNodeNewlyReached()) {
    471             dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
    472             typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     471            dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
     472            typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    473473            original_edge.update();
    474474            original_edge.set(f, e);
     
    476476            residual_capacity.set(f, res_graph.resCap(e));
    477477          } else {
    478             if (dist.get(res_graph.head(e))==(dist.get(res_graph.tail(e))+1)) {
    479               typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     478            if (dist.get(res_graph.target(e))==(dist.get(res_graph.source(e))+1)) {
     479              typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    480480              original_edge.update();
    481481              original_edge.set(f, e);
     
    532532            typename MG::Edge e=pred.get(n);
    533533            res_graph.augment(original_edge.get(e), augment_value);
    534             n=F.tail(e);
     534            n=F.source(e);
    535535            if (residual_capacity.get(e)==augment_value)
    536536              F.erase(e);
     
    558558        ResGWOutEdgeIt e=bfs;
    559559        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    560           dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     560          dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    561561        }
    562562        ++bfs;
     
    634634            typename ErasingResGW::OutEdgeIt e=pred.get(n);
    635635            res_graph.augment(e, augment_value);
    636             n=erasing_res_graph.tail(e);
     636            n=erasing_res_graph.source(e);
    637637            if (res_graph.resCap(e)==0)
    638638              erasing_res_graph.erase(e);
     
    669669//      typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
    670670//      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    671 //        dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     671//        dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    672672//      }
    673673//      ++bfs; 
     
    723723//          EAugEdge e=pred.get(n);
    724724//          res_graph.augment(e, augment_value);
    725 //          n=res_graph.tail(e);
     725//          n=res_graph.source(e);
    726726//          if (res_graph.free(e)==0)
    727727//            res_graph.erase(e);
     
    818818//      AugOutEdgeIt e=bfs;
    819819//      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    820 //        Node v=res_graph.tail(e);
    821 //        Node w=res_graph.head(e);
     820//        Node v=res_graph.source(e);
     821//        Node w=res_graph.target(e);
    822822//        pred.set(w, e);
    823823//        if (res_graph.valid(pred.get(v))) {
     
    826826//          free.set(w, res_graph.free(e));
    827827//        }
    828 //        n=res_graph.head(e);
     828//        n=res_graph.target(e);
    829829//        if (T->get(n) && (used.get(n)<1) ) {
    830830//          //Number u=0;
     
    848848//        AugEdge e=pred.get(n);
    849849//        res_graph.augment(e, augment_value);
    850 //        n=res_graph.tail(e);
     850//        n=res_graph.source(e);
    851851//      }
    852852//      used.set(n, 1); //mind2 vegen jav
     
    889889// //   AugOutEdgeIt e=bfs;
    890890// //   if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    891 // //     dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     891// //     dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    892892// //   }
    893893       
     
    911911// //       //which are in some shortest paths
    912912// //       for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
    913 // //   if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    914 // //     typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     913// //   if (dist.get(res_graph.target(e))==dist.get(res_graph.source(e))+1) {
     914// //     typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    915915// //     original_edge.update();
    916916// //     original_edge.set(f, e);
     
    964964// //       typename MutableGraph::Edge e=pred.get(n);
    965965// //       res_graph.augment(original_edge.get(e), augment_value);
    966 // //       n=F.tail(e);
     966// //       n=F.source(e);
    967967// //       if (residual_capacity.get(e)==augment_value)
    968968// //         F.erase(e);
     
    10151015//      typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
    10161016//      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    1017 //        dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     1017//        dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    10181018//      }
    10191019//      ++bfs; 
     
    10921092//          EAugEdge e=pred.get(n);
    10931093//          res_graph.augment(e, augment_value);
    1094 //          n=res_graph.tail(e);
     1094//          n=res_graph.source(e);
    10951095//          if (res_graph.free(e)==0)
    10961096//            res_graph.erase(e);
     
    11851185// //   AugOutEdgeIt e=/*AugOutEdgeIt*/(bfs);
    11861186// //   if (e.valid() && bfs.isBNodeNewlyReached()) {
    1187 // //     Node v=res_graph.tail(e);
    1188 // //     Node w=res_graph.head(e);
     1187// //     Node v=res_graph.source(e);
     1188// //     Node w=res_graph.target(e);
    11891189// //     pred.set(w, e);
    11901190// //     if (pred.get(v).valid()) {
     
    11931193// //       free.set(w, e.free());
    11941194// //     }
    1195 // //     if (TMap.get(res_graph.head(e))) {
     1195// //     if (TMap.get(res_graph.target(e))) {
    11961196// //       _augment=true;
    1197 // //       reached_t_node=res_graph.head(e);
     1197// //       reached_t_node=res_graph.target(e);
    11981198// //       break;
    11991199// //     }
     
    12091209// //     AugEdge e=pred.get(n);
    12101210// //     e.augment(augment_value);
    1211 // //     n=res_graph.tail(e);
     1211// //     n=res_graph.source(e);
    12121212// //   }
    12131213// //       }
  • src/work/marci/experiment/edmonds_karp_1.h

    r921 r986  
    4242      //Edge(const Edge& e) : resG(e.resG), sym(e.sym) { }
    4343      Number free() const {
    44         if (resG->G.aNode(sym)==resG->G.tail(sym)) {
     44        if (resG->G.aNode(sym)==resG->G.source(sym)) {
    4545          return (resG->capacity.get(sym)-resG->flow.get(sym));
    4646        } else {
     
    5050      bool valid() const { return sym.valid(); }
    5151      void augment(Number a) const {
    52         if (resG->G.aNode(sym)==resG->G.tail(sym)) {
     52        if (resG->G.aNode(sym)==resG->G.source(sym)) {
    5353          resG->flow.set(sym, resG->flow.get(sym)+a);
    5454          //resG->flow[sym]+=a;
     
    9898    }
    9999
    100     Node tail(Edge e) const { return G.aNode(e.sym); }
    101     Node head(Edge e) const { return G.bNode(e.sym); }
     100    Node source(Edge e) const { return G.aNode(e.sym); }
     101    Node target(Edge e) const { return G.bNode(e.sym); }
    102102
    103103    Node aNode(OutEdgeIt e) const { return G.aNode(e.sym); }
     
    225225    }
    226226
    227     Node tail(Edge e) const {
     227    Node source(Edge e) const {
    228228      return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
    229     Node head(Edge e) const {
     229    Node target(Edge e) const {
    230230      return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
    231231
     
    287287        ResGWOutEdgeIt e=bfs;
    288288        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    289           Node v=res_graph.tail(e);
    290           Node w=res_graph.head(e);
     289          Node v=res_graph.source(e);
     290          Node w=res_graph.target(e);
    291291          pred.set(w, e);
    292292          if (res_graph.valid(pred.get(v))) {
     
    295295            free.set(w, res_graph.resCap(e));
    296296          }
    297           if (res_graph.head(e)==t) { _augment=true; break; }
     297          if (res_graph.target(e)==t) { _augment=true; break; }
    298298        }
    299299       
     
    307307          ResGWEdge e=pred.get(n);
    308308          res_graph.augment(e, augment_value);
    309           n=res_graph.tail(e);
     309          n=res_graph.source(e);
    310310        }
    311311      }
     
    324324      int get(const typename MapGraphWrapper::Node& n) const { return dist[n]; }
    325325      bool get(const typename MapGraphWrapper::Edge& e) const {
    326         return (dist.get(g->tail(e))<dist.get(g->head(e)));
     326        return (dist.get(g->source(e))<dist.get(g->target(e)));
    327327      }
    328328    };
     
    343343        ResGWOutEdgeIt e=bfs;
    344344        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    345           dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     345          dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    346346        }
    347347        ++bfs;
     
    369369        typename FilterResGW::EdgeIt e;
    370370        for(filter_res_graph.first(e); filter_res_graph.valid(e); filter_res_graph.next(e)) {
    371           //if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    372           typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     371          //if (dist.get(res_graph.target(e))==dist.get(res_graph.source(e))+1) {
     372          typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    373373          original_edge.update();
    374374          original_edge.set(f, e);
     
    423423            typename MG::Edge e=pred.get(n);
    424424            res_graph.augment(original_edge.get(e), augment_value);
    425             n=F.tail(e);
     425            n=F.source(e);
    426426            if (residual_capacity.get(e)==augment_value)
    427427              F.erase(e);
     
    468468        if (res_graph.valid(e)) {
    469469          if (bfs.isBNodeNewlyReached()) {
    470             dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
    471             typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     470            dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
     471            typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    472472            original_edge.update();
    473473            original_edge.set(f, e);
     
    475475            residual_capacity.set(f, res_graph.resCap(e));
    476476          } else {
    477             if (dist.get(res_graph.head(e))==(dist.get(res_graph.tail(e))+1)) {
    478               typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     477            if (dist.get(res_graph.target(e))==(dist.get(res_graph.source(e))+1)) {
     478              typename MG::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    479479              original_edge.update();
    480480              original_edge.set(f, e);
     
    531531            typename MG::Edge e=pred.get(n);
    532532            res_graph.augment(original_edge.get(e), augment_value);
    533             n=F.tail(e);
     533            n=F.source(e);
    534534            if (residual_capacity.get(e)==augment_value)
    535535              F.erase(e);
     
    557557        ResGWOutEdgeIt e=bfs;
    558558        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    559           dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     559          dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    560560        }
    561561        ++bfs;
     
    633633            typename ErasingResGW::OutEdgeIt e=pred.get(n);
    634634            res_graph.augment(e, augment_value);
    635             n=erasing_res_graph.tail(e);
     635            n=erasing_res_graph.source(e);
    636636            if (res_graph.resCap(e)==0)
    637637              erasing_res_graph.erase(e);
     
    728728//      AugOutEdgeIt e=bfs;
    729729//      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    730 //        Node v=res_graph.tail(e);
    731 //        Node w=res_graph.head(e);
     730//        Node v=res_graph.source(e);
     731//        Node w=res_graph.target(e);
    732732//        pred.set(w, e);
    733733//        if (res_graph.valid(pred.get(v))) {
     
    736736//          free.set(w, res_graph.free(e));
    737737//        }
    738 //        n=res_graph.head(e);
     738//        n=res_graph.target(e);
    739739//        if (T->get(n) && (used.get(n)<1) ) {
    740740//          //Number u=0;
     
    758758//        AugEdge e=pred.get(n);
    759759//        res_graph.augment(e, augment_value);
    760 //        n=res_graph.tail(e);
     760//        n=res_graph.source(e);
    761761//      }
    762762//      used.set(n, 1); //mind2 vegen jav
     
    799799// //   AugOutEdgeIt e=bfs;
    800800// //   if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    801 // //     dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     801// //     dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    802802// //   }
    803803       
     
    821821// //       //which are in some shortest paths
    822822// //       for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
    823 // //   if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    824 // //     typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     823// //   if (dist.get(res_graph.target(e))==dist.get(res_graph.source(e))+1) {
     824// //     typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    825825// //     original_edge.update();
    826826// //     original_edge.set(f, e);
     
    874874// //       typename MutableGraph::Edge e=pred.get(n);
    875875// //       res_graph.augment(original_edge.get(e), augment_value);
    876 // //       n=F.tail(e);
     876// //       n=F.source(e);
    877877// //       if (residual_capacity.get(e)==augment_value)
    878878// //         F.erase(e);
     
    925925//      typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
    926926//      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    927 //        dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     927//        dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    928928//      }
    929929//      ++bfs; 
     
    10021002//          EAugEdge e=pred.get(n);
    10031003//          res_graph.augment(e, augment_value);
    1004 //          n=res_graph.tail(e);
     1004//          n=res_graph.source(e);
    10051005//          if (res_graph.free(e)==0)
    10061006//            res_graph.erase(e);
     
    10951095// //   AugOutEdgeIt e=/*AugOutEdgeIt*/(bfs);
    10961096// //   if (e.valid() && bfs.isBNodeNewlyReached()) {
    1097 // //     Node v=res_graph.tail(e);
    1098 // //     Node w=res_graph.head(e);
     1097// //     Node v=res_graph.source(e);
     1098// //     Node w=res_graph.target(e);
    10991099// //     pred.set(w, e);
    11001100// //     if (pred.get(v).valid()) {
     
    11031103// //       free.set(w, e.free());
    11041104// //     }
    1105 // //     if (TMap.get(res_graph.head(e))) {
     1105// //     if (TMap.get(res_graph.target(e))) {
    11061106// //       _augment=true;
    1107 // //       reached_t_node=res_graph.head(e);
     1107// //       reached_t_node=res_graph.target(e);
    11081108// //       break;
    11091109// //     }
     
    11191119// //     AugEdge e=pred.get(n);
    11201120// //     e.augment(augment_value);
    1121 // //     n=res_graph.tail(e);
     1121// //     n=res_graph.source(e);
    11221122// //   }
    11231123// //       }
  • src/work/marci/experiment/edmonds_karp_demo.cc

    r921 r986  
    105105    while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) {
    106106//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    107 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    108 //     }
    109 //     std::cout<<std::endl;
    110       ++i;
    111     }
    112 
    113 //   std::cout << "maximum flow: "<< std::endl;
    114 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    115 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     107//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     108//     }
     109//     std::cout<<std::endl;
     110      ++i;
     111    }
     112
     113//   std::cout << "maximum flow: "<< std::endl;
     114//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     115//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    116116//   }
    117117//   std::cout<<std::endl;
     
    136136    while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
    137137//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    138 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    139 //     }
    140 //     std::cout<<std::endl;
    141       ++i;
    142     }
    143 
    144 //   std::cout << "maximum flow: "<< std::endl;
    145 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    146 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     138//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     139//     }
     140//     std::cout<<std::endl;
     141      ++i;
     142    }
     143
     144//   std::cout << "maximum flow: "<< std::endl;
     145//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     146//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    147147//   }
    148148//   std::cout<<std::endl;
     
    167167    while (max_flow_test.augmentOnBlockingFlow2()) {
    168168//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    169 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    170 //     }
    171 //     std::cout<<std::endl;
    172       ++i;
    173     }
    174 
    175 //   std::cout << "maximum flow: "<< std::endl;
    176 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    177 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     169//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     170//     }
     171//     std::cout<<std::endl;
     172      ++i;
     173    }
     174
     175//   std::cout << "maximum flow: "<< std::endl;
     176//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     177//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    178178//   }
    179179//   std::cout<<std::endl;
     
    198198    while (max_flow_test.augmentOnShortestPath()) {
    199199//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    200 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    201 //     }
    202 //     std::cout<<std::endl;
    203       ++i;
    204     }
    205 
    206 //   std::cout << "maximum flow: "<< std::endl;
    207 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    208 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     200//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     201//     }
     202//     std::cout<<std::endl;
     203      ++i;
     204    }
     205
     206//   std::cout << "maximum flow: "<< std::endl;
     207//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     208//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    209209//   }
    210210//   std::cout<<std::endl;
  • src/work/marci/experiment/edmonds_karp_demo_1.cc

    r921 r986  
    105105    while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) {
    106106//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    107 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    108 //     }
    109 //     std::cout<<std::endl;
    110       ++i;
    111     }
    112 
    113 //   std::cout << "maximum flow: "<< std::endl;
    114 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    115 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     107//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     108//     }
     109//     std::cout<<std::endl;
     110      ++i;
     111    }
     112
     113//   std::cout << "maximum flow: "<< std::endl;
     114//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     115//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    116116//   }
    117117//   std::cout<<std::endl;
     
    136136    while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) {
    137137//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    138 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    139 //     }
    140 //     std::cout<<std::endl;
    141       ++i;
    142     }
    143 
    144 //   std::cout << "maximum flow: "<< std::endl;
    145 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    146 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     138//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     139//     }
     140//     std::cout<<std::endl;
     141      ++i;
     142    }
     143
     144//   std::cout << "maximum flow: "<< std::endl;
     145//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     146//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    147147//   }
    148148//   std::cout<<std::endl;
     
    167167    while (max_flow_test.augmentOnBlockingFlow2()) {
    168168//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    169 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    170 //     }
    171 //     std::cout<<std::endl;
    172       ++i;
    173     }
    174 
    175 //   std::cout << "maximum flow: "<< std::endl;
    176 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    177 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     169//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     170//     }
     171//     std::cout<<std::endl;
     172      ++i;
     173    }
     174
     175//   std::cout << "maximum flow: "<< std::endl;
     176//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     177//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    178178//   }
    179179//   std::cout<<std::endl;
     
    198198    while (max_flow_test.augmentOnShortestPath()) {
    199199//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    200 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    201 //     }
    202 //     std::cout<<std::endl;
    203       ++i;
    204     }
    205 
    206 //   std::cout << "maximum flow: "<< std::endl;
    207 //   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    208 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     200//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
     201//     }
     202//     std::cout<<std::endl;
     203      ++i;
     204    }
     205
     206//   std::cout << "maximum flow: "<< std::endl;
     207//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
     208//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    209209//   }
    210210//   std::cout<<std::endl;
  • src/work/marci/experiment/graph_wrapper.h

    r921 r986  
    9797      It e; first(e, v); return e; }
    9898
    99     Node head(const Edge& e) const { return graph->head(e); }
    100     Node tail(const Edge& e) const { return graph->tail(e); }
     99    Node target(const Edge& e) const { return graph->target(e); }
     100    Node source(const Edge& e) const { return graph->source(e); }
    101101
    102102    template<typename I> bool valid(const I& i) const
     
    115115 
    116116    Node addNode() const { return graph->addNode(); }
    117     Edge addEdge(const Node& tail, const Node& head) const {
    118       return graph->addEdge(tail, head); }
     117    Edge addEdge(const Node& source, const Node& target) const {
     118      return graph->addEdge(source, target); }
    119119 
    120120    template<typename I> void erase(const I& i) const { graph->erase(i); }
     
    246246      It e; this->first(e, v); return e; }
    247247
    248     Node head(const Edge& e) const { return gw.head(e); }
    249     Node tail(const Edge& e) const { return gw.tail(e); }
     248    Node target(const Edge& e) const { return gw.target(e); }
     249    Node source(const Edge& e) const { return gw.source(e); }
    250250
    251251    template<typename I> bool valid(const I& i) const { return gw.valid(i); }
     
    261261 
    262262    Node addNode() const { return gw.addNode(); }
    263     Edge addEdge(const Node& tail, const Node& head) const {
    264       return gw.addEdge(tail, head); }
     263    Edge addEdge(const Node& source, const Node& target) const {
     264      return gw.addEdge(source, target); }
    265265 
    266266    template<typename I> void erase(const I& i) const { gw.erase(i); }
     
    323323//       It e; first(e, v); return e; }
    324324
    325 //     Node head(const Edge& e) const { return graph->tail(e); }
    326 //     Node tail(const Edge& e) const { return graph->head(e); }
     325//     Node target(const Edge& e) const { return graph->source(e); }
     326//     Node source(const Edge& e) const { return graph->target(e); }
    327327 
    328328//     template<typename I> bool valid(const I& i) const
     
    338338
    339339//     Node addNode() const { return graph->addNode(); }
    340 //     Edge addEdge(const Node& tail, const Node& head) const {
    341 //       return graph->addEdge(tail, head); }
     340//     Edge addEdge(const Node& source, const Node& target) const {
     341//       return graph->addEdge(source, target); }
    342342 
    343343//     int nodeNum() const { return graph->nodeNum(); }
     
    404404//     //  It e; first(e, v); return e; }
    405405
    406 //     //Node head(const Edge& e) const { return graph->tail(e); }
    407 //     //Node tail(const Edge& e) const { return graph->head(e); }
     406//     //Node target(const Edge& e) const { return graph->source(e); }
     407//     //Node source(const Edge& e) const { return graph->target(e); }
    408408 
    409409//     //template<typename I> bool valid(const I& i) const
     
    419419
    420420//     //Node addNode() const { return graph->addNode(); }
    421 //     //Edge addEdge(const Node& tail, const Node& head) const {
    422 //     //  return graph->addEdge(tail, head); }
     421//     //Edge addEdge(const Node& source, const Node& target) const {
     422//     //  return graph->addEdge(source, target); }
    423423 
    424424//     //int nodeNum() const { return graph->nodeNum(); }
     
    468468      GraphWrapper<GraphWrapper>(_gw) { } 
    469469
    470     Node head(const Edge& e) const
    471       { return GraphWrapper<GraphWrapper>::tail(e); }
    472     Node tail(const Edge& e) const
    473       { return GraphWrapper<GraphWrapper>::head(e); }
     470    Node target(const Edge& e) const
     471      { return GraphWrapper<GraphWrapper>::source(e); }
     472    Node source(const Edge& e) const
     473      { return GraphWrapper<GraphWrapper>::target(e); }
    474474  };
    475475
     
    600600//     OutEdgeIt& next(OutEdgeIt& e) const {
    601601//       if (e.out_or_in) {
    602 //      Node n=gw.tail(e.out);
     602//      Node n=gw.source(e.out);
    603603//      gw.next(e.out);
    604604//      if (!gw.valid(e.out)) {
     
    613613
    614614//     Node aNode(const OutEdgeIt& e) const {
    615 //       if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
     615//       if (e.out_or_in) return gw.source(e); else return gw.target(e); }
    616616//     Node bNode(const OutEdgeIt& e) const {
    617 //       if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
     617//       if (e.out_or_in) return gw.target(e); else return gw.source(e); }
    618618
    619619//     typedef OutEdgeIt InEdgeIt;
     
    633633//       It e; first(e, v); return e; }
    634634
    635 //     Node head(const Edge& e) const { return gw.head(e); }
    636 //     Node tail(const Edge& e) const { return gw.tail(e); }
     635//     Node target(const Edge& e) const { return gw.target(e); }
     636//     Node source(const Edge& e) const { return gw.source(e); }
    637637
    638638//     template<typename I> bool valid(const I& i) const
     
    652652//     Node addNode() const { return gw.addNode(); }
    653653// // FIXME: ez igy nem jo, mert nem
    654 // //    Edge addEdge(const Node& tail, const Node& head) const {
    655 // //      return graph->addEdge(tail, head); }
     654// //    Edge addEdge(const Node& source, const Node& target) const {
     655// //      return graph->addEdge(source, target); }
    656656 
    657657//     template<typename I> void erase(const I& i) const { gw.erase(i); }
     
    799799    OutEdgeIt& next(OutEdgeIt& e) const {
    800800      if (e.out_or_in) {
    801         Node n=gw.tail(e.out);
     801        Node n=gw.source(e.out);
    802802        gw.next(e.out);
    803803        if (!gw.valid(e.out)) { e.out_or_in=false; gw.first(e.in, n); }
     
    809809
    810810    EdgeIt& next(EdgeIt& e) const {
    811       //NodeIt v=tail(e);
     811      //NodeIt v=source(e);
    812812      gw.next(e.out);
    813813      while (valid(e.v) && !gw.valid(e.out)) {
     
    827827      It e; first(e, v); return e; }
    828828
    829 //    Node head(const Edge& e) const { return gw.head(e); }
    830 //    Node tail(const Edge& e) const { return gw.tail(e); }
     829//    Node target(const Edge& e) const { return gw.target(e); }
     830//    Node source(const Edge& e) const { return gw.source(e); }
    831831
    832832//    template<typename I> bool valid(const I& i) const
     
    842842
    843843    Node aNode(const OutEdgeIt& e) const {
    844       if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
     844      if (e.out_or_in) return gw.source(e); else return gw.target(e); }
    845845    Node bNode(const OutEdgeIt& e) const {
    846       if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
     846      if (e.out_or_in) return gw.target(e); else return gw.source(e); }
    847847 
    848848//    Node addNode() const { return gw.addNode(); }
    849849
    850850// FIXME: ez igy nem jo, mert nem
    851 //    Edge addEdge(const Node& tail, const Node& head) const {
    852 //      return graph->addEdge(tail, head); }
     851//    Edge addEdge(const Node& source, const Node& target) const {
     852//      return graph->addEdge(source, target); }
    853853 
    854854//    template<typename I> void erase(const I& i) const { gw.erase(i); }
     
    914914//       It e; first(e, v); return e; }
    915915
    916 //     Node head(const Edge& e) const { return graph->head(e); }
    917 //     Node tail(const Edge& e) const { return graph->tail(e); }
     916//     Node target(const Edge& e) const { return graph->target(e); }
     917//     Node source(const Edge& e) const { return graph->source(e); }
    918918 
    919919//     template<typename I> Node aNode(const I& e) const {
     
    929929 
    930930//     Node addNode() { return graph->addNode(); }
    931 //     Edge addEdge(const Node& tail, const Node& head) {
    932 //       return graph->addEdge(tail, head); }
     931//     Edge addEdge(const Node& source, const Node& target) {
     932//       return graph->addEdge(source, target); }
    933933 
    934934//     template<typename I> void erase(const I& i) { graph->erase(i); }
     
    11811181    }
    11821182
    1183     Node tail(Edge e) const {
     1183    Node source(Edge e) const {
    11841184      return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); }
    1185     Node head(Edge e) const {
     1185    Node target(Edge e) const {
    11861186      return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
    11871187
     
    13121312      OutEdgeIt f=e;
    13131313      this->next(f);
    1314       first_out_edges->set(this->tail(e), f);
     1314      first_out_edges->set(this->source(e), f);
    13151315    }
    13161316  };
     
    13821382//       It e; first(e, v); return e; }
    13831383
    1384 //     //Node head(const Edge& e) const { return gw.head(e); }
    1385 //     //Node tail(const Edge& e) const { return gw.tail(e); }
     1384//     //Node target(const Edge& e) const { return gw.target(e); }
     1385//     //Node source(const Edge& e) const { return gw.source(e); }
    13861386
    13871387//     //template<typename I> bool valid(const I& i) const
     
    13971397 
    13981398//     //Node addNode() const { return gw.addNode(); }
    1399 //     //Edge addEdge(const Node& tail, const Node& head) const {
    1400 //     //  return gw.addEdge(tail, head); }
     1399//     //Edge addEdge(const Node& source, const Node& target) const {
     1400//     //  return gw.addEdge(source, target); }
    14011401 
    14021402//     //void erase(const OutEdgeIt& e) {
    1403 //     //  first_out_edge(this->tail(e))=e;
     1403//     //  first_out_edge(this->source(e))=e;
    14041404//     //}
    14051405//     void erase(const Edge& e) {
    14061406//       OutEdgeIt f(e);
    14071407//       next(f);
    1408 //       first_out_edges.set(this->tail(e), f);
     1408//       first_out_edges.set(this->source(e), f);
    14091409//     }
    14101410//     //template<typename I> void erase(const I& i) const { gw.erase(i); }
     
    14601460//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
    14611461//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
    1462 //       while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e))))
     1462//       while (valid(e) && (dist.get(source(e))/*+1!=*/>=dist.get(target(e))))
    14631463//      ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
    14641464//       return e;
     
    14711471//     OutEdgeIt& next(OutEdgeIt& e) const {
    14721472//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
    1473 //       while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e))))
     1473//       while (valid(e) && (dist.get(source(e))/*+1!*/>=dist.get(target(e))))
    14741474//      ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
    14751475//       return e;
     
    14831483//       OutEdgeIt f(e);
    14841484//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
    1485 //       while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f))))
     1485//       while (valid(f) && (dist.get(source(f))/*+1!=*/>=dist.get(target(f))))
    14861486//      ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
    1487 //       first_out_edges.set(this->tail(e), f);
     1487//       first_out_edges.set(this->source(e), f);
    14881488//     }
    14891489
     
    15081508//       It e; first(e, v); return e; }
    15091509
    1510 //     //Node head(const Edge& e) const { return gw.head(e); }
    1511 //     //Node tail(const Edge& e) const { return gw.tail(e); }
     1510//     //Node target(const Edge& e) const { return gw.target(e); }
     1511//     //Node source(const Edge& e) const { return gw.source(e); }
    15121512
    15131513//     //template<typename I> bool valid(const I& i) const
     
    15261526 
    15271527//     //Node addNode() const { return gw.addNode(); }
    1528 //     //Edge addEdge(const Node& tail, const Node& head) const {
    1529 //     //  return gw.addEdge(tail, head); }
     1528//     //Edge addEdge(const Node& source, const Node& target) const {
     1529//     //  return gw.addEdge(source, target); }
    15301530 
    15311531//     //template<typename I> void erase(const I& i) const { gw.erase(i); }
     
    16701670//       It e; first(e, v); return e; }
    16711671
    1672 //     Node head(const Edge& e) const { return gw.head(e); }
    1673 //     Node tail(const Edge& e) const { return gw.tail(e); }
     1672//     Node target(const Edge& e) const { return gw.target(e); }
     1673//     Node source(const Edge& e) const { return gw.source(e); }
    16741674 
    16751675//     template<typename I> Node aNode(const I& e) const {
     
    16851685 
    16861686//     Node addNode() { return gw.addNode(); }
    1687 //     Edge addEdge(const Node& tail, const Node& head) {
    1688 //       return gw.addEdge(tail, head); }
     1687//     Edge addEdge(const Node& source, const Node& target) {
     1688//       return gw.addEdge(source, target); }
    16891689 
    16901690//     template<typename I> void erase(const I& i) { gw.erase(i); }
  • src/work/marci/experiment/graph_wrapper_1.h

    r921 r986  
    9191      It e; this->first(e, v); return e; }
    9292
    93     Node head(const Edge& e) const { return graph->head(e); }
    94     Node tail(const Edge& e) const { return graph->tail(e); }
     93    Node target(const Edge& e) const { return graph->target(e); }
     94    Node source(const Edge& e) const { return graph->source(e); }
    9595
    9696    template<typename I> bool valid(const I& i) const {
     
    109109 
    110110    Node addNode() const { return graph->addNode(); }
    111     Edge addEdge(const Node& tail, const Node& head) const {
    112       return graph->addEdge(tail, head); }
     111    Edge addEdge(const Node& source, const Node& target) const {
     112      return graph->addEdge(source, target); }
    113113 
    114114    template<typename I> void erase(const I& i) const { graph->erase(i); }
     
    236236      It e; this->first(e, v); return e; }
    237237
    238     Node head(const Edge& e) const { return graph->head(e); }
    239     Node tail(const Edge& e) const { return graph->tail(e); }
     238    Node target(const Edge& e) const { return graph->target(e); }
     239    Node source(const Edge& e) const { return graph->source(e); }
    240240
    241241    template<typename I> bool valid(const I& i) const {
     
    254254 
    255255    Node addNode() const { return graph->addNode(); }
    256     Edge addEdge(const Node& tail, const Node& head) const {
    257       return graph->addEdge(tail, head); }
     256    Edge addEdge(const Node& source, const Node& target) const {
     257      return graph->addEdge(source, target); }
    258258 
    259259    template<typename I> void erase(const I& i) const { graph->erase(i); }
     
    317317//       It e; first(e, v); return e; }
    318318
    319 //     Node head(const Edge& e) const { return graph->tail(e); }
    320 //     Node tail(const Edge& e) const { return graph->head(e); }
     319//     Node target(const Edge& e) const { return graph->source(e); }
     320//     Node source(const Edge& e) const { return graph->target(e); }
    321321 
    322322//     template<typename I> bool valid(const I& i) const
     
    332332
    333333//     Node addNode() const { return graph->addNode(); }
    334 //     Edge addEdge(const Node& tail, const Node& head) const {
    335 //       return graph->addEdge(tail, head); }
     334//     Edge addEdge(const Node& source, const Node& target) const {
     335//       return graph->addEdge(source, target); }
    336336 
    337337//     int nodeNum() const { return graph->nodeNum(); }
     
    379379    RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { } 
    380380
    381     Node head(const Edge& e) const
    382       { return GraphWrapper<Graph>::tail(e); }
    383     Node tail(const Edge& e) const
    384       { return GraphWrapper<Graph>::head(e); }
     381    Node target(const Edge& e) const
     382      { return GraphWrapper<Graph>::source(e); }
     383    Node source(const Edge& e) const
     384      { return GraphWrapper<Graph>::target(e); }
    385385  };
    386386
     
    512512//     OutEdgeIt& next(OutEdgeIt& e) const {
    513513//       if (e.out_or_in) {
    514 //      Node n=gw.tail(e.out);
     514//      Node n=gw.source(e.out);
    515515//      gw.next(e.out);
    516516//      if (!gw.valid(e.out)) {
     
    525525
    526526//     Node aNode(const OutEdgeIt& e) const {
    527 //       if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
     527//       if (e.out_or_in) return gw.source(e); else return gw.target(e); }
    528528//     Node bNode(const OutEdgeIt& e) const {
    529 //       if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
     529//       if (e.out_or_in) return gw.target(e); else return gw.source(e); }
    530530
    531531//     typedef OutEdgeIt InEdgeIt;
     
    545545//       It e; first(e, v); return e; }
    546546
    547 //     Node head(const Edge& e) const { return gw.head(e); }
    548 //     Node tail(const Edge& e) const { return gw.tail(e); }
     547//     Node target(const Edge& e) const { return gw.target(e); }
     548//     Node source(const Edge& e) const { return gw.source(e); }
    549549
    550550//     template<typename I> bool valid(const I& i) const
     
    564564//     Node addNode() const { return gw.addNode(); }
    565565// // FIXME: ez igy nem jo, mert nem
    566 // //    Edge addEdge(const Node& tail, const Node& head) const {
    567 // //      return graph->addEdge(tail, head); }
     566// //    Edge addEdge(const Node& source, const Node& target) const {
     567// //      return graph->addEdge(source, target); }
    568568 
    569569//     template<typename I> void erase(const I& i) const { gw.erase(i); }
     
    693693    OutEdgeIt& next(OutEdgeIt& e) const {
    694694      if (e.out_or_in) {
    695         Node n=graph->tail(e.out);
     695        Node n=graph->source(e.out);
    696696        graph->next(e.out);
    697697        if (!graph->valid(e.out)) { e.out_or_in=false; graph->first(e.in, n); }
     
    703703
    704704    EdgeIt& next(EdgeIt& e) const {
    705       //NodeIt v=tail(e);
     705      //NodeIt v=source(e);
    706706      graph->next(e.out);
    707707      while (valid(e.v) && !graph->valid(e.out)) {
     
    721721      It e; this->first(e, v); return e; }
    722722
    723 //    Node head(const Edge& e) const { return gw.head(e); }
    724 //    Node tail(const Edge& e) const { return gw.tail(e); }
     723//    Node target(const Edge& e) const { return gw.target(e); }
     724//    Node source(const Edge& e) const { return gw.source(e); }
    725725
    726726//    template<typename I> bool valid(const I& i) const
     
    736736
    737737    Node aNode(const OutEdgeIt& e) const {
    738       if (e.out_or_in) return graph->tail(e); else return graph->head(e); }
     738      if (e.out_or_in) return graph->source(e); else return graph->target(e); }
    739739    Node bNode(const OutEdgeIt& e) const {
    740       if (e.out_or_in) return graph->head(e); else return graph->tail(e); }
     740      if (e.out_or_in) return graph->target(e); else return graph->source(e); }
    741741 
    742742//    Node addNode() const { return gw.addNode(); }
    743743
    744744// FIXME: ez igy nem jo, mert nem
    745 //    Edge addEdge(const Node& tail, const Node& head) const {
    746 //      return graph->addEdge(tail, head); }
     745//    Edge addEdge(const Node& source, const Node& target) const {
     746//      return graph->addEdge(source, target); }
    747747 
    748748//    template<typename I> void erase(const I& i) const { gw.erase(i); }
     
    808808//       It e; first(e, v); return e; }
    809809
    810 //     Node head(const Edge& e) const { return graph->head(e); }
    811 //     Node tail(const Edge& e) const { return graph->tail(e); }
     810//     Node target(const Edge& e) const { return graph->target(e); }
     811//     Node source(const Edge& e) const { return graph->source(e); }
    812812 
    813813//     template<typename I> Node aNode(const I& e) const {
     
    823823 
    824824//     Node addNode() { return graph->addNode(); }
    825 //     Edge addEdge(const Node& tail, const Node& head) {
    826 //       return graph->addEdge(tail, head); }
     825//     Edge addEdge(const Node& source, const Node& target) {
     826//       return graph->addEdge(source, target); }
    827827 
    828828//     template<typename I> void erase(const I& i) { graph->erase(i); }
     
    10641064    }
    10651065
    1066     Node tail(Edge e) const {
     1066    Node source(Edge e) const {
    10671067      return ((e.out_or_in) ? graph->aNode(e.out) : graph->aNode(e.in)); }
    1068     Node head(Edge e) const {
     1068    Node target(Edge e) const {
    10691069      return ((e.out_or_in) ? graph->bNode(e.out) : graph->bNode(e.in)); }
    10701070
     
    11931193      OutEdgeIt f=e;
    11941194      this->next(f);
    1195       first_out_edges->set(this->tail(e), f);
     1195      first_out_edges->set(this->source(e), f);
    11961196    }
    11971197  };
     
    13111311//       It e; first(e, v); return e; }
    13121312
    1313 //     Node head(const Edge& e) const { return gw.head(e); }
    1314 //     Node tail(const Edge& e) const { return gw.tail(e); }
     1313//     Node target(const Edge& e) const { return gw.target(e); }
     1314//     Node source(const Edge& e) const { return gw.source(e); }
    13151315 
    13161316//     template<typename I> Node aNode(const I& e) const {
     
    13261326 
    13271327//     Node addNode() { return gw.addNode(); }
    1328 //     Edge addEdge(const Node& tail, const Node& head) {
    1329 //       return gw.addEdge(tail, head); }
     1328//     Edge addEdge(const Node& source, const Node& target) {
     1329//       return gw.addEdge(source, target); }
    13301330 
    13311331//     template<typename I> void erase(const I& i) { gw.erase(i); }
  • src/work/marci/experiment/graph_wrapper_st_ostream_op.h

    r921 r986  
    167167    EdgeIt& next(EdgeIt& i) const { graph->next(i.e); return i; }   
    168168
    169     Node tail(const Edge& e) const {
    170       return Node(graph->tail(static_cast<typename Graph::Edge>(e))); }
    171     Node head(const Edge& e) const {
    172       return Node(graph->head(static_cast<typename Graph::Edge>(e))); }
     169    Node source(const Edge& e) const {
     170      return Node(graph->source(static_cast<typename Graph::Edge>(e))); }
     171    Node target(const Edge& e) const {
     172      return Node(graph->target(static_cast<typename Graph::Edge>(e))); }
    173173
    174174    bool valid(const Node& n) const {
     
    186186 
    187187    Node addNode() const { return Node(graph->addNode()); }
    188     Edge addEdge(const Node& tail, const Node& head) const {
    189       return Edge(graph->addEdge(tail, head)); }
     188    Edge addEdge(const Node& source, const Node& target) const {
     189      return Edge(graph->addEdge(source, target)); }
    190190
    191191    void erase(const Node& i) const { graph->erase(i); }
     
    273273      return Node(this->graph->bNode(e.e)); }
    274274
    275     Node tail(const Edge& e) const {
    276       return GraphWrapper<Graph>::head(e); }
    277     Node head(const Edge& e) const {
    278       return GraphWrapper<Graph>::tail(e); }
     275    Node source(const Edge& e) const {
     276      return GraphWrapper<Graph>::target(e); }
     277    Node target(const Edge& e) const {
     278      return GraphWrapper<Graph>::source(e); }
    279279
    280280  };
     
    490490    OutEdgeIt& next(OutEdgeIt& e) const {
    491491      if (e.out_or_in) {
    492         typename Graph::Node n=this->graph->tail(e.out);
     492        typename Graph::Node n=this->graph->source(e.out);
    493493        this->graph->next(e.out);
    494494        if (!this->graph->valid(e.out)) {
     
    507507
    508508    Node aNode(const OutEdgeIt& e) const {
    509       if (e.out_or_in) return this->graph->tail(e); else
    510         return this->graph->head(e); }
     509      if (e.out_or_in) return this->graph->source(e); else
     510        return this->graph->target(e); }
    511511    Node bNode(const OutEdgeIt& e) const {
    512       if (e.out_or_in) return this->graph->head(e); else
    513         return this->graph->tail(e); }
     512      if (e.out_or_in) return this->graph->target(e); else
     513        return this->graph->source(e); }
    514514  };
    515515 
     
    725725    }
    726726
    727     Node tail(Edge e) const {
    728       return ((e.forward) ? this->graph->tail(e) : this->graph->head(e)); }
    729     Node head(Edge e) const {
    730       return ((e.forward) ? this->graph->head(e) : this->graph->tail(e)); }
     727    Node source(Edge e) const {
     728      return ((e.forward) ? this->graph->source(e) : this->graph->target(e)); }
     729    Node target(Edge e) const {
     730      return ((e.forward) ? this->graph->target(e) : this->graph->source(e)); }
    731731
    732732    Node aNode(OutEdgeIt e) const {
     
    914914      OutEdgeIt f=e;
    915915      this->next(f);
    916       first_out_edges->set(this->tail(e), f.e);
     916      first_out_edges->set(this->source(e), f.e);
    917917    }
    918918  };
     
    10421042    InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }
    10431043
    1044     Node tail(const Edge& e) {
    1045       if (!(*(this->s_false_t_true_map))[this->graph->tail(e)])
    1046         return Node(this->graph->tail(e));
     1044    Node source(const Edge& e) {
     1045      if (!(*(this->s_false_t_true_map))[this->graph->source(e)])
     1046        return Node(this->graph->source(e));
    10471047      else
    1048         return Node(this->graph->head(e));     
    1049     }
    1050     Node head(const Edge& e) {
    1051       if (!(*(this->s_false_t_true_map))[this->graph->tail(e)])
    1052         return Node(this->graph->head(e));
     1048        return Node(this->graph->target(e));   
     1049    }
     1050    Node target(const Edge& e) {
     1051      if (!(*(this->s_false_t_true_map))[this->graph->source(e)])
     1052        return Node(this->graph->target(e));
    10531053      else
    1054         return Node(this->graph->tail(e));     
     1054        return Node(this->graph->source(e));   
    10551055    }
    10561056
     
    14701470    }   
    14711471
    1472     Node tail(const Edge& e) const {
     1472    Node source(const Edge& e) const {
    14731473      switch (e.spec) {
    14741474      case 0:
    1475         return Node(this->graph->tail(e));
     1475        return Node(this->graph->source(e));
    14761476        break;
    14771477      case 1:
     
    14841484      }
    14851485    }
    1486     Node head(const Edge& e) const {
     1486    Node target(const Edge& e) const {
    14871487      switch (e.spec) {
    14881488      case 0:
    1489         return Node(this->graph->head(e));
     1489        return Node(this->graph->target(e));
    14901490        break;
    14911491      case 1:
     
    15071507    }
    15081508 
    1509     Node aNode(const OutEdgeIt& e) const { return tail(e); }
    1510     Node aNode(const InEdgeIt& e) const { return head(e); }
    1511     Node bNode(const OutEdgeIt& e) const { return head(e); }
    1512     Node bNode(const InEdgeIt& e) const { return tail(e); }
     1509    Node aNode(const OutEdgeIt& e) const { return source(e); }
     1510    Node aNode(const InEdgeIt& e) const { return target(e); }
     1511    Node bNode(const OutEdgeIt& e) const { return target(e); }
     1512    Node bNode(const InEdgeIt& e) const { return source(e); }
    15131513
    15141514    void addNode() const { }
     
    15161516   
    15171517//    Node addNode() const { return Node(this->graph->addNode()); }
    1518 //    Edge addEdge(const Node& tail, const Node& head) const {
    1519 //      return Edge(this->graph->addEdge(tail, head)); }
     1518//    Edge addEdge(const Node& source, const Node& target) const {
     1519//      return Edge(this->graph->addEdge(source, target)); }
    15201520
    15211521//    void erase(const Node& i) const { this->graph->erase(i); }
  • src/work/marci/experiment/iterator_bfs_demo.cc

    r921 r986  
    2323  string get(typename Graph::Edge e) const {
    2424    return
    25       (node_name_map.get(graph.tail(e))+"->"+node_name_map.get(graph.head(e)));
     25      (node_name_map.get(graph.source(e))+"->"+node_name_map.get(graph.target(e)));
    2626  }
    2727};
  • src/work/marci/experiment/iterator_bfs_demo_1.cc

    r921 r986  
    2323  string get(typename Graph::Edge e) const {
    2424    return
    25       (node_name_map.get(graph.tail(e))+"->"+node_name_map.get(graph.head(e)));
     25      (node_name_map.get(graph.source(e))+"->"+node_name_map.get(graph.target(e)));
    2626  }
    2727};
  • 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
  • src/work/marci/graph_concept.h

    r921 r986  
    104104
    105105
    106     /// Gives back the head node of an edge.
    107     Node head(const Edge&) const { return INVALID; }
    108     /// Gives back the tail node of an edge.
    109     Node tail(const Edge&) const { return INVALID; }
     106    /// Gives back the target node of an edge.
     107    Node target(const Edge&) const { return INVALID; }
     108    /// Gives back the source node of an edge.
     109    Node source(const Edge&) const { return INVALID; }
    110110 
    111111    //   Node aNode(SymEdgeIt) const {}
     
    143143    /// \brief Add a new edge to the graph.
    144144    ///
    145     /// Add a new edge to the graph with tail node \c tail
    146     /// and head node \c head.
     145    /// Add a new edge to the graph with source node \c source
     146    /// and target node \c target.
    147147    /// \return the new edge.
    148     Edge addEdge(const Node& tail, const Node& head) { return INVALID; }
     148    Edge addEdge(const Node& source, const Node& target) { return INVALID; }
    149149   
    150150    /// \brief Resets the graph.
  • src/work/marci/iterator_bfs_demo.cc

    r921 r986  
    2424  string operator[](typename Graph::Edge e) const {
    2525    return
    26       (node_name_map[graph.tail(e)]+"->"+node_name_map[graph.head(e)]);
     26      (node_name_map[graph.source(e)]+"->"+node_name_map[graph.target(e)]);
    2727  }
    2828};
     
    9696      if (Graph::Edge(bfs)!=INVALID) {
    9797        cout << edge_name[bfs] << /*endl*/", " <<
    98           node_name[G.tail(bfs)] <<
    99           (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    100           node_name[G.head(bfs)] <<
     98          node_name[G.source(bfs)] <<
     99          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     100          node_name[G.target(bfs)] <<
    101101          (bfs.isBNodeNewlyReached() ? ": is newly reached." :
    102102           ": is not newly reached.");
    103103      } else {
    104104        cout << "invalid" << /*endl*/", " <<
    105           node_name[bfs.tail()] <<
     105          node_name[bfs.source()] <<
    106106          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    107107         
     
    130130      if (Graph::Edge(dfs)!=INVALID) {
    131131        cout << edge_name[dfs] << /*endl*/", " <<
    132           node_name[G.tail(dfs)] <<
    133           (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    134           node_name[G.head(dfs)] <<
     132          node_name[G.source(dfs)] <<
     133          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     134          node_name[G.target(dfs)] <<
    135135          (dfs.isBNodeNewlyReached() ? ": is newly reached." :
    136136           ": is not newly reached.");
    137137      } else {
    138138        cout << "invalid" << /*endl*/", " <<
    139           node_name[dfs.tail()] <<
     139          node_name[dfs.source()] <<
    140140          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    141141         
     
    172172      if (GW::Edge(bfs)!=INVALID) {
    173173        cout << edge_name[GW::Edge(bfs)] << /*endl*/", " <<
    174           node_name[gw.tail(bfs)] <<
    175           (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    176           node_name[gw.head(bfs)] <<
     174          node_name[gw.source(bfs)] <<
     175          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     176          node_name[gw.target(bfs)] <<
    177177          (bfs.isBNodeNewlyReached() ? ": is newly reached." :
    178178           ": is not newly reached.");
    179179      } else {
    180180        cout << "invalid" << /*endl*/", " <<
    181           node_name[bfs.tail()] <<
     181          node_name[bfs.source()] <<
    182182          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    183183         
     
    206206      if (GW::Edge(dfs)!=INVALID) {
    207207        cout << edge_name[GW::Edge(dfs)] << /*endl*/", " <<
    208           node_name[gw.tail(dfs)] <<
    209           (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    210           node_name[gw.head(dfs)] <<
     208          node_name[gw.source(dfs)] <<
     209          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     210          node_name[gw.target(dfs)] <<
    211211          (dfs.isBNodeNewlyReached() ? ": is newly reached." :
    212212           ": is not newly reached.");
    213213      } else {
    214214        cout << "invalid" << /*endl*/", " <<
    215           node_name[dfs.tail()] <<
     215          node_name[dfs.source()] <<
    216216          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    217217         
     
    311311    cout << "bfs and dfs iterator demo on the bidirected graph" << endl;
    312312//     for(GW::EdgeIt e(gw); e!=INVALID; ++e) {
    313 //       cout << node_name[gw.tail(e)] << "->" << node_name[gw.head(e)] << " ";
     313//       cout << node_name[gw.source(e)] << "->" << node_name[gw.target(e)] << " ";
    314314//     }
    315315    for(GW::NodeIt n(gw); n!=INVALID; ++n) {
     
    335335      if (GW::Edge(bfs)!=INVALID) {
    336336        cout << edge_name[GW::Edge(bfs)] << /*endl*/", " <<
    337           node_name[gw.tail(bfs)] <<
    338           (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    339           node_name[gw.head(bfs)] <<
     337          node_name[gw.source(bfs)] <<
     338          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     339          node_name[gw.target(bfs)] <<
    340340          (bfs.isBNodeNewlyReached() ? ": is newly reached." :
    341341           ": is not newly reached.");
    342342      } else {
    343343        cout << "invalid" << /*endl*/", " <<
    344           node_name[bfs.tail()] <<
     344          node_name[bfs.source()] <<
    345345          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    346346         
     
    369369      if (GW::Edge(dfs)!=INVALID) {
    370370        cout << edge_name[GW::Edge(dfs)] << /*endl*/", " <<
    371           node_name[gw.tail(dfs)] <<
    372           (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    373           node_name[gw.head(dfs)] <<
     371          node_name[gw.source(dfs)] <<
     372          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     373          node_name[gw.target(dfs)] <<
    374374          (dfs.isBNodeNewlyReached() ? ": is newly reached." :
    375375           ": is not newly reached.");
    376376      } else {
    377377        cout << "invalid" << /*endl*/", " <<
    378           node_name[dfs.tail()] <<
     378          node_name[dfs.source()] <<
    379379          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    380380         
  • src/work/marci/leda/bipartite_matching_comparison.cc

    r921 r986  
    130130
    131131  FOR_EACH_LOC(BGW::EdgeIt, e, bgw)
    132     hg.addEdge(b_s_nodes[bgw.tail(e)], b_t_nodes[bgw.head(e)]);
     132    hg.addEdge(b_s_nodes[bgw.source(e)], b_t_nodes[bgw.target(e)]);
    133133
    134134  ConstMap<SageGraph::Edge, int> cm(1);
  • src/work/marci/leda/leda_graph_wrapper.h

    r921 r986  
    214214//     }
    215215
    216     ///Gives back the head node of an edge.
    217     Node head(Edge e) const {
     216    ///Gives back the target node of an edge.
     217    Node target(Edge e) const {
    218218      return Node(l_graph->target(e.l_e));
    219219    }
    220     ///Gives back the tail node of an edge.
    221     Node tail(Edge e) const {
     220    ///Gives back the source node of an edge.
     221    Node source(Edge e) const {
    222222      return Node(l_graph->source(e.l_e));
    223223    }
    224224 
    225     Node aNode(InEdgeIt e) const { return head(e); }
    226     Node aNode(OutEdgeIt e) const { return tail(e); }
     225    Node aNode(InEdgeIt e) const { return target(e); }
     226    Node aNode(OutEdgeIt e) const { return source(e); }
    227227    //   Node aNode(SymEdgeIt) const {}
    228228
    229     Node bNode(InEdgeIt e) const { return tail(e); }
    230     Node bNode(OutEdgeIt e) const { return head(e); }
     229    Node bNode(InEdgeIt e) const { return source(e); }
     230    Node bNode(OutEdgeIt e) const { return target(e); }
    231231    //   Node bNode(SymEdgeIt) const {}
    232232
     
    245245 
    246246    Node addNode() const { return Node(l_graph->new_node()); }
    247     Edge addEdge(Node tail, Node head) const {
    248       return Edge(l_graph->new_edge(tail.l_n, head.l_n));
     247    Edge addEdge(Node source, Node target) const {
     248      return Edge(l_graph->new_edge(source.l_n, target.l_n));
    249249    }
    250250   
  • src/work/marci/leda/max_bipartite_matching_demo.cc

    r921 r986  
    104104//     cout << "out edges: ";
    105105//     for(OutEdgeIt e=G.first<OutEdgeIt>(n); G.valid(e); G.next(e))
    106 //       cout << G.id(G.tail(e)) << "->" << G.id(G.head(e)) << " ";
     106//       cout << G.id(G.source(e)) << "->" << G.id(G.target(e)) << " ";
    107107//     cout << "in edges: ";
    108108//     for(InEdgeIt e=G.first<InEdgeIt>(n); G.valid(e); G.next(e))
    109 //       cout << G.id(G.tail(e)) << "->" << G.id(G.head(e)) << " ";
     109//       cout << G.id(G.source(e)) << "->" << G.id(G.target(e)) << " ";
    110110//     cout << endl;
    111111//   }
     
    124124    while (max_flow_test.augmentOnShortestPath()) {
    125125//       for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    126 //      std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     126//      std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    127127//       std::cout<<std::endl;
    128128      ++i;
     
    132132//     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    133133//       if (flow.get(e))
    134 //      std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     134//      std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    135135//     std::cout<<std::endl;
    136136//     std::cout << "edges which are not in this maximum matching: "<< std::endl;
    137137//     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    138138//       if (!flow.get(e))
    139 //      std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     139//      std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    140140//     std::cout<<std::endl;
    141141   
     
    157157//     while (max_flow_test.augmentOnBlockingFlow2()) {
    158158// //       for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    159 // //   std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     159// //   std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    160160// //       std::cout<<std::endl;
    161161//       ++i;
     
    165165// //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    166166// //       if (flow.get(e))
    167 // //   std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     167// //   std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    168168// //     std::cout<<std::endl;
    169169// //     std::cout << "edges which are not in this maximum matching: "<< std::endl;
    170170// //     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    171171// //       if (!flow.get(e))
    172 // //   std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     172// //   std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    173173// //     std::cout<<std::endl;
    174174   
     
    199199//     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    200200//       if (flow.get(e))
    201 //      std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     201//      std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    202202//     std::cout<<std::endl;
    203203//     std::cout << "edges which are not in this maximum matching: "<< std::endl;
    204204//     for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) 
    205205//       if (!flow.get(e))
    206 //      std::cout << G.id(G.tail(e)) << "-" << flow.get(e) << "->" << G.id(G.head(e)) << " ";
     206//      std::cout << G.id(G.source(e)) << "-" << flow.get(e) << "->" << G.id(G.target(e)) << " ";
    207207//     std::cout<<std::endl;
    208208   
  • src/work/marci/leda_bfs_dfs.cc

    r921 r986  
    2626  string get(typename Graph::Edge e) const {
    2727    return
    28       (node_name_map.get(graph.tail(e))+"->"+node_name_map.get(graph.head(e)));
     28      (node_name_map.get(graph.source(e))+"->"+node_name_map.get(graph.target(e)));
    2929  }
    3030};
  • src/work/marci/leda_graph_demo.cc

    r921 r986  
    3939//     cout << "out edges: ";
    4040//     for(OutEdgeIt e=G.first<OutEdgeIt>(n); G.valid(e); G.next(e))
    41 //       cout << G.id(G.tail(e)) << "-" << cap.get(e) << "->" << G.id(G.head(e)) << " ";
     41//       cout << G.id(G.source(e)) << "-" << cap.get(e) << "->" << G.id(G.target(e)) << " ";
    4242//     cout << "in edges: ";
    4343//     for(InEdgeIt e=G.first<InEdgeIt>(n); G.valid(e); G.next(e))
    44 //       cout << G.id(G.tail(e)) << "-" << cap.get(e) << "->" << G.id(G.head(e)) << " ";
     44//       cout << G.id(G.source(e)) << "-" << cap.get(e) << "->" << G.id(G.target(e)) << " ";
    4545//     cout << endl;
    4646//   }
     
    6565    while (max_flow_test.augmentOnShortestPath()) {
    6666//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) {
    67 //       std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     67//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    6868//     }
    6969//     std::cout<<std::endl;
     
    7373//   std::cout << "maximum flow: "<< std::endl;
    7474//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) {
    75 //     std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     75//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    7676//   }
    7777//   std::cout<<std::endl;
  • src/work/marci/lp/max_flow_by_lp.cc

    r921 r986  
    6464
    6565    FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    66       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    67         std::cout << "Slackness does not hold!" << std::endl;
    68       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     66      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     67        std::cout << "Slackness does not hold!" << std::endl;
     68      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    6969        std::cout << "Slackness does not hold!" << std::endl;
    7070    }
     
    8080
    8181//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    82 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    83 //      std::cout << "Slackness does not hold!" << std::endl;
    84 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     82//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     83//      std::cout << "Slackness does not hold!" << std::endl;
     84//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    8585//      std::cout << "Slackness does not hold!" << std::endl;
    8686//     }
     
    107107
    108108    FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    109       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    110         std::cout << "Slackness does not hold!" << std::endl;
    111       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     109      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     110        std::cout << "Slackness does not hold!" << std::endl;
     111      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    112112        std::cout << "Slackness does not hold!" << std::endl;
    113113    }
     
    136136
    137137    FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    138       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    139         std::cout << "Slackness does not hold!" << std::endl;
    140       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     138      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     139        std::cout << "Slackness does not hold!" << std::endl;
     140      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    141141        std::cout << "Slackness does not hold!" << std::endl;
    142142    }
     
    154154
    155155//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    156 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    157 //      std::cout << "Slackness does not hold!" << std::endl;
    158 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     156//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     157//      std::cout << "Slackness does not hold!" << std::endl;
     158//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    159159//      std::cout << "Slackness does not hold!" << std::endl;
    160160//     }
     
    172172
    173173//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    174 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    175 //      std::cout << "Slackness does not hold!" << std::endl;
    176 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     174//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     175//      std::cout << "Slackness does not hold!" << std::endl;
     176//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    177177//      std::cout << "Slackness does not hold!" << std::endl;
    178178//     }
  • src/work/marci/max_flow_demo.cc

    r921 r986  
    4848
    4949    for(Graph::EdgeIt e(g); e!=INVALID; ++e) {
    50       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
     50      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
    5151        std::cout << "Slackness does not hold!" << std::endl;
    52       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     52      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    5353        std::cout << "Slackness does not hold!" << std::endl;
    5454    }
     
    6464
    6565    for(Graph::EdgeIt e(g); e!=INVALID; ++e) {
    66       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
     66      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
    6767        std::cout << "Slackness does not hold!" << std::endl;
    68       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     68      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    6969        std::cout << "Slackness does not hold!" << std::endl;
    7070    }
     
    9191
    9292    for(Graph::EdgeIt e(g); e!=INVALID; ++e) {
    93       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
     93      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
    9494        std::cout << "Slackness does not hold!" << std::endl;
    95       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     95      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    9696        std::cout << "Slackness does not hold!" << std::endl;
    9797    }
     
    109109
    110110    for(Graph::EdgeIt e(g); e!=INVALID; ++e) {
    111       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
     111      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
    112112        std::cout << "Slackness does not hold!" << std::endl;
    113       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     113      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    114114        std::cout << "Slackness does not hold!" << std::endl;
    115115    }
     
    127127
    128128    for(Graph::EdgeIt e(g); e!=INVALID; ++e) {
    129       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
     129      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
    130130        std::cout << "Slackness does not hold!" << std::endl;
    131       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     131      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    132132        std::cout << "Slackness does not hold!" << std::endl;
    133133    }
     
    145145
    146146    for(Graph::EdgeIt e(g); e!=INVALID; ++e) {
    147       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
     147      if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
    148148        std::cout << "Slackness does not hold!" << std::endl;
    149       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     149      if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    150150        std::cout << "Slackness does not hold!" << std::endl;
    151151    }
  • src/work/marci/oldies/edmonds_karp.h

    r921 r986  
    6060        ResGWOutEdgeIt e=bfs;
    6161        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    62           Node v=res_graph.tail(e);
    63           Node w=res_graph.head(e);
     62          Node v=res_graph.source(e);
     63          Node w=res_graph.target(e);
    6464          pred.set(w, e);
    6565          if (res_graph.valid(pred[v])) {
     
    6868            free.set(w, res_graph.resCap(e));
    6969          }
    70           if (res_graph.head(e)==t) { _augment=true; break; }
     70          if (res_graph.target(e)==t) { _augment=true; break; }
    7171        }
    7272       
     
    8080          ResGWEdge e=pred[n];
    8181          res_graph.augment(e, augment_value);
    82           n=res_graph.tail(e);
     82          n=res_graph.source(e);
    8383        }
    8484      }
     
    102102//      return dist[n]; }
    103103//       bool get(const typename MapGraphWrapper::Edge& e) const {
    104 //      return (dist.get(g->tail(e))<dist.get(g->head(e))); }
     104//      return (dist.get(g->source(e))<dist.get(g->target(e))); }
    105105      bool operator[](const typename MapGraphWrapper::Edge& e) const {
    106         return (dist[g->tail(e)]<dist[g->head(e)]);
     106        return (dist[g->source(e)]<dist[g->target(e)]);
    107107      }
    108108    };
     
    124124        ResGWOutEdgeIt e=bfs;
    125125        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    126           dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
     126          dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
    127127        }
    128128        ++bfs;
     
    153153        typename FilterResGW::EdgeIt e;
    154154        for(filter_res_graph.first(e); filter_res_graph.valid(e); filter_res_graph.next(e)) {
    155           //if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    156           typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)], res_graph_to_F[res_graph.head(e)]);
     155          //if (dist.get(res_graph.target(e))==dist.get(res_graph.source(e))+1) {
     156          typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)], res_graph_to_F[res_graph.target(e)]);
    157157          original_edge.update();
    158158          original_edge.set(f, e);
     
    207207            typename MG::Edge e=pred[n];
    208208            res_graph.augment(original_edge[e], augment_value);
    209             n=F.tail(e);
     209            n=F.source(e);
    210210            if (residual_capacity[e]==augment_value)
    211211              F.erase(e);
     
    255255        if (res_graph.valid(e)) {
    256256          if (bfs.isBNodeNewlyReached()) {
    257             dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
    258             typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)], res_graph_to_F[res_graph.head(e)]);
     257            dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
     258            typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)], res_graph_to_F[res_graph.target(e)]);
    259259            original_edge.update();
    260260            original_edge.set(f, e);
     
    262262            residual_capacity.set(f, res_graph.resCap(e));
    263263          } else {
    264             if (dist[res_graph.head(e)]==(dist[res_graph.tail(e)]+1)) {
    265               typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.tail(e)], res_graph_to_F[res_graph.head(e)]);
     264            if (dist[res_graph.target(e)]==(dist[res_graph.source(e)]+1)) {
     265              typename MG::Edge f=F.addEdge(res_graph_to_F[res_graph.source(e)], res_graph_to_F[res_graph.target(e)]);
    266266              original_edge.update();
    267267              original_edge.set(f, e);
     
    317317            typename MG::Edge e=pred[n];
    318318            res_graph.augment(original_edge[e], augment_value);
    319             n=F.tail(e);
     319            n=F.source(e);
    320320            if (residual_capacity[e]==augment_value)
    321321              F.erase(e);
     
    344344        ResGWOutEdgeIt e=bfs;
    345345        if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    346           dist.set(res_graph.head(e), dist[res_graph.tail(e)]+1);
     346          dist.set(res_graph.target(e), dist[res_graph.source(e)]+1);
    347347        }
    348348        ++bfs;
     
    441441            typename ErasingResGW::OutEdgeIt e=pred[n];
    442442            res_graph.augment(e, augment_value);
    443             n=erasing_res_graph.tail(e);
     443            n=erasing_res_graph.source(e);
    444444            if (res_graph.resCap(e)==0)
    445445              erasing_res_graph.erase(e);
     
    536536//      AugOutEdgeIt e=bfs;
    537537//      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    538 //        Node v=res_graph.tail(e);
    539 //        Node w=res_graph.head(e);
     538//        Node v=res_graph.source(e);
     539//        Node w=res_graph.target(e);
    540540//        pred.set(w, e);
    541541//        if (res_graph.valid(pred.get(v))) {
     
    544544//          free.set(w, res_graph.free(e));
    545545//        }
    546 //        n=res_graph.head(e);
     546//        n=res_graph.target(e);
    547547//        if (T->get(n) && (used.get(n)<1) ) {
    548548//          //Num u=0;
     
    566566//        AugEdge e=pred.get(n);
    567567//        res_graph.augment(e, augment_value);
    568 //        n=res_graph.tail(e);
     568//        n=res_graph.source(e);
    569569//      }
    570570//      used.set(n, 1); //mind2 vegen jav
     
    607607// //   AugOutEdgeIt e=bfs;
    608608// //   if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    609 // //     dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     609// //     dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    610610// //   }
    611611       
     
    629629// //       //which are in some shortest paths
    630630// //       for(typename AugGraph::EdgeIt e=res_graph.template first<typename AugGraph::EdgeIt>(); res_graph.valid(e); res_graph.next(e)) {
    631 // //   if (dist.get(res_graph.head(e))==dist.get(res_graph.tail(e))+1) {
    632 // //     typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.tail(e)), res_graph_to_F.get(res_graph.head(e)));
     631// //   if (dist.get(res_graph.target(e))==dist.get(res_graph.source(e))+1) {
     632// //     typename MutableGraph::Edge f=F.addEdge(res_graph_to_F.get(res_graph.source(e)), res_graph_to_F.get(res_graph.target(e)));
    633633// //     original_edge.update();
    634634// //     original_edge.set(f, e);
     
    682682// //       typename MutableGraph::Edge e=pred.get(n);
    683683// //       res_graph.augment(original_edge.get(e), augment_value);
    684 // //       n=F.tail(e);
     684// //       n=F.source(e);
    685685// //       if (residual_capacity.get(e)==augment_value)
    686686// //         F.erase(e);
     
    733733//      typename ErasingResGraphWrapper<Graph, Num, FlowMap, CapMap>::OutEdgeIt e=bfs;
    734734//      if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
    735 //        dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
     735//        dist.set(res_graph.target(e), dist.get(res_graph.source(e))+1);
    736736//      }
    737737//      ++bfs; 
     
    810810//          EAugEdge e=pred.get(n);
    811811//          res_graph.augment(e, augment_value);
    812 //          n=res_graph.tail(e);
     812//          n=res_graph.source(e);
    813813//          if (res_graph.free(e)==0)
    814814//            res_graph.erase(e);
     
    903903// //   AugOutEdgeIt e=/*AugOutEdgeIt*/(bfs);
    904904// //   if (e.valid() && bfs.isBNodeNewlyReached()) {
    905 // //     Node v=res_graph.tail(e);
    906 // //     Node w=res_graph.head(e);
     905// //     Node v=res_graph.source(e);
     906// //     Node w=res_graph.target(e);
    907907// //     pred.set(w, e);
    908908// //     if (pred.get(v).valid()) {
     
    911911// //       free.set(w, e.free());
    912912// //     }
    913 // //     if (TMap.get(res_graph.head(e))) {
     913// //     if (TMap.get(res_graph.target(e))) {
    914914// //       _augment=true;
    915 // //       reached_t_node=res_graph.head(e);
     915// //       reached_t_node=res_graph.target(e);
    916916// //       break;
    917917// //     }
     
    927927// //     AugEdge e=pred.get(n);
    928928// //     e.augment(augment_value);
    929 // //     n=res_graph.tail(e);
     929// //     n=res_graph.source(e);
    930930// //   }
    931931// //       }
  • src/work/marci/oldies/marci_graph_demo.cc

    r921 r986  
    3232    std::cout << " outdegree (OutEdgeIt): " << count(G.first<OutEdgeIt>(i)) << " ";
    3333    for(OutEdgeIt j=G.first<OutEdgeIt>(i); G.valid(j); G.next(j)) {
    34       std::cout << "(" << G.id(G.tail(j)) << "--" << G.id(j) << "->" << G.id(G.head(j)) << ") ";
     34      std::cout << "(" << G.id(G.source(j)) << "--" << G.id(j) << "->" << G.id(G.target(j)) << ") ";
    3535    }
    3636    std::cout << std::endl;
     
    9090  }
    9191
    92   std::cout << "node and edge property values on the tails and heads of edges..." << std::endl;
     92  std::cout << "node and edge property values on the sources and targets of edges..." << std::endl;
    9393  for(EdgeIt j=G.first<EdgeIt>(); G.valid(j); G.next(j)) {
    94     std::cout << my_property_vector.get(G.tail(j)) << "--" << my_edge_property.get(j) << "-->" << my_property_vector.get(G.head(j)) << " ";
     94    std::cout << my_property_vector.get(G.source(j)) << "--" << my_edge_property.get(j) << "-->" << my_property_vector.get(G.target(j)) << " ";
    9595  }
    9696  std::cout << std::endl;
     
    159159    std::cout << "out edges: ";
    160160    for(OutEdgeIt j=flowG.first<OutEdgeIt>(i); flowG.valid(j); flowG.next(j))
    161       std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     161      std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    162162    std::cout << "in edges: ";
    163163    for(InEdgeIt j=flowG.first<InEdgeIt>(i); flowG.valid(j); flowG.next(j))
    164       std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     164      std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    165165    std::cout << std::endl;
    166166  }
     
    172172 
    173173
    174   //flowG.setTail(v3_t, v2);
    175   //flowG.setHead(v3_t, s);
     174  //flowG.setSource(v3_t, v2);
     175  //flowG.setTarget(v3_t, s);
    176176/*
    177177  for(NodeIt i=flowG.first<NodeIt>(); flowG.valid(i); flowG.next(i)) {
     
    179179    std::cout << "out edges: ";
    180180    for(OutEdgeIt j=flowG.first<OutEdgeIt>(i); flowG.valid(j); flowG.next(j))
    181       std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     181      std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    182182    std::cout << "in edges: ";
    183183    for(InEdgeIt j=flowG.first<InEdgeIt>(i); flowG.valid(j); flowG.next(j))
    184       std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     184      std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    185185    std::cout << std::endl;
    186186  }
    187187 
    188188  for(EdgeIt e=flowG.first<EdgeIt>(); flowG.valid(e); flowG.next(e)) {
    189     std::cout << node_name.get(flowG.tail(e)) << "-"<< cap.get(e) << "->" << node_name.get(flowG.head(e)) << " ";
     189    std::cout << node_name.get(flowG.source(e)) << "-"<< cap.get(e) << "->" << node_name.get(flowG.target(e)) << " ";
    190190  }
    191191*/
     
    197197      std::cout << "out edges: ";
    198198      for(OutEdgeIt j=flowG.first<OutEdgeIt>(i); flowG.valid(j); flowG.next(j))
    199         std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     199        std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    200200      std::cout << "in edges: ";
    201201      for(InEdgeIt j=flowG.first<InEdgeIt>(i); flowG.valid(j); flowG.next(j))
    202         std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     202        std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    203203      std::cout << std::endl;
    204204    }
     
    211211      std::cout << "out edges: ";
    212212      for(OutEdgeIt j=flowG.first<OutEdgeIt>(i); flowG.valid(j); flowG.next(j))
    213         std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     213        std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    214214      std::cout << "in edges: ";
    215215      for(InEdgeIt j=flowG.first<InEdgeIt>(i); flowG.valid(j); flowG.next(j))
    216         std::cout << node_name.get(flowG.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.head(j)) << " ";
     216        std::cout << node_name.get(flowG.source(j)) << "-"<< cap.get(j) << "->" << node_name.get(flowG.target(j)) << " ";
    217217      std::cout << std::endl;
    218218    }
     
    229229    max_flow_test.augmentOnBlockingFlow<ListGraph>();
    230230    for(EdgeIt e=flowG.template first<EdgeIt>(); flowG.valid(e); flowG.next(e)) {
    231       std::cout<<"("<<flowG.tail(e)<< "-"<<flow.get(e)<<"->"<<flowG.head(e)<<") ";
     231      std::cout<<"("<<flowG.source(e)<< "-"<<flow.get(e)<<"->"<<flowG.target(e)<<") ";
    232232    }
    233233    std::cout<<std::endl;
    234234    max_flow_test.augmentOnBlockingFlow<ListGraph>();
    235235    for(EdgeIt e=flowG.template first<EdgeIt>(); flowG.valid(e); flowG.next(e)) {
    236       std::cout<<"("<<flowG.tail(e)<< "-"<<flow.get(e)<<"->"<<flowG.head(e)<<") ";
     236      std::cout<<"("<<flowG.source(e)<< "-"<<flow.get(e)<<"->"<<flowG.target(e)<<") ";
    237237    }
    238238    std::cout<<std::endl;*/
     
    242242    while (max_flow_test.augmentOnShortestPath()) {
    243243      for(EdgeIt e=flowG.template first<EdgeIt>(); flowG.valid(e); flowG.next(e)) {
    244         std::cout<<"("<<flowG.tail(e)<< "-"<<flow.get(e)<<"->"<<flowG.head(e)<<") ";
     244        std::cout<<"("<<flowG.source(e)<< "-"<<flow.get(e)<<"->"<<flowG.target(e)<<") ";
    245245      }
    246246      std::cout<<std::endl;
     
    261261    std::cout << "maximum flow: "<< std::endl;
    262262    for(EdgeIt e=flowG.template first<EdgeIt>(); flowG.valid(e); flowG.next(e)) {
    263       std::cout<<"("<<flowG.tail(e)<< "-"<<flow.get(e)<<"->"<<flowG.head(e)<<") ";
     263      std::cout<<"("<<flowG.source(e)<< "-"<<flow.get(e)<<"->"<<flowG.target(e)<<") ";
    264264    }
    265265    std::cout<<std::endl;
  • src/work/marci/preflow_bug.cc

    r921 r986  
    4646    Graph::EdgeIt e;
    4747    for (g.first(e); g.valid(e); g.next(e))
    48       cout << 1+g.id(g.tail(e)) << "->" << 1+g.id(g.head(e)) << " cap: " << cap[e] << " preflow: " << flow[e] << endl;
     48      cout << 1+g.id(g.source(e)) << "->" << 1+g.id(g.target(e)) << " cap: " << cap[e] << " preflow: " << flow[e] << endl;
    4949  }
    5050  {
     
    7676    Graph::EdgeIt e;
    7777    for (g.first(e); g.valid(e); g.next(e)) {
    78       if (cut[g.tail(e)] && !cut[g.head(e)]) {
    79         cout << 1+g.id(g.tail(e)) << "->" << 1+g.id(g.head(e))
     78      if (cut[g.source(e)] && !cut[g.target(e)]) {
     79        cout << 1+g.id(g.source(e)) << "->" << 1+g.id(g.target(e))
    8080             << "(forward edge) flow: " << flow[e]
    8181             << " cap: " << cap[e]<< endl;
     
    8383        std::cout << "Slackness does not hold!" << std::endl;
    8484      }
    85       if (!cut[g.tail(e)] && cut[g.head(e)]) {
    86         cout << 1+g.id(g.tail(e)) << "->" << 1+g.id(g.head(e))
     85      if (!cut[g.source(e)] && cut[g.target(e)]) {
     86        cout << 1+g.id(g.source(e)) << "->" << 1+g.id(g.target(e))
    8787             << "(backward edge) flow: " << flow[e] << endl;
    8888        if (flow[e]!=0)
     
    106106
    107107//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    108 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    109 //      std::cout << "Slackness does not hold!" << std::endl;
    110 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     108//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     109//      std::cout << "Slackness does not hold!" << std::endl;
     110//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    111111//      std::cout << "Slackness does not hold!" << std::endl;
    112112//     }
     
    122122
    123123//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    124 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    125 //      std::cout << "Slackness does not hold!" << std::endl;
    126 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     124//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     125//      std::cout << "Slackness does not hold!" << std::endl;
     126//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    127127//      std::cout << "Slackness does not hold!" << std::endl;
    128128//     }
     
    149149
    150150//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    151 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    152 //      std::cout << "Slackness does not hold!" << std::endl;
    153 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     151//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     152//      std::cout << "Slackness does not hold!" << std::endl;
     153//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    154154//      std::cout << "Slackness does not hold!" << std::endl;
    155155//     }
     
    178178
    179179//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    180 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    181 //      std::cout << "Slackness does not hold!" << std::endl;
    182 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     180//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     181//      std::cout << "Slackness does not hold!" << std::endl;
     182//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    183183//      std::cout << "Slackness does not hold!" << std::endl;
    184184//     }
     
    196196
    197197//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    198 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    199 //      std::cout << "Slackness does not hold!" << std::endl;
    200 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     198//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     199//      std::cout << "Slackness does not hold!" << std::endl;
     200//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    201201//      std::cout << "Slackness does not hold!" << std::endl;
    202202//     }
     
    214214
    215215//     FOR_EACH_LOC(Graph::EdgeIt, e, g) {
    216 //       if (cut[g.tail(e)] && !cut[g.head(e)] && !flow[e]==cap[e])
    217 //      std::cout << "Slackness does not hold!" << std::endl;
    218 //       if (!cut[g.tail(e)] && cut[g.head(e)] && flow[e]>0)
     216//       if (cut[g.source(e)] && !cut[g.target(e)] && !flow[e]==cap[e])
     217//      std::cout << "Slackness does not hold!" << std::endl;
     218//       if (!cut[g.source(e)] && cut[g.target(e)] && flow[e]>0)
    219219//      std::cout << "Slackness does not hold!" << std::endl;
    220220//     }
  • src/work/marci/preflow_demo_athos.cc

    r921 r986  
    2929  //int cut_value=0;
    3030  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    31   //  if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
     31  //  if (cut.get(G.source(e)) && !cut.get(G.target(e))) cut_value+=cap.get(e);
    3232  //}
    3333  double post_time=currTime();
    3434  //std::cout << "maximum flow: "<< std::endl;
    3535  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    36   //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     36  //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    3737  //}
    3838  //std::cout<<std::endl;
  • src/work/marci/preflow_demo_jacint.cc

    r921 r986  
    3232  int cut_value=0;
    3333  for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    34     if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
     34    if (cut.get(G.source(e)) && !cut.get(G.target(e))) cut_value+=cap.get(e);
    3535  }
    3636  double post_time=currTime();
    3737  //std::cout << "maximum flow: "<< std::endl;
    3838  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    39   //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     39  //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    4040  //}
    4141  //std::cout<<std::endl;
     
    5656  int cut_value=0;
    5757  for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    58     if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
     58    if (cut.get(G.source(e)) && !cut.get(G.target(e))) cut_value+=cap.get(e);
    5959  }
    6060  double post_time=currTime();
    6161  //std::cout << "maximum flow: "<< std::endl;
    6262  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
    63   //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
     63  //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    6464  //}
    6565  //std::cout<<std::endl;
  • src/work/peter/edgepathgraph.h

    r921 r986  
    7474        PEdgeIt f;
    7575
    76         //dep//cout << "Edge " << id(tail(e)) << " - " << id(head(e)) << " in actual layer is";
     76        //dep//cout << "Edge " << id(source(e)) << " - " << id(target(e)) << " in actual layer is";
    7777        T1 incr=actmap[e];
    7878        //cout << incr << endl;
     
    8383          for(edgepath[e]->first(f); edgepath[e]->valid(f); edgepath[e]->next(f))
    8484          {
    85             //dep//cout << " " << sublayer->id(sublayer->tail(f)) << "-" << sublayer->id(sublayer->head(f));
     85            //dep//cout << " " << sublayer->id(sublayer->source(f)) << "-" << sublayer->id(sublayer->target(f));
    8686            submap[f]+=incr;
    8787          }
    88           //dep////cout << EPGr2.id(EPGr2.head(f)) << endl;
     88          //dep////cout << EPGr2.id(EPGr2.target(f)) << endl;
    8989          //dep//cout << endl;
    9090        }
     
    108108        PEdgeIt f;
    109109
    110         cout << "Edge " << id(tail(e)) << " - " << id(head(e)) << " in actual layer is";
     110        cout << "Edge " << id(source(e)) << " - " << id(target(e)) << " in actual layer is";
    111111        if(edgepath[e])
    112112        {
     
    114114          for(edgepath[e]->first(f); edgepath[e]->valid(f); edgepath[e]->next(f))
    115115          {
    116             cout << " " << sublayer->id(sublayer->tail(f)) << "-" << sublayer->id(sublayer->head(f));
     116            cout << " " << sublayer->id(sublayer->source(f)) << "-" << sublayer->id(sublayer->target(f));
    117117          }
    118           //cout << EPGr2.id(EPGr2.head(f)) << endl;
     118          //cout << EPGr2.id(EPGr2.target(f)) << endl;
    119119          cout << endl;
    120120        }
     
    235235    typename Gact::EdgeIt &next(typename Gact::EdgeIt &i) const { return actuallayer.next(i);}
    236236
    237     ///Gives back the head node of an edge.
    238     typename Gact::Node head(typename Gact::Edge edge) const { return actuallayer.head(edge); }
    239     ///Gives back the tail node of an edge.
    240     typename Gact::Node tail(typename Gact::Edge edge) const { return actuallayer.tail(edge); }
     237    ///Gives back the target node of an edge.
     238    typename Gact::Node target(typename Gact::Edge edge) const { return actuallayer.target(edge); }
     239    ///Gives back the source node of an edge.
     240    typename Gact::Node source(typename Gact::Edge edge) const { return actuallayer.source(edge); }
    241241 
    242242    //   Node aNode(InEdgeIt) const {}
     
    280280    ///Add a new edge to the graph.
    281281
    282     ///Add a new edge to the graph with tail node \c tail
    283     ///and head node \c head.
     282    ///Add a new edge to the graph with source node \c source
     283    ///and target node \c target.
    284284    ///\return the new edge.
    285285    typename Gact::Edge addEdge(typename Gact::Node node1, typename Gact::Node node2) { return actuallayer.addEdge(node1, node2);}
  • src/work/peter/edgepathgraph_test.cc

    r921 r986  
    136136        PEdgeIt f;
    137137
    138         cout << "Edge " << EPGr.id(EPGr.tail(e)) << " - " << EPGr.id(EPGr.head(e)) << " in actual layer is";
     138        cout << "Edge " << EPGr.id(EPGr.source(e)) << " - " << EPGr.id(EPGr.target(e)) << " in actual layer is";
    139139        if(EPGr.edgepath[e])
    140140        {
     
    142142          for(EPGr.edgepath[e]->first(f); EPGr.edgepath[e]->valid(f); EPGr.edgepath[e]->next(f))
    143143          {
    144             cout << " " << EPGr2.id(EPGr2.tail(f)) << "-" << EPGr2.id(EPGr2.head(f));
     144            cout << " " << EPGr2.id(EPGr2.source(f)) << "-" << EPGr2.id(EPGr2.target(f));
    145145          }
    146           //cout << EPGr2.id(EPGr2.head(f)) << endl;
     146          //cout << EPGr2.id(EPGr2.target(f)) << endl;
    147147          cout << endl;
    148148        }
     
    170170      for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
    171171      {
    172         cout << EPGr.id(EPGr.tail(e)) << "-" << EPGr.id(EPGr.head(e)) << ":" << actlaymap[e] << " ";
     172        cout << EPGr.id(EPGr.source(e)) << "-" << EPGr.id(EPGr.target(e)) << ":" << actlaymap[e] << " ";
    173173      }
    174174      cout << endl;
     
    176176      for(ListGraph::EdgeIt e(EPGr2.actuallayer);EPGr2.actuallayer.valid(e);EPGr2.actuallayer.next(e))
    177177      {
    178         cout << EPGr2.id(EPGr2.tail(e)) << "-" << EPGr2.id(EPGr2.head(e)) << ":" << sublaymap[e] << " ";
     178        cout << EPGr2.id(EPGr2.source(e)) << "-" << EPGr2.id(EPGr2.target(e)) << ":" << sublaymap[e] << " ";
    179179      }
    180180      cout << endl;
     
    191191      for(EdgeIt e(EPGr.actuallayer);EPGr.actuallayer.valid(e);EPGr.actuallayer.next(e))
    192192      {
    193         cout << EPGr.id(EPGr.tail(e)) << "-" << EPGr.id(EPGr.head(e)) << ":" << actlaymap[e] << " ";
     193        cout << EPGr.id(EPGr.source(e)) << "-" << EPGr.id(EPGr.target(e)) << ":" << actlaymap[e] << " ";
    194194      }
    195195      cout << endl;
     
    197197      for(ListGraph::EdgeIt e(EPGr2.actuallayer);EPGr2.actuallayer.valid(e);EPGr2.actuallayer.next(e))
    198198      {
    199         cout << EPGr2.id(EPGr2.tail(e)) << "-" << EPGr2.id(EPGr2.head(e)) << ":" << sublaymap[e] << " ";
     199        cout << EPGr2.id(EPGr2.source(e)) << "-" << EPGr2.id(EPGr2.target(e)) << ":" << sublaymap[e] << " ";
    200200      }
    201201      cout << endl;
  • src/work/peter/hierarchygraph.h

    r921 r986  
    6161            return -1;
    6262          }
    63         else if ((actuallayer->id (actuallayer->tail (actedge)) !=
     63        else if ((actuallayer->id (actuallayer->source (actedge)) !=
    6464                  actuallayer->id (*actuallayernode))
    65                  && (actuallayer->id (actuallayer->head (actedge)) !=
     65                 && (actuallayer->id (actuallayer->target (actedge)) !=
    6666                     actuallayer->id (*actuallayernode)))
    6767          {
     
    133133            for (iei = actuallayer->first (iei, (*actuallayernode));
    134134                 ((actuallayer->valid (iei))
    135                   && (actuallayer->head (iei) == (*actuallayernode)));
     135                  && (actuallayer->target (iei) == (*actuallayernode)));
    136136                 actuallayer->next (iei))
    137137              {
    138138                cout << actuallayer->id (actuallayer->
    139                                          tail (iei)) << " " << actuallayer->
    140                   id (actuallayer->head (iei)) << endl;
     139                                         source (iei)) << " " << actuallayer->
     140                  id (actuallayer->target (iei)) << endl;
    141141                edgenumber++;
    142142              }
     
    144144            for (oei = actuallayer->first (oei, (*actuallayernode));
    145145                 ((actuallayer->valid (oei))
    146                   && (actuallayer->tail (oei) == (*actuallayernode)));
     146                  && (actuallayer->source (oei) == (*actuallayernode)));
    147147                 actuallayer->next (oei))
    148148              {
    149149                cout << actuallayer->id (actuallayer->
    150                                          tail (oei)) << " " << actuallayer->
    151                   id (actuallayer->head (oei)) << endl;
     150                                         source (oei)) << " " << actuallayer->
     151                  id (actuallayer->target (oei)) << endl;
    152152                edgenumber++;
    153153              }
     
    328328    }
    329329
    330     ///Gives back the head node of an edge.
    331     typename Gact::Node head (typename Gact::Edge edge) const
    332     {
    333       return actuallayer.head (edge);
    334     }
    335     ///Gives back the tail node of an edge.
    336     typename Gact::Node tail (typename Gact::Edge edge) const
    337     {
    338       return actuallayer.tail (edge);
     330    ///Gives back the target node of an edge.
     331    typename Gact::Node target (typename Gact::Edge edge) const
     332    {
     333      return actuallayer.target (edge);
     334    }
     335    ///Gives back the source node of an edge.
     336    typename Gact::Node source (typename Gact::Edge edge) const
     337    {
     338      return actuallayer.source (edge);
    339339    }
    340340
     
    394394    ///Add a new edge to the graph.
    395395
    396     ///Add a new edge to the graph with tail node \c tail
    397     ///and head node \c head.
     396    ///Add a new edge to the graph with source node \c source
     397    ///and target node \c target.
    398398    ///\return the new edge.
    399399    typename Gact::Edge addEdge (typename Gact::Node node1,
  • 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
  • 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.