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