src/include/graph.h
author alpar
Tue, 16 Dec 2003 17:52:52 +0000
changeset 7 0f527d1b9149
parent 3 272a5677bd6d
child 8 cd54905012bc
permissions -rw-r--r--
.
alpar@1
     1
// -*-mode: c++; -*-
alpar@1
     2
#ifndef __GRAPH_H_
alpar@1
     3
#define __GRAPH_H_
alpar@1
     4
alpar@1
     5
//inline void *operator new(size_t s, void *p) { return p; }
alpar@1
     6
#include <new>
alpar@6
     7
#include <vector>
alpar@1
     8
alpar@1
     9
namespace NEGRO 
alpar@1
    10
{
alpar@1
    11
  using namespace std;
alpar@1
    12
  
alpar@1
    13
#include "oldgraph.h"
alpar@1
    14
  
alpar@1
    15
  template <class N, class E> class Graph : protected OldGraph<N,E>
alpar@1
    16
  {
alpar@1
    17
  public:
alpar@1
    18
    typedef E EdgeType;
alpar@1
    19
    typedef N NodeType;
alpar@1
    20
    
alpar@1
    21
    class EdgePoint
alpar@1
    22
    {
alpar@1
    23
    public:
alpar@1
    24
      NEGRO::EdgePoint e;
alpar@1
    25
      bool isValid() { return e; }
alpar@1
    26
    };
alpar@1
    27
    
alpar@1
    28
    class InEdgePoint : public EdgePoint {};
alpar@1
    29
    class OutEdgePoint : public EdgePoint {};
alpar@1
    30
    class BiEdgePoint : public EdgePoint {};
alpar@1
    31
    class SymEdgePoint : public EdgePoint {};
alpar@1
    32
    
alpar@1
    33
    typedef int NodePoint;
alpar@1
    34
    
alpar@1
    35
    class NodeIterator;
alpar@1
    36
    
alpar@1
    37
    class EdgeIterator;
alpar@1
    38
    class InEdgeIterator;
alpar@1
    39
    class OutEdgeIterator;
alpar@1
    40
    class BiEdgeIterator;
alpar@1
    41
    class SymEdgeIterator;
alpar@1
    42
    class AllEdgeIterator;
alpar@1
    43
    
alpar@6
    44
    class FirstAnythingTypeNode; //Required by the unified First() function.
alpar@1
    45
alpar@1
    46
    friend class NodeIterator;
alpar@1
    47
    friend class EdgeIterator;
alpar@1
    48
    friend class InEdgeIterator;
alpar@1
    49
    friend class OutEdgeIterator;
alpar@1
    50
    friend class BiEdgeIterator;
alpar@1
    51
    friend class SymEdgeIterator;
alpar@1
    52
    friend class AllEdgeIterator;
alpar@1
    53
    
alpar@1
    54
    class NodeIterator
alpar@1
    55
    {
alpar@1
    56
      Graph<N,E> *G;  //operator*() miatt kell!!!
alpar@1
    57
      int n;     //nem kellene, ha itt mutato lenne!!
alpar@1
    58
    public:    
alpar@1
    59
      
alpar@1
    60
      NodeIterator() {;} 
alpar@3
    61
      NodeIterator(Graph<N,E> &Gr)//'const Graph<N,E> &G' would be wrong.
alpar@3
    62
      {G=&Gr;n=Gr.OldGraph<N,E>::FirstNode();} 
alpar@1
    63
      NodeIterator(const NodeIterator &i) {G=i.G;n=i.n;}
alpar@1
    64
      
alpar@1
    65
      NodeIterator &GoNext() { n=G->NextNode(n); return *this;}
alpar@1
    66
      NodeIterator Next() const { return NodeIterator(*this).GoNext();}
alpar@1
    67
      NodeIterator &operator++() { return GoNext();} 
alpar@1
    68
      NodeIterator operator++(int)
alpar@1
    69
      {NodeIterator tmp(*this); GoNext(); return tmp;}
alpar@1
    70
      bool isValid() { return n!=INVALID; }
alpar@1
    71
      
alpar@1
    72
      N &operator*() const { return G->Data(n); }
alpar@1
    73
      N *operator->() const { return &G->Data(n); }
alpar@1
    74
      
alpar@1
    75
      bool operator==(const NodeIterator &i) const {return n==i.n;}
alpar@1
    76
      bool operator!=(const NodeIterator &i) const {return n!=i.n;}
alpar@1
    77
      
alpar@2
    78
      int Index() { return n; } //If the nodes are indexable 
alpar@1
    79
      friend class Graph;
alpar@1
    80
      friend class EdgeIterator;
alpar@1
    81
      friend class InEdgeIterator;
alpar@1
    82
      friend class OutEdgeIterator;
alpar@1
    83
      friend class BiEdgeIterator;
alpar@1
    84
      friend class SymEdgeIterator;
alpar@1
    85
      friend class AllEdgeIterator;
alpar@1
    86
      friend class FirstAnythingTypeNode;
alpar@1
    87
alpar@1
    88
      //Nem kellene egy:
alpar@1
    89
      //      static NodeIterator &GetInvalid();  ?
alpar@1
    90
    };
alpar@1
    91
    
alpar@1
    92
    class EdgeIterator
alpar@1
    93
    {
alpar@1
    94
      
alpar@1
    95
      Graph<N,E> *G; //Itt baj van!!!!! operator*() miatt kell!
alpar@1
    96
      //Ez csak kicsit baj, de:
alpar@1
    97
      // Meg a From() es To() miatt!!!!!!!!!!
alpar@1
    98
      
alpar@1
    99
      NEGRO::EdgePoint e;
alpar@1
   100
      
alpar@1
   101
    public:
alpar@1
   102
      EdgeIterator() {;} //Kell inicializalni? (Nem)
alpar@1
   103
      EdgeIterator(const EdgeIterator &i) {G=i.G;e=i.e;}
alpar@1
   104
      
alpar@1
   105
      // Lehet, hogy ez a ketto nem kell!!!
alpar@1
   106
      
alpar@1
   107
      NodeIterator From() const {NodeIterator i;i.G=G;i.n=e->From();return i;}
alpar@1
   108
      NodeIterator To() const {NodeIterator i;i.G=G;i.n=e->To();return i;}
alpar@1
   109
      
alpar@1
   110
      bool isValid() {return e;}
alpar@1
   111
      E &operator*() const { return G->Data(e); }
alpar@1
   112
      E *operator->() const { return &G->Data(e); }
alpar@1
   113
      
alpar@1
   114
      //operator const OutEdgeIterator ();
alpar@1
   115
      //operator const InEdgeIterator ();
alpar@1
   116
      //operator const BiEdgeIterator ();
alpar@1
   117
      //operator const SymEdgeIterator(); //Ez kerdeses, mit csinal
alpar@1
   118
      
alpar@1
   119
      bool operator==(const EdgeIterator &i) const {return e==i.e;}
alpar@1
   120
      bool operator!=(const EdgeIterator &i) const {return e!=i.e;}
alpar@2
   121
       
alpar@2
   122
      int Index() { return e.index.block*EDGE_BLOCK_SIZE+e.index.index; }
alpar@2
   123
      //If the edges are indexable 
alpar@2
   124
alpar@1
   125
      friend class Graph;
alpar@1
   126
      friend class InEdgeIterator;
alpar@1
   127
      friend class OutEdgeIterator;
alpar@1
   128
      friend class BiEdgeIterator;
alpar@1
   129
      friend class SymEdgeIterator;
alpar@1
   130
      friend class AllEdgeIterator;
alpar@1
   131
    };
alpar@1
   132
    
alpar@1
   133
    class BiEdgeIterator : public EdgeIterator
alpar@1
   134
    {
alpar@1
   135
    public:
alpar@1
   136
      BiEdgeIterator &GoNextIn()  { e=e->NextIn(); return *this;}
alpar@1
   137
      BiEdgeIterator &GoNextOut() { e=e->NextOut(); return *this;}
alpar@1
   138
      BiEdgeIterator NextIn() const  {return BiEdgeIterator(*this).GoNextIn();}
alpar@1
   139
      BiEdgeIterator NextOut() const {return BiEdgeIterator(*this).GoNextOut();}
alpar@1
   140
      
alpar@1
   141
      operator InEdgeIterator ()
alpar@1
   142
      {InEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   143
      operator OutEdgeIterator ()
alpar@1
   144
      {OutEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   145
      //operator const SymEdgeIterator ()
alpar@1
   146
      
alpar@1
   147
      friend class Graph;
alpar@1
   148
    };
alpar@1
   149
    
alpar@1
   150
    class InEdgeIterator : public EdgeIterator
alpar@1
   151
    //Ne a BiEdgeIterator-bol szarmazzon?
alpar@1
   152
    {
alpar@1
   153
    public:
alpar@3
   154
      InEdgeIterator() {}
alpar@3
   155
      InEdgeIterator(const Graph<N,E> &Gr,const NodeIterator &n)
alpar@3
   156
      { G=&Gr; e=Gr.OldGraph<N,E>::FirstIn(n.n);}
alpar@3
   157
alpar@1
   158
      InEdgeIterator &GoNext() { e=e->NextIn(); return *this;}
alpar@1
   159
      InEdgeIterator Next() const {return InEdgeIterator(*this).GoNext();}
alpar@1
   160
      InEdgeIterator &operator++() { return GoNext();}
alpar@1
   161
      InEdgeIterator operator++(int)
alpar@1
   162
      {InEdgeIterator tmp(*this); GoNext(); return tmp;}
alpar@1
   163
      
alpar@1
   164
      operator const OutEdgeIterator ()
alpar@1
   165
      {OutEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   166
      operator const BiEdgeIterator ()
alpar@1
   167
      {EdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   168
      //      operator const SymEdgeIterator ();
alpar@1
   169
      
alpar@1
   170
      NodeIterator Anode() const {return To();}
alpar@1
   171
      NodeIterator Bnode() const {return From();}
alpar@1
   172
      
alpar@1
   173
      friend class Graph;
alpar@1
   174
    };
alpar@1
   175
    
alpar@1
   176
    class OutEdgeIterator : public EdgeIterator
alpar@1
   177
    {
alpar@1
   178
    public:
alpar@3
   179
      OutEdgeIterator() {}
alpar@3
   180
      OutEdgeIterator(Graph<N,E> &Gr,const NodeIterator &n)
alpar@3
   181
      { G=&Gr; e=Gr.OldGraph<N,E>::FirstOut(n.n);}
alpar@3
   182
alpar@1
   183
      OutEdgeIterator &GoNext() { e=e->NextOut(); return *this;}
alpar@1
   184
      OutEdgeIterator Next() const {return OutEdgeIterator(*this).GoNext();}
alpar@1
   185
      OutEdgeIterator &operator++() { return GoNext();}
alpar@1
   186
      OutEdgeIterator operator++(int)
alpar@1
   187
      {OutEdgeIterator tmp(*this); GoNext(); return tmp;}
alpar@1
   188
      
alpar@1
   189
      NodeIterator Anode() const {return From();}
alpar@1
   190
      NodeIterator Bnode() const {return To();}
alpar@1
   191
      
alpar@1
   192
      operator const InEdgeIterator ()
alpar@1
   193
      {InEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   194
      operator const BiEdgeIterator ()
alpar@1
   195
      {BiEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   196
      //operator const SymEdgeIterator(); 
alpar@1
   197
      
alpar@1
   198
      friend class Graph;
alpar@1
   199
    };
alpar@1
   200
    
alpar@1
   201
    class SymEdgeIterator : public EdgeIterator
alpar@1
   202
    {
alpar@1
   203
      NodeIterator n;  // Itt ketszer van a G
alpar@1
   204
      
alpar@1
   205
    public:
alpar@3
   206
      SymEdgeIterator() {}
alpar@3
   207
      SymEdgeIterator(const Graph<N,E> &Gr,const NodeIterator &nn)
alpar@3
   208
      { G=&Gr; n=nn; e=Gr.FirstSym(nn.n); }
alpar@3
   209
alpar@1
   210
      SymEdgeIterator &GoNext() { e=e->NextEdge(n.n); return *this;}
alpar@1
   211
      SymEdgeIterator Next() const {return SymEdgeIterator(*this).GoNext();}
alpar@1
   212
      SymEdgeIterator &operator++() { return GoNext();}
alpar@1
   213
      SymEdgeIterator operator++(int)
alpar@1
   214
      {SymEdgeIterator tmp(*this); GoNext(); return tmp;}
alpar@1
   215
      
alpar@1
   216
      NodeIterator Anode() const {return n;}
alpar@1
   217
      NodeIterator Bnode() const {return n.n==From().n?To():From();}
alpar@1
   218
      
alpar@1
   219
      operator const InEdgeIterator ()
alpar@1
   220
      {InEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   221
      operator const OutEdgeIterator ()
alpar@1
   222
      {OutEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   223
      operator const BiEdgeIterator ()
alpar@1
   224
      {BiEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   225
      
alpar@1
   226
      friend class Graph;
alpar@1
   227
    };
alpar@1
   228
    
alpar@1
   229
    class AllEdgeIterator : public EdgeIterator
alpar@1
   230
    {
alpar@1
   231
      NodeIterator n;  // Itt ketszer van a G
alpar@1
   232
      
alpar@1
   233
    public:
alpar@3
   234
      AllEdgeIterator() {}
alpar@3
   235
      AllEdgeIterator(Graph<N,E> &Gr) : n(Gr)
alpar@3
   236
      {
alpar@3
   237
	e=n.isValid()?Gr.OldGraph<N,E>::FirstOut(n.n):NULL;
alpar@3
   238
      }  
alpar@3
   239
alpar@1
   240
      AllEdgeIterator &GoNext()
alpar@1
   241
      {
alpar@1
   242
	e=e->NextOut();
alpar@1
   243
	if(!e && (++n).isValid()) e=G->OldGraph<N,E>::FirstOut(n.n);
alpar@1
   244
	return *this;
alpar@1
   245
      }
alpar@1
   246
      AllEdgeIterator Next() const {return AllEdgeIterator(*this).GoNext();}
alpar@1
   247
      AllEdgeIterator &operator++() { return GoNext();}
alpar@1
   248
      AllEdgeIterator operator++(int)
alpar@1
   249
	{AllEdgeIterator tmp(*this); GoNext(); return tmp;}
alpar@1
   250
      
alpar@1
   251
      
alpar@1
   252
      NodeIterator Anode() const {return n;}
alpar@1
   253
      NodeIterator Bnode() const {return n.n==From().n?To():From();}
alpar@1
   254
      
alpar@1
   255
      operator const InEdgeIterator ()
alpar@1
   256
      {InEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   257
      operator const OutEdgeIterator ()
alpar@1
   258
      {OutEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   259
      operator const BiEdgeIterator ()
alpar@1
   260
      {BiEdgeIterator i; i.G=G;i.e=e;return i;}
alpar@1
   261
      
alpar@1
   262
      friend class Graph;
alpar@1
   263
    };
alpar@1
   264
    
alpar@1
   265
    typedef NodeIterator DeletingNodeIterator;
alpar@1
   266
    typedef EdgeIterator DeletingEdgeIterator;
alpar@1
   267
    typedef BiEdgeIterator DeletingBiEdgeIterator;
alpar@1
   268
    typedef OutEdgeIterator DeletingOutEdgeIterator;
alpar@1
   269
    typedef InEdgeIterator DeletingInEdgeIterator;
alpar@1
   270
    typedef SymEdgeIterator DeletingSymEdgeIterator;
alpar@1
   271
    
alpar@3
   272
    const NodeIterator FirstNode()
alpar@1
   273
    {
alpar@1
   274
      NodeIterator i;
alpar@1
   275
      i.G=this;i.n=OldGraph<N,E>::FirstNode();
alpar@1
   276
      return i;
alpar@1
   277
    }
alpar@1
   278
    
alpar@1
   279
    void GetFirst(NodePoint &p)   { p=OldGraph<N,E>::FirstNode(); }
alpar@1
   280
    
alpar@1
   281
    void GetFirst(InEdgePoint &p,const NodePoint &n)
alpar@1
   282
    { p=OldGraph<N,E>::FirstIn(n); }
alpar@1
   283
    void GetFirst(OutEdgePoint &p,const NodePoint &n)
alpar@1
   284
    { p=OldGraph<N,E>::FirstOut(n); }
alpar@1
   285
    void GetFirst(SymEdgePoint &p,const NodePoint &n)
alpar@1
   286
    { p=OldGraph<N,E>::FirstEdge(n); }
alpar@1
   287
    void GetFirst(EdgePoint &p) //Vegigmegy mindenen
alpar@1
   288
    { p.e=NodeNum()?OldGraph<N,E>::FirstOut(OldGraph<N,E>::FirstNode()):NULL;}
alpar@1
   289
alpar@1
   290
    void GetFirst(NodeIterator &i) { i.G=this;i.n=OldGraph<N,E>::FirstNode();}
alpar@1
   291
    
alpar@1
   292
    void GetFirst(InEdgeIterator &i,const NodeIterator &n)
alpar@1
   293
    { i.G=this;i.e=OldGraph<N,E>::FirstIn(n.n); }
alpar@1
   294
    void GetFirst(OutEdgeIterator &i,const NodeIterator &n)
alpar@1
   295
    { i.G=this;i.e=OldGraph<N,E>::FirstOut(n.n); }
alpar@1
   296
    void GetFirst(SymEdgeIterator &i,const NodeIterator &n)
alpar@1
   297
    { i.G=this;i.e=OldGraph<N,E>::FirstSym(n.n); }
alpar@1
   298
    void GetFirst(AllEdgeIterator &i) //Vegigmegy mindenen
alpar@1
   299
    {
alpar@1
   300
      i.G=this;
alpar@1
   301
      GetFirst(i.n);
alpar@1
   302
      i.e=OldGraph<N,E>::NodeNum()?OldGraph<N,E>::FirstOut(i.n.n):NULL;
alpar@1
   303
    }  
alpar@1
   304
    
alpar@1
   305
    
alpar@1
   306
    
alpar@1
   307
    //Vagy beginnode()?
alpar@3
   308
    const DeletingEdgeIterator FirstOut(const NodeIterator &n)
alpar@1
   309
    {
alpar@1
   310
      EdgeIterator i;
alpar@1
   311
      i.G=n.G;i.edge=n.G->OldGraph<N,E>::FirstOut(n.n);
alpar@1
   312
      return i;
alpar@1
   313
    }
alpar@3
   314
    const DeletingEdgeIterator FirstIn(const NodeIterator &n)
alpar@1
   315
    {
alpar@1
   316
      EdgeIterator i;
alpar@1
   317
      i.G=n.G;i.edge=n.G->OldGraph<N,E>::FirstIn(n.n);
alpar@1
   318
      return i;
alpar@1
   319
    }
alpar@3
   320
    const DeletingSymEdgeIterator FirstSym(const NodeIterator &n)
alpar@1
   321
    {
alpar@1
   322
      EdgeIterator i;
alpar@1
   323
      i.G=n.G;i.n=n.n;
alpar@1
   324
      i.edge=n.G->OldGraph<N,E>::FirstEdge(n.n);
alpar@1
   325
      return i;
alpar@1
   326
    }
alpar@1
   327
    
alpar@1
   328
    //    class FirstAnythingType;
alpar@1
   329
    //    friend class FirstAnythingType;
alpar@1
   330
alpar@1
   331
    class FirstAnythingTypeNode
alpar@1
   332
    {
alpar@1
   333
      NodeIterator n;
alpar@1
   334
    public:
alpar@1
   335
      FirstAnythingTypeNode(NodeIterator i) : n(i) {}
alpar@1
   336
alpar@1
   337
      operator const InEdgeIterator () const
alpar@1
   338
      {InEdgeIterator i; n.G->GetFirst(i,n);return i;}
alpar@1
   339
      operator const OutEdgeIterator () const
alpar@1
   340
      {OutEdgeIterator i; n.G->GetFirst(i,n);return i;}
alpar@1
   341
      operator const SymEdgeIterator () const
alpar@1
   342
      {SymEdgeIterator i; n.G->GetFirst(i,n);return i;}
alpar@1
   343
  
alpar@1
   344
      operator const InEdgePoint () const
alpar@1
   345
      {InEdgePoint i; n.G->GetFirst(i,n);return i;}
alpar@1
   346
      operator const OutEdgePoint () const
alpar@1
   347
      {OutEdgePoint i; n.G->GetFirst(i,n);return i;}
alpar@1
   348
      operator const SymEdgePoint () const
alpar@1
   349
      {SymEdgePoint i; n.G->GetFirst(i,n);return i;}
alpar@1
   350
    };
alpar@1
   351
    
alpar@1
   352
    class FirstAnythingType
alpar@1
   353
    {
alpar@1
   354
      Graph<N,E> *G;
alpar@1
   355
    public:
alpar@1
   356
      FirstAnythingType(Graph<N,E> *gg) : G(gg) {}
alpar@1
   357
alpar@1
   358
      operator const AllEdgeIterator () const
alpar@1
   359
      {AllEdgeIterator i; G->GetFirst(i);return i;}  
alpar@1
   360
      operator const EdgePoint () const
alpar@1
   361
      {EdgePoint i; G->GetFirst(i);return i;}
alpar@1
   362
      operator const NodeIterator () const
alpar@1
   363
      {NodeIterator i; G->GetFirst(i);return i;}  
alpar@1
   364
      operator const NodePoint () const
alpar@1
   365
      {NodePoint i; G->GetFirst(i);return i;}
alpar@1
   366
    } _FST;
alpar@1
   367
    
alpar@1
   368
    //    const NodeIterator First() {NodeIterator i;GetFirst(i); return i;}
alpar@1
   369
    FirstAnythingTypeNode First(NodeIterator &i)
alpar@1
   370
    {FirstAnythingTypeNode t(i); return t;}
alpar@1
   371
    const FirstAnythingType &First() {return _FST;}
alpar@1
   372
    
alpar@1
   373
    // LastNode() vagy endnode() stb. Nem kell?
alpar@1
   374
    
alpar@1
   375
    DeletingNodeIterator AddNode()
alpar@1
   376
    {
alpar@1
   377
      DeletingNodeIterator i;
alpar@1
   378
      i.G=this; i.n=OldGraph<N,E>::AddNode();
alpar@1
   379
      return i;
alpar@1
   380
    }
alpar@1
   381
    DeletingEdgeIterator
alpar@1
   382
    AddEdge(const NodeIterator from,const NodeIterator to)
alpar@1
   383
    {
alpar@1
   384
      DeletingEdgeIterator i;
alpar@1
   385
      i.G=this;i.e=OldGraph<N,E>::AddEdge(from.n,to.n);return i;
alpar@1
   386
    }
alpar@1
   387
    
alpar@1
   388
    void Delete(DeletingNodeIterator n) {n.G->OldGraph<N,E>::Delete(n.n);}
alpar@1
   389
    void Delete(DeletingEdgeIterator e) {e.G->OldGraph<N,E>::Delete(e.e);}
alpar@1
   390
    
alpar@1
   391
    int NodeNum() { OldGraph<N,E>::NodeNum(); }
alpar@3
   392
    void Clean() { OldGraph<N,E>::Clean(); }
alpar@1
   393
alpar@1
   394
    Graph() : _FST(this) {}
alpar@6
   395
alpar@6
   396
    // MAPS:
alpar@6
   397
    template<class T> class NodeMap
alpar@6
   398
    {
alpar@6
   399
      Graph<N,E> *G;
alpar@6
   400
      vector<T> map;
alpar@6
   401
alpar@6
   402
    public:
alpar@6
   403
      typedef T value_type;
alpar@6
   404
      void Set(NodeIterator i, const T &t) {map[i.Index()]=t;}
alpar@6
   405
      T &Get(NodeIterator i) {return map[i.Index()];}
alpar@6
   406
      T &operator[](NodeIterator i) {return map[i.Index()];}
alpar@6
   407
alpar@6
   408
      void update() { map.resize(G->OldGraph<N,E>::NodeMax());}
alpar@6
   409
alpar@6
   410
      NodeMap(Graph<N,E> &Gr) : map(Gr.OldGraph<N,E>::NodeMax()) { G=&Gr ;}
alpar@6
   411
      
alpar@6
   412
    };
alpar@6
   413
alpar@6
   414
    template<class T> class EdgeMap
alpar@6
   415
    {
alpar@6
   416
      Graph<N,E> *G;
alpar@6
   417
      vector<T> map;
alpar@6
   418
alpar@6
   419
    public:
alpar@6
   420
      typedef T value_type;
alpar@6
   421
      void Set(NodeIterator i, const T &t) {map[i.Index()]=t;}
alpar@6
   422
      T &Get(NodeIterator i) {return map[i.Index()];}
alpar@6
   423
      T &operator[](NodeIterator i) {return map[i.Index()];}
alpar@6
   424
      
alpar@6
   425
      void update()
alpar@6
   426
	{ map.resize(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE);}
alpar@6
   427
      
alpar@6
   428
      EdgeMap(Graph<N,E> &Gr) 
alpar@6
   429
	:map(Gr.OldGraph<N,E>::edge_block_num*EDGE_BLOCK_SIZE)
alpar@6
   430
	{ G=&Gr ;}
alpar@6
   431
      
alpar@6
   432
    };
alpar@6
   433
    
alpar@1
   434
  };
alpar@1
   435
  
alpar@1
   436
  /*   Ez itt a fiam kommentje:
alpar@1
   437
       <v n  nnnnnnnnnnnnnncncccccccccccccccccvvvvvv
alpar@1
   438
       vvnvnvnvnvnvvnnvnvnvnnvnbbbvfffffvvffffffffffffffffffffz
alpar@1
   439
       <<  < < <  < <  <   .cx..x.c.cc.c          
alpar@1
   440
       mcmn   
alpar@1
   441
  */
alpar@1
   442
  
alpar@1
   443
}
alpar@1
   444
alpar@1
   445
#endif