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