COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
04/24/04 14:44:41 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@520
Message:

modifications for better compatibility with gcc 3.4.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/graph_wrapper.h

    r381 r389  
    184184    void clear() const { graph->clear(); }
    185185   
    186     template<typename T> class NodeMap : public Graph::NodeMap<T> {
    187     public:
    188       NodeMap(const GraphWrapper<Graph>& _G) : 
    189         Graph::NodeMap<T>(*(_G.graph)) { }
    190       NodeMap(const GraphWrapper<Graph>& _G, T a) :
    191         Graph::NodeMap<T>(*(_G.graph), a) { }
    192     };
    193 
    194     template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
    195     public:
    196       EdgeMap(const GraphWrapper<Graph>& _G) : 
    197         Graph::EdgeMap<T>(*(_G.graph)) { }
    198       EdgeMap(const GraphWrapper<Graph>& _G, T a) :
    199         Graph::EdgeMap<T>(*(_G.graph), a) { }
     186    template<typename T> class NodeMap : public Graph::template NodeMap<T> {
     187      typedef typename Graph::template NodeMap<T> Parent;
     188    public:
     189      NodeMap(const GraphWrapper<Graph>& _G) :  Parent(*(_G.graph)) { }
     190      NodeMap(const GraphWrapper<Graph>& _G, T a) : Parent(*(_G.graph), a) { }
     191    };
     192
     193    template<typename T> class EdgeMap : public Graph::template EdgeMap<T> {
     194      typedef typename Graph::template EdgeMap<T> Parent;
     195    public:
     196      EdgeMap(const GraphWrapper<Graph>& _G) : Parent(*(_G.graph)) { }
     197      EdgeMap(const GraphWrapper<Graph>& _G, T a) : Parent(*(_G.graph), a) { }
    200198    };
    201199  };
     
    253251
    254252    using GraphWrapper<Graph>::next;
    255     OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }
    256     InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }
    257 
    258     Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    259     Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    260     Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
    261     Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
     253    OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; }
     254    InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }
     255
     256    Node aNode(const OutEdgeIt& e) const {
     257      return Node(this->graph->aNode(e.e)); }
     258    Node aNode(const InEdgeIt& e) const {
     259      return Node(this->graph->aNode(e.e)); }
     260    Node bNode(const OutEdgeIt& e) const {
     261      return Node(this->graph->bNode(e.e)); }
     262    Node bNode(const InEdgeIt& e) const {
     263      return Node(this->graph->bNode(e.e)); }
    262264
    263265    Node tail(const Edge& e) const {
     
    367369   
    368370    NodeIt& next(NodeIt& i) const {
    369       graph->next(i.n);
    370       while (graph->valid(i) && !(*node_filter_map)[i.n]) { graph->next(i.n); }
     371      this->graph->next(i.n);
     372      while (this->graph->valid(i) && !(*node_filter_map)[i.n]) {
     373        this->graph->next(i.n); }
    371374      return i;
    372375    }
    373376    OutEdgeIt& next(OutEdgeIt& i) const {
    374       graph->next(i.e);
    375       while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); }
     377      this->graph->next(i.e);
     378      while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) {
     379        this->graph->next(i.e); }
    376380      return i;
    377381    }
    378382    InEdgeIt& next(InEdgeIt& i) const {
    379       graph->next(i.e);
    380       while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); }
     383      this->graph->next(i.e);
     384      while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) {
     385        this->graph->next(i.e); }
    381386      return i;
    382387    }
    383388    EdgeIt& next(EdgeIt& i) const {
    384       graph->next(i.e);
    385       while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); }
     389      this->graph->next(i.e);
     390      while (this->graph->valid(i) && !(*edge_filter_map)[i.e]) {
     391        this->graph->next(i.e); }
    386392      return i;
    387393    }
    388394
    389     Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    390     Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    391     Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
    392     Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
     395    Node aNode(const OutEdgeIt& e) const {
     396      return Node(this->graph->aNode(e.e)); }
     397    Node aNode(const InEdgeIt& e) const {
     398      return Node(this->graph->aNode(e.e)); }
     399    Node bNode(const OutEdgeIt& e) const {
     400      return Node(this->graph->bNode(e.e)); }
     401    Node bNode(const InEdgeIt& e) const {
     402      return Node(this->graph->bNode(e.e)); }
    393403
    394404    ///\todo
     
    470480    OutEdgeIt& next(OutEdgeIt& e) const {
    471481      if (e.out_or_in) {
    472         typename Graph::Node n=graph->tail(e.out);
    473         graph->next(e.out);
    474         if (!graph->valid(e.out)) { e.out_or_in=false; graph->first(e.in, n); }
     482        typename Graph::Node n=this->graph->tail(e.out);
     483        this->graph->next(e.out);
     484        if (!this->graph->valid(e.out)) {
     485          e.out_or_in=false; this->graph->first(e.in, n); }
    475486      } else {
    476         graph->next(e.in);
     487        this->graph->next(e.in);
    477488      }
    478489      return e;
     
    486497
    487498    Node aNode(const OutEdgeIt& e) const {
    488       if (e.out_or_in) return graph->tail(e); else return graph->head(e); }
     499      if (e.out_or_in) return this->graph->tail(e); else
     500        return this->graph->head(e); }
    489501    Node bNode(const OutEdgeIt& e) const {
    490       if (e.out_or_in) return graph->head(e); else return graph->tail(e); }
     502      if (e.out_or_in) return this->graph->head(e); else
     503        return this->graph->tail(e); }
    491504  };
    492505 
     
    646659    OutEdgeIt& next(OutEdgeIt& e) const {
    647660      if (e.forward) {
    648         Node v=graph->aNode(e.out);
    649         graph->next(e.out);
    650         while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); }
    651         if (!graph->valid(e.out)) {
     661        Node v=this->graph->aNode(e.out);
     662        this->graph->next(e.out);
     663        while( this->graph->valid(e.out) && !(resCap(e)>0) ) {
     664          this->graph->next(e.out); }
     665        if (!this->graph->valid(e.out)) {
    652666          e.forward=false;
    653           graph->first(e.in, v);
    654           while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); }
     667          this->graph->first(e.in, v);
     668          while( this->graph->valid(e.in) && !(resCap(e)>0) ) {
     669            this->graph->next(e.in); }
    655670        }
    656671      } else {
    657         graph->next(e.in);
    658         while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); }
     672        this->graph->next(e.in);
     673        while( this->graph->valid(e.in) && !(resCap(e)>0) ) {
     674          this->graph->next(e.in); }
    659675      }
    660676      return e;
     
    663679    InEdgeIt& next(InEdgeIt& e) const {
    664680      if (e.forward) {
    665         Node v=graph->aNode(e.in);
    666         graph->next(e.in);
    667         while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); }
    668         if (!graph->valid(e.in)) {
     681        Node v=this->graph->aNode(e.in);
     682        this->graph->next(e.in);
     683        while( this->graph->valid(e.in) && !(resCap(e)>0) ) {
     684          this->graph->next(e.in); }
     685        if (!this->graph->valid(e.in)) {
    669686          e.forward=false;
    670           graph->first(e.out, v);
    671           while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); }
     687          this->graph->first(e.out, v);
     688          while( this->graph->valid(e.out) && !(resCap(e)>0) ) {
     689            this->graph->next(e.out); }
    672690        }
    673691      } else {
    674         graph->next(e.out);
    675         while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); }
     692        this->graph->next(e.out);
     693        while( this->graph->valid(e.out) && !(resCap(e)>0) ) {
     694          this->graph->next(e.out); }
    676695      }
    677696      return e;
     
    679698    EdgeIt& next(EdgeIt& e) const {
    680699      if (e.forward) {
    681         graph->next(e.e);
    682         while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); }
    683         if (!graph->valid(e.e)) {
     700        this->graph->next(e.e);
     701        while( this->graph->valid(e.e) && !(resCap(e)>0) ) {
     702          this->graph->next(e.e); }
     703        if (!this->graph->valid(e.e)) {
    684704          e.forward=false;
    685           graph->first(e.e);
    686           while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); }
     705          this->graph->first(e.e);
     706          while( this->graph->valid(e.e) && !(resCap(e)>0) ) {
     707            this->graph->next(e.e); }
    687708        }
    688709      } else {
    689         graph->next(e.e);
    690         while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); }
     710        this->graph->next(e.e);
     711        while( this->graph->valid(e.e) && !(resCap(e)>0) ) {
     712          this->graph->next(e.e); }
    691713      }
    692714      return e;
     
    694716
    695717    Node tail(Edge e) const {
    696       return ((e.forward) ? graph->tail(e) : graph->head(e)); }
     718      return ((e.forward) ? this->graph->tail(e) : this->graph->head(e)); }
    697719    Node head(Edge e) const {
    698       return ((e.forward) ? graph->head(e) : graph->tail(e)); }
     720      return ((e.forward) ? this->graph->head(e) : this->graph->tail(e)); }
    699721
    700722    Node aNode(OutEdgeIt e) const {
    701       return ((e.forward) ? graph->aNode(e.out) : graph->aNode(e.in)); }
     723      return ((e.forward) ? this->graph->aNode(e.out) :
     724              this->graph->aNode(e.in)); }
    702725    Node bNode(OutEdgeIt e) const {
    703       return ((e.forward) ? graph->bNode(e.out) : graph->bNode(e.in)); }
     726      return ((e.forward) ? this->graph->bNode(e.out) :
     727              this->graph->bNode(e.in)); }
    704728
    705729    Node aNode(InEdgeIt e) const {
    706       return ((e.forward) ? graph->aNode(e.in) : graph->aNode(e.out)); }
     730      return ((e.forward) ? this->graph->aNode(e.in) :
     731              this->graph->aNode(e.out)); }
    707732    Node bNode(InEdgeIt e) const {
    708       return ((e.forward) ? graph->bNode(e.in) : graph->bNode(e.out)); }
     733      return ((e.forward) ? this->graph->bNode(e.in) :
     734              this->graph->bNode(e.out)); }
    709735
    710736//    int nodeNum() const { return graph->nodeNum(); }
     
    718744    bool valid(Node n) const { return GraphWrapper<Graph>::valid(n); }
    719745    bool valid(Edge e) const {
    720       return graph->valid(e);
     746      return this->graph->valid(e);
    721747        //return e.forward ? graph->valid(e.out) : graph->valid(e.in);
    722748    }
     
    752778    template <typename T>
    753779    class EdgeMap {
    754       typename Graph::EdgeMap<T> forward_map, backward_map;
     780      typename Graph::template EdgeMap<T> forward_map, backward_map;
    755781    public:
    756782      EdgeMap(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& _G) : forward_map(*(_G.graph)), backward_map(*(_G.graph)) { }
     
    862888    using GraphWrapper<Graph>::next;
    863889//    NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }
    864     OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }
    865     InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }
    866     EdgeIt& next(EdgeIt& i) const { graph->next(i.e); return i; }   
     890    OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; }
     891    InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }
     892    EdgeIt& next(EdgeIt& i) const { this->graph->next(i.e); return i; }   
    867893   
    868     Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    869     Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
    870     Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
    871     Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
     894    Node aNode(const OutEdgeIt& e) const {
     895      return Node(this->graph->aNode(e.e)); }
     896    Node aNode(const InEdgeIt& e) const {
     897      return Node(this->graph->aNode(e.e)); }
     898    Node bNode(const OutEdgeIt& e) const {
     899      return Node(this->graph->bNode(e.e)); }
     900    Node bNode(const InEdgeIt& e) const {
     901      return Node(this->graph->bNode(e.e)); }
    872902
    873903    void erase(const OutEdgeIt& e) const {
     
    886916  template<typename Graph>
    887917  class BipartiteGraphWrapper : public GraphWrapper<Graph> {
    888     typedef IterableBoolMap< typename Graph::NodeMap<int> > SFalseTTrueMap;
     918    typedef IterableBoolMap< typename Graph::template NodeMap<int> >
     919    SFalseTTrueMap;
    889920    SFalseTTrueMap* s_false_t_true_map;
    890921   
     
    9841015//       this->s_false_t_true_map->next(n); return n;
    9851016//     }
    986     OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }
    987     InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }
     1017    OutEdgeIt& next(OutEdgeIt& i) const { this->graph->next(i.e); return i; }
     1018    InEdgeIt& next(InEdgeIt& i) const { this->graph->next(i.e); return i; }
    9881019
    9891020    Node tail(const Edge& e) {
     
    10791110      friend class GraphWrapper<Graph>;
    10801111      friend class stGraphWrapper<Graph>;
    1081       template <typename T> friend class stGraphWrapper<Graph>::NodeMap;
     1112      template <typename T> friend class NodeMap;
    10821113      friend class Edge;
    10831114      friend class OutEdgeIt;
     
    11201151      friend class GraphWrapper<Graph>;
    11211152      friend class stGraphWrapper<Graph>;
    1122       template <typename T> friend class stGraphWrapper<Graph>::EdgeMap;
     1153      template <typename T> friend class EdgeMap;
    11231154      int spec;
    11241155      typename Graph::Node n;
     
    12741305      switch (i.spec) {
    12751306        case 0:
    1276           graph->next(i.n);
    1277           if (!graph->valid(i.n)) {
     1307          this->graph->next(i.n);
     1308          if (!this->graph->valid(i.n)) {
    12781309            i.spec=1;
    12791310          }
     
    12911322      switch (i.spec) {
    12921323        case 0: //normal edge
    1293           typename Graph::Node v=graph->aNode(i.e);
    1294           graph->next(i.e);
    1295           if (!graph->valid(i.e)) { //Az igazi elek vegere ertunk
    1296             if (graph->inSClass(v)) { //S, nincs kiel
     1324          typename Graph::Node v=this->graph->aNode(i.e);
     1325          this->graph->next(i.e);
     1326          if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
     1327            if (this->graph->inSClass(v)) { //S, nincs kiel
    12971328              i.spec=3;
    12981329              i.n=INVALID;
     
    13041335          break;
    13051336        case 1: //s->vmi
    1306           graph->next(i.n);
    1307           if (!graph->valid(i.n)) i.spec=3;
     1337          this->graph->next(i.n);
     1338          if (!this->graph->valid(i.n)) i.spec=3;
    13081339          break;
    13091340        case 2: //vmi->t
     
    13171348      switch (i.spec) {
    13181349        case 0: //normal edge
    1319           typename Graph::Node v=graph->aNode(i.e);
    1320           graph->next(i.e);
    1321           if (!graph->valid(i.e)) { //Az igazi elek vegere ertunk
    1322             if (graph->inTClass(v)) { //S, nincs beel
     1350          typename Graph::Node v=this->graph->aNode(i.e);
     1351          this->graph->next(i.e);
     1352          if (!this->graph->valid(i.e)) { //Az igazi elek vegere ertunk
     1353            if (this->graph->inTClass(v)) { //S, nincs beel
    13231354              i.spec=3;
    13241355              i.n=INVALID;
     
    13341365          break;
    13351366        case 2: //vmi->t
    1336           graph->next(i.n);
    1337           if (!graph->valid(i.n)) i.spec=3;
     1367          this->graph->next(i.n);
     1368          if (!this->graph->valid(i.n)) i.spec=3;
    13381369          break;
    13391370      }
     
    13441375      switch (i.spec) {
    13451376        case 0:
    1346           graph->next(i.e);
    1347           if (!graph->valid(i.e)) {
     1377          this->graph->next(i.e);
     1378          if (!this->graph->valid(i.e)) {
    13481379            i.spec=1;
    1349             graph->first(n, S_CLASS);
    1350             if (!graph->valid(i.n)) {
     1380            this->graph->first(i.n, S_CLASS);
     1381            if (!this->graph->valid(i.n)) {
    13511382              i.spec=2;
    1352               graph->first(n, T_CLASS);
    1353               if (!graph->valid(i.n)) spec=3;
     1383              this->graph->first(i.n, T_CLASS);
     1384              if (!this->graph->valid(i.n)) i.spec=3;
    13541385            }
    13551386          }
    13561387          break;
    13571388        case 1:
    1358           graph->next(i.n);
    1359           if (!graph->valid(i.n)) {
     1389          this->graph->next(i.n);
     1390          if (!this->graph->valid(i.n)) {
    13601391            i.spec=2;
    1361             graph->first(n, T_CLASS);
    1362             if (!graph->valid(i.n)) spec=3;
     1392            this->graph->first(i.n, T_CLASS);
     1393            if (!this->graph->valid(i.n)) i.spec=3;
    13631394          }
    13641395          break;
    13651396        case 2:
    1366           graph->next(i.n);
    1367           if (!graph->valid(i.n)) i.spec=3;
     1397          this->graph->next(i.n);
     1398          if (!this->graph->valid(i.n)) i.spec=3;
    13681399          break;
    13691400      }
     
    13741405      switch (e.spec) {
    13751406        case 0:
    1376           return Node(graph->tail(e));
     1407          return Node(this->graph->tail(e));
    13771408          break;
    13781409        case 1:
     
    13871418      switch (e.spec) {
    13881419        case 0:
    1389           return Node(graph->head(e));
     1420          return Node(this->graph->head(e));
    13901421          break;
    13911422        case 1:
     
    14011432    bool valid(const Edge& e) const { return (e.spec<3); }
    14021433
    1403 //    int nodeNum() const { return graph->nodeNum(); }
    1404 //    int edgeNum() const { return graph->edgeNum(); }
     1434//    int nodeNum() const { return this->graph->nodeNum(); }
     1435//    int edgeNum() const { return this->graph->edgeNum(); }
    14051436 
    14061437    Node aNode(const OutEdgeIt& e) const { return tail(e); }
     
    14091440    Node bNode(const InEdgeIt& e) const { return tail(e); }
    14101441 
    1411 //    Node addNode() const { return Node(graph->addNode()); }
     1442//    Node addNode() const { return Node(this->graph->addNode()); }
    14121443//    Edge addEdge(const Node& tail, const Node& head) const {
    1413 //      return Edge(graph->addEdge(tail, head)); }
    1414 
    1415 //    void erase(const Node& i) const { graph->erase(i); }
    1416 //    void erase(const Edge& i) const { graph->erase(i); }
     1444//      return Edge(this->graph->addEdge(tail, head)); }
     1445
     1446//    void erase(const Node& i) const { this->graph->erase(i); }
     1447//    void erase(const Edge& i) const { this->graph->erase(i); }
    14171448 
    1418 //    void clear() const { graph->clear(); }
     1449//    void clear() const { this->graph->clear(); }
    14191450   
    1420     template<typename T> class NodeMap : public GraphWrapper<Graph>::NodeMap<T> {
     1451    template<typename T> class NodeMap : public GraphWrapper<Graph>::template NodeMap<T> {
     1452      typedef typename GraphWrapper<Graph>::template NodeMap<T> Parent;
    14211453      T s_value, t_value;
    14221454    public:
    1423       NodeMap(const stGraphWrapper<Graph>& _G) : 
    1424         GraphWrapper<Graph>::NodeMap<T>(_G) { }
    1425       NodeMap(const stGraphWrapper<Graph>& _G, T a) :
    1426         GraphWrapper<Graph>::NodeMap<T>(_G, a), s_value(a), t_value(a) { }
     1455      NodeMap(const stGraphWrapper<Graph>& _G) :  Parent(_G) { }
     1456      NodeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a),
     1457                                                      s_value(a),
     1458                                                      t_value(a) { }
    14271459      T operator[](const Node& n) const {
    14281460        switch (n.spec) {
     
    14411473        switch (n.spec) {
    14421474          case 0:
    1443             GraphWrapper<Graph>::NodeMap<T>::set(n, t);
     1475            GraphWrapper<Graph>::template NodeMap<T>::set(n, t);
    14441476            break;
    14451477          case 1:
     
    14531485    };
    14541486
    1455     template<typename T> class EdgeMap : public GraphWrapper<Graph>::EdgeMap<T> {
    1456       typename GraphWrapper<Graph>::NodeMap<T> node_value;
    1457     public:
    1458       EdgeMap(const stGraphWrapper<Graph>& _G) : 
    1459         GraphWrapper<Graph>::EdgeMap<T>(_G), node_value(_G) { }
    1460       EdgeMap(const stGraphWrapper<Graph>& _G, T a) :
    1461         GraphWrapper<Graph>::EdgeMap<T>(_G, a), node_value(_G, a) { }
     1487    template<typename T> class EdgeMap : public GraphWrapper<Graph>::template EdgeMap<T> {
     1488      typedef typename Graph::template NodeMap<T> Parent;
     1489      typename GraphWrapper<Graph>::template NodeMap<T> node_value;
     1490    public:
     1491      EdgeMap(const stGraphWrapper<Graph>& _G) :  Parent(_G),
     1492                                                  node_value(_G) { }
     1493      EdgeMap(const stGraphWrapper<Graph>& _G, T a) : Parent(_G, a),
     1494                                                      node_value(_G, a) { }
    14621495      T operator[](const Edge& e) const {
    14631496        switch (e.spec) {
Note: See TracChangeset for help on using the changeset viewer.