lemon/bits/edge_set_extender.h
author Peter Kovacs <kpeter@inf.elte.hu>
Fri, 24 Apr 2009 12:22:06 +0200
changeset 613 b1811c363299
parent 519 c786cd201266
child 617 4137ef9aacc6
permissions -rw-r--r--
Bug fix in NetworkSimplex (#234)
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 {
deba@468
    37
  public:
deba@468
    38
deba@468
    39
    typedef Base Parent;
deba@468
    40
    typedef ArcSetExtender Digraph;
deba@468
    41
deba@468
    42
    // Base extensions
deba@468
    43
deba@468
    44
    typedef typename Parent::Node Node;
deba@468
    45
    typedef typename Parent::Arc Arc;
deba@468
    46
deba@468
    47
    int maxId(Node) const {
deba@468
    48
      return Parent::maxNodeId();
deba@468
    49
    }
deba@468
    50
deba@468
    51
    int maxId(Arc) const {
deba@468
    52
      return Parent::maxArcId();
deba@468
    53
    }
deba@468
    54
deba@468
    55
    Node fromId(int id, Node) const {
deba@468
    56
      return Parent::nodeFromId(id);
deba@468
    57
    }
deba@468
    58
deba@468
    59
    Arc fromId(int id, Arc) const {
deba@468
    60
      return Parent::arcFromId(id);
deba@468
    61
    }
deba@468
    62
deba@468
    63
    Node oppositeNode(const Node &n, const Arc &e) const {
deba@468
    64
      if (n == Parent::source(e))
deba@468
    65
	return Parent::target(e);
deba@468
    66
      else if(n==Parent::target(e))
deba@468
    67
	return Parent::source(e);
deba@468
    68
      else
deba@468
    69
	return INVALID;
deba@468
    70
    }
deba@468
    71
deba@468
    72
deba@468
    73
    // Alteration notifier extensions
deba@468
    74
kpeter@559
    75
    // The arc observer registry.
deba@468
    76
    typedef AlterationNotifier<ArcSetExtender, Arc> ArcNotifier;
deba@468
    77
deba@468
    78
  protected:
deba@468
    79
deba@468
    80
    mutable ArcNotifier arc_notifier;
deba@468
    81
deba@468
    82
  public:
deba@468
    83
deba@468
    84
    using Parent::notifier;
deba@468
    85
kpeter@559
    86
    // Gives back the arc alteration notifier.
deba@468
    87
    ArcNotifier& notifier(Arc) const {
deba@468
    88
      return arc_notifier;
deba@468
    89
    }
deba@468
    90
deba@468
    91
    // Iterable extensions
deba@468
    92
deba@468
    93
    class NodeIt : public Node { 
deba@468
    94
      const Digraph* digraph;
deba@468
    95
    public:
deba@468
    96
deba@468
    97
      NodeIt() {}
deba@468
    98
deba@468
    99
      NodeIt(Invalid i) : Node(i) { }
deba@468
   100
deba@468
   101
      explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
deba@468
   102
	_graph.first(static_cast<Node&>(*this));
deba@468
   103
      }
deba@468
   104
deba@468
   105
      NodeIt(const Digraph& _graph, const Node& node) 
deba@468
   106
	: Node(node), digraph(&_graph) {}
deba@468
   107
deba@468
   108
      NodeIt& operator++() { 
deba@468
   109
	digraph->next(*this);
deba@468
   110
	return *this; 
deba@468
   111
      }
deba@468
   112
deba@468
   113
    };
deba@468
   114
deba@468
   115
deba@468
   116
    class ArcIt : public Arc { 
deba@468
   117
      const Digraph* digraph;
deba@468
   118
    public:
deba@468
   119
deba@468
   120
      ArcIt() { }
deba@468
   121
deba@468
   122
      ArcIt(Invalid i) : Arc(i) { }
deba@468
   123
deba@468
   124
      explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
deba@468
   125
	_graph.first(static_cast<Arc&>(*this));
deba@468
   126
      }
deba@468
   127
deba@468
   128
      ArcIt(const Digraph& _graph, const Arc& e) : 
deba@468
   129
	Arc(e), digraph(&_graph) { }
deba@468
   130
deba@468
   131
      ArcIt& operator++() { 
deba@468
   132
	digraph->next(*this);
deba@468
   133
	return *this; 
deba@468
   134
      }
deba@468
   135
deba@468
   136
    };
deba@468
   137
deba@468
   138
deba@468
   139
    class OutArcIt : public Arc { 
deba@468
   140
      const Digraph* digraph;
deba@468
   141
    public:
deba@468
   142
deba@468
   143
      OutArcIt() { }
deba@468
   144
deba@468
   145
      OutArcIt(Invalid i) : Arc(i) { }
deba@468
   146
deba@468
   147
      OutArcIt(const Digraph& _graph, const Node& node) 
deba@468
   148
	: digraph(&_graph) {
deba@468
   149
	_graph.firstOut(*this, node);
deba@468
   150
      }
deba@468
   151
deba@468
   152
      OutArcIt(const Digraph& _graph, const Arc& arc) 
deba@468
   153
	: Arc(arc), digraph(&_graph) {}
deba@468
   154
deba@468
   155
      OutArcIt& operator++() { 
deba@468
   156
	digraph->nextOut(*this);
deba@468
   157
	return *this; 
deba@468
   158
      }
deba@468
   159
deba@468
   160
    };
deba@468
   161
deba@468
   162
deba@468
   163
    class InArcIt : public Arc { 
deba@468
   164
      const Digraph* digraph;
deba@468
   165
    public:
deba@468
   166
deba@468
   167
      InArcIt() { }
deba@468
   168
deba@468
   169
      InArcIt(Invalid i) : Arc(i) { }
deba@468
   170
deba@468
   171
      InArcIt(const Digraph& _graph, const Node& node) 
deba@468
   172
	: digraph(&_graph) {
deba@468
   173
	_graph.firstIn(*this, node);
deba@468
   174
      }
deba@468
   175
deba@468
   176
      InArcIt(const Digraph& _graph, const Arc& arc) : 
deba@468
   177
	Arc(arc), digraph(&_graph) {}
deba@468
   178
deba@468
   179
      InArcIt& operator++() { 
deba@468
   180
	digraph->nextIn(*this);
deba@468
   181
	return *this; 
deba@468
   182
      }
deba@468
   183
deba@468
   184
    };
deba@468
   185
kpeter@559
   186
    // \brief Base node of the iterator
kpeter@559
   187
    //
kpeter@559
   188
    // Returns the base node (ie. the source in this case) of the iterator
deba@468
   189
    Node baseNode(const OutArcIt &e) const {
deba@468
   190
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   191
    }
kpeter@559
   192
    // \brief Running node of the iterator
kpeter@559
   193
    //
kpeter@559
   194
    // Returns the running node (ie. the target in this case) of the
kpeter@559
   195
    // iterator
deba@468
   196
    Node runningNode(const OutArcIt &e) const {
deba@468
   197
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   198
    }
deba@468
   199
kpeter@559
   200
    // \brief Base node of the iterator
kpeter@559
   201
    //
kpeter@559
   202
    // Returns the base node (ie. the target in this case) of the iterator
deba@468
   203
    Node baseNode(const InArcIt &e) const {
deba@468
   204
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   205
    }
kpeter@559
   206
    // \brief Running node of the iterator
kpeter@559
   207
    //
kpeter@559
   208
    // Returns the running node (ie. the source in this case) of the
kpeter@559
   209
    // iterator
deba@468
   210
    Node runningNode(const InArcIt &e) const {
deba@468
   211
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   212
    }
deba@468
   213
deba@468
   214
    using Parent::first;
deba@468
   215
deba@468
   216
    // Mappable extension
deba@468
   217
    
deba@468
   218
    template <typename _Value>
deba@468
   219
    class ArcMap 
deba@468
   220
      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
deba@468
   221
    public:
deba@468
   222
      typedef ArcSetExtender Digraph;
deba@468
   223
      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
deba@468
   224
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 {
deba@468
   277
deba@468
   278
  public:
deba@468
   279
deba@468
   280
    typedef Base Parent;
deba@468
   281
    typedef EdgeSetExtender Digraph;
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
deba@468
   288
    int maxId(Node) const {
deba@468
   289
      return Parent::maxNodeId();
deba@468
   290
    }
deba@468
   291
deba@468
   292
    int maxId(Arc) const {
deba@468
   293
      return Parent::maxArcId();
deba@468
   294
    }
deba@468
   295
deba@468
   296
    int maxId(Edge) const {
deba@468
   297
      return Parent::maxEdgeId();
deba@468
   298
    }
deba@468
   299
deba@468
   300
    Node fromId(int id, Node) const {
deba@468
   301
      return Parent::nodeFromId(id);
deba@468
   302
    }
deba@468
   303
deba@468
   304
    Arc fromId(int id, Arc) const {
deba@468
   305
      return Parent::arcFromId(id);
deba@468
   306
    }
deba@468
   307
deba@468
   308
    Edge fromId(int id, Edge) const {
deba@468
   309
      return Parent::edgeFromId(id);
deba@468
   310
    }
deba@468
   311
deba@468
   312
    Node oppositeNode(const Node &n, const Edge &e) const {
deba@468
   313
      if( n == Parent::u(e))
deba@468
   314
	return Parent::v(e);
deba@468
   315
      else if( n == Parent::v(e))
deba@468
   316
	return Parent::u(e);
deba@468
   317
      else
deba@468
   318
	return INVALID;
deba@468
   319
    }
deba@468
   320
deba@468
   321
    Arc oppositeArc(const Arc &e) const {
deba@468
   322
      return Parent::direct(e, !Parent::direction(e));
deba@468
   323
    }
deba@468
   324
deba@468
   325
    using Parent::direct;
deba@468
   326
    Arc direct(const Edge &e, const Node &s) const {
deba@468
   327
      return Parent::direct(e, Parent::u(e) == s);
deba@468
   328
    }
deba@468
   329
deba@468
   330
    typedef AlterationNotifier<EdgeSetExtender, Arc> ArcNotifier;
deba@468
   331
    typedef AlterationNotifier<EdgeSetExtender, Edge> EdgeNotifier;
deba@468
   332
deba@468
   333
deba@468
   334
  protected:
deba@468
   335
deba@468
   336
    mutable ArcNotifier arc_notifier;
deba@468
   337
    mutable EdgeNotifier edge_notifier;
deba@468
   338
deba@468
   339
  public:
deba@468
   340
deba@468
   341
    using Parent::notifier;
deba@468
   342
    
deba@468
   343
    ArcNotifier& notifier(Arc) const {
deba@468
   344
      return arc_notifier;
deba@468
   345
    }
deba@468
   346
deba@468
   347
    EdgeNotifier& notifier(Edge) const {
deba@468
   348
      return edge_notifier;
deba@468
   349
    }
deba@468
   350
deba@468
   351
deba@468
   352
    class NodeIt : public Node { 
deba@468
   353
      const Digraph* digraph;
deba@468
   354
    public:
deba@468
   355
deba@468
   356
      NodeIt() {}
deba@468
   357
deba@468
   358
      NodeIt(Invalid i) : Node(i) { }
deba@468
   359
deba@468
   360
      explicit NodeIt(const Digraph& _graph) : digraph(&_graph) {
deba@468
   361
	_graph.first(static_cast<Node&>(*this));
deba@468
   362
      }
deba@468
   363
deba@468
   364
      NodeIt(const Digraph& _graph, const Node& node) 
deba@468
   365
	: Node(node), digraph(&_graph) {}
deba@468
   366
deba@468
   367
      NodeIt& operator++() { 
deba@468
   368
	digraph->next(*this);
deba@468
   369
	return *this; 
deba@468
   370
      }
deba@468
   371
deba@468
   372
    };
deba@468
   373
deba@468
   374
deba@468
   375
    class ArcIt : public Arc { 
deba@468
   376
      const Digraph* digraph;
deba@468
   377
    public:
deba@468
   378
deba@468
   379
      ArcIt() { }
deba@468
   380
deba@468
   381
      ArcIt(Invalid i) : Arc(i) { }
deba@468
   382
deba@468
   383
      explicit ArcIt(const Digraph& _graph) : digraph(&_graph) {
deba@468
   384
	_graph.first(static_cast<Arc&>(*this));
deba@468
   385
      }
deba@468
   386
deba@468
   387
      ArcIt(const Digraph& _graph, const Arc& e) : 
deba@468
   388
	Arc(e), digraph(&_graph) { }
deba@468
   389
deba@468
   390
      ArcIt& operator++() { 
deba@468
   391
	digraph->next(*this);
deba@468
   392
	return *this; 
deba@468
   393
      }
deba@468
   394
deba@468
   395
    };
deba@468
   396
deba@468
   397
deba@468
   398
    class OutArcIt : public Arc { 
deba@468
   399
      const Digraph* digraph;
deba@468
   400
    public:
deba@468
   401
deba@468
   402
      OutArcIt() { }
deba@468
   403
deba@468
   404
      OutArcIt(Invalid i) : Arc(i) { }
deba@468
   405
deba@468
   406
      OutArcIt(const Digraph& _graph, const Node& node) 
deba@468
   407
	: digraph(&_graph) {
deba@468
   408
	_graph.firstOut(*this, node);
deba@468
   409
      }
deba@468
   410
deba@468
   411
      OutArcIt(const Digraph& _graph, const Arc& arc) 
deba@468
   412
	: Arc(arc), digraph(&_graph) {}
deba@468
   413
deba@468
   414
      OutArcIt& operator++() { 
deba@468
   415
	digraph->nextOut(*this);
deba@468
   416
	return *this; 
deba@468
   417
      }
deba@468
   418
deba@468
   419
    };
deba@468
   420
deba@468
   421
deba@468
   422
    class InArcIt : public Arc { 
deba@468
   423
      const Digraph* digraph;
deba@468
   424
    public:
deba@468
   425
deba@468
   426
      InArcIt() { }
deba@468
   427
deba@468
   428
      InArcIt(Invalid i) : Arc(i) { }
deba@468
   429
deba@468
   430
      InArcIt(const Digraph& _graph, const Node& node) 
deba@468
   431
	: digraph(&_graph) {
deba@468
   432
	_graph.firstIn(*this, node);
deba@468
   433
      }
deba@468
   434
deba@468
   435
      InArcIt(const Digraph& _graph, const Arc& arc) : 
deba@468
   436
	Arc(arc), digraph(&_graph) {}
deba@468
   437
deba@468
   438
      InArcIt& operator++() { 
deba@468
   439
	digraph->nextIn(*this);
deba@468
   440
	return *this; 
deba@468
   441
      }
deba@468
   442
deba@468
   443
    };
deba@468
   444
deba@468
   445
deba@468
   446
    class EdgeIt : public Parent::Edge { 
deba@468
   447
      const Digraph* digraph;
deba@468
   448
    public:
deba@468
   449
deba@468
   450
      EdgeIt() { }
deba@468
   451
deba@468
   452
      EdgeIt(Invalid i) : Edge(i) { }
deba@468
   453
deba@468
   454
      explicit EdgeIt(const Digraph& _graph) : digraph(&_graph) {
deba@468
   455
	_graph.first(static_cast<Edge&>(*this));
deba@468
   456
      }
deba@468
   457
deba@468
   458
      EdgeIt(const Digraph& _graph, const Edge& e) : 
deba@468
   459
	Edge(e), digraph(&_graph) { }
deba@468
   460
deba@468
   461
      EdgeIt& operator++() { 
deba@468
   462
	digraph->next(*this);
deba@468
   463
	return *this; 
deba@468
   464
      }
deba@468
   465
deba@468
   466
    };
deba@468
   467
deba@468
   468
    class IncEdgeIt : public Parent::Edge {
deba@468
   469
      friend class EdgeSetExtender;
deba@468
   470
      const Digraph* digraph;
deba@468
   471
      bool direction;
deba@468
   472
    public:
deba@468
   473
deba@468
   474
      IncEdgeIt() { }
deba@468
   475
deba@468
   476
      IncEdgeIt(Invalid i) : Edge(i), direction(false) { }
deba@468
   477
deba@468
   478
      IncEdgeIt(const Digraph& _graph, const Node &n) : digraph(&_graph) {
deba@468
   479
	_graph.firstInc(*this, direction, n);
deba@468
   480
      }
deba@468
   481
deba@468
   482
      IncEdgeIt(const Digraph& _graph, const Edge &ue, const Node &n)
deba@468
   483
	: digraph(&_graph), Edge(ue) {
deba@468
   484
	direction = (_graph.source(ue) == n);
deba@468
   485
      }
deba@468
   486
deba@468
   487
      IncEdgeIt& operator++() {
deba@468
   488
	digraph->nextInc(*this, direction);
deba@468
   489
	return *this; 
deba@468
   490
      }
deba@468
   491
    };
deba@468
   492
kpeter@559
   493
    // \brief Base node of the iterator
kpeter@559
   494
    //
kpeter@559
   495
    // Returns the base node (ie. the source in this case) of the iterator
deba@468
   496
    Node baseNode(const OutArcIt &e) const {
deba@468
   497
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   498
    }
kpeter@559
   499
    // \brief Running node of the iterator
kpeter@559
   500
    //
kpeter@559
   501
    // Returns the running node (ie. the target in this case) of the
kpeter@559
   502
    // iterator
deba@468
   503
    Node runningNode(const OutArcIt &e) const {
deba@468
   504
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   505
    }
deba@468
   506
kpeter@559
   507
    // \brief Base node of the iterator
kpeter@559
   508
    //
kpeter@559
   509
    // Returns the base node (ie. the target in this case) of the iterator
deba@468
   510
    Node baseNode(const InArcIt &e) const {
deba@468
   511
      return Parent::target(static_cast<const Arc&>(e));
deba@468
   512
    }
kpeter@559
   513
    // \brief Running node of the iterator
kpeter@559
   514
    //
kpeter@559
   515
    // Returns the running node (ie. the source in this case) of the
kpeter@559
   516
    // iterator
deba@468
   517
    Node runningNode(const InArcIt &e) const {
deba@468
   518
      return Parent::source(static_cast<const Arc&>(e));
deba@468
   519
    }
deba@468
   520
kpeter@559
   521
    // Base node of the iterator
kpeter@559
   522
    //
kpeter@559
   523
    // Returns the base node of the iterator
deba@468
   524
    Node baseNode(const IncEdgeIt &e) const {
deba@468
   525
      return e.direction ? u(e) : v(e);
deba@468
   526
    }
kpeter@559
   527
    // Running node of the iterator
kpeter@559
   528
    //
kpeter@559
   529
    // Returns the running node of the iterator
deba@468
   530
    Node runningNode(const IncEdgeIt &e) const {
deba@468
   531
      return e.direction ? v(e) : u(e);
deba@468
   532
    }
deba@468
   533
deba@468
   534
deba@468
   535
    template <typename _Value>
deba@468
   536
    class ArcMap 
deba@468
   537
      : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
deba@468
   538
    public:
deba@468
   539
      typedef EdgeSetExtender Digraph;
deba@468
   540
      typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
deba@468
   541
deba@468
   542
      ArcMap(const Digraph& _g) 
deba@468
   543
	: Parent(_g) {}
deba@468
   544
      ArcMap(const Digraph& _g, const _Value& _v) 
deba@468
   545
	: Parent(_g, _v) {}
deba@468
   546
deba@468
   547
      ArcMap& operator=(const ArcMap& cmap) {
deba@468
   548
	return operator=<ArcMap>(cmap);
deba@468
   549
      }
deba@468
   550
deba@468
   551
      template <typename CMap>
deba@468
   552
      ArcMap& operator=(const CMap& cmap) {
deba@468
   553
        Parent::operator=(cmap);
deba@468
   554
	return *this;
deba@468
   555
      }
deba@468
   556
deba@468
   557
    };
deba@468
   558
deba@468
   559
deba@468
   560
    template <typename _Value>
deba@468
   561
    class EdgeMap 
deba@468
   562
      : public MapExtender<DefaultMap<Digraph, Edge, _Value> > {
deba@468
   563
    public:
deba@468
   564
      typedef EdgeSetExtender Digraph;
deba@468
   565
      typedef MapExtender<DefaultMap<Digraph, Edge, _Value> > Parent;
deba@468
   566
deba@468
   567
      EdgeMap(const Digraph& _g) 
deba@468
   568
	: Parent(_g) {}
deba@468
   569
deba@468
   570
      EdgeMap(const Digraph& _g, const _Value& _v) 
deba@468
   571
	: Parent(_g, _v) {}
deba@468
   572
deba@468
   573
      EdgeMap& operator=(const EdgeMap& cmap) {
deba@468
   574
	return operator=<EdgeMap>(cmap);
deba@468
   575
      }
deba@468
   576
deba@468
   577
      template <typename CMap>
deba@468
   578
      EdgeMap& operator=(const CMap& cmap) {
deba@468
   579
        Parent::operator=(cmap);
deba@468
   580
	return *this;
deba@468
   581
      }
deba@468
   582
deba@468
   583
    };
deba@468
   584
deba@468
   585
deba@468
   586
    // Alteration extension
deba@468
   587
deba@468
   588
    Edge addEdge(const Node& from, const Node& to) {
deba@468
   589
      Edge edge = Parent::addEdge(from, to);
deba@468
   590
      notifier(Edge()).add(edge);
deba@468
   591
      std::vector<Arc> arcs;
deba@468
   592
      arcs.push_back(Parent::direct(edge, true));
deba@468
   593
      arcs.push_back(Parent::direct(edge, false));
deba@468
   594
      notifier(Arc()).add(arcs);
deba@468
   595
      return edge;
deba@468
   596
    }
deba@468
   597
    
deba@468
   598
    void clear() {
deba@468
   599
      notifier(Arc()).clear();
deba@468
   600
      notifier(Edge()).clear();
deba@468
   601
      Parent::clear();
deba@468
   602
    }
deba@468
   603
deba@468
   604
    void erase(const Edge& edge) {
deba@468
   605
      std::vector<Arc> arcs;
deba@468
   606
      arcs.push_back(Parent::direct(edge, true));
deba@468
   607
      arcs.push_back(Parent::direct(edge, false));
deba@468
   608
      notifier(Arc()).erase(arcs);
deba@468
   609
      notifier(Edge()).erase(edge);
deba@468
   610
      Parent::erase(edge);
deba@468
   611
    }
deba@468
   612
deba@468
   613
deba@468
   614
    EdgeSetExtender() {
deba@468
   615
      arc_notifier.setContainer(*this);
deba@468
   616
      edge_notifier.setContainer(*this);
deba@468
   617
    }
deba@468
   618
deba@468
   619
    ~EdgeSetExtender() {
deba@468
   620
      edge_notifier.clear();
deba@468
   621
      arc_notifier.clear();
deba@468
   622
    }
deba@468
   623
    
deba@468
   624
  };
deba@468
   625
deba@468
   626
}
deba@468
   627
deba@468
   628
#endif