src/work/alpar/gwrapper.h
changeset 65 a63cef252656
child 70 851ca9a60e90
equal deleted inserted replaced
-1:000000000000 0:3fdba4a14f06
       
     1 // -*-mode: c++; -*-
       
     2 
       
     3 template<typename G>
       
     4 class TrivGraphWrapper
       
     5 {
       
     6   G *graph;
       
     7   
       
     8 public:
       
     9   typedef G BaseGraph;
       
    10 
       
    11   typedef typename G::EdgeIt EdgeIt;
       
    12   
       
    13   typedef typename G::InEdgeIt InEdgeIt;
       
    14   typedef typename G::OutEdgeIt OutEdgeIt;
       
    15   typedef typename G::SymEdgeIt SymEdgeIt;
       
    16   typedef typename G::EachEdgeIt EachEdgeIt;
       
    17 
       
    18   typedef typename G::NodeIt NodeIt;
       
    19     
       
    20   template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
       
    21   template<typename I,typename P> I &getFirst(I &i,const P &p);
       
    22   { return graph->getFirst(i,p); }
       
    23   template<typename I> I next(const I i); { return graph->goNext(i); }
       
    24   template<typename I> I &goNext(I &i); { return graph->goNext(i); }
       
    25 
       
    26   NodeIt head(const EdgeIt &e);
       
    27   { return graph->head(e); }
       
    28   NodeIt tail(const EdgeIt &e);
       
    29   { return graph->tail(e); }
       
    30   
       
    31   template<typename I> NodeIt aNode(const I e);
       
    32   { return graph->aNode(e); }
       
    33   template<typename I> NodeIt bNode(const I e);
       
    34   { return graph->bNode(e); }
       
    35   
       
    36   template<typename I> bool valid(const I i);
       
    37   { return graph->valid(i); }
       
    38   
       
    39   template<typename I> void setInvalid(const I &i);
       
    40   { return graph->setInvalid(i); }
       
    41   
       
    42   NodeIt addNode(); { return graph->addNode(); }
       
    43   EdgeIt addEdge(const NodeIt from,const NodeIt to);
       
    44   { return graph->addEdge(ftom,to); }
       
    45   
       
    46   template<I> void delete(I i); { graph->delete(i); }
       
    47   
       
    48   void clean();  { graph->clean(); }
       
    49   
       
    50   template<class T> class NodeMap : public typename G::NodeMap<T>;
       
    51   template<class T> class EdgeMap : public typename G::EdgeMap<T>;
       
    52   
       
    53   void SetG(G &g) {graph = &g;}
       
    54   
       
    55   TrivGraphWrapper() {graph = NULL;}
       
    56   TrivGraphWrapper(G &g) {graph = &g;}
       
    57 };
       
    58 
       
    59 template<typename G>
       
    60 class RevGraphWrapper
       
    61 {
       
    62   G *graph;
       
    63   
       
    64 public:
       
    65   typedef G BaseGraph;
       
    66 
       
    67   typedef typename G::EdgeIt EdgeIt;
       
    68   
       
    69   typedef typename G::InEdgeIt OutEdgeIt;
       
    70   typedef typename G::OutEdgeIt InEdgeIt;
       
    71   typedef typename G::SymEdgeIt SymEdgeIt;
       
    72   typedef typename G::EachEdgeIt EachEdgeIt;
       
    73 
       
    74   typedef typename G::NodeIt NodeIt;
       
    75     
       
    76   template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
       
    77   template<typename I,typename P> I &getFirst(I &i,const P &p);
       
    78   { return graph->getFirst(i,p); }
       
    79   template<typename I> I next(const I i); { return graph->goNext(i); }
       
    80   template<typename I> I &goNext(I &i); { return graph->goNext(i); }
       
    81 
       
    82   NodeIt head(const EdgeIt &e);
       
    83   { return graph->tail(e); }
       
    84   NodeIt tail(const EdgeIt &e);
       
    85   { return graph->head(e); }
       
    86   
       
    87   template<typename I> NodeIt aNode(const I e);
       
    88   { return graph->aNode(e); }
       
    89   template<typename I> NodeIt bNode(const I e);
       
    90   { return graph->bNode(e); }
       
    91   
       
    92   template<typename I> bool valid(const I i);
       
    93   { return graph->valid(i); }
       
    94   
       
    95   template<typename I> void setInvalid(const I &i);
       
    96   { return graph->setInvalid(i); }
       
    97   
       
    98   NodeIt addNode(); { return graph->addNode(); }
       
    99   EdgeIt addEdge(const NodeIt from,const NodeIt to);
       
   100   { return graph->addEdge(to,from); }
       
   101   
       
   102   template<I> void delete(I i); { graph->delete(i); }
       
   103   
       
   104   void clean();  { graph->clean(); }
       
   105   
       
   106   template<class T> class NodeMap : public typename G::NodeMap<T>;
       
   107   template<class T> class EdgeMap : public typename G::EdgeMap<T>;
       
   108   
       
   109   void SetG(G &g) {graph = &g;}
       
   110   
       
   111   RevGraphWrapper() {graph = NULL;}
       
   112   RevGraphWrapper(G &g) {graph = &g;}
       
   113 };
       
   114 
       
   115 
       
   116 
       
   117 //   NodeIt &getFirst(NodeIt &n) { return graph->getFirst(n); }
       
   118 //   InEdgeIt &getFirst(InEdgeIt &e,const NodeIt &n);
       
   119 //   { return graph->getFirst(e,n); }
       
   120 //   OutEdgeIt &getFirst(OutEdgeIt &e,const NodeIt &n);
       
   121 //   { return graph->getFirst(e,n); }
       
   122 //   SymEdgeIt &getFirst(SymEdgeIt &e,const NodeIt &n);
       
   123 //   { return graph->getFirst(e,n); }
       
   124 //   EachEdgeIt &getFirst(EachEdgeIt &e);
       
   125 //   { return graph->getFirst(e); }
       
   126    
       
   127 //   NodeIt next(const NodeIt &n);
       
   128 //   { return graph->next(n); }
       
   129 //   InEdgeIt next(const InEdgeIt &e);
       
   130 //   { return graph->next(e); }
       
   131 //   OutEdgeIt next(const OutEdgeIt &e);
       
   132 //   { return graph->next(e); }
       
   133 //   SymEdgeIt next(const SymEdgeIt &e);
       
   134 //   { return graph->next(e); }
       
   135 //   EachEdgeIt next(const EachEdgeIt &e);
       
   136 //   { return graph->next(e); }
       
   137  
       
   138 //   NodeIt &goNext(NodeIt &n);
       
   139 //   { return graph->goNext(n); }
       
   140 //   InEdgeIt &goNext(InEdgeIt &e);
       
   141 //   { return graph->goNext(e); }
       
   142 //   OutEdgeIt &goNext(OutEdgeIt &e);
       
   143 //   { return graph->goNext(e); }
       
   144 //   SymEdgeIt &goNext(SymEdgeIt &e);
       
   145 //   { return graph->goNext(e); }
       
   146 //   EachEdgeIt &goNext(EachEdgeIt &e);
       
   147 //   { return graph->goNext(e); }
       
   148