src/hugo/graph_wrapper.h
changeset 877 66dd225ca128
parent 876 26c573ca6a99
child 878 86b42ec55f3e
equal deleted inserted replaced
36:41ad209cc725 37:14e49c4257e4
   222     int id(const Node& v) const { return graph->id(v); }
   222     int id(const Node& v) const { return graph->id(v); }
   223     int id(const Edge& e) const { return graph->id(e); }
   223     int id(const Edge& e) const { return graph->id(e); }
   224     
   224     
   225     Edge opposite(const Edge& e) const { return Edge(graph->opposite(e)); }
   225     Edge opposite(const Edge& e) const { return Edge(graph->opposite(e)); }
   226 
   226 
   227     template<typename T> class NodeMap : public Graph::template NodeMap<T> { 
   227 
   228       typedef typename Graph::template NodeMap<T> Parent;
   228     IMPORT_NODE_MAP(Graph, *(gw.graph), GraphWrapper, gw);    
   229     public:
   229     IMPORT_EDGE_MAP(Graph, *(gw.graph), GraphWrapper, gw);
   230       NodeMap(const GraphWrapper<Graph>& gw) :  Parent(*(gw.graph)) { }
   230     
   231       NodeMap(const GraphWrapper<Graph>& gw, T a) : Parent(*(gw.graph), a) { }
   231 
   232 //       NodeMap(const NodeMap<T>& map) : Parent(map) { }
       
   233 //       template<typename Map>
       
   234 //       NodeMap(const Map& map) :  Parent(map) { }
       
   235     };
       
   236 
       
   237     template<typename T> class EdgeMap : public Graph::template EdgeMap<T> { 
       
   238       typedef typename Graph::template EdgeMap<T> Parent;
       
   239     public:
       
   240       EdgeMap(const GraphWrapper<Graph>& gw) : Parent(*(gw.graph)) { }
       
   241       EdgeMap(const GraphWrapper<Graph>& gw, T a) : Parent(*(gw.graph), a) { }
       
   242 //       EdgeMap(const EdgeMap<T>& map) : Parent(map) { }
       
   243 //       template<typename Map>
       
   244 //       EdgeMap(const Map& map) :  Parent(map) { }
       
   245     };
       
   246   };
   232   };
   247 
   233 
   248 
   234 
   249 
   235 
   250   /// A graph wrapper which reverses the orientation of the edges.
   236   /// A graph wrapper which reverses the orientation of the edges.
   328     Node tail(const Edge& e) const { 
   314     Node tail(const Edge& e) const { 
   329       return GraphWrapper<Graph>::head(e); }
   315       return GraphWrapper<Graph>::head(e); }
   330     Node head(const Edge& e) const { 
   316     Node head(const Edge& e) const { 
   331       return GraphWrapper<Graph>::tail(e); }
   317       return GraphWrapper<Graph>::tail(e); }
   332 
   318 
       
   319     KEEP_MAPS(Parent, RevGraphWrapper);
       
   320 
   333   };
   321   };
   334 
   322 
   335 
   323 
   336 
   324 
   337   /// A graph wrapper for hiding nodes and edges from a graph.
   325   /// A graph wrapper for hiding nodes and edges from a graph.
   567       int i=0;
   555       int i=0;
   568       for (EdgeIt e(*this); e!=INVALID; ++e) ++i;
   556       for (EdgeIt e(*this); e!=INVALID; ++e) ++i;
   569       return i; 
   557       return i; 
   570     }
   558     }
   571 
   559 
       
   560     KEEP_MAPS(Parent, SubGraphWrapper);
   572   };
   561   };
   573 
   562 
   574 
   563 
   575 
   564 
   576 //   /// \brief A wrapper for forgetting the orientation of a graph.
   565 //   /// \brief A wrapper for forgetting the orientation of a graph.
   657       if (e.out_or_in) return this->graph->tail(e); else 
   646       if (e.out_or_in) return this->graph->tail(e); else 
   658 	return this->graph->head(e); }
   647 	return this->graph->head(e); }
   659     Node bNode(const OutEdgeIt& e) const { 
   648     Node bNode(const OutEdgeIt& e) const { 
   660       if (e.out_or_in) return this->graph->head(e); else 
   649       if (e.out_or_in) return this->graph->head(e); else 
   661 	return this->graph->tail(e); }
   650 	return this->graph->tail(e); }
       
   651 
       
   652     KEEP_MAPS(Parent, UndirGraphWrapper);
       
   653 
   662   };
   654   };
   663   
   655   
   664   /// \brief An undirected graph template.
   656   /// \brief An undirected graph template.
   665   ///
   657   ///
   666   /// An undirected graph template.
   658   /// An undirected graph template.
   674     Graph gr;
   666     Graph gr;
   675   public:
   667   public:
   676     UndirGraph() : UndirGraphWrapper<Graph>() { 
   668     UndirGraph() : UndirGraphWrapper<Graph>() { 
   677       Parent::setGraph(gr); 
   669       Parent::setGraph(gr); 
   678     }
   670     }
       
   671 
       
   672     KEEP_MAPS(Parent, UndirGraph);
   679   };
   673   };
   680 
   674 
   681 
   675 
   682 
   676 
   683   ///\brief A wrapper for composing a subgraph of a 
   677   ///\brief A wrapper for composing a subgraph of a 
  1106 // 	  return forward_map.get(e.out); 
  1100 // 	  return forward_map.get(e.out); 
  1107 // 	else 
  1101 // 	else 
  1108 // 	  return backward_map.get(e.in); 
  1102 // 	  return backward_map.get(e.in); 
  1109 //       }
  1103 //       }
  1110     };
  1104     };
       
  1105 
       
  1106 
       
  1107     KEEP_NODE_MAP(Parent, SubBidirGraphWrapper);
       
  1108 
  1111   };
  1109   };
  1112 
  1110 
  1113 
  1111 
  1114   ///\brief A wrapper for composing bidirected graph from a directed one. 
  1112   ///\brief A wrapper for composing bidirected graph from a directed one. 
  1115   ///
  1113   ///
  1143     }
  1141     }
  1144 
  1142 
  1145     int edgeNum() const { 
  1143     int edgeNum() const { 
  1146       return 2*this->graph->edgeNum();
  1144       return 2*this->graph->edgeNum();
  1147     }
  1145     }
       
  1146     KEEP_MAPS(Parent, BidirGraphWrapper);
  1148   };
  1147   };
  1149 
  1148 
  1150 
  1149 
  1151   /// \brief A bidirected graph template.
  1150   /// \brief A bidirected graph template.
  1152   ///
  1151   ///
  1165     Graph gr;
  1164     Graph gr;
  1166   public:
  1165   public:
  1167     BidirGraph() : BidirGraphWrapper<Graph>() { 
  1166     BidirGraph() : BidirGraphWrapper<Graph>() { 
  1168       Parent::setGraph(gr); 
  1167       Parent::setGraph(gr); 
  1169     }
  1168     }
       
  1169     KEEP_MAPS(Parent, BidirGraph);
  1170   };
  1170   };
  1171 
  1171 
  1172 
  1172 
  1173 
  1173 
  1174   template<typename Graph, typename Number,
  1174   template<typename Graph, typename Number,
  1305       }
  1305       }
  1306       /// \bug not needed with dynamic maps, or does it?
  1306       /// \bug not needed with dynamic maps, or does it?
  1307       void update() { }
  1307       void update() { }
  1308     };
  1308     };
  1309 
  1309 
       
  1310     KEEP_MAPS(Parent, ResGraphWrapper);
  1310   };
  1311   };
  1311 
  1312 
  1312 
  1313 
  1313   /// For blocking flows.
  1314   /// For blocking flows.
  1314 
  1315 
  1416       Node n=tail(e);
  1417       Node n=tail(e);
  1417       typename Graph::OutEdgeIt f(*Parent::graph, n);
  1418       typename Graph::OutEdgeIt f(*Parent::graph, n);
  1418       ++f;
  1419       ++f;
  1419       first_out_edges->set(n, f);
  1420       first_out_edges->set(n, f);
  1420     }
  1421     }
       
  1422 
       
  1423     KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
  1421   };
  1424   };
  1422 
  1425 
  1423   ///@}
  1426   ///@}
  1424 
  1427 
  1425 } //namespace hugo
  1428 } //namespace hugo