COIN-OR::LEMON - Graph Library

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

Naming changes:

  • head -> target
  • tail -> source
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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// //       }
Note: See TracChangeset for help on using the changeset viewer.