|      1 /* -*- C++ -*- |      1 /* -*- mode: C++; indent-tabs-mode: nil; -*- | 
|      2  * |      2  * | 
|      3  * This file is a part of LEMON, a generic C++ optimization library |      3  * This file is a part of LEMON, a generic C++ optimization library. | 
|      4  * |      4  * | 
|      5  * Copyright (C) 2003-2008 |      5  * Copyright (C) 2003-2008 | 
|      6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |      6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport | 
|      7  * (Egervary Research Group on Combinatorial Optimization, EGRES). |      7  * (Egervary Research Group on Combinatorial Optimization, EGRES). | 
|      8  * |      8  * | 
|     51  |     51  | 
|     52     class RevArcIt { |     52     class RevArcIt { | 
|     53     public: |     53     public: | 
|     54       RevArcIt() {} |     54       RevArcIt() {} | 
|     55       RevArcIt(Invalid) : path(0), current(INVALID) {} |     55       RevArcIt(Invalid) : path(0), current(INVALID) {} | 
|     56       RevArcIt(const PredMapPath& _path)  |     56       RevArcIt(const PredMapPath& _path) | 
|     57         : path(&_path), current(_path.target) { |     57         : path(&_path), current(_path.target) { | 
|     58         if (path->predMap[current] == INVALID) current = INVALID; |     58         if (path->predMap[current] == INVALID) current = INVALID; | 
|     59       } |     59       } | 
|     60  |     60  | 
|     61       operator const typename Digraph::Arc() const { |     61       operator const typename Digraph::Arc() const { | 
|     66         current = path->digraph.source(path->predMap[current]); |     66         current = path->digraph.source(path->predMap[current]); | 
|     67         if (path->predMap[current] == INVALID) current = INVALID; |     67         if (path->predMap[current] == INVALID) current = INVALID; | 
|     68         return *this; |     68         return *this; | 
|     69       } |     69       } | 
|     70  |     70  | 
|     71       bool operator==(const RevArcIt& e) const {  |     71       bool operator==(const RevArcIt& e) const { | 
|     72         return current == e.current;  |     72         return current == e.current; | 
|     73       } |     73       } | 
|     74  |     74  | 
|     75       bool operator!=(const RevArcIt& e) const { |     75       bool operator!=(const RevArcIt& e) const { | 
|     76         return current != e.current;  |     76         return current != e.current; | 
|     77       } |     77       } | 
|     78  |     78  | 
|     79       bool operator<(const RevArcIt& e) const {  |     79       bool operator<(const RevArcIt& e) const { | 
|     80         return current < e.current;  |     80         return current < e.current; | 
|     81       } |     81       } | 
|     82        |     82  | 
|     83     private: |     83     private: | 
|     84       const PredMapPath* path; |     84       const PredMapPath* path; | 
|     85       typename Digraph::Node current; |     85       typename Digraph::Node current; | 
|     86     }; |     86     }; | 
|     87  |     87  | 
|     99  |     99  | 
|    100     typedef _Digraph Digraph; |    100     typedef _Digraph Digraph; | 
|    101     typedef typename Digraph::Arc Arc; |    101     typedef typename Digraph::Arc Arc; | 
|    102     typedef _PredMatrixMap PredMatrixMap; |    102     typedef _PredMatrixMap PredMatrixMap; | 
|    103  |    103  | 
|    104     PredMatrixMapPath(const Digraph& _digraph,  |    104     PredMatrixMapPath(const Digraph& _digraph, | 
|    105                       const PredMatrixMap& _predMatrixMap, |    105                       const PredMatrixMap& _predMatrixMap, | 
|    106                       typename Digraph::Node _source,  |    106                       typename Digraph::Node _source, | 
|    107                       typename Digraph::Node _target) |    107                       typename Digraph::Node _target) | 
|    108       : digraph(_digraph), predMatrixMap(_predMatrixMap),  |    108       : digraph(_digraph), predMatrixMap(_predMatrixMap), | 
|    109         source(_source), target(_target) {} |    109         source(_source), target(_target) {} | 
|    110  |    110  | 
|    111     int length() const { |    111     int length() const { | 
|    112       int len = 0; |    112       int len = 0; | 
|    113       typename Digraph::Node node = target; |    113       typename Digraph::Node node = target; | 
|    125  |    125  | 
|    126     class RevArcIt { |    126     class RevArcIt { | 
|    127     public: |    127     public: | 
|    128       RevArcIt() {} |    128       RevArcIt() {} | 
|    129       RevArcIt(Invalid) : path(0), current(INVALID) {} |    129       RevArcIt(Invalid) : path(0), current(INVALID) {} | 
|    130       RevArcIt(const PredMatrixMapPath& _path)  |    130       RevArcIt(const PredMatrixMapPath& _path) | 
|    131         : path(&_path), current(_path.target) { |    131         : path(&_path), current(_path.target) { | 
|    132         if (path->predMatrixMap(path->source, current) == INVALID)  |    132         if (path->predMatrixMap(path->source, current) == INVALID) | 
|    133           current = INVALID; |    133           current = INVALID; | 
|    134       } |    134       } | 
|    135  |    135  | 
|    136       operator const typename Digraph::Arc() const { |    136       operator const typename Digraph::Arc() const { | 
|    137         return path->predMatrixMap(path->source, current); |    137         return path->predMatrixMap(path->source, current); | 
|    138       } |    138       } | 
|    139  |    139  | 
|    140       RevArcIt& operator++() { |    140       RevArcIt& operator++() { | 
|    141         current =  |    141         current = | 
|    142           path->digraph.source(path->predMatrixMap(path->source, current)); |    142           path->digraph.source(path->predMatrixMap(path->source, current)); | 
|    143         if (path->predMatrixMap(path->source, current) == INVALID)  |    143         if (path->predMatrixMap(path->source, current) == INVALID) | 
|    144           current = INVALID; |    144           current = INVALID; | 
|    145         return *this; |    145         return *this; | 
|    146       } |    146       } | 
|    147  |    147  | 
|    148       bool operator==(const RevArcIt& e) const {  |    148       bool operator==(const RevArcIt& e) const { | 
|    149         return current == e.current;  |    149         return current == e.current; | 
|    150       } |    150       } | 
|    151  |    151  | 
|    152       bool operator!=(const RevArcIt& e) const { |    152       bool operator!=(const RevArcIt& e) const { | 
|    153         return current != e.current;  |    153         return current != e.current; | 
|    154       } |    154       } | 
|    155  |    155  | 
|    156       bool operator<(const RevArcIt& e) const {  |    156       bool operator<(const RevArcIt& e) const { | 
|    157         return current < e.current;  |    157         return current < e.current; | 
|    158       } |    158       } | 
|    159        |    159  | 
|    160     private: |    160     private: | 
|    161       const PredMatrixMapPath* path; |    161       const PredMatrixMapPath* path; | 
|    162       typename Digraph::Node current; |    162       typename Digraph::Node current; | 
|    163     }; |    163     }; | 
|    164  |    164  |