Changeset 1008:3fef334f5f37 in lemon-0.x for src/work/marci/merge_node_graph_wrapper.h
- Timestamp:
- 11/18/04 23:31:21 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1398
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/merge_node_graph_wrapper.h
r1007 r1008 23 23 #include <lemon/graph_wrapper.h> 24 24 #include <iostream> 25 using std::cout; 26 using std::endl; 25 27 26 28 #include <boost/type_traits.hpp> … … 126 128 const _Value& value) : 127 129 ParentMap1(gw, value), ParentMap2(gw, value) { } 128 // NodeMap(const NodeMap& copy)129 // : ParentMap1(copy),130 // ParentMap2(copy) { }131 // template <typename TT>132 // NodeMap(const NodeMap<TT>& copy)133 // : ParentMap1(copy),134 // ParentMap2(copy) { }135 // NodeMap& operator=(const NodeMap& copy) {136 // ParentMap1::operator=(copy);137 // ParentMap2::operator=(copy);138 // return *this;139 // }140 // template <typename TT>141 // NodeMap& operator=(const NodeMap<TT>& copy) {142 // ParentMap1::operator=(copy);143 // ParentMap2::operator=(copy);144 // return *this;145 // }146 130 _Value operator[](const Node& n) const { 147 131 if (!n.backward) … … 162 146 }; 163 147 148 //not yet working 164 149 template <typename _Graph1, typename _Graph2> 165 150 class MergeNodeGraphWrapperBase< … … 184 169 }; 185 170 171 //not yet working 186 172 template <typename _Graph1, typename _Graph2> 187 173 class MergeNodeGraphWrapperBase< … … 206 192 }; 207 193 194 //not yet working 208 195 template <typename _Graph1, typename _Graph2> 209 196 class MergeNodeGraphWrapperBase< … … 246 233 }; 247 234 235 236 template <typename _Graph, typename _EdgeSetGraph> 237 class NewEdgeSetGraphWrapperBase : public GraphWrapperBase<_Graph> { 238 public: 239 typedef GraphWrapperBase<_Graph> Parent; 240 typedef _Graph Graph; 241 typedef _EdgeSetGraph EdgeSetGraph; 242 typedef typename _Graph::Node Node; 243 typedef typename _EdgeSetGraph::Node ENode; 244 protected: 245 EdgeSetGraph* edge_set_graph; 246 typename Graph::NodeMap<ENode>* e_node; 247 typename EdgeSetGraph::NodeMap<Node>* n_node; 248 void setEdgeSetGraph(EdgeSetGraph& _edge_set_graph) { 249 edge_set_graph=&_edge_set_graph; 250 } 251 /// For each node of \c Graph, this gives a node of \c EdgeSetGraph . 252 void setNodeMap(typename EdgeSetGraph::NodeMap<Node>& _n_node) { 253 n_node=&_n_node; 254 } 255 /// For each node of \c EdgeSetGraph, this gives a node of \c Graph . 256 void setENodeMap(typename Graph::NodeMap<ENode>& _e_node) { 257 e_node=&_e_node; 258 } 259 public: 260 class Edge : public EdgeSetGraph::Edge { 261 typedef typename EdgeSetGraph::Edge Parent; 262 public: 263 Edge() { } 264 Edge(const Parent& e) : Parent(e) { } 265 Edge(Invalid i) : Parent(i) { } 266 }; 267 268 using Parent::first; 269 void first(Edge &e) const { 270 edge_set_graph->first(e); 271 } 272 void firstOut(Edge& e, const Node& n) const { 273 // cout << e_node << endl; 274 // cout << n_node << endl; 275 edge_set_graph->firstOut(e, (*e_node)[n]); 276 } 277 void firstIn(Edge& e, const Node& n) const { 278 edge_set_graph->firstIn(e, (*e_node)[n]); 279 } 280 281 using Parent::next; 282 void next(Edge &e) const { 283 edge_set_graph->next(e); 284 } 285 void nextOut(Edge& e) const { 286 edge_set_graph->nextOut(e); 287 } 288 void nextIn(Edge& e) const { 289 edge_set_graph->nextIn(e); 290 } 291 292 Node source(const Edge& e) const { 293 return (*n_node)[edge_set_graph->source(e)]; 294 } 295 Node target(const Edge& e) const { 296 return (*n_node)[edge_set_graph->target(e)]; 297 } 298 299 int edgeNum() const { return edge_set_graph->edgeNum(); } 300 301 Edge addEdge(const Node& u, const Node& v) { 302 return edge_set_graph->addEdge((*e_node)[u], (*e_node)[v]); 303 } 304 305 using Parent::erase; 306 void erase(const Edge& i) const { edge_set_graph->erase(i); } 307 308 void clear() const { Parent::clear(); edge_set_graph->clear(); } 309 310 bool forward(const Edge& e) const { return edge_set_graph->forward(e); } 311 bool backward(const Edge& e) const { return edge_set_graph->backward(e); } 312 313 using Parent::id; 314 int id(const Edge& e) const { return edge_set_graph->id(e); } 315 316 Edge opposite(const Edge& e) const { return edge_set_graph->opposite(e); } 317 318 template <typename _Value> 319 class EdgeMap : public EdgeSetGraph::EdgeMap<_Value> { 320 public: 321 typedef typename EdgeSetGraph::EdgeMap<_Value> Parent; 322 typedef _Value Value; 323 typedef Edge Key; 324 EdgeMap(const NewEdgeSetGraphWrapperBase& gw) : 325 Parent(*(gw.edge_set_graph)) { } 326 EdgeMap(const NewEdgeSetGraphWrapperBase& gw, const _Value& _value) : 327 Parent(*(gw.edge_set_graph), _value) { } 328 }; 329 330 }; 331 332 template <typename _Graph, typename _EdgeSetGraph> 333 class NewEdgeSetGraphWrapper : 334 public IterableGraphExtender< 335 NewEdgeSetGraphWrapperBase<_Graph, _EdgeSetGraph> > { 336 public: 337 typedef _Graph Graph; 338 typedef _EdgeSetGraph EdgeSetGraph; 339 typedef IterableGraphExtender< 340 NewEdgeSetGraphWrapper<_Graph, _EdgeSetGraph> > Parent; 341 protected: 342 NewEdgeSetGraphWrapper() { } 343 public: 344 NewEdgeSetGraphWrapper(_Graph& _graph, 345 _EdgeSetGraph& _edge_set_graph, 346 typename _Graph:: 347 NodeMap<typename _EdgeSetGraph::Node>& _e_node, 348 typename _EdgeSetGraph:: 349 NodeMap<typename _Graph::Node>& _n_node) { 350 setGraph(_graph); 351 setEdgeSetGraph(_edge_set_graph); 352 setNodeMap(_n_node); 353 setENodeMap(_e_node); 354 } 355 }; 356 248 357 } //namespace lemon 249 358
Note: See TracChangeset
for help on using the changeset viewer.