73 N *operator->() const { return &G->Data(n); } |
73 N *operator->() const { return &G->Data(n); } |
74 |
74 |
75 bool operator==(const NodeIterator &i) const {return n==i.n;} |
75 bool operator==(const NodeIterator &i) const {return n==i.n;} |
76 bool operator!=(const NodeIterator &i) const {return n!=i.n;} |
76 bool operator!=(const NodeIterator &i) const {return n!=i.n;} |
77 |
77 |
78 int Index() { return n; } //If the nodes are indexable |
78 int Index() const { return n; } //If the nodes are indexable |
79 friend class Graph; |
79 friend class Graph; |
80 friend class EdgeIterator; |
80 friend class EdgeIterator; |
81 friend class InEdgeIterator; |
81 friend class InEdgeIterator; |
82 friend class OutEdgeIterator; |
82 friend class OutEdgeIterator; |
83 friend class BiEdgeIterator; |
83 friend class BiEdgeIterator; |
117 //operator const SymEdgeIterator(); //Ez kerdeses, mit csinal |
117 //operator const SymEdgeIterator(); //Ez kerdeses, mit csinal |
118 |
118 |
119 bool operator==(const EdgeIterator &i) const {return e==i.e;} |
119 bool operator==(const EdgeIterator &i) const {return e==i.e;} |
120 bool operator!=(const EdgeIterator &i) const {return e!=i.e;} |
120 bool operator!=(const EdgeIterator &i) const {return e!=i.e;} |
121 |
121 |
122 int Index() { return e.index.block*EDGE_BLOCK_SIZE+e.index.index; } |
122 int Index() const { return e.index.block*EDGE_BLOCK_SIZE+e.index.index; } |
123 //If the edges are indexable |
123 //If the edges are indexable |
124 |
124 |
125 friend class Graph; |
125 friend class Graph; |
126 friend class InEdgeIterator; |
126 friend class InEdgeIterator; |
127 friend class OutEdgeIterator; |
127 friend class OutEdgeIterator; |
399 Graph<N,E> *G; |
399 Graph<N,E> *G; |
400 vector<T> map; |
400 vector<T> map; |
401 |
401 |
402 public: |
402 public: |
403 typedef T value_type; |
403 typedef T value_type; |
404 void Set(NodeIterator i, const T &t) {map[i.Index()]=t;} |
404 void Put(const NodeIterator i, const T &t) {map[i.Index()]=t;} |
405 T &Get(NodeIterator i) {return map[i.Index()];} |
405 T Get(const NodeIterator i) const {return map[i.Index()];} |
406 T &operator[](NodeIterator i) {return map[i.Index()];} |
406 T operator[](NodeIterator i) {return map[i.Index()];} |
407 |
407 |
408 void update() { map.resize(G->OldGraph<N,E>::NodeMax());} |
408 void update() { map.resize(G->MaxNode());} |
409 |
409 |
410 NodeMap(Graph<N,E> &Gr) : map(Gr.OldGraph<N,E>::NodeMax()) { G=&Gr ;} |
410 NodeMap() {} |
411 |
411 void SetG(Graph<N,E> &Gr) { G=&Gr; update();} |
412 }; |
412 }; |
413 |
413 |
414 template<class T> class EdgeMap |
414 template<class T> class EdgeMap |
415 { |
415 { |
416 Graph<N,E> *G; |
416 Graph<N,E> *G; |
417 vector<T> map; |
417 vector<T> map; |
418 |
418 |
419 public: |
419 public: |
420 typedef T value_type; |
420 typedef T value_type; |
421 void Set(NodeIterator i, const T &t) {map[i.Index()]=t;} |
421 void Put(const NodeIterator i, const T &t) {map[i.Index()]=t;} |
422 T &Get(NodeIterator i) {return map[i.Index()];} |
422 T &Get(const NodeIterator i) {return map[i.Index()];} |
423 T &operator[](NodeIterator i) {return map[i.Index()];} |
423 T &operator[](NodeIterator i) {return map[i.Index()];} |
424 |
424 |
425 void update() |
425 void update() |
426 { map.resize(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE);} |
426 { map.resize(G->MaxEdge());} |
427 |
427 |
428 EdgeMap(Graph<N,E> &Gr) |
428 EdgeMap() {} |
429 :map(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE) |
429 void SetG(Graph<N,E> &Gr) |
430 { G=&Gr ;} |
430 { G=&Gr ;update();} |
431 |
431 |
432 }; |
432 }; |
|
433 |
|
434 |
|
435 int MaxNode() { return OldGraph<N,E>::MaxNode();} |
|
436 int MaxEdge() { return ::edge_block_num*EDGE_BLOCK_SIZE;} |
433 |
437 |
434 }; |
438 }; |
435 |
439 |
436 /* Ez itt a fiam kommentje: |
440 /* Ez itt a fiam kommentje: |
437 <v n nnnnnnnnnnnnnncncccccccccccccccccvvvvvv |
441 <v n nnnnnnnnnnnnnncncccccccccccccccccvvvvvv |