src/work/marci/graph_wrapper.h
changeset 265 bf7aea53635a
parent 263 f24f276e0b6b
child 266 4cec4981dfd1
     1.1 --- a/src/work/marci/graph_wrapper.h	Tue Mar 30 13:18:10 2004 +0000
     1.2 +++ b/src/work/marci/graph_wrapper.h	Tue Mar 30 13:37:21 2004 +0000
     1.3 @@ -15,27 +15,80 @@
     1.4      typedef Graph BaseGraph;
     1.5  
     1.6      typedef typename Graph::Node Node;
     1.7 -    typedef typename Graph::NodeIt NodeIt;
     1.8 -
     1.9 +    class NodeIt : public Graph::NodeIt { 
    1.10 +    public:
    1.11 +      NodeIt() { }
    1.12 +      NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
    1.13 +      NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
    1.14 +      NodeIt(const TrivGraphWrapper<Graph>& _G) : 
    1.15 +	Graph::NodeIt(*(_G.graph)) { }
    1.16 +    };
    1.17      typedef typename Graph::Edge Edge;
    1.18 -    typedef typename Graph::OutEdgeIt OutEdgeIt;
    1.19 -    typedef typename Graph::InEdgeIt InEdgeIt;
    1.20 +    //typedef typename Graph::OutEdgeIt OutEdgeIt;
    1.21 +    class OutEdgeIt : public Graph::OutEdgeIt { 
    1.22 +    public:
    1.23 +      OutEdgeIt() { }
    1.24 +      OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
    1.25 +      OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
    1.26 +      OutEdgeIt(const TrivGraphWrapper<Graph>& _G, const Node& n) : 
    1.27 +	Graph::OutEdgeIt(*(_G.graph), n) { }
    1.28 +    };
    1.29 +    //typedef typename Graph::InEdgeIt InEdgeIt;
    1.30 +    class InEdgeIt : public Graph::InEdgeIt { 
    1.31 +    public:
    1.32 +      InEdgeIt() { }
    1.33 +      InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
    1.34 +      InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
    1.35 +      InEdgeIt(const TrivGraphWrapper<Graph>& _G, const Node& n) : 
    1.36 +	Graph::InEdgeIt(*(_G.graph), n) { }
    1.37 +    };
    1.38      //typedef typename Graph::SymEdgeIt SymEdgeIt;
    1.39 -    typedef typename Graph::EdgeIt EdgeIt;
    1.40 +    //typedef typename Graph::EdgeIt EdgeIt;
    1.41 +    class EdgeIt : public Graph::EdgeIt { 
    1.42 +    public:
    1.43 +      EdgeIt() { }
    1.44 +      EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
    1.45 +      EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
    1.46 +      EdgeIt(const TrivGraphWrapper<Graph>& _G) : 
    1.47 +	Graph::EdgeIt(*(_G.graph)) { }
    1.48 +    };
    1.49  
    1.50      //TrivGraphWrapper() : graph(0) { }
    1.51      TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
    1.52  
    1.53 -    void setGraph(Graph& _graph) { graph = &_graph; }
    1.54 -    Graph& getGraph() const { return (*graph); }
    1.55 +//    void setGraph(Graph& _graph) { graph = &_graph; }
    1.56 +//    Graph& getGraph() const { return (*graph); }
    1.57 +
    1.58 +    NodeIt& first(NodeIt& i) const { 
    1.59 +      i=NodeIt(*this);
    1.60 +      return i;
    1.61 +    }
    1.62 +    EdgeIt& first(EdgeIt& i) const { 
    1.63 +      i=EdgeIt(*this);
    1.64 +      return i;
    1.65 +    }
    1.66 +//     template<typename I> I& first(I& i) const { 
    1.67 +//       //return graph->first(i); 
    1.68 +//       i=I(*this);
    1.69 +//       return i;
    1.70 +//     }
    1.71 +    OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
    1.72 +      i=OutEdgeIt(*this, p);
    1.73 +      return i;
    1.74 +    }
    1.75 +    InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
    1.76 +      i=InEdgeIt(*this, p);
    1.77 +      return i;
    1.78 +    }
    1.79 +//     template<typename I, typename P> I& first(I& i, const P& p) const { 
    1.80 +//       //return graph->first(i, p);
    1.81 +//       i=I(*this, p);
    1.82 +//       return i;
    1.83 +//     }
    1.84      
    1.85 -    template<typename I> I& first(I& i) const { return graph->first(i); }
    1.86 -    template<typename I, typename P> I& first(I& i, const P& p) const { 
    1.87 -      return graph->first(i, p); }
    1.88 -    
    1.89 -    template<typename I> I getNext(const I& i) const { 
    1.90 -      return graph->getNext(i); }
    1.91 -    template<typename I> I& next(I &i) const { return graph->next(i); }    
    1.92 +//    template<typename I> I getNext(const I& i) const { 
    1.93 +//      return graph->getNext(i); }
    1.94 +    template<typename I> I& next(I &i) const { graph->next(i); return i; }    
    1.95  
    1.96      template< typename It > It first() const { 
    1.97        It e; first(e); return e; }
    1.98 @@ -71,17 +124,17 @@
    1.99      template<typename T> class NodeMap : public Graph::NodeMap<T> { 
   1.100      public:
   1.101        NodeMap(const TrivGraphWrapper<Graph>& _G) : 
   1.102 -	Graph::NodeMap<T>(_G.getGraph()) { }
   1.103 +	Graph::NodeMap<T>(*(_G.graph)) { }
   1.104        NodeMap(const TrivGraphWrapper<Graph>& _G, T a) : 
   1.105 -	Graph::NodeMap<T>(_G.getGraph(), a) { }
   1.106 +	Graph::NodeMap<T>(*(_G.graph), a) { }
   1.107      };
   1.108  
   1.109      template<typename T> class EdgeMap : public Graph::EdgeMap<T> { 
   1.110      public:
   1.111        EdgeMap(const TrivGraphWrapper<Graph>& _G) : 
   1.112 -	Graph::EdgeMap<T>(_G.getGraph()) { }
   1.113 +	Graph::EdgeMap<T>(*(_G.graph)) { }
   1.114        EdgeMap(const TrivGraphWrapper<Graph>& _G, T a) : 
   1.115 -	Graph::EdgeMap<T>(_G.getGraph(), a) { }
   1.116 +	Graph::EdgeMap<T>(*(_G.graph), a) { }
   1.117      };
   1.118    };
   1.119  
   1.120 @@ -93,14 +146,58 @@
   1.121    public:
   1.122      //typedef typename GraphWrapper::BaseGraph BaseGraph;
   1.123  
   1.124 +//     typedef typename GraphWrapper::Node Node;
   1.125 +//     typedef typename GraphWrapper::NodeIt NodeIt;
   1.126 +
   1.127 +//     typedef typename GraphWrapper::Edge Edge;
   1.128 +//     typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
   1.129 +//     typedef typename GraphWrapper::InEdgeIt InEdgeIt;
   1.130 +//     //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt;
   1.131 +//     typedef typename GraphWrapper::EdgeIt EdgeIt;
   1.132 +
   1.133      typedef typename GraphWrapper::Node Node;
   1.134 -    typedef typename GraphWrapper::NodeIt NodeIt;
   1.135 +    class NodeIt : public GraphWrapper::NodeIt { 
   1.136 +    public:
   1.137 +      NodeIt() { }
   1.138 +      NodeIt(const typename GraphWrapper::NodeIt& n) : 
   1.139 +	GraphWrapper::NodeIt(n) { }
   1.140 +      NodeIt(const Invalid& i) : GraphWrapper::NodeIt(i) { }
   1.141 +      NodeIt(const GraphWrapperSkeleton<GraphWrapper>& _G) : 
   1.142 +	GraphWrapper::NodeIt(_G.gw) { }
   1.143 +    };
   1.144 +    typedef typename GraphWrapper::Edge Edge;
   1.145 +    //typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
   1.146 +    class OutEdgeIt : public GraphWrapper::OutEdgeIt { 
   1.147 +    public:
   1.148 +      OutEdgeIt() { }
   1.149 +      OutEdgeIt(const typename GraphWrapper::OutEdgeIt& e) : 
   1.150 +	GraphWrapper::OutEdgeIt(e) { }
   1.151 +      OutEdgeIt(const Invalid& i) : GraphWrapper::OutEdgeIt(i) { }
   1.152 +      OutEdgeIt(const GraphWrapperSkeleton<GraphWrapper>& _G, const Node& n) : 
   1.153 +	GraphWrapper::OutEdgeIt(_G.gw, n) { }
   1.154 +    };
   1.155 +    //typedef typename GraphWrapper::InEdgeIt InEdgeIt;
   1.156 +    class InEdgeIt : public GraphWrapper::InEdgeIt { 
   1.157 +    public:
   1.158 +      InEdgeIt() { }
   1.159 +      InEdgeIt(const typename GraphWrapper::InEdgeIt& e) : 
   1.160 +	GraphWrapper::InEdgeIt(e) { }
   1.161 +      InEdgeIt(const Invalid& i) : GraphWrapper::InEdgeIt(i) { }
   1.162 +      InEdgeIt(const GraphWrapperSkeleton<GraphWrapper>& _G, const Node& n) : 
   1.163 +	GraphWrapper::InEdgeIt(_G.gw, n) { }
   1.164 +    };
   1.165 +    //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt;
   1.166 +    //typedef typename GraphWrapper::EdgeIt EdgeIt;
   1.167 +    class EdgeIt : public GraphWrapper::EdgeIt { 
   1.168 +    public:
   1.169 +      EdgeIt() { }
   1.170 +      EdgeIt(const typename GraphWrapper::EdgeIt& e) : 
   1.171 +	GraphWrapper::EdgeIt(e) { }
   1.172 +      EdgeIt(const Invalid& i) : GraphWrapper::EdgeIt(i) { }
   1.173 +      EdgeIt(const GraphWrapperSkeleton<GraphWrapper>& _G) : 
   1.174 +	GraphWrapper::EdgeIt(_G.gw) { }
   1.175 +    };
   1.176  
   1.177 -    typedef typename GraphWrapper::Edge Edge;
   1.178 -    typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
   1.179 -    typedef typename GraphWrapper::InEdgeIt InEdgeIt;
   1.180 -    //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt;
   1.181 -    typedef typename GraphWrapper::EdgeIt EdgeIt;
   1.182  
   1.183      //GraphWrapperSkeleton() : gw() { }
   1.184      GraphWrapperSkeleton(GraphWrapper _gw) : gw(_gw) { }
   1.185 @@ -108,12 +205,17 @@
   1.186      //void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); }
   1.187      //BaseGraph& getGraph() const { return gw.getGraph(); }
   1.188      
   1.189 -    template<typename I> I& first(I& i) const { return gw.first(i); }
   1.190 +    template<typename I> I& first(I& i) const {       
   1.191 +      i=I(*this);
   1.192 +      return i;
   1.193 +    }
   1.194      template<typename I, typename P> I& first(I& i, const P& p) const { 
   1.195 -      return gw.first(i, p); }
   1.196 +      i=I(*this, p);
   1.197 +      return i; 
   1.198 +    }
   1.199      
   1.200 -    template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
   1.201 -    template<typename I> I& next(I &i) const { return gw.next(i); }    
   1.202 +//    template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
   1.203 +    template<typename I> I& next(I &i) const { gw.next(i); return i; }    
   1.204  
   1.205      template< typename It > It first() const { 
   1.206        It e; this->first(e); return e; }
   1.207 @@ -655,9 +757,9 @@
   1.208        return e;
   1.209      }
   1.210  
   1.211 -    template<typename I> I& first(I& i) const { return gw.first(i); }
   1.212 +    template<typename I> I& first(I& i) const { gw.first(i); return i; }
   1.213      template<typename I, typename P> I& first(I& i, const P& p) const { 
   1.214 -      return graph->first(i, p); }
   1.215 +      graph->first(i, p); return i; }
   1.216  
   1.217      OutEdgeIt& next(OutEdgeIt& e) const {
   1.218        if (e.out_or_in) {
   1.219 @@ -681,7 +783,7 @@
   1.220      }
   1.221  
   1.222      template<typename I> I& next(I &i) const { return gw.next(i); }    
   1.223 -    template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
   1.224 +//    template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
   1.225  
   1.226      template< typename It > It first() const { 
   1.227        It e; first(e); return e; }
   1.228 @@ -813,14 +915,14 @@
   1.229    class ResGraphWrapper {
   1.230    public:
   1.231      //typedef Graph BaseGraph;
   1.232 -    typedef typename Graph::Node Node;
   1.233 -    typedef typename Graph::NodeIt NodeIt;
   1.234 +    typedef TrivGraphWrapper<const Graph> GraphWrapper;
   1.235 +    typedef typename GraphWrapper::Node Node;
   1.236 +    typedef typename GraphWrapper::NodeIt NodeIt;
   1.237    private:
   1.238 -    typedef typename Graph::OutEdgeIt OldOutEdgeIt;
   1.239 -    typedef typename Graph::InEdgeIt OldInEdgeIt;
   1.240 +    typedef typename GraphWrapper::OutEdgeIt OldOutEdgeIt;
   1.241 +    typedef typename GraphWrapper::InEdgeIt OldInEdgeIt;
   1.242    protected:
   1.243      //const Graph* graph;
   1.244 -    typedef TrivGraphWrapper<const Graph> GraphWrapper;
   1.245      GraphWrapper gw;
   1.246      FlowMap* flow;
   1.247      const CapacityMap* capacity;
   1.248 @@ -871,7 +973,7 @@
   1.249        //FIXME
   1.250        OutEdgeIt(const Edge& e) : Edge(e) { }
   1.251        OutEdgeIt(const Invalid& i) : Edge(i) { }
   1.252 -    private:
   1.253 +    protected:
   1.254        OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() { 
   1.255  	resG.gw.first(out, v);
   1.256  	while( resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
   1.257 @@ -905,7 +1007,7 @@
   1.258  
   1.259      class EdgeIt : public Edge {
   1.260        friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
   1.261 -      typename Graph::NodeIt v;
   1.262 +      NodeIt v; 
   1.263      public:
   1.264        EdgeIt() { }
   1.265        //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }