Some Graph wrapper classes
authoralpar
Thu, 05 Feb 2004 15:56:12 +0000
changeset 65a63cef252656
parent 64 72bd463289a9
child 66 cd56b9c11492
Some Graph wrapper classes
src/work/alpar/gwrapper.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/alpar/gwrapper.h	Thu Feb 05 15:56:12 2004 +0000
     1.3 @@ -0,0 +1,148 @@
     1.4 +// -*-mode: c++; -*-
     1.5 +
     1.6 +template<typename G>
     1.7 +class TrivGraphWrapper
     1.8 +{
     1.9 +  G *graph;
    1.10 +  
    1.11 +public:
    1.12 +  typedef G BaseGraph;
    1.13 +
    1.14 +  typedef typename G::EdgeIt EdgeIt;
    1.15 +  
    1.16 +  typedef typename G::InEdgeIt InEdgeIt;
    1.17 +  typedef typename G::OutEdgeIt OutEdgeIt;
    1.18 +  typedef typename G::SymEdgeIt SymEdgeIt;
    1.19 +  typedef typename G::EachEdgeIt EachEdgeIt;
    1.20 +
    1.21 +  typedef typename G::NodeIt NodeIt;
    1.22 +    
    1.23 +  template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
    1.24 +  template<typename I,typename P> I &getFirst(I &i,const P &p);
    1.25 +  { return graph->getFirst(i,p); }
    1.26 +  template<typename I> I next(const I i); { return graph->goNext(i); }
    1.27 +  template<typename I> I &goNext(I &i); { return graph->goNext(i); }
    1.28 +
    1.29 +  NodeIt head(const EdgeIt &e);
    1.30 +  { return graph->head(e); }
    1.31 +  NodeIt tail(const EdgeIt &e);
    1.32 +  { return graph->tail(e); }
    1.33 +  
    1.34 +  template<typename I> NodeIt aNode(const I e);
    1.35 +  { return graph->aNode(e); }
    1.36 +  template<typename I> NodeIt bNode(const I e);
    1.37 +  { return graph->bNode(e); }
    1.38 +  
    1.39 +  template<typename I> bool valid(const I i);
    1.40 +  { return graph->valid(i); }
    1.41 +  
    1.42 +  template<typename I> void setInvalid(const I &i);
    1.43 +  { return graph->setInvalid(i); }
    1.44 +  
    1.45 +  NodeIt addNode(); { return graph->addNode(); }
    1.46 +  EdgeIt addEdge(const NodeIt from,const NodeIt to);
    1.47 +  { return graph->addEdge(ftom,to); }
    1.48 +  
    1.49 +  template<I> void delete(I i); { graph->delete(i); }
    1.50 +  
    1.51 +  void clean();  { graph->clean(); }
    1.52 +  
    1.53 +  template<class T> class NodeMap : public typename G::NodeMap<T>;
    1.54 +  template<class T> class EdgeMap : public typename G::EdgeMap<T>;
    1.55 +  
    1.56 +  void SetG(G &g) {graph = &g;}
    1.57 +  
    1.58 +  TrivGraphWrapper() {graph = NULL;}
    1.59 +  TrivGraphWrapper(G &g) {graph = &g;}
    1.60 +};
    1.61 +
    1.62 +template<typename G>
    1.63 +class RevGraphWrapper
    1.64 +{
    1.65 +  G *graph;
    1.66 +  
    1.67 +public:
    1.68 +  typedef G BaseGraph;
    1.69 +
    1.70 +  typedef typename G::EdgeIt EdgeIt;
    1.71 +  
    1.72 +  typedef typename G::InEdgeIt OutEdgeIt;
    1.73 +  typedef typename G::OutEdgeIt InEdgeIt;
    1.74 +  typedef typename G::SymEdgeIt SymEdgeIt;
    1.75 +  typedef typename G::EachEdgeIt EachEdgeIt;
    1.76 +
    1.77 +  typedef typename G::NodeIt NodeIt;
    1.78 +    
    1.79 +  template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
    1.80 +  template<typename I,typename P> I &getFirst(I &i,const P &p);
    1.81 +  { return graph->getFirst(i,p); }
    1.82 +  template<typename I> I next(const I i); { return graph->goNext(i); }
    1.83 +  template<typename I> I &goNext(I &i); { return graph->goNext(i); }
    1.84 +
    1.85 +  NodeIt head(const EdgeIt &e);
    1.86 +  { return graph->tail(e); }
    1.87 +  NodeIt tail(const EdgeIt &e);
    1.88 +  { return graph->head(e); }
    1.89 +  
    1.90 +  template<typename I> NodeIt aNode(const I e);
    1.91 +  { return graph->aNode(e); }
    1.92 +  template<typename I> NodeIt bNode(const I e);
    1.93 +  { return graph->bNode(e); }
    1.94 +  
    1.95 +  template<typename I> bool valid(const I i);
    1.96 +  { return graph->valid(i); }
    1.97 +  
    1.98 +  template<typename I> void setInvalid(const I &i);
    1.99 +  { return graph->setInvalid(i); }
   1.100 +  
   1.101 +  NodeIt addNode(); { return graph->addNode(); }
   1.102 +  EdgeIt addEdge(const NodeIt from,const NodeIt to);
   1.103 +  { return graph->addEdge(to,from); }
   1.104 +  
   1.105 +  template<I> void delete(I i); { graph->delete(i); }
   1.106 +  
   1.107 +  void clean();  { graph->clean(); }
   1.108 +  
   1.109 +  template<class T> class NodeMap : public typename G::NodeMap<T>;
   1.110 +  template<class T> class EdgeMap : public typename G::EdgeMap<T>;
   1.111 +  
   1.112 +  void SetG(G &g) {graph = &g;}
   1.113 +  
   1.114 +  RevGraphWrapper() {graph = NULL;}
   1.115 +  RevGraphWrapper(G &g) {graph = &g;}
   1.116 +};
   1.117 +
   1.118 +
   1.119 +
   1.120 +//   NodeIt &getFirst(NodeIt &n) { return graph->getFirst(n); }
   1.121 +//   InEdgeIt &getFirst(InEdgeIt &e,const NodeIt &n);
   1.122 +//   { return graph->getFirst(e,n); }
   1.123 +//   OutEdgeIt &getFirst(OutEdgeIt &e,const NodeIt &n);
   1.124 +//   { return graph->getFirst(e,n); }
   1.125 +//   SymEdgeIt &getFirst(SymEdgeIt &e,const NodeIt &n);
   1.126 +//   { return graph->getFirst(e,n); }
   1.127 +//   EachEdgeIt &getFirst(EachEdgeIt &e);
   1.128 +//   { return graph->getFirst(e); }
   1.129 +   
   1.130 +//   NodeIt next(const NodeIt &n);
   1.131 +//   { return graph->next(n); }
   1.132 +//   InEdgeIt next(const InEdgeIt &e);
   1.133 +//   { return graph->next(e); }
   1.134 +//   OutEdgeIt next(const OutEdgeIt &e);
   1.135 +//   { return graph->next(e); }
   1.136 +//   SymEdgeIt next(const SymEdgeIt &e);
   1.137 +//   { return graph->next(e); }
   1.138 +//   EachEdgeIt next(const EachEdgeIt &e);
   1.139 +//   { return graph->next(e); }
   1.140 + 
   1.141 +//   NodeIt &goNext(NodeIt &n);
   1.142 +//   { return graph->goNext(n); }
   1.143 +//   InEdgeIt &goNext(InEdgeIt &e);
   1.144 +//   { return graph->goNext(e); }
   1.145 +//   OutEdgeIt &goNext(OutEdgeIt &e);
   1.146 +//   { return graph->goNext(e); }
   1.147 +//   SymEdgeIt &goNext(SymEdgeIt &e);
   1.148 +//   { return graph->goNext(e); }
   1.149 +//   EachEdgeIt &goNext(EachEdgeIt &e);
   1.150 +//   { return graph->goNext(e); }
   1.151 +