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