lemon/bits/edge_set_extender.h
author Alpar Juttner <alpar@cs.elte.hu>
Sun, 28 Feb 2010 19:58:24 +0100
changeset 847 754272f20318
parent 617 4137ef9aacc6
child 877 141f9c0db4a3
child 962 4efe7b32b134
permissions -rw-r--r--
Merge #347
deba@468
     1
/* -*- C++ -*-
deba@468
     2
 *
deba@468
     3
 * This file is a part of LEMON, a generic C++ optimization library
deba@468
     4
 *
deba@468
     5
 * Copyright (C) 2003-2008
deba@468
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@468
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@468
     8
 *
deba@468
     9
 * Permission to use, modify and distribute this software is granted
deba@468
    10
 * provided that this copyright notice appears in all copies. For
deba@468
    11
 * precise terms see the accompanying LICENSE file.
deba@468
    12
 *
deba@468
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@468
    14
 * express or implied, and with no claim as to its suitability for any
deba@468
    15
 * purpose.
deba@468
    16
 *
deba@468
    17
 */
deba@468
    18
deba@468
    19
#ifndef LEMON_BITS_EDGE_SET_EXTENDER_H
deba@468
    20
#define LEMON_BITS_EDGE_SET_EXTENDER_H
deba@468
    21
deba@519
    22
#include <lemon/core.h>
deba@468
    23
#include <lemon/error.h>
deba@468
    24
#include <lemon/bits/default_map.h>
deba@519
    25
#include <lemon/bits/map_extender.h>
deba@468
    26
kpeter@559
    27
//\ingroup digraphbits
kpeter@559
    28
//\file
kpeter@559
    29
//\brief Extenders for the arc set types
deba@468
    30
namespace lemon {
deba@468
    31
kpeter@559
    32
  // \ingroup digraphbits
kpeter@559
    33
  //
kpeter@559
    34
  // \brief Extender for the ArcSets
deba@468
    35
  template <typename Base>
deba@468
    36
  class ArcSetExtender : public Base {
kpeter@617
    37
    typedef Base Parent;
kpeter@617
    38
deba@468
    39
  public:
deba@468
    40
deba@468
    41
    typedef ArcSetExtender Digraph;
deba@468
    42
deba@468
    43
    // Base extensions
deba@468
    44
deba@468
    45
    typedef typename Parent::Node Node;
deba@468
    46
    typedef typename Parent::Arc Arc;
deba@468
    47
deba@468
    48
    int maxId(Node) const {
deba@468
    49
      return Parent::maxNodeId();
deba@468
    50
    }
deba@468
    51
deba@468
    52
    int maxId(Arc) const {
deba@468
    53
      return Parent::maxArcId();
deba@468
    54
    }
deba@468
    55
deba@468
    56
    Node fromId(int id, Node) const {
deba@468
    57
      return Parent::nodeFromId(id);
deba@468
    58
    }
deba@468
    59
deba@468
    60
    Arc fromId(int id, Arc) const {
deba@468
    61
      return Parent::arcFromId(id);
deba@468
    62
    }
deba@468
    63
deba@468
    64
    Node oppositeNode(const Node &n, const Arc &e) const {
deba@468
    65
      if (n == Parent::source(e))
deba@468
    66
	return Parent::target(e);
deba@468
    67
      else if(n==Parent::target(e))
deba@468
    68
	return Parent::source(e);
deba@468
    69
      else
deba@468
    70
	return INVALID;
deba@468
    71
    }
deba@468
    72
deba@468
    73
deba@468
    74
    // Alteration notifier extensions
deba@468
    75
kpeter@559
    76
    // The arc observer registry.
deba@468
    77
    typedef AlterationNotifier<ArcSetExtender, Arc> ArcNotifier;
deba@468
    78
deba@468
    79
  protected:
deba@468
    80
deba@468
    81
    mutable ArcNotifier arc_notifier;
deba@468
    82
deba@468
    83
  public:
deba@468
    84
deba@468
    85
    using Parent::notifier;
deba@468
    86
kpeter@559
    87
    // Gives back the arc alteration notifier.
deba@468
    88
    ArcNotifier& notifier(Arc) const {
deba@468
    89
      return arc_notifier;
deba@468
    90
    }
deba@468
    91
deba@468
    92
    // Iterable extensions
deba@468
    93
deba@468
    94
    class NodeIt : public Node { 
deba@468
    95
      const Digraph* digraph;
deba@468
    96
    public:
deba@468
    97
deba@468
    98
      NodeIt() {}
deba@468
    99
deba@468
   100
      NodeIt(Invalid i) : Node(i) { }
deba@468
   101
deba@468
   102
      explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
deba@468
   103
	_graph.first(static_cast<Node&>(*this));
deba@468
   104
      }
deba@468
   105
deba@468
   106
      NodeIt(const Digraph& _graph, const Node& node) 
deba@468
   107
	: Node(node), digraph(&_graph) {}
deba@468
   108
deba@468
   109
      NodeIt& operator++() { 
deba@468
   110
	digraph->next(*this);
deba@468
   111
	return *this; 
deba@468
   112
      }
deba@468
   113
deba@468
   114
    };
deba@468
   115
deba@468
   116
deba@468
   117
    class ArcIt : public Arc { 
deba@468
   118
      const Digraph* digraph;
deba@468
   119
    public:
deba@468
   120
deba@468
   121
      ArcIt() { }
deba@468
   122
deba@468
   123
      ArcIt(Invalid i) : Arc(i) { }
deba@468
   124
deba@468
   125
      explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
deba@468
   126
	_graph.first(static_cast<Arc&>(*this));
deba@468
   127
      }
deba@468
   128
deba@468
   129
      ArcIt(const Digraph& _graph, const Arc& e) : 
deba@468
   130
	Arc(e), digraph(&_graph) { }
deba@468
   131
deba@468
   132
      ArcIt& operator++() { 
deba@468
   133
	digraph->next(*this);
deba@468
   134
	return *this; 
deba@468
   135
      }
deba@468
   136
deba@468
   137
    };
deba@468
   138
deba@468
   139
deba@468
   140
    class OutArcIt : public Arc { 
deba@468
   141
      const Digraph* digraph;
deba@468
   142
    public:
deba@468
   143
deba@468
   144
      OutArcIt() { }
deba@468
   145
deba@468
   146
      OutArcIt(Invalid i) : Arc(i) { }
deba@468
   147
deba@468
   148
      OutArcIt(const Digraph& _graph, const Node& node) 
deba@468
   149
	: digraph(&_graph) {
deba@468
   150
	_graph.firstOut(*this, node);
deba@468
   151
      }
deba@468
   152
deba@468
   153
      OutArcIt(const Digraph& _graph, const Arc& arc) 
deba@468
   154
	: Arc(arc), digraph(&_graph) {}
deba@468
   155
deba@468
   156
      OutArcIt& operator++() { 
deba@468
   157
	digraph->nextOut(*this);
deba@468
   158
	return *this; 
deba@468
   159
      }
deba@468
   160
deba@468
   161
    };
deba@468
   162
deba@468
   163
deba@468
   164
    class InArcIt : public Arc { 
deba@468
   165
      const Digraph* digraph;
deba@468
   166
    public:
deba@468
   167
deba@468
   168
      InArcIt() { }
deba@468
   169
deba@468
   170
      InArcIt(Invalid i) : Arc(i) { }
deba@468
   171
deba@468
   172
      InArcIt(const Digraph& _graph, const Node& node) 
deba@468
   173
	: digraph(&_graph) {
deba@468
   174
	_graph.firstIn(*this, node);
deba@468
   175
      }
deba@468
   176
deba@468
   177
      InArcIt(const Digraph& _graph, const Arc& arc) : 
deba@468
   178
	Arc(arc), digraph(&_graph) {}
deba@468
   179
deba@468
   180
      InArcIt& operator++() { 
deba@468
   181
	digraph->nextIn(*this);
deba@468
   182
	return *this; 
deba@468
   183
      }
deba@468
   184
deba@468
   185
    };
deba@468
   186
kpeter@559
   187
    // \brief Base node of the iterator
kpeter@559
   188
    //
kpeter@559
   189
    // Returns the base node (ie. the source in this case) of the iterator
deba@468
   190
    Node baseNode(const OutArcIt &e) const {
deba@468
   191
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   192
    }
kpeter@559
   193
    // \brief Running node of the iterator
kpeter@559
   194
    //
kpeter@559
   195
    // Returns the running node (ie. the target in this case) of the
kpeter@559
   196
    // iterator
deba@468
   197
    Node runningNode(const OutArcIt &e) const {
deba@468
   198
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   199
    }
deba@468
   200
kpeter@559
   201
    // \brief Base node of the iterator
kpeter@559
   202
    //
kpeter@559
   203
    // Returns the base node (ie. the target in this case) of the iterator
deba@468
   204
    Node baseNode(const InArcIt &e) const {
deba@468
   205
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   206
    }
kpeter@559
   207
    // \brief Running node of the iterator
kpeter@559
   208
    //
kpeter@559
   209
    // Returns the running node (ie. the source in this case) of the
kpeter@559
   210
    // iterator
deba@468
   211
    Node runningNode(const InArcIt &e) const {
deba@468
   212
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   213
    }
deba@468
   214
deba@468
   215
    using Parent::first;
deba@468
   216
deba@468
   217
    // Mappable extension
deba@468
   218
    
deba@468
   219
    template <typename _Value>
deba@468
   220
    class ArcMap 
deba@468
   221
      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
deba@468
   222
      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
deba@468
   223
kpeter@617
   224
    public:
deba@468
   225
      explicit ArcMap(const Digraph& _g) 
deba@468
   226
	: Parent(_g) {}
deba@468
   227
      ArcMap(const Digraph& _g, const _Value& _v) 
deba@468
   228
	: Parent(_g, _v) {}
deba@468
   229
deba@468
   230
      ArcMap& operator=(const ArcMap& cmap) {
deba@468
   231
	return operator=<ArcMap>(cmap);
deba@468
   232
      }
deba@468
   233
deba@468
   234
      template <typename CMap>
deba@468
   235
      ArcMap& operator=(const CMap& cmap) {
deba@468
   236
        Parent::operator=(cmap);
deba@468
   237
	return *this;
deba@468
   238
      }
deba@468
   239
deba@468
   240
    };
deba@468
   241
deba@468
   242
deba@468
   243
    // Alteration extension
deba@468
   244
deba@468
   245
    Arc addArc(const Node& from, const Node& to) {
deba@468
   246
      Arc arc = Parent::addArc(from, to);
deba@468
   247
      notifier(Arc()).add(arc);
deba@468
   248
      return arc;
deba@468
   249
    }
deba@468
   250
    
deba@468
   251
    void clear() {
deba@468
   252
      notifier(Arc()).clear();
deba@468
   253
      Parent::clear();
deba@468
   254
    }
deba@468
   255
deba@468
   256
    void erase(const Arc& arc) {
deba@468
   257
      notifier(Arc()).erase(arc);
deba@468
   258
      Parent::erase(arc);
deba@468
   259
    }
deba@468
   260
deba@468
   261
    ArcSetExtender() {
deba@468
   262
      arc_notifier.setContainer(*this);
deba@468
   263
    }
deba@468
   264
deba@468
   265
    ~ArcSetExtender() {
deba@468
   266
      arc_notifier.clear();
deba@468
   267
    }
deba@468
   268
deba@468
   269
  };
deba@468
   270
deba@468
   271
kpeter@559
   272
  // \ingroup digraphbits
kpeter@559
   273
  //
kpeter@559
   274
  // \brief Extender for the EdgeSets
deba@468
   275
  template <typename Base>
deba@468
   276
  class EdgeSetExtender : public Base {
kpeter@617
   277
    typedef Base Parent;
deba@468
   278
deba@468
   279
  public:
deba@468
   280
kpeter@617
   281
    typedef EdgeSetExtender Graph;
deba@468
   282
deba@468
   283
    typedef typename Parent::Node Node;
deba@468
   284
    typedef typename Parent::Arc Arc;
deba@468
   285
    typedef typename Parent::Edge Edge;
deba@468
   286
deba@468
   287
    int maxId(Node) const {
deba@468
   288
      return Parent::maxNodeId();
deba@468
   289
    }
deba@468
   290
deba@468
   291
    int maxId(Arc) const {
deba@468
   292
      return Parent::maxArcId();
deba@468
   293
    }
deba@468
   294
deba@468
   295
    int maxId(Edge) const {
deba@468
   296
      return Parent::maxEdgeId();
deba@468
   297
    }
deba@468
   298
deba@468
   299
    Node fromId(int id, Node) const {
deba@468
   300
      return Parent::nodeFromId(id);
deba@468
   301
    }
deba@468
   302
deba@468
   303
    Arc fromId(int id, Arc) const {
deba@468
   304
      return Parent::arcFromId(id);
deba@468
   305
    }
deba@468
   306
deba@468
   307
    Edge fromId(int id, Edge) const {
deba@468
   308
      return Parent::edgeFromId(id);
deba@468
   309
    }
deba@468
   310
deba@468
   311
    Node oppositeNode(const Node &n, const Edge &e) const {
deba@468
   312
      if( n == Parent::u(e))
deba@468
   313
	return Parent::v(e);
deba@468
   314
      else if( n == Parent::v(e))
deba@468
   315
	return Parent::u(e);
deba@468
   316
      else
deba@468
   317
	return INVALID;
deba@468
   318
    }
deba@468
   319
deba@468
   320
    Arc oppositeArc(const Arc &e) const {
deba@468
   321
      return Parent::direct(e, !Parent::direction(e));
deba@468
   322
    }
deba@468
   323
deba@468
   324
    using Parent::direct;
deba@468
   325
    Arc direct(const Edge &e, const Node &s) const {
deba@468
   326
      return Parent::direct(e, Parent::u(e) == s);
deba@468
   327
    }
deba@468
   328
deba@468
   329
    typedef AlterationNotifier<EdgeSetExtender, Arc> ArcNotifier;
deba@468
   330
    typedef AlterationNotifier<EdgeSetExtender, Edge> EdgeNotifier;
deba@468
   331
deba@468
   332
deba@468
   333
  protected:
deba@468
   334
deba@468
   335
    mutable ArcNotifier arc_notifier;
deba@468
   336
    mutable EdgeNotifier edge_notifier;
deba@468
   337
deba@468
   338
  public:
deba@468
   339
deba@468
   340
    using Parent::notifier;
deba@468
   341
    
deba@468
   342
    ArcNotifier& notifier(Arc) const {
deba@468
   343
      return arc_notifier;
deba@468
   344
    }
deba@468
   345
deba@468
   346
    EdgeNotifier& notifier(Edge) const {
deba@468
   347
      return edge_notifier;
deba@468
   348
    }
deba@468
   349
deba@468
   350
deba@468
   351
    class NodeIt : public Node { 
kpeter@617
   352
      const Graph* graph;
deba@468
   353
    public:
deba@468
   354
deba@468
   355
      NodeIt() {}
deba@468
   356
deba@468
   357
      NodeIt(Invalid i) : Node(i) { }
deba@468
   358
kpeter@617
   359
      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
deba@468
   360
	_graph.first(static_cast<Node&>(*this));
deba@468
   361
      }
deba@468
   362
kpeter@617
   363
      NodeIt(const Graph& _graph, const Node& node) 
kpeter@617
   364
	: Node(node), graph(&_graph) {}
deba@468
   365
deba@468
   366
      NodeIt& operator++() { 
kpeter@617
   367
	graph->next(*this);
deba@468
   368
	return *this; 
deba@468
   369
      }
deba@468
   370
deba@468
   371
    };
deba@468
   372
deba@468
   373
deba@468
   374
    class ArcIt : public Arc { 
kpeter@617
   375
      const Graph* graph;
deba@468
   376
    public:
deba@468
   377
deba@468
   378
      ArcIt() { }
deba@468
   379
deba@468
   380
      ArcIt(Invalid i) : Arc(i) { }
deba@468
   381
kpeter@617
   382
      explicit ArcIt(const Graph& _graph) : graph(&_graph) {
deba@468
   383
	_graph.first(static_cast<Arc&>(*this));
deba@468
   384
      }
deba@468
   385
kpeter@617
   386
      ArcIt(const Graph& _graph, const Arc& e) : 
kpeter@617
   387
	Arc(e), graph(&_graph) { }
deba@468
   388
deba@468
   389
      ArcIt& operator++() { 
kpeter@617
   390
	graph->next(*this);
deba@468
   391
	return *this; 
deba@468
   392
      }
deba@468
   393
deba@468
   394
    };
deba@468
   395
deba@468
   396
deba@468
   397
    class OutArcIt : public Arc { 
kpeter@617
   398
      const Graph* graph;
deba@468
   399
    public:
deba@468
   400
deba@468
   401
      OutArcIt() { }
deba@468
   402
deba@468
   403
      OutArcIt(Invalid i) : Arc(i) { }
deba@468
   404
kpeter@617
   405
      OutArcIt(const Graph& _graph, const Node& node) 
kpeter@617
   406
	: graph(&_graph) {
deba@468
   407
	_graph.firstOut(*this, node);
deba@468
   408
      }
deba@468
   409
kpeter@617
   410
      OutArcIt(const Graph& _graph, const Arc& arc) 
kpeter@617
   411
	: Arc(arc), graph(&_graph) {}
deba@468
   412
deba@468
   413
      OutArcIt& operator++() { 
kpeter@617
   414
	graph->nextOut(*this);
deba@468
   415
	return *this; 
deba@468
   416
      }
deba@468
   417
deba@468
   418
    };
deba@468
   419
deba@468
   420
deba@468
   421
    class InArcIt : public Arc { 
kpeter@617
   422
      const Graph* graph;
deba@468
   423
    public:
deba@468
   424
deba@468
   425
      InArcIt() { }
deba@468
   426
deba@468
   427
      InArcIt(Invalid i) : Arc(i) { }
deba@468
   428
kpeter@617
   429
      InArcIt(const Graph& _graph, const Node& node) 
kpeter@617
   430
	: graph(&_graph) {
deba@468
   431
	_graph.firstIn(*this, node);
deba@468
   432
      }
deba@468
   433
kpeter@617
   434
      InArcIt(const Graph& _graph, const Arc& arc) : 
kpeter@617
   435
	Arc(arc), graph(&_graph) {}
deba@468
   436
deba@468
   437
      InArcIt& operator++() { 
kpeter@617
   438
	graph->nextIn(*this);
deba@468
   439
	return *this; 
deba@468
   440
      }
deba@468
   441
deba@468
   442
    };
deba@468
   443
deba@468
   444
deba@468
   445
    class EdgeIt : public Parent::Edge { 
kpeter@617
   446
      const Graph* graph;
deba@468
   447
    public:
deba@468
   448
deba@468
   449
      EdgeIt() { }
deba@468
   450
deba@468
   451
      EdgeIt(Invalid i) : Edge(i) { }
deba@468
   452
kpeter@617
   453
      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
deba@468
   454
	_graph.first(static_cast<Edge&>(*this));
deba@468
   455
      }
deba@468
   456
kpeter@617
   457
      EdgeIt(const Graph& _graph, const Edge& e) : 
kpeter@617
   458
	Edge(e), graph(&_graph) { }
deba@468
   459
deba@468
   460
      EdgeIt& operator++() { 
kpeter@617
   461
	graph->next(*this);
deba@468
   462
	return *this; 
deba@468
   463
      }
deba@468
   464
deba@468
   465
    };
deba@468
   466
deba@468
   467
    class IncEdgeIt : public Parent::Edge {
deba@468
   468
      friend class EdgeSetExtender;
kpeter@617
   469
      const Graph* graph;
deba@468
   470
      bool direction;
deba@468
   471
    public:
deba@468
   472
deba@468
   473
      IncEdgeIt() { }
deba@468
   474
deba@468
   475
      IncEdgeIt(Invalid i) : Edge(i), direction(false) { }
deba@468
   476
kpeter@617
   477
      IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
deba@468
   478
	_graph.firstInc(*this, direction, n);
deba@468
   479
      }
deba@468
   480
kpeter@617
   481
      IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n)
kpeter@617
   482
	: graph(&_graph), Edge(ue) {
deba@468
   483
	direction = (_graph.source(ue) == n);
deba@468
   484
      }
deba@468
   485
deba@468
   486
      IncEdgeIt& operator++() {
kpeter@617
   487
	graph->nextInc(*this, direction);
deba@468
   488
	return *this; 
deba@468
   489
      }
deba@468
   490
    };
deba@468
   491
kpeter@559
   492
    // \brief Base node of the iterator
kpeter@559
   493
    //
kpeter@559
   494
    // Returns the base node (ie. the source in this case) of the iterator
deba@468
   495
    Node baseNode(const OutArcIt &e) const {
deba@468
   496
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   497
    }
kpeter@559
   498
    // \brief Running node of the iterator
kpeter@559
   499
    //
kpeter@559
   500
    // Returns the running node (ie. the target in this case) of the
kpeter@559
   501
    // iterator
deba@468
   502
    Node runningNode(const OutArcIt &e) const {
deba@468
   503
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   504
    }
deba@468
   505
kpeter@559
   506
    // \brief Base node of the iterator
kpeter@559
   507
    //
kpeter@559
   508
    // Returns the base node (ie. the target in this case) of the iterator
deba@468
   509
    Node baseNode(const InArcIt &e) const {
deba@468
   510
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   511
    }
kpeter@559
   512
    // \brief Running node of the iterator
kpeter@559
   513
    //
kpeter@559
   514
    // Returns the running node (ie. the source in this case) of the
kpeter@559
   515
    // iterator
deba@468
   516
    Node runningNode(const InArcIt &e) const {
deba@468
   517
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   518
    }
deba@468
   519
kpeter@559
   520
    // Base node of the iterator
kpeter@559
   521
    //
kpeter@559
   522
    // Returns the base node of the iterator
deba@468
   523
    Node baseNode(const IncEdgeIt &e) const {
deba@468
   524
      return e.direction ? u(e) : v(e);
deba@468
   525
    }
kpeter@559
   526
    // Running node of the iterator
kpeter@559
   527
    //
kpeter@559
   528
    // Returns the running node of the iterator
deba@468
   529
    Node runningNode(const IncEdgeIt &e) const {
deba@468
   530
      return e.direction ? v(e) : u(e);
deba@468
   531
    }
deba@468
   532
deba@468
   533
deba@468
   534
    template <typename _Value>
deba@468
   535
    class ArcMap 
kpeter@617
   536
      : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
kpeter@617
   537
      typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
kpeter@617
   538
deba@468
   539
    public:
kpeter@685
   540
      explicit ArcMap(const Graph& _g) 
deba@468
   541
	: Parent(_g) {}
kpeter@617
   542
      ArcMap(const Graph& _g, const _Value& _v) 
deba@468
   543
	: Parent(_g, _v) {}
deba@468
   544
deba@468
   545
      ArcMap& operator=(const ArcMap& cmap) {
deba@468
   546
	return operator=<ArcMap>(cmap);
deba@468
   547
      }
deba@468
   548
deba@468
   549
      template <typename CMap>
deba@468
   550
      ArcMap& operator=(const CMap& cmap) {
deba@468
   551
        Parent::operator=(cmap);
deba@468
   552
	return *this;
deba@468
   553
      }
deba@468
   554
deba@468
   555
    };
deba@468
   556
deba@468
   557
deba@468
   558
    template <typename _Value>
deba@468
   559
    class EdgeMap 
kpeter@617
   560
      : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
kpeter@617
   561
      typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
kpeter@617
   562
deba@468
   563
    public:
kpeter@685
   564
      explicit EdgeMap(const Graph& _g) 
deba@468
   565
	: Parent(_g) {}
deba@468
   566
kpeter@617
   567
      EdgeMap(const Graph& _g, const _Value& _v) 
deba@468
   568
	: Parent(_g, _v) {}
deba@468
   569
deba@468
   570
      EdgeMap& operator=(const EdgeMap& cmap) {
deba@468
   571
	return operator=<EdgeMap>(cmap);
deba@468
   572
      }
deba@468
   573
deba@468
   574
      template <typename CMap>
deba@468
   575
      EdgeMap& operator=(const CMap& cmap) {
deba@468
   576
        Parent::operator=(cmap);
deba@468
   577
	return *this;
deba@468
   578
      }
deba@468
   579
deba@468
   580
    };
deba@468
   581
deba@468
   582
deba@468
   583
    // Alteration extension
deba@468
   584
deba@468
   585
    Edge addEdge(const Node& from, const Node& to) {
deba@468
   586
      Edge edge = Parent::addEdge(from, to);
deba@468
   587
      notifier(Edge()).add(edge);
deba@468
   588
      std::vector<Arc> arcs;
deba@468
   589
      arcs.push_back(Parent::direct(edge, true));
deba@468
   590
      arcs.push_back(Parent::direct(edge, false));
deba@468
   591
      notifier(Arc()).add(arcs);
deba@468
   592
      return edge;
deba@468
   593
    }
deba@468
   594
    
deba@468
   595
    void clear() {
deba@468
   596
      notifier(Arc()).clear();
deba@468
   597
      notifier(Edge()).clear();
deba@468
   598
      Parent::clear();
deba@468
   599
    }
deba@468
   600
deba@468
   601
    void erase(const Edge& edge) {
deba@468
   602
      std::vector<Arc> arcs;
deba@468
   603
      arcs.push_back(Parent::direct(edge, true));
deba@468
   604
      arcs.push_back(Parent::direct(edge, false));
deba@468
   605
      notifier(Arc()).erase(arcs);
deba@468
   606
      notifier(Edge()).erase(edge);
deba@468
   607
      Parent::erase(edge);
deba@468
   608
    }
deba@468
   609
deba@468
   610
deba@468
   611
    EdgeSetExtender() {
deba@468
   612
      arc_notifier.setContainer(*this);
deba@468
   613
      edge_notifier.setContainer(*this);
deba@468
   614
    }
deba@468
   615
deba@468
   616
    ~EdgeSetExtender() {
deba@468
   617
      edge_notifier.clear();
deba@468
   618
      arc_notifier.clear();
deba@468
   619
    }
deba@468
   620
    
deba@468
   621
  };
deba@468
   622
deba@468
   623
}
deba@468
   624
deba@468
   625
#endif