Changeset 75:87623302a68f in lemon0.x for src/work/list_graph.hh
 Timestamp:
 02/16/04 12:29:48 (17 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@98
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/work/list_graph.hh
r69 r75 45 45 NodeMap(const ListGraph& _G, T a) : 46 46 G(_G), container(G.node_id, a) { } 47 void set(NodeIt nit, T a) { container[G.id(nit)]=a; } 48 T get(NodeIt nit) const { return container[G.id(nit)]; } 47 void set(NodeIt n, T a) { container[/*G.id(n)*/n.node>id]=a; } 48 T get(NodeIt n) const { return container[/*G.id(n)*/n.node>id]; } 49 T& operator[](NodeIt n) { return container[/*G.id(n)*/n.node>id]; } 50 const T& operator[](NodeIt n) const { return container[/*G.id(n)*/n.node>id]; } 49 51 void resize() { container.resize(G.node_id); } 50 52 void resize(T a) { container.resize(G.node_id, a); } … … 61 63 EdgeMap(const ListGraph& _G, T a) : 62 64 G(_G), container(G.edge_id, a) { } 63 void set(EdgeIt eit, T a) { container[G.id(eit)]=a; } 64 T get(EdgeIt eit) const { return container[G.id(eit)]; } 65 void set(EdgeIt e, T a) { container[/*G.id(e)*/e.edge>id]=a; } 66 T get(EdgeIt e) const { return container[/*G.id(e)*/e.edge>id]; } 67 T& operator[](EdgeIt e) { return container[/*G.id(e)*/e.edge>id]; } 68 const T& operator[](EdgeIt e) const { return container[/*G.id(e)*/e.edge>id]; } 65 69 void resize() { container.resize(G.edge_id); } 66 70 void resize(T a) { container.resize(G.edge_id, a); } … … 77 81 class node_item { 78 82 friend class ListGraph; 83 template <typename T> friend class NodeMap; 84 79 85 friend class NodeIt; 80 86 friend class EachNodeIt; … … 100 106 class edge_item { 101 107 friend class ListGraph; 108 template <typename T> friend class EdgeMap; 109 102 110 friend class NodeIt; 103 111 friend class EachNodeIt; … … 255 263 /* for experimental purpose */ 256 264 257 void getFirst(EachNodeIt& v) const { v=EachNodeIt(*this); } 258 void getFirst(EachEdgeIt& e) const { e=EachEdgeIt(*this); } 259 void getFirst(OutEdgeIt& e, NodeIt v) const { e=OutEdgeIt(v); } 260 void getFirst(InEdgeIt& e, NodeIt v) const { e=InEdgeIt(v); } 261 void getFirst(SymEdgeIt& e, NodeIt v) const { e=SymEdgeIt(v); } 265 EachNodeIt& getFirst(EachNodeIt& v) const { 266 v=EachNodeIt(*this); return v; } 267 EachEdgeIt& getFirst(EachEdgeIt& e) const { 268 e=EachEdgeIt(*this); return e; } 269 OutEdgeIt& getFirst(OutEdgeIt& e, NodeIt v) const { 270 e=OutEdgeIt(v); return e; } 271 InEdgeIt& getFirst(InEdgeIt& e, NodeIt v) const { 272 e=InEdgeIt(v); return e; } 273 SymEdgeIt& getFirst(SymEdgeIt& e, NodeIt v) const { 274 e=SymEdgeIt(v); return e; } 262 275 //void getTail(NodeIt& n, const EdgeIt& e) const { n=tail(e); } 263 276 //void getHead(NodeIt& n, const EdgeIt& e) const { n=head(e); } … … 334 347 class NodeIt { 335 348 friend class ListGraph; 349 template <typename T> friend class NodeMap; 336 350 337 351 friend class EdgeIt; … … 368 382 class EdgeIt { 369 383 friend class ListGraph; 384 template <typename T> friend class EdgeMap; 370 385 371 386 friend class NodeIt; … … 414 429 class OutEdgeIt : public EdgeIt { 415 430 friend class ListGraph; 416 node_item* v;417 protected: 418 OutEdgeIt(const NodeIt& _v) : v(_v.node) { edge=v>_first_out_edge; }419 public: 420 OutEdgeIt() : EdgeIt() , v(0){ }421 OutEdgeIt(const ListGraph& G, NodeIt _v) : v(_v.node) { edge=v>_first_out_edge; }431 //node_item* v; 432 protected: 433 OutEdgeIt(const NodeIt& _v) /*: v(_v.node)*/ { edge=_v.node>_first_out_edge; } 434 public: 435 OutEdgeIt() : EdgeIt()/*, v(0)*/ { } 436 OutEdgeIt(const ListGraph& G, NodeIt _v) /*: v(_v.node)*/ { edge=_v.node>_first_out_edge; } 422 437 OutEdgeIt& operator++() { edge=edge>_next_out; return *this; } 423 438 protected: 424 NodeIt aNode() const { return NodeIt(v); } 425 NodeIt bNode() const { 426 return (edge>_tail==v) ? NodeIt(edge>_head) : NodeIt(edge>_tail); } 439 NodeIt aNode() const { return NodeIt(edge>_tail); } 440 NodeIt bNode() const { return NodeIt(edge>_head); } 427 441 }; 428 442 429 443 class InEdgeIt : public EdgeIt { 430 444 friend class ListGraph; 431 node_item* v;432 protected: 433 InEdgeIt(const NodeIt& _v) : v(_v.node) { edge=v>_first_in_edge; }434 public: 435 InEdgeIt() : EdgeIt() , v(0){ }436 InEdgeIt(const ListGraph& G, NodeIt _v) : v(_v.node) { edge=v>_first_in_edge; }445 //node_item* v; 446 protected: 447 InEdgeIt(const NodeIt& _v) /*: v(_v.node)*/ { edge=_v.node>_first_in_edge; } 448 public: 449 InEdgeIt() : EdgeIt()/*, v(0)*/ { } 450 InEdgeIt(const ListGraph& G, NodeIt _v) /*: v(_v.node)*/ { edge=_v.node>_first_in_edge; } 437 451 InEdgeIt& operator++() { edge=edge>_next_in; return *this; } 438 452 protected: 439 NodeIt aNode() const { return NodeIt(v); } 440 NodeIt bNode() const { 441 return (edge>_tail==v) ? NodeIt(edge>_head) : NodeIt(edge>_tail); } 453 NodeIt aNode() const { return NodeIt(edge>_head); } 454 NodeIt bNode() const { return NodeIt(edge>_tail); } 442 455 }; 443 456 … … 445 458 friend class ListGraph; 446 459 bool out_or_in; //1 iff out, 0 iff in 447 node_item* v;448 protected: 449 SymEdgeIt(const NodeIt& _v) : v(_v.node){460 //node_item* v; 461 protected: 462 SymEdgeIt(const NodeIt& _v) /*: v(_v.node)*/ { 450 463 out_or_in=1; 451 edge= v>_first_out_edge;452 if (!edge) { edge= v>_first_in_edge; out_or_in=0; }464 edge=_v.node>_first_out_edge; 465 if (!edge) { edge=_v.node>_first_in_edge; out_or_in=0; } 453 466 } 454 467 public: 455 SymEdgeIt() : EdgeIt() , v(0){ }456 SymEdgeIt(const ListGraph& G, NodeIt _v) : v(_v.node){468 SymEdgeIt() : EdgeIt() /*, v(0)*/ { } 469 SymEdgeIt(const ListGraph& G, NodeIt _v) /*: v(_v.node)*/ { 457 470 out_or_in=1; 458 edge= v>_first_out_edge;459 if (!edge) { edge= v>_first_in_edge; out_or_in=0; }471 edge=_v.node>_first_out_edge; 472 if (!edge) { edge=_v.node>_first_in_edge; out_or_in=0; } 460 473 } 461 474 SymEdgeIt& operator++() { 462 475 if (out_or_in) { 476 node_item* v=edge>_tail; 463 477 edge=edge>_next_out; 464 478 if (!edge) { out_or_in=0; edge=v>_first_in_edge; } … … 469 483 } 470 484 protected: 471 NodeIt aNode() const { return NodeIt(v); } 485 NodeIt aNode() const { 486 return (out_or_in) ? NodeIt(edge>_tail) : NodeIt(edge>_head); } 472 487 NodeIt bNode() const { 473 return ( edge>_tail==v) ? NodeIt(edge>_head) : NodeIt(edge>_tail); }488 return (out_or_in) ? NodeIt(edge>_head) : NodeIt(edge>_tail); } 474 489 }; 475 490
Note: See TracChangeset
for help on using the changeset viewer.