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