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