COIN-OR::LEMON - Graph Library

Changeset 230:734dd0649941 in lemon-0.x for src/work


Ignore:
Timestamp:
03/22/04 13:17:44 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@327
Message:

.

File:
1 edited

Legend:

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

    r212 r230  
    104104
    105105    //GraphWrapperSkeleton() : gw() { }
    106     GraphWrapperSkeleton(GraphWrapper& _gw) : gw(_gw) { }
     106    GraphWrapperSkeleton(GraphWrapper _gw) : gw(_gw) { }
    107107
    108108    void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); }
     
    161161  };
    162162
     163//   template<typename Graph>
     164//   class RevGraphWrapper
     165//   {
     166//   protected:
     167//     Graph* graph;
     168 
     169//   public:
     170//     typedef Graph BaseGraph;
     171
     172//     typedef typename Graph::Node Node;   
     173//     typedef typename Graph::NodeIt NodeIt;
     174 
     175//     typedef typename Graph::Edge Edge;
     176//     typedef typename Graph::OutEdgeIt InEdgeIt;
     177//     typedef typename Graph::InEdgeIt OutEdgeIt;
     178//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
     179//     typedef typename Graph::EdgeIt EdgeIt;
     180
     181//     //RevGraphWrapper() : graph(0) { }
     182//     RevGraphWrapper(Graph& _graph) : graph(&_graph) { }
     183
     184//     void setGraph(Graph& _graph) { graph = &_graph; }
     185//     Graph& getGraph() const { return (*graph); }
     186   
     187//     template<typename I> I& first(I& i) const { return graph->first(i); }
     188//     template<typename I, typename P> I& first(I& i, const P& p) const {
     189//       return graph->first(i, p); }
     190
     191//     template<typename I> I getNext(const I& i) const {
     192//       return graph->getNext(i); }
     193//     template<typename I> I& next(I &i) const { return graph->next(i); }   
     194
     195//     template< typename It > It first() const {
     196//       It e; first(e); return e; }
     197
     198//     template< typename It > It first(const Node& v) const {
     199//       It e; first(e, v); return e; }
     200
     201//     Node head(const Edge& e) const { return graph->tail(e); }
     202//     Node tail(const Edge& e) const { return graph->head(e); }
     203 
     204//     template<typename I> bool valid(const I& i) const
     205//       { return graph->valid(i); }
     206 
     207//     //template<typename I> void setInvalid(const I &i);
     208//     //{ return graph->setInvalid(i); }
     209 
     210//     template<typename I> Node aNode(const I& e) const {
     211//       return graph->aNode(e); }
     212//     template<typename I> Node bNode(const I& e) const {
     213//       return graph->bNode(e); }
     214
     215//     Node addNode() const { return graph->addNode(); }
     216//     Edge addEdge(const Node& tail, const Node& head) const {
     217//       return graph->addEdge(tail, head); }
     218 
     219//     int nodeNum() const { return graph->nodeNum(); }
     220//     int edgeNum() const { return graph->edgeNum(); }
     221 
     222//     template<typename I> void erase(const I& i) const { graph->erase(i); }
     223 
     224//     void clear() const { graph->clear(); }
     225
     226//     template<typename T> class NodeMap : public Graph::NodeMap<T> {
     227//     public:
     228//       NodeMap(const RevGraphWrapper<Graph>& _G) :
     229//      Graph::NodeMap<T>(_G.getGraph()) { }
     230//       NodeMap(const RevGraphWrapper<Graph>& _G, T a) :
     231//      Graph::NodeMap<T>(_G.getGraph(), a) { }
     232//     };
     233
     234//     template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
     235//     public:
     236//       EdgeMap(const RevGraphWrapper<Graph>& _G) :
     237//      Graph::EdgeMap<T>(_G.getGraph()) { }
     238//       EdgeMap(const RevGraphWrapper<Graph>& _G, T a) :
     239//      Graph::EdgeMap<T>(_G.getGraph(), a) { }
     240//     };
     241//   };
     242
    163243  template<typename Graph>
    164   class RevGraphWrapper
    165   {
     244  class RevGraphWrapper :
     245    public GraphWrapperSkeleton< TrivGraphWrapper<Graph> > {
    166246  protected:
    167     Graph* graph;
    168  
     247    //Graph* graph;
     248   
    169249  public:
    170     typedef Graph BaseGraph;
    171 
    172     typedef typename Graph::Node Node;   
    173     typedef typename Graph::NodeIt NodeIt;
    174  
    175     typedef typename Graph::Edge Edge;
    176     typedef typename Graph::OutEdgeIt InEdgeIt;
    177     typedef typename Graph::InEdgeIt OutEdgeIt;
     250    //typedef Graph BaseGraph;
     251
     252    //typedef typename Graph::Node Node;   
     253    //typedef typename Graph::NodeIt NodeIt;
     254 
     255    //typedef typename Graph::Edge Edge;
     256    typedef typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::OutEdgeIt InEdgeIt;
     257    typedef typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::InEdgeIt OutEdgeIt;
    178258    //typedef typename Graph::SymEdgeIt SymEdgeIt;
    179     typedef typename Graph::EdgeIt EdgeIt;
     259    //typedef typename Graph::EdgeIt EdgeIt;
    180260
    181261    //RevGraphWrapper() : graph(0) { }
    182     RevGraphWrapper(Graph& _graph) : graph(&_graph) { }
    183 
    184     void setGraph(Graph& _graph) { graph = &_graph; }
    185     Graph& getGraph() const { return (*graph); }
    186    
    187     template<typename I> I& first(I& i) const { return graph->first(i); }
    188     template<typename I, typename P> I& first(I& i, const P& p) const {
    189       return graph->first(i, p); }
    190 
    191     template<typename I> I getNext(const I& i) const {
    192       return graph->getNext(i); }
    193     template<typename I> I& next(I &i) const { return graph->next(i); }   
    194 
    195     template< typename It > It first() const {
    196       It e; first(e); return e; }
    197 
    198     template< typename It > It first(const Node& v) const {
    199       It e; first(e, v); return e; }
    200 
    201     Node head(const Edge& e) const { return graph->tail(e); }
    202     Node tail(const Edge& e) const { return graph->head(e); }
    203  
    204     template<typename I> bool valid(const I& i) const
    205       { return graph->valid(i); }
     262    RevGraphWrapper(Graph& _graph) : GraphWrapperSkeleton< TrivGraphWrapper<Graph> >(TrivGraphWrapper<Graph>(_graph)) { }
     263   
     264    //void setGraph(Graph& _graph) { graph = &_graph; }
     265    //Graph& getGraph() const { return (*graph); }
     266   
     267    //template<typename I> I& first(I& i) const { return graph->first(i); }
     268    //template<typename I, typename P> I& first(I& i, const P& p) const {
     269    //  return graph->first(i, p); }
     270
     271    //template<typename I> I getNext(const I& i) const {
     272    //  return graph->getNext(i); }
     273    //template<typename I> I& next(I &i) const { return graph->next(i); }   
     274
     275    //template< typename It > It first() const {
     276    //  It e; first(e); return e; }
     277
     278    //template< typename It > It first(const Node& v) const {
     279    //  It e; first(e, v); return e; }
     280
     281    //Node head(const Edge& e) const { return graph->tail(e); }
     282    //Node tail(const Edge& e) const { return graph->head(e); }
     283 
     284    //template<typename I> bool valid(const I& i) const
     285    //  { return graph->valid(i); }
    206286 
    207287    //template<typename I> void setInvalid(const I &i);
    208288    //{ return graph->setInvalid(i); }
    209289 
    210     template<typename I> Node aNode(const I& e) const {
    211       return graph->aNode(e); }
    212     template<typename I> Node bNode(const I& e) const {
    213       return graph->bNode(e); }
    214 
    215     Node addNode() const { return graph->addNode(); }
    216     Edge addEdge(const Node& tail, const Node& head) const {
    217       return graph->addEdge(tail, head); }
    218  
    219     int nodeNum() const { return graph->nodeNum(); }
    220     int edgeNum() const { return graph->edgeNum(); }
    221  
    222     template<typename I> void erase(const I& i) const { graph->erase(i); }
    223  
    224     void clear() const { graph->clear(); }
    225 
    226     template<typename T> class NodeMap : public Graph::NodeMap<T> {
     290    //template<typename I> Node aNode(const I& e) const {
     291    //  return graph->aNode(e); }
     292    //template<typename I> Node bNode(const I& e) const {
     293    //  return graph->bNode(e); }
     294
     295    //Node addNode() const { return graph->addNode(); }
     296    //Edge addEdge(const Node& tail, const Node& head) const {
     297    //  return graph->addEdge(tail, head); }
     298 
     299    //int nodeNum() const { return graph->nodeNum(); }
     300    //int edgeNum() const { return graph->edgeNum(); }
     301 
     302    //template<typename I> void erase(const I& i) const { graph->erase(i); }
     303 
     304    //void clear() const { graph->clear(); }
     305
     306    template<typename T> class NodeMap :
     307      public GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T>
     308    {
    227309    public:
    228310      NodeMap(const RevGraphWrapper<Graph>& _G) :
    229         Graph::NodeMap<T>(_G.getGraph()) { }
     311        GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T>(_G) { }
    230312      NodeMap(const RevGraphWrapper<Graph>& _G, T a) :
    231         Graph::NodeMap<T>(_G.getGraph(), a) { }
    232     };
    233 
    234     template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
     313        GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::NodeMap<T>(_G, a) { }
     314    };
     315   
     316    template<typename T> class EdgeMap :
     317      public GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T> {
    235318    public:
    236319      EdgeMap(const RevGraphWrapper<Graph>& _G) :
    237         Graph::EdgeMap<T>(_G.getGraph()) { }
     320        GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T>(_G) { }
    238321      EdgeMap(const RevGraphWrapper<Graph>& _G, T a) :
    239         Graph::EdgeMap<T>(_G.getGraph(), a) { }
     322        GraphWrapperSkeleton< TrivGraphWrapper<Graph> >::EdgeMap<T>(_G, a) { }
    240323    };
    241324  };
     325
     326
     327
    242328
    243329
Note: See TracChangeset for help on using the changeset viewer.