COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
03/30/04 15:37:21 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@371
Message:

GraphWrappers?

File:
1 edited

Legend:

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

    r263 r265  
    1616
    1717    typedef typename Graph::Node Node;
    18     typedef typename Graph::NodeIt NodeIt;
    19 
     18    class NodeIt : public Graph::NodeIt {
     19    public:
     20      NodeIt() { }
     21      NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
     22      NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
     23      NodeIt(const TrivGraphWrapper<Graph>& _G) :
     24        Graph::NodeIt(*(_G.graph)) { }
     25    };
    2026    typedef typename Graph::Edge Edge;
    21     typedef typename Graph::OutEdgeIt OutEdgeIt;
    22     typedef typename Graph::InEdgeIt InEdgeIt;
     27    //typedef typename Graph::OutEdgeIt OutEdgeIt;
     28    class OutEdgeIt : public Graph::OutEdgeIt {
     29    public:
     30      OutEdgeIt() { }
     31      OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
     32      OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
     33      OutEdgeIt(const TrivGraphWrapper<Graph>& _G, const Node& n) :
     34        Graph::OutEdgeIt(*(_G.graph), n) { }
     35    };
     36    //typedef typename Graph::InEdgeIt InEdgeIt;
     37    class InEdgeIt : public Graph::InEdgeIt {
     38    public:
     39      InEdgeIt() { }
     40      InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
     41      InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
     42      InEdgeIt(const TrivGraphWrapper<Graph>& _G, const Node& n) :
     43        Graph::InEdgeIt(*(_G.graph), n) { }
     44    };
    2345    //typedef typename Graph::SymEdgeIt SymEdgeIt;
    24     typedef typename Graph::EdgeIt EdgeIt;
     46    //typedef typename Graph::EdgeIt EdgeIt;
     47    class EdgeIt : public Graph::EdgeIt {
     48    public:
     49      EdgeIt() { }
     50      EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
     51      EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
     52      EdgeIt(const TrivGraphWrapper<Graph>& _G) :
     53        Graph::EdgeIt(*(_G.graph)) { }
     54    };
    2555
    2656    //TrivGraphWrapper() : graph(0) { }
    2757    TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
    2858
    29     void setGraph(Graph& _graph) { graph = &_graph; }
    30     Graph& getGraph() const { return (*graph); }
    31    
    32     template<typename I> I& first(I& i) const { return graph->first(i); }
    33     template<typename I, typename P> I& first(I& i, const P& p) const {
    34       return graph->first(i, p); }
    35    
    36     template<typename I> I getNext(const I& i) const {
    37       return graph->getNext(i); }
    38     template<typename I> I& next(I &i) const { return graph->next(i); }   
     59//    void setGraph(Graph& _graph) { graph = &_graph; }
     60//    Graph& getGraph() const { return (*graph); }
     61
     62    NodeIt& first(NodeIt& i) const {
     63      i=NodeIt(*this);
     64      return i;
     65    }
     66    EdgeIt& first(EdgeIt& i) const {
     67      i=EdgeIt(*this);
     68      return i;
     69    }
     70//     template<typename I> I& first(I& i) const {
     71//       //return graph->first(i);
     72//       i=I(*this);
     73//       return i;
     74//     }
     75    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
     76      i=OutEdgeIt(*this, p);
     77      return i;
     78    }
     79    InEdgeIt& first(InEdgeIt& i, const Node& p) const {
     80      i=InEdgeIt(*this, p);
     81      return i;
     82    }
     83//     template<typename I, typename P> I& first(I& i, const P& p) const {
     84//       //return graph->first(i, p);
     85//       i=I(*this, p);
     86//       return i;
     87//     }
     88   
     89//    template<typename I> I getNext(const I& i) const {
     90//      return graph->getNext(i); }
     91    template<typename I> I& next(I &i) const { graph->next(i); return i; }   
    3992
    4093    template< typename It > It first() const {
     
    72125    public:
    73126      NodeMap(const TrivGraphWrapper<Graph>& _G) :
    74         Graph::NodeMap<T>(_G.getGraph()) { }
     127        Graph::NodeMap<T>(*(_G.graph)) { }
    75128      NodeMap(const TrivGraphWrapper<Graph>& _G, T a) :
    76         Graph::NodeMap<T>(_G.getGraph(), a) { }
     129        Graph::NodeMap<T>(*(_G.graph), a) { }
    77130    };
    78131
     
    80133    public:
    81134      EdgeMap(const TrivGraphWrapper<Graph>& _G) :
    82         Graph::EdgeMap<T>(_G.getGraph()) { }
     135        Graph::EdgeMap<T>(*(_G.graph)) { }
    83136      EdgeMap(const TrivGraphWrapper<Graph>& _G, T a) :
    84         Graph::EdgeMap<T>(_G.getGraph(), a) { }
     137        Graph::EdgeMap<T>(*(_G.graph), a) { }
    85138    };
    86139  };
     
    94147    //typedef typename GraphWrapper::BaseGraph BaseGraph;
    95148
     149//     typedef typename GraphWrapper::Node Node;
     150//     typedef typename GraphWrapper::NodeIt NodeIt;
     151
     152//     typedef typename GraphWrapper::Edge Edge;
     153//     typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
     154//     typedef typename GraphWrapper::InEdgeIt InEdgeIt;
     155//     //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt;
     156//     typedef typename GraphWrapper::EdgeIt EdgeIt;
     157
    96158    typedef typename GraphWrapper::Node Node;
    97     typedef typename GraphWrapper::NodeIt NodeIt;
    98 
     159    class NodeIt : public GraphWrapper::NodeIt {
     160    public:
     161      NodeIt() { }
     162      NodeIt(const typename GraphWrapper::NodeIt& n) :
     163        GraphWrapper::NodeIt(n) { }
     164      NodeIt(const Invalid& i) : GraphWrapper::NodeIt(i) { }
     165      NodeIt(const GraphWrapperSkeleton<GraphWrapper>& _G) :
     166        GraphWrapper::NodeIt(_G.gw) { }
     167    };
    99168    typedef typename GraphWrapper::Edge Edge;
    100     typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
    101     typedef typename GraphWrapper::InEdgeIt InEdgeIt;
     169    //typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
     170    class OutEdgeIt : public GraphWrapper::OutEdgeIt {
     171    public:
     172      OutEdgeIt() { }
     173      OutEdgeIt(const typename GraphWrapper::OutEdgeIt& e) :
     174        GraphWrapper::OutEdgeIt(e) { }
     175      OutEdgeIt(const Invalid& i) : GraphWrapper::OutEdgeIt(i) { }
     176      OutEdgeIt(const GraphWrapperSkeleton<GraphWrapper>& _G, const Node& n) :
     177        GraphWrapper::OutEdgeIt(_G.gw, n) { }
     178    };
     179    //typedef typename GraphWrapper::InEdgeIt InEdgeIt;
     180    class InEdgeIt : public GraphWrapper::InEdgeIt {
     181    public:
     182      InEdgeIt() { }
     183      InEdgeIt(const typename GraphWrapper::InEdgeIt& e) :
     184        GraphWrapper::InEdgeIt(e) { }
     185      InEdgeIt(const Invalid& i) : GraphWrapper::InEdgeIt(i) { }
     186      InEdgeIt(const GraphWrapperSkeleton<GraphWrapper>& _G, const Node& n) :
     187        GraphWrapper::InEdgeIt(_G.gw, n) { }
     188    };
    102189    //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt;
    103     typedef typename GraphWrapper::EdgeIt EdgeIt;
     190    //typedef typename GraphWrapper::EdgeIt EdgeIt;
     191    class EdgeIt : public GraphWrapper::EdgeIt {
     192    public:
     193      EdgeIt() { }
     194      EdgeIt(const typename GraphWrapper::EdgeIt& e) :
     195        GraphWrapper::EdgeIt(e) { }
     196      EdgeIt(const Invalid& i) : GraphWrapper::EdgeIt(i) { }
     197      EdgeIt(const GraphWrapperSkeleton<GraphWrapper>& _G) :
     198        GraphWrapper::EdgeIt(_G.gw) { }
     199    };
     200
    104201
    105202    //GraphWrapperSkeleton() : gw() { }
     
    109206    //BaseGraph& getGraph() const { return gw.getGraph(); }
    110207   
    111     template<typename I> I& first(I& i) const { return gw.first(i); }
     208    template<typename I> I& first(I& i) const {       
     209      i=I(*this);
     210      return i;
     211    }
    112212    template<typename I, typename P> I& first(I& i, const P& p) const {
    113       return gw.first(i, p); }
    114    
    115     template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
    116     template<typename I> I& next(I &i) const { return gw.next(i); }   
     213      i=I(*this, p);
     214      return i;
     215    }
     216   
     217//    template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
     218    template<typename I> I& next(I &i) const { gw.next(i); return i; }   
    117219
    118220    template< typename It > It first() const {
     
    656758    }
    657759
    658     template<typename I> I& first(I& i) const { return gw.first(i); }
     760    template<typename I> I& first(I& i) const { gw.first(i); return i; }
    659761    template<typename I, typename P> I& first(I& i, const P& p) const {
    660       return graph->first(i, p); }
     762      graph->first(i, p); return i; }
    661763
    662764    OutEdgeIt& next(OutEdgeIt& e) const {
     
    682784
    683785    template<typename I> I& next(I &i) const { return gw.next(i); }   
    684     template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
     786//    template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
    685787
    686788    template< typename It > It first() const {
     
    814916  public:
    815917    //typedef Graph BaseGraph;
    816     typedef typename Graph::Node Node;
    817     typedef typename Graph::NodeIt NodeIt;
     918    typedef TrivGraphWrapper<const Graph> GraphWrapper;
     919    typedef typename GraphWrapper::Node Node;
     920    typedef typename GraphWrapper::NodeIt NodeIt;
    818921  private:
    819     typedef typename Graph::OutEdgeIt OldOutEdgeIt;
    820     typedef typename Graph::InEdgeIt OldInEdgeIt;
     922    typedef typename GraphWrapper::OutEdgeIt OldOutEdgeIt;
     923    typedef typename GraphWrapper::InEdgeIt OldInEdgeIt;
    821924  protected:
    822925    //const Graph* graph;
    823     typedef TrivGraphWrapper<const Graph> GraphWrapper;
    824926    GraphWrapper gw;
    825927    FlowMap* flow;
     
    872974      OutEdgeIt(const Edge& e) : Edge(e) { }
    873975      OutEdgeIt(const Invalid& i) : Edge(i) { }
    874     private:
     976    protected:
    875977      OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
    876978        resG.gw.first(out, v);
     
    9061008    class EdgeIt : public Edge {
    9071009      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
    908       typename Graph::NodeIt v;
     1010      NodeIt v;
    9091011    public:
    9101012      EdgeIt() { }
Note: See TracChangeset for help on using the changeset viewer.