COIN-OR::LEMON - Graph Library

Changeset 2031:080d51024ac5 in lemon-0.x


Ignore:
Timestamp:
04/03/06 11:45:23 (18 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2670
Message:

Correcting the structure of the graph's and adaptor's map.
The template assign operators and map iterators can be used for adaptors also.

Some bugfix in the adaptors

New class SwapBpUGraphAdaptor which swaps the two nodeset of the graph.

Location:
lemon
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • lemon/Makefile.am

    r2017 r2031  
    2828        dfs.h \
    2929        bin_heap.h \
     30        bpugraph_adaptor.h \
    3031        color.h \
    3132        config.h \
  • lemon/bits/array_map.h

    r1999 r2031  
    2424#include <lemon/bits/traits.h>
    2525#include <lemon/bits/alteration_notifier.h>
     26#include <lemon/concept_check.h>
     27#include <lemon/concept/maps.h>
    2628
    2729/// \ingroup graphbits
     
    120122    }
    121123
     124    /// \brief Assign operator.
     125    ///
     126    /// This operator assigns for each item in the map the
     127    /// value mapped to the same item in the copied map. 
     128    /// The parameter map should be indiced with the same
     129    /// itemset because this assign operator does not change
     130    /// the container of the map.
     131    ArrayMap& operator=(const ArrayMap& cmap) {
     132      return operator=<ArrayMap>(cmap);
     133    }
     134
     135
     136    /// \brief Template assign operator.
     137    ///
     138    /// The given parameter should be conform to the ReadMap
     139    /// concecpt and could be indiced by the current item set of
     140    /// the NodeMap. In this case the value for each item
     141    /// is assigned by the value of the given ReadMap.
     142    template <typename CMap>
     143    ArrayMap& operator=(const CMap& cmap) {
     144      checkConcept<concept::ReadMap<Key, _Value>, CMap>();
     145      const typename Parent::Notifier* notifier = Parent::getNotifier();
     146      Item it;
     147      for (notifier->first(it); it != INVALID; notifier->next(it)) {
     148        set(it, cmap[it]);
     149      }
     150      return *this;
     151    }
     152
    122153    /// \brief The destructor of the map.
    123154    ///     
     
    130161    }
    131162               
    132   private:
    133 
    134     ArrayMap& operator=(const ArrayMap&);
    135 
    136163  protected:
    137164
  • lemon/bits/base_extender.h

    r1999 r2031  
    467467      return Edge(edge, direction);
    468468    }
     469
     470    int edgeNum() const {
     471      return 2 * Parent::edgeNum();
     472    }
     473
     474    int uEdgeNum() const {
     475      return Parent::edgeNum();
     476    }
     477
    469478  };
    470479
  • lemon/bits/default_map.h

    r1999 r2031  
    164164      : Parent(graph, value) {}
    165165
     166    DefaultMap& operator=(const DefaultMap& cmap) {
     167      return operator=<DefaultMap>(cmap);
     168    }
     169
     170    template <typename CMap>
     171    DefaultMap& operator=(const CMap& cmap) {
     172      Parent::operator=(cmap);
     173      return *this;
     174    }
     175
    166176  };
    167177
  • lemon/bits/edge_set_extender.h

    r1999 r2031  
    102102
    103103      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    104         _graph.first(*static_cast<Node*>(this));
     104        _graph.first(static_cast<Node&>(*this));
    105105      }
    106106
     
    125125
    126126      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
    127         _graph.first(*static_cast<Edge*>(this));
     127        _graph.first(static_cast<Edge&>(*this));
    128128      }
    129129
     
    236236      template <typename CMap>
    237237      EdgeMap& operator=(const CMap& cmap) {
    238         checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
    239         const typename Parent::Graph* graph = Parent::getGraph();
    240         Edge it;
    241         for (graph->first(it); it != INVALID; graph->next(it)) {
    242           Parent::set(it, cmap[it]);
    243         }
     238        Parent::operator=(cmap);
    244239        return *this;
    245240      }
     241
    246242    };
    247243
     
    365361
    366362      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    367         _graph.first(*static_cast<Node*>(this));
     363        _graph.first(static_cast<Node&>(*this));
    368364      }
    369365
     
    388384
    389385      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
    390         _graph.first(*static_cast<Edge*>(this));
     386        _graph.first(static_cast<Edge&>(*this));
    391387      }
    392388
     
    459455
    460456      explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
    461         _graph.first(*static_cast<UEdge*>(this));
     457        _graph.first(static_cast<UEdge&>(*this));
    462458      }
    463459
     
    557553      template <typename CMap>
    558554      EdgeMap& operator=(const CMap& cmap) {
    559         checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
    560         const typename Parent::Graph* graph = Parent::getGraph();
    561         Edge it;
    562         for (graph->first(it); it != INVALID; graph->next(it)) {
    563           Parent::set(it, cmap[it]);
    564         }
     555        Parent::operator=(cmap);
    565556        return *this;
    566557      }
     558
    567559    };
    568560
     
    577569      UEdgeMap(const Graph& _g)
    578570        : Parent(_g) {}
     571
    579572      UEdgeMap(const Graph& _g, const _Value& _v)
    580573        : Parent(_g, _v) {}
     
    586579      template <typename CMap>
    587580      UEdgeMap& operator=(const CMap& cmap) {
    588         checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
    589         const typename Parent::Graph* graph = Parent::getGraph();
    590         UEdge it;
    591         for (graph->first(it); it != INVALID; graph->next(it)) {
    592           Parent::set(it, cmap[it]);
    593         }
     581        Parent::operator=(cmap);
    594582        return *this;
    595583      }
     584
    596585    };
    597586
  • lemon/bits/graph_adaptor_extender.h

    r1996 r2031  
    3434  ///
    3535  /// \brief Extender for the GraphAdaptors
    36   template <typename Base>
    37   class GraphAdaptorExtender : public Base {
     36  template <typename _Graph>
     37  class GraphAdaptorExtender : public _Graph {
    3838  public:
    3939
    40     typedef Base Parent;
    41     typedef GraphAdaptorExtender Graph;
     40    typedef _Graph Parent;
     41    typedef _Graph Graph;
     42    typedef GraphAdaptorExtender Adaptor;
    4243
    4344    // Base extensions
     
    7273
    7374    class NodeIt : public Node {
    74       const Graph* graph;
     75      const Adaptor* graph;
    7576    public:
    7677
     
    7980      NodeIt(Invalid i) : Node(i) { }
    8081
    81       explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    82         _graph.first(*static_cast<Node*>(this));
    83       }
    84 
    85       NodeIt(const Graph& _graph, const Node& node)
     82      explicit NodeIt(const Adaptor& _graph) : graph(&_graph) {
     83        _graph.first(static_cast<Node&>(*this));
     84      }
     85
     86      NodeIt(const Adaptor& _graph, const Node& node)
    8687        : Node(node), graph(&_graph) {}
    8788
     
    9596
    9697    class EdgeIt : public Edge {
    97       const Graph* graph;
     98      const Adaptor* graph;
    9899    public:
    99100
     
    102103      EdgeIt(Invalid i) : Edge(i) { }
    103104
    104       explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
    105         _graph.first(*static_cast<Edge*>(this));
    106       }
    107 
    108       EdgeIt(const Graph& _graph, const Edge& e) :
     105      explicit EdgeIt(const Adaptor& _graph) : graph(&_graph) {
     106        _graph.first(static_cast<Edge&>(*this));
     107      }
     108
     109      EdgeIt(const Adaptor& _graph, const Edge& e) :
    109110        Edge(e), graph(&_graph) { }
    110111
     
    118119
    119120    class OutEdgeIt : public Edge {
    120       const Graph* graph;
     121      const Adaptor* graph;
    121122    public:
    122123
     
    125126      OutEdgeIt(Invalid i) : Edge(i) { }
    126127
    127       OutEdgeIt(const Graph& _graph, const Node& node)
     128      OutEdgeIt(const Adaptor& _graph, const Node& node)
    128129        : graph(&_graph) {
    129130        _graph.firstOut(*this, node);
    130131      }
    131132
    132       OutEdgeIt(const Graph& _graph, const Edge& edge)
     133      OutEdgeIt(const Adaptor& _graph, const Edge& edge)
    133134        : Edge(edge), graph(&_graph) {}
    134135
     
    142143
    143144    class InEdgeIt : public Edge {
    144       const Graph* graph;
     145      const Adaptor* graph;
    145146    public:
    146147
     
    149150      InEdgeIt(Invalid i) : Edge(i) { }
    150151
    151       InEdgeIt(const Graph& _graph, const Node& node)
     152      InEdgeIt(const Adaptor& _graph, const Node& node)
    152153        : graph(&_graph) {
    153154        _graph.firstIn(*this, node);
    154155      }
    155156
    156       InEdgeIt(const Graph& _graph, const Edge& edge) :
     157      InEdgeIt(const Adaptor& _graph, const Edge& edge) :
    157158        Edge(edge), graph(&_graph) {}
    158159
     
    198199  ///
    199200  /// \brief Extender for the UGraphAdaptors
    200   template <typename Base>
    201   class UGraphAdaptorExtender : public Base {
     201  template <typename _UGraph>
     202  class UGraphAdaptorExtender : public _UGraph {
    202203  public:
    203204   
    204     typedef Base Parent;
    205     typedef UGraphAdaptorExtender Graph;
     205    typedef _UGraph Parent;
     206    typedef _UGraph UGraph;
     207    typedef UGraphAdaptorExtender Adaptor;
    206208
    207209    typedef typename Parent::Node Node;
     
    255257
    256258    class NodeIt : public Node {
    257       const Graph* graph;
     259      const Adaptor* graph;
    258260    public:
    259261
     
    262264      NodeIt(Invalid i) : Node(i) { }
    263265
    264       explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    265         _graph.first(*static_cast<Node*>(this));
    266       }
    267 
    268       NodeIt(const Graph& _graph, const Node& node)
     266      explicit NodeIt(const Adaptor& _graph) : graph(&_graph) {
     267        _graph.first(static_cast<Node&>(*this));
     268      }
     269
     270      NodeIt(const Adaptor& _graph, const Node& node)
    269271        : Node(node), graph(&_graph) {}
    270272
     
    278280
    279281    class EdgeIt : public Edge {
    280       const Graph* graph;
     282      const Adaptor* graph;
    281283    public:
    282284
     
    285287      EdgeIt(Invalid i) : Edge(i) { }
    286288
    287       explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
    288         _graph.first(*static_cast<Edge*>(this));
    289       }
    290 
    291       EdgeIt(const Graph& _graph, const Edge& e) :
     289      explicit EdgeIt(const Adaptor& _graph) : graph(&_graph) {
     290        _graph.first(static_cast<Edge&>(*this));
     291      }
     292
     293      EdgeIt(const Adaptor& _graph, const Edge& e) :
    292294        Edge(e), graph(&_graph) { }
    293295
     
    301303
    302304    class OutEdgeIt : public Edge {
    303       const Graph* graph;
     305      const Adaptor* graph;
    304306    public:
    305307
     
    308310      OutEdgeIt(Invalid i) : Edge(i) { }
    309311
    310       OutEdgeIt(const Graph& _graph, const Node& node)
     312      OutEdgeIt(const Adaptor& _graph, const Node& node)
    311313        : graph(&_graph) {
    312314        _graph.firstOut(*this, node);
    313315      }
    314316
    315       OutEdgeIt(const Graph& _graph, const Edge& edge)
     317      OutEdgeIt(const Adaptor& _graph, const Edge& edge)
    316318        : Edge(edge), graph(&_graph) {}
    317319
     
    325327
    326328    class InEdgeIt : public Edge {
    327       const Graph* graph;
     329      const Adaptor* graph;
    328330    public:
    329331
     
    332334      InEdgeIt(Invalid i) : Edge(i) { }
    333335
    334       InEdgeIt(const Graph& _graph, const Node& node)
     336      InEdgeIt(const Adaptor& _graph, const Node& node)
    335337        : graph(&_graph) {
    336338        _graph.firstIn(*this, node);
    337339      }
    338340
    339       InEdgeIt(const Graph& _graph, const Edge& edge) :
     341      InEdgeIt(const Adaptor& _graph, const Edge& edge) :
    340342        Edge(edge), graph(&_graph) {}
    341343
     
    348350
    349351    class UEdgeIt : public Parent::UEdge {
    350       const Graph* graph;
     352      const Adaptor* graph;
    351353    public:
    352354
     
    355357      UEdgeIt(Invalid i) : UEdge(i) { }
    356358
    357       explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
    358         _graph.first(*static_cast<UEdge*>(this));
    359       }
    360 
    361       UEdgeIt(const Graph& _graph, const UEdge& e) :
     359      explicit UEdgeIt(const Adaptor& _graph) : graph(&_graph) {
     360        _graph.first(static_cast<UEdge&>(*this));
     361      }
     362
     363      UEdgeIt(const Adaptor& _graph, const UEdge& e) :
    362364        UEdge(e), graph(&_graph) { }
    363365
     
    371373    class IncEdgeIt : public Parent::UEdge {
    372374      friend class UGraphAdaptorExtender;
    373       const Graph* graph;
     375      const Adaptor* graph;
    374376      bool direction;
    375377    public:
     
    379381      IncEdgeIt(Invalid i) : UEdge(i), direction(false) { }
    380382
    381       IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
     383      IncEdgeIt(const Adaptor& _graph, const Node &n) : graph(&_graph) {
    382384        _graph.firstInc(static_cast<UEdge&>(*this), direction, n);
    383385      }
    384386
    385       IncEdgeIt(const Graph& _graph, const UEdge &ue, const Node &n)
     387      IncEdgeIt(const Adaptor& _graph, const UEdge &ue, const Node &n)
    386388        : graph(&_graph), UEdge(ue) {
    387389        direction = (_graph.source(ue) == n);
     
    437439  };
    438440
     441  /// \ingroup graphbits
     442  ///
     443  /// \brief Extender for the BpUGraphAdaptors
     444  template <typename Base>
     445  class BpUGraphAdaptorExtender : public Base {
     446  public:
     447    typedef Base Parent;
     448    typedef BpUGraphAdaptorExtender Graph;
     449
     450    typedef typename Parent::Node Node;
     451    typedef typename Parent::BNode BNode;
     452    typedef typename Parent::ANode ANode;
     453    typedef typename Parent::Edge Edge;
     454    typedef typename Parent::UEdge UEdge;
     455
     456    Node oppositeNode(const UEdge& edge, const Node& node) const {
     457      return source(edge) == node ?
     458        target(edge) : source(edge);
     459    }
     460
     461
     462    int maxId(Node) const {
     463      return Parent::maxNodeId();
     464    }
     465    int maxId(BNode) const {
     466      return Parent::maxBNodeId();
     467    }
     468    int maxId(ANode) const {
     469      return Parent::maxANodeId();
     470    }
     471    int maxId(Edge) const {
     472      return Parent::maxEdgeId();
     473    }
     474    int maxId(UEdge) const {
     475      return Parent::maxUEdgeId();
     476    }
     477
     478
     479    Node fromId(int id, Node) const {
     480      return Parent::nodeFromId(id);
     481    }
     482    ANode fromId(int id, ANode) const {
     483      return Parent::fromANodeId(id);
     484    }
     485    BNode fromId(int id, BNode) const {
     486      return Parent::fromBNodeId(id);
     487    }
     488    Edge fromId(int id, Edge) const {
     489      return Parent::edgeFromId(id);
     490    }
     491    UEdge fromId(int id, UEdge) const {
     492      return Parent::uEdgeFromId(id);
     493    } 
     494 
     495    class NodeIt : public Node {
     496      const Graph* graph;
     497    public:
     498   
     499      NodeIt() { }
     500   
     501      NodeIt(Invalid i) : Node(INVALID) { }
     502   
     503      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
     504        graph->first(static_cast<Node&>(*this));
     505      }
     506
     507      NodeIt(const Graph& _graph, const Node& node)
     508        : Node(node), graph(&_graph) { }
     509   
     510      NodeIt& operator++() {
     511        graph->next(*this);
     512        return *this;
     513      }
     514
     515    };
     516
     517    class ANodeIt : public Node {
     518      friend class BpUGraphAdaptorExtender;
     519      const Graph* graph;
     520    public:
     521   
     522      ANodeIt() { }
     523   
     524      ANodeIt(Invalid i) : Node(INVALID) { }
     525   
     526      explicit ANodeIt(const Graph& _graph) : graph(&_graph) {
     527        graph->firstANode(static_cast<Node&>(*this));
     528      }
     529
     530      ANodeIt(const Graph& _graph, const Node& node)
     531        : Node(node), graph(&_graph) {}
     532   
     533      ANodeIt& operator++() {
     534        graph->nextANode(*this);
     535        return *this;
     536      }
     537    };
     538
     539    class BNodeIt : public Node {
     540      friend class BpUGraphAdaptorExtender;
     541      const Graph* graph;
     542    public:
     543   
     544      BNodeIt() { }
     545   
     546      BNodeIt(Invalid i) : Node(INVALID) { }
     547   
     548      explicit BNodeIt(const Graph& _graph) : graph(&_graph) {
     549        graph->firstBNode(static_cast<Node&>(*this));
     550      }
     551
     552      BNodeIt(const Graph& _graph, const Node& node)
     553        : Node(node), graph(&_graph) {}
     554   
     555      BNodeIt& operator++() {
     556        graph->nextBNode(*this);
     557        return *this;
     558      }
     559    };
     560
     561    class EdgeIt : public Edge {
     562      friend class BpUGraphAdaptorExtender;
     563      const Graph* graph;
     564    public:
     565   
     566      EdgeIt() { }
     567   
     568      EdgeIt(Invalid i) : Edge(INVALID) { }
     569   
     570      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
     571        graph->first(static_cast<Edge&>(*this));
     572      }
     573
     574      EdgeIt(const Graph& _graph, const Edge& edge)
     575        : Edge(edge), graph(&_graph) { }
     576   
     577      EdgeIt& operator++() {
     578        graph->next(*this);
     579        return *this;
     580      }
     581
     582    };
     583
     584    class UEdgeIt : public UEdge {
     585      friend class BpUGraphAdaptorExtender;
     586      const Graph* graph;
     587    public:
     588   
     589      UEdgeIt() { }
     590   
     591      UEdgeIt(Invalid i) : UEdge(INVALID) { }
     592   
     593      explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
     594        graph->first(static_cast<UEdge&>(*this));
     595      }
     596
     597      UEdgeIt(const Graph& _graph, const UEdge& edge)
     598        : UEdge(edge), graph(&_graph) { }
     599   
     600      UEdgeIt& operator++() {
     601        graph->next(*this);
     602        return *this;
     603      }
     604    };
     605
     606    class OutEdgeIt : public Edge {
     607      friend class BpUGraphAdaptorExtender;
     608      const Graph* graph;
     609    public:
     610   
     611      OutEdgeIt() { }
     612   
     613      OutEdgeIt(Invalid i) : Edge(i) { }
     614   
     615      OutEdgeIt(const Graph& _graph, const Node& node)
     616        : graph(&_graph) {
     617        graph->firstOut(*this, node);
     618      }
     619   
     620      OutEdgeIt(const Graph& _graph, const Edge& edge)
     621        : Edge(edge), graph(&_graph) {}
     622   
     623      OutEdgeIt& operator++() {
     624        graph->nextOut(*this);
     625        return *this;
     626      }
     627
     628    };
     629
     630
     631    class InEdgeIt : public Edge {
     632      friend class BpUGraphAdaptorExtender;
     633      const Graph* graph;
     634    public:
     635   
     636      InEdgeIt() { }
     637   
     638      InEdgeIt(Invalid i) : Edge(i) { }
     639   
     640      InEdgeIt(const Graph& _graph, const Node& node)
     641        : graph(&_graph) {
     642        graph->firstIn(*this, node);
     643      }
     644   
     645      InEdgeIt(const Graph& _graph, const Edge& edge) :
     646        Edge(edge), graph(&_graph) {}
     647   
     648      InEdgeIt& operator++() {
     649        graph->nextIn(*this);
     650        return *this;
     651      }
     652
     653    };
     654 
     655    /// \brief Base node of the iterator
     656    ///
     657    /// Returns the base node (ie. the source in this case) of the iterator
     658    Node baseNode(const OutEdgeIt &e) const {
     659      return Parent::source((Edge&)e);
     660    }
     661    /// \brief Running node of the iterator
     662    ///
     663    /// Returns the running node (ie. the target in this case) of the
     664    /// iterator
     665    Node runningNode(const OutEdgeIt &e) const {
     666      return Parent::target((Edge&)e);
     667    }
     668 
     669    /// \brief Base node of the iterator
     670    ///
     671    /// Returns the base node (ie. the target in this case) of the iterator
     672    Node baseNode(const InEdgeIt &e) const {
     673      return Parent::target((Edge&)e);
     674    }
     675    /// \brief Running node of the iterator
     676    ///
     677    /// Returns the running node (ie. the source in this case) of the
     678    /// iterator
     679    Node runningNode(const InEdgeIt &e) const {
     680      return Parent::source((Edge&)e);
     681    }
     682 
     683    class IncEdgeIt : public Parent::UEdge {
     684      friend class BpUGraphAdaptorExtender;
     685      const Graph* graph;
     686      bool direction;
     687    public:
     688   
     689      IncEdgeIt() { }
     690   
     691      IncEdgeIt(Invalid i) : UEdge(i), direction(true) { }
     692   
     693      IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
     694        graph->firstInc(*this, direction, n);
     695      }
     696
     697      IncEdgeIt(const Graph& _graph, const UEdge &ue, const Node &n)
     698        : graph(&_graph), UEdge(ue) {
     699        direction = (graph->source(ue) == n);
     700      }
     701
     702      IncEdgeIt& operator++() {
     703        graph->nextInc(*this, direction);
     704        return *this;
     705      }
     706    };
     707 
     708
     709    /// Base node of the iterator
     710    ///
     711    /// Returns the base node of the iterator
     712    Node baseNode(const IncEdgeIt &e) const {
     713      return e.direction ? source(e) : target(e);
     714    }
     715
     716    /// Running node of the iterator
     717    ///
     718    /// Returns the running node of the iterator
     719    Node runningNode(const IncEdgeIt &e) const {
     720      return e.direction ? target(e) : source(e);
     721    }
     722
     723  };
     724
    439725
    440726}
  • lemon/bits/graph_extender.h

    r1999 r2031  
    104104
    105105      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    106         _graph.first(*static_cast<Node*>(this));
     106        _graph.first(static_cast<Node&>(*this));
    107107      }
    108108
     
    127127
    128128      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
    129         _graph.first(*static_cast<Edge*>(this));
     129        _graph.first(static_cast<Edge&>(*this));
    130130      }
    131131
     
    233233      }
    234234
    235 
    236       /// \brief Template assign operator.
    237       ///
    238       /// The given parameter should be conform to the ReadMap
    239       /// concecpt and could be indiced by the current item set of
    240       /// the NodeMap. In this case the value for each item
    241       /// is assigned by the value of the given ReadMap.
    242235      template <typename CMap>
    243236      NodeMap& operator=(const CMap& cmap) {
    244         checkConcept<concept::ReadMap<Node, _Value>, CMap>();
    245         const typename Parent::Notifier* notifier = Parent::getNotifier();
    246         Node it;
    247         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    248           Parent::set(it, cmap[it]);
    249         }
     237        Parent::operator=(cmap);
    250238        return *this;
    251239      }
     
    271259      template <typename CMap>
    272260      EdgeMap& operator=(const CMap& cmap) {
    273         checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
    274         const typename Parent::Notifier* notifier = Parent::getNotifier();
    275         Edge it;
    276         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    277           Parent::set(it, cmap[it]);
    278         }
     261        Parent::operator=(cmap);
    279262        return *this;
    280263      }
     
    432415
    433416      explicit NodeIt(const Graph& _graph) : graph(&_graph) {
    434         _graph.first(*static_cast<Node*>(this));
     417        _graph.first(static_cast<Node&>(*this));
    435418      }
    436419
     
    455438
    456439      explicit EdgeIt(const Graph& _graph) : graph(&_graph) {
    457         _graph.first(*static_cast<Edge*>(this));
     440        _graph.first(static_cast<Edge&>(*this));
    458441      }
    459442
     
    526509
    527510      explicit UEdgeIt(const Graph& _graph) : graph(&_graph) {
    528         _graph.first(*static_cast<UEdge*>(this));
     511        _graph.first(static_cast<UEdge&>(*this));
    529512      }
    530513
     
    623606      }
    624607
    625 
    626       /// \brief Template assign operator.
    627       ///
    628       /// The given parameter should be conform to the ReadMap
    629       /// concecpt and could be indiced by the current item set of
    630       /// the NodeMap. In this case the value for each item
    631       /// is assigned by the value of the given ReadMap.
    632608      template <typename CMap>
    633609      NodeMap& operator=(const CMap& cmap) {
    634         checkConcept<concept::ReadMap<Node, _Value>, CMap>();
    635         const typename Parent::Notifier* notifier = Parent::getNotifier();
    636         Node it;
    637         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    638           Parent::set(it, cmap[it]);
    639         }
     610        Parent::operator=(cmap);
    640611        return *this;
    641612      }
     
    661632      template <typename CMap>
    662633      EdgeMap& operator=(const CMap& cmap) {
    663         checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
    664         const typename Parent::Notifier* notifier = Parent::getNotifier();
    665         Edge it;
    666         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    667           Parent::set(it, cmap[it]);
    668         }
     634        Parent::operator=(cmap);
    669635        return *this;
    670636      }
     
    681647      UEdgeMap(const Graph& graph)
    682648        : Parent(graph) {}
     649
    683650      UEdgeMap(const Graph& graph, const _Value& value)
    684651        : Parent(graph, value) {}
     
    690657      template <typename CMap>
    691658      UEdgeMap& operator=(const CMap& cmap) {
    692         checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
    693         const typename Parent::Notifier* notifier = Parent::getNotifier();
    694         Edge it;
    695         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    696           Parent::set(it, cmap[it]);
    697         }
     659        Parent::operator=(cmap);
    698660        return *this;
    699661      }
     662
    700663    };
    701664
     
    11051068      }
    11061069   
    1107 
    1108       /// \brief Template assign operator.
    1109       ///
    1110       /// The given parameter should be conform to the ReadMap
    1111       /// concept and could be indiced by the current item set of
    1112       /// the ANodeMap. In this case the value for each item
    1113       /// is assigned by the value of the given ReadMap.
    11141070      template <typename CMap>
    11151071      ANodeMap& operator=(const CMap& cmap) {
    1116         checkConcept<concept::ReadMap<ANode, _Value>, CMap>();
    1117         const typename Parent::Graph* graph = Parent::getGraph();
    1118         ANode it;
    1119         for (graph->first(it); it != INVALID; graph->next(it)) {
    1120           Parent::set(it, cmap[it]);
    1121         }
     1072        Parent::operator=(cmap);
    11221073        return *this;
    11231074      }
     
    11411092      }
    11421093   
    1143 
    1144       /// \brief Template assign operator.
    1145       ///
    1146       /// The given parameter should be conform to the ReadMap
    1147       /// concept and could be indiced by the current item set of
    1148       /// the BNodeMap. In this case the value for each item
    1149       /// is assigned by the value of the given ReadMap.
    11501094      template <typename CMap>
    11511095      BNodeMap& operator=(const CMap& cmap) {
    1152         checkConcept<concept::ReadMap<BNode, _Value>, CMap>();
    1153         const typename Parent::Graph* graph = Parent::getGraph();
    1154         BNode it;
    1155         for (graph->first(it); it != INVALID; graph->next(it)) {
    1156           Parent::set(it, cmap[it]);
    1157         }
     1096        Parent::operator=(cmap);
    11581097        return *this;
    11591098      }
     
    11611100    };
    11621101
    1163   protected:
     1102  public:
    11641103
    11651104    template <typename _Value>
    1166     class NodeMapBase {
     1105    class NodeMap {
    11671106    public:
    11681107      typedef BpUGraphExtender Graph;
     
    11781117      typedef True ReferenceMapTag;
    11791118
    1180       NodeMapBase(const Graph& graph)
    1181         : aNodeMap(graph), bNodeMap(graph) {}
    1182       NodeMapBase(const Graph& graph, const _Value& value)
    1183         : aNodeMap(graph, value), bNodeMap(graph, value) {}
     1119      NodeMap(const Graph& _graph)
     1120        : graph(_graph), aNodeMap(_graph), bNodeMap(_graph) {}
     1121      NodeMap(const Graph& _graph, const _Value& _value)
     1122        : graph(_graph), aNodeMap(_graph, _value), bNodeMap(_graph, _value) {}
     1123
     1124      NodeMap& operator=(const NodeMap& cmap) {
     1125        return operator=<NodeMap>(cmap);
     1126      }
     1127   
     1128      template <typename CMap>
     1129      NodeMap& operator=(const CMap& cmap) {
     1130        checkConcept<concept::ReadMap<Node, _Value>, CMap>();
     1131        const typename Parent::Notifier* notifier = Parent::getNotifier();
     1132        Edge it;
     1133        for (graph.first(it); it != INVALID; graph.next(it)) {
     1134          Parent::set(it, cmap[it]);
     1135        }
     1136        return *this;
     1137      }
    11841138
    11851139      ConstReference operator[](const Key& node) const {
     
    12071161      }
    12081162
    1209       const Graph* getGraph() const {
    1210         return aNodeMap.getGraph();
    1211       }
    1212 
     1163      class MapIt : public NodeIt {
     1164      public:
     1165
     1166        typedef NodeIt Parent;
     1167       
     1168        explicit MapIt(NodeMap& _map)
     1169          : Parent(_map.graph), map(_map) {}
     1170       
     1171        typename MapTraits<NodeMap>::ConstReturnValue operator*() const {
     1172          return map[*this];
     1173        }
     1174       
     1175        typename MapTraits<NodeMap>::ReturnValue operator*() {
     1176          return map[*this];
     1177        }
     1178       
     1179        void set(const Value& value) {
     1180          map.set(*this, value);
     1181        }
     1182
     1183      private:
     1184        NodeMap& map;
     1185      };
     1186
     1187      class ConstMapIt : public NodeIt {
     1188      public:
     1189
     1190        typedef NodeIt Parent;
     1191       
     1192        explicit ConstMapIt(const NodeMap& _map)
     1193          : Parent(_map.graph), map(_map) {}
     1194       
     1195        typename MapTraits<NodeMap>::ConstReturnValue operator*() const {
     1196          return map[*this];
     1197        }
     1198       
     1199      private:
     1200        const NodeMap& map;
     1201      };
     1202
     1203      class ItemIt : public NodeIt {
     1204      public:
     1205
     1206        typedef NodeIt Parent;
     1207
     1208        explicit ItemIt(const NodeMap& _map)
     1209          : Parent(_map.graph) {}
     1210       
     1211      };
     1212     
    12131213    private:
     1214      const Graph& graph;
    12141215      ANodeMap<_Value> aNodeMap;
    12151216      BNodeMap<_Value> bNodeMap;
    12161217    };
    12171218   
    1218   public:
    1219 
    1220     template <typename _Value>
    1221     class NodeMap
    1222       : public MapExtender<NodeMapBase<_Value> > {
    1223     public:
    1224       typedef BpUGraphExtender Graph;
    1225       typedef MapExtender< NodeMapBase<_Value> > Parent;
    1226    
    1227       NodeMap(const Graph& graph)
    1228         : Parent(graph) {}
    1229       NodeMap(const Graph& graph, const _Value& value)
    1230         : Parent(graph, value) {}
    1231    
    1232       NodeMap& operator=(const NodeMap& cmap) {
    1233         return operator=<NodeMap>(cmap);
    1234       }
    1235    
    1236 
    1237       /// \brief Template assign operator.
    1238       ///
    1239       /// The given parameter should be conform to the ReadMap
    1240       /// concept and could be indiced by the current item set of
    1241       /// the NodeMap. In this case the value for each item
    1242       /// is assigned by the value of the given ReadMap.
    1243       template <typename CMap>
    1244       NodeMap& operator=(const CMap& cmap) {
    1245         checkConcept<concept::ReadMap<Node, _Value>, CMap>();
    1246         const typename Parent::Notifier* notifier = Parent::getNotifier();
    1247         Edge it;
    1248         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    1249           Parent::set(it, cmap[it]);
    1250         }
    1251         return *this;
    1252       }
    1253    
    1254     };
    1255 
    1256 
    12571219
    12581220    template <typename _Value>
     
    12741236      template <typename CMap>
    12751237      EdgeMap& operator=(const CMap& cmap) {
    1276         checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
    1277         const typename Parent::Notifier* notifier = Parent::getNotifier();
    1278         Edge it;
    1279         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    1280           Parent::set(it, cmap[it]);
    1281         }
     1238        Parent::operator=(cmap);
    12821239        return *this;
    12831240      }
     
    13021259      template <typename CMap>
    13031260      UEdgeMap& operator=(const CMap& cmap) {
    1304         checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
    1305         const typename Parent::Notifier* notifier = Parent::getNotifier();
    1306         Edge it;
    1307         for (notifier->first(it); it != INVALID; notifier->next(it)) {
    1308           Parent::set(it, cmap[it]);
    1309         }
     1261        Parent::operator=(cmap);
    13101262        return *this;
    13111263      }
  • lemon/bits/map_extender.h

    r1999 r2031  
    2323
    2424#include <lemon/bits/traits.h>
     25
     26#include <lemon/concept_check.h>
     27#include <lemon/concept/maps.h>
    2528
    2629///\file
     
    6063      : Parent(graph, value) {}
    6164
     65    MapExtender& operator=(const MapExtender& cmap) {
     66      return operator=<MapExtender>(cmap);
     67    }
     68
     69    template <typename CMap>
     70    MapExtender& operator=(const CMap& cmap) {
     71      Parent::operator=(cmap);
     72      return *this;
     73    }
    6274
    6375    class MapIt : public Item {
     
    131143    };
    132144
    133     class ItemIt : Item {
     145    class ItemIt : public Item {
    134146    public:
    135147     
     
    141153
    142154      explicit ItemIt(Map& _map) : map(_map) {
    143         map->getNotifier()->first(*this);
     155        map.getNotifier()->first(*this);
    144156      }
    145157
     
    158170  };
    159171
     172  /// \ingroup graphbits
     173  ///
     174  /// \brief Extender for maps which use a subset of the items.
     175  template <typename _Graph, typename _Map>
     176  class SubMapExtender : public _Map {
     177  public:
     178
     179    typedef _Map Parent;
     180    typedef SubMapExtender Map;
     181
     182    typedef _Graph Graph;
     183
     184    typedef typename Parent::Key Item;
     185
     186    typedef typename Parent::Key Key;
     187    typedef typename Parent::Value Value;
     188
     189    class MapIt;
     190    class ConstMapIt;
     191
     192    friend class MapIt;
     193    friend class ConstMapIt;
     194
     195  public:
     196
     197    SubMapExtender(const Graph& _graph)
     198      : Parent(_graph), graph(_graph) {}
     199
     200    SubMapExtender(const Graph& _graph, const Value& _value)
     201      : Parent(_graph, _value), graph(_graph) {}
     202
     203    SubMapExtender& operator=(const SubMapExtender& cmap) {
     204      return operator=<MapExtender>(cmap);
     205    }
     206
     207    template <typename CMap>
     208    SubMapExtender& operator=(const CMap& cmap) {
     209      checkConcept<concept::ReadMap<Key, Value>, CMap>();
     210      Item it;
     211      for (graph.first(it); it != INVALID; graph.next(it)) {
     212        Parent::set(it, cmap[it]);
     213      }
     214      return *this;
     215    }
     216
     217    class MapIt : public Item {
     218    public:
     219     
     220      typedef Item Parent;
     221      typedef typename Map::Value Value;
     222     
     223      MapIt() {}
     224
     225      MapIt(Invalid i) : Parent(i) { }
     226
     227      explicit MapIt(Map& _map) : map(_map) {
     228        map.graph.first(*this);
     229      }
     230
     231      MapIt(const Map& _map, const Item& item)
     232        : Parent(item), map(_map) {}
     233
     234      MapIt& operator++() {
     235        map.graph.next(*this);
     236        return *this;
     237      }
     238     
     239      typename MapTraits<Map>::ConstReturnValue operator*() const {
     240        return map[*this];
     241      }
     242
     243      typename MapTraits<Map>::ReturnValue operator*() {
     244        return map[*this];
     245      }
     246     
     247      void set(const Value& value) {
     248        map.set(*this, value);
     249      }
     250     
     251    protected:
     252      Map& map;
     253     
     254    };
     255
     256    class ConstMapIt : public Item {
     257    public:
     258
     259      typedef Item Parent;
     260
     261      typedef typename Map::Value Value;
     262     
     263      ConstMapIt() {}
     264
     265      ConstMapIt(Invalid i) : Parent(i) { }
     266
     267      explicit ConstMapIt(Map& _map) : map(_map) {
     268        map.graph.first(*this);
     269      }
     270
     271      ConstMapIt(const Map& _map, const Item& item)
     272        : Parent(item), map(_map) {}
     273
     274      ConstMapIt& operator++() {
     275        map.graph.next(*this);
     276        return *this;
     277      }
     278
     279      typename MapTraits<Map>::ConstReturnValue operator*() const {
     280        return map[*this];
     281      }
     282
     283    protected:
     284      const Map& map;
     285    };
     286
     287    class ItemIt : public Item {
     288    public:
     289     
     290      typedef Item Parent;
     291     
     292      ItemIt() {}
     293
     294      ItemIt(Invalid i) : Parent(i) { }
     295
     296      explicit ItemIt(Map& _map) : map(_map) {
     297        map.graph.first(*this);
     298      }
     299
     300      ItemIt(const Map& _map, const Item& item)
     301        : Parent(item), map(_map) {}
     302
     303      ItemIt& operator++() {
     304        map.graph.next(*this);
     305        return *this;
     306      }
     307
     308    protected:
     309      const Map& map;
     310     
     311    };
     312   
     313  private:
     314
     315    const Graph& graph;
     316   
     317  };
     318
    160319}
    161320
  • lemon/bits/vector_map.h

    r1999 r2031  
    2727
    2828#include <lemon/bits/alteration_notifier.h>
     29
     30#include <lemon/concept_check.h>
     31#include <lemon/concept/maps.h>
    2932
    3033///\ingroup graphbits
     
    113116    }
    114117
    115   private:
    116 
    117     VectorMap& operator=(const VectorMap&);
    118 
     118    /// \brief Assign operator.
     119    ///
     120    /// This operator assigns for each item in the map the
     121    /// value mapped to the same item in the copied map. 
     122    /// The parameter map should be indiced with the same
     123    /// itemset because this assign operator does not change
     124    /// the container of the map.
     125    VectorMap& operator=(const VectorMap& cmap) {
     126      return operator=<VectorMap>(cmap);
     127    }
     128
     129
     130    /// \brief Template assign operator.
     131    ///
     132    /// The given parameter should be conform to the ReadMap
     133    /// concecpt and could be indiced by the current item set of
     134    /// the NodeMap. In this case the value for each item
     135    /// is assigned by the value of the given ReadMap.
     136    template <typename CMap>
     137    VectorMap& operator=(const CMap& cmap) {
     138      checkConcept<concept::ReadMap<Key, _Value>, CMap>();
     139      const typename Parent::Notifier* notifier = Parent::getNotifier();
     140      Item it;
     141      for (notifier->first(it); it != INVALID; notifier->next(it)) {
     142        set(it, cmap[it]);
     143      }
     144      return *this;
     145    }
     146   
    119147  public:
    120148
  • lemon/edge_set.h

    r1999 r2031  
    207207    class NodeMap : public Graph::template NodeMap<_Value> {
    208208    public:
     209
    209210      typedef typename _Graph::template NodeMap<_Value> Parent;
     211
    210212      explicit NodeMap(const ListEdgeSetBase<Graph>& edgeset)
    211         : Parent(*edgeset.graph) { }
     213        : Parent(*edgeset.graph) {}
     214
    212215      NodeMap(const ListEdgeSetBase<Graph>& edgeset, const _Value& value)
    213         : Parent(*edgeset.graph, value) { }
     216        : Parent(*edgeset.graph, value) {}
     217
     218      NodeMap& operator=(const NodeMap& cmap) {
     219        return operator=<NodeMap>(cmap);
     220      }
     221
     222      template <typename CMap>
     223      NodeMap& operator=(const CMap& cmap) {
     224        Parent::operator=(cmap);
     225        return *this;
     226      }
    214227    };
    215228
     
    522535    class NodeMap : public Graph::template NodeMap<_Value> {
    523536    public:
     537
    524538      typedef typename _Graph::template NodeMap<_Value> Parent;
     539
    525540      explicit NodeMap(const SmartEdgeSetBase<Graph>& edgeset)
    526541        : Parent(*edgeset.graph) { }
     542
    527543      NodeMap(const SmartEdgeSetBase<Graph>& edgeset, const _Value& value)
    528544        : Parent(*edgeset.graph, value) { }
     545
     546      NodeMap& operator=(const NodeMap& cmap) {
     547        return operator=<NodeMap>(cmap);
     548      }
     549
     550      template <typename CMap>
     551      NodeMap& operator=(const CMap& cmap) {
     552        Parent::operator=(cmap);
     553        return *this;
     554      }
    529555    };
    530556
     
    668694
    669695    void eraseNode(const Node& node) {
    670       if (Parent::IncEdgeIt(*this, node) == INVALID) {
     696      if (typename Parent::IncEdgeIt(*this, node) == INVALID) {
    671697        return;
    672698      }
  • lemon/full_graph.h

    r1999 r2031  
    646646    }
    647647
     648    typedef True NodeNumTag;
     649    int nodeNum() const { return _aNodeNum + _bNodeNum; }
     650    int aNodeNum() const { return _aNodeNum; }
     651    int bNodeNum() const { return _bNodeNum; }
     652
     653    typedef True EdgeNumTag;
     654    int edgeNum() const { return _edgeNum; }
     655
    648656  };
    649657
  • lemon/graph_adaptor.h

    r1999 r2031  
    2020#define LEMON_GRAPH_ADAPTOR_H
    2121
    22 ///\ingroup graph_adaptors
    23 ///\file
    24 ///\brief Several graph adaptors.
     22/// \ingroup graph_adaptors
     23/// \file
     24/// \brief Several graph adaptors.
    2525///
    26 ///This file contains several useful graph adaptor functions.
     26/// This file contains several useful graph adaptor functions.
    2727///
    28 ///\author Marton Makai
     28/// \author Marton Makai and Balazs Dezso
    2929
    3030#include <lemon/bits/invalid.h>
     
    6262  public:
    6363    typedef _Graph Graph;
     64    typedef GraphAdaptorBase Adaptor;
    6465    typedef Graph ParentGraph;
    6566
     
    116117    int id(const Edge& e) const { return graph->id(e); }
    117118
     119    Node fromNodeId(int id) const {
     120      return graph->fromNodeId(id);
     121    }
     122
     123    Edge fromEdgeId(int id) const {
     124      return graph->fromEdgeId(id);
     125    }
     126
    118127    int maxNodeId() const {
    119128      return graph->maxNodeId();
     
    137146   
    138147    template <typename _Value>
    139     class NodeMap : public _Graph::template NodeMap<_Value> {
     148    class NodeMap : public Graph::template NodeMap<_Value> {
    140149    public:
    141       typedef typename _Graph::template NodeMap<_Value> Parent;
    142       explicit NodeMap(const GraphAdaptorBase<_Graph>& ga)
    143         : Parent(*ga.graph) { }
    144       NodeMap(const GraphAdaptorBase<_Graph>& ga, const _Value& value)
     150
     151      typedef typename Graph::template NodeMap<_Value> Parent;
     152
     153      explicit NodeMap(const Adaptor& ga)
     154        : Parent(*ga.graph) {}
     155
     156      NodeMap(const Adaptor& ga, const _Value& value)
    145157        : Parent(*ga.graph, value) { }
     158
     159      NodeMap& operator=(const NodeMap& cmap) {
     160        return operator=<NodeMap>(cmap);
     161      }
     162
     163      template <typename CMap>
     164      NodeMap& operator=(const CMap& cmap) {
     165        Parent::operator=(cmap);
     166        return *this;
     167      }
     168     
    146169    };
    147170
    148171    template <typename _Value>
    149     class EdgeMap : public _Graph::template EdgeMap<_Value> {
     172    class EdgeMap : public Graph::template EdgeMap<_Value> {
    150173    public:
    151       typedef typename _Graph::template EdgeMap<_Value> Parent;
    152       explicit EdgeMap(const GraphAdaptorBase<_Graph>& ga)
    153         : Parent(*ga.graph) { }
    154       EdgeMap(const GraphAdaptorBase<_Graph>& ga, const _Value& value)
    155         : Parent(*ga.graph, value) { }
     174     
     175      typedef typename Graph::template EdgeMap<_Value> Parent;
     176     
     177      explicit EdgeMap(const Adaptor& ga)
     178        : Parent(*ga.graph) {}
     179
     180      EdgeMap(const Adaptor& ga, const _Value& value)
     181        : Parent(*ga.graph, value) {}
     182
     183      EdgeMap& operator=(const EdgeMap& cmap) {
     184        return operator=<EdgeMap>(cmap);
     185      }
     186
     187      template <typename CMap>
     188      EdgeMap& operator=(const CMap& cmap) {
     189        Parent::operator=(cmap);
     190        return *this;
     191      }
     192
    156193    };
    157194
     
    256293  public:
    257294    typedef _Graph Graph;
     295    typedef SubGraphAdaptorBase Adaptor;
    258296    typedef GraphAdaptorBase<_Graph> Parent;
    259297  protected:
     
    378416      return edge;
    379417    }
     418
     419    template <typename _Value>
     420    class NodeMap
     421      : public SubMapExtender<Adaptor,
     422                              typename Parent::template NodeMap<_Value> >
     423    {
     424    public:
     425      typedef Adaptor Graph;
     426      typedef SubMapExtender<Adaptor, typename Parent::
     427                             template NodeMap<_Value> > Parent;
     428   
     429      NodeMap(const Graph& graph)
     430        : Parent(graph) {}
     431      NodeMap(const Graph& graph, const _Value& value)
     432        : Parent(graph, value) {}
     433   
     434      NodeMap& operator=(const NodeMap& cmap) {
     435        return operator=<NodeMap>(cmap);
     436      }
     437   
     438      template <typename CMap>
     439      NodeMap& operator=(const CMap& cmap) {
     440        Parent::operator=(cmap);
     441        return *this;
     442      }
     443    };
     444
     445    template <typename _Value>
     446    class EdgeMap
     447      : public SubMapExtender<Adaptor,
     448                              typename Parent::template EdgeMap<_Value> >
     449    {
     450    public:
     451      typedef Adaptor Graph;
     452      typedef SubMapExtender<Adaptor, typename Parent::
     453                             template EdgeMap<_Value> > Parent;
     454   
     455      EdgeMap(const Graph& graph)
     456        : Parent(graph) {}
     457      EdgeMap(const Graph& graph, const _Value& value)
     458        : Parent(graph, value) {}
     459   
     460      EdgeMap& operator=(const EdgeMap& cmap) {
     461        return operator=<EdgeMap>(cmap);
     462      }
     463   
     464      template <typename CMap>
     465      EdgeMap& operator=(const CMap& cmap) {
     466        Parent::operator=(cmap);
     467        return *this;
     468      }
     469    };
     470
    380471  };
    381472
     
    385476  public:
    386477    typedef _Graph Graph;
     478    typedef SubGraphAdaptorBase Adaptor;
    387479    typedef GraphAdaptorBase<_Graph> Parent;
    388480  protected:
     
    497589      return edge;
    498590    }
     591
     592    template <typename _Value>
     593    class NodeMap
     594      : public SubMapExtender<Adaptor,
     595                              typename Parent::template NodeMap<_Value> >
     596    {
     597    public:
     598      typedef Adaptor Graph;
     599      typedef SubMapExtender<Adaptor, typename Parent::
     600                             template NodeMap<_Value> > Parent;
     601   
     602      NodeMap(const Graph& graph)
     603        : Parent(graph) {}
     604      NodeMap(const Graph& graph, const _Value& value)
     605        : Parent(graph, value) {}
     606   
     607      NodeMap& operator=(const NodeMap& cmap) {
     608        return operator=<NodeMap>(cmap);
     609      }
     610   
     611      template <typename CMap>
     612      NodeMap& operator=(const CMap& cmap) {
     613        Parent::operator=(cmap);
     614        return *this;
     615      }
     616    };
     617
     618    template <typename _Value>
     619    class EdgeMap
     620      : public SubMapExtender<Adaptor,
     621                              typename Parent::template EdgeMap<_Value> >
     622    {
     623    public:
     624      typedef Adaptor Graph;
     625      typedef SubMapExtender<Adaptor, typename Parent::
     626                             template EdgeMap<_Value> > Parent;
     627   
     628      EdgeMap(const Graph& graph)
     629        : Parent(graph) {}
     630      EdgeMap(const Graph& graph, const _Value& value)
     631        : Parent(graph, value) {}
     632   
     633      EdgeMap& operator=(const EdgeMap& cmap) {
     634        return operator=<EdgeMap>(cmap);
     635      }
     636   
     637      template <typename CMap>
     638      EdgeMap& operator=(const CMap& cmap) {
     639        Parent::operator=(cmap);
     640        return *this;
     641      }
     642    };
     643
    499644  };
    500645
     
    567712  public:
    568713    typedef _Graph Graph;
    569     typedef GraphAdaptorExtender<
    570       SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent;
     714    typedef GraphAdaptorExtender< SubGraphAdaptorBase<_Graph, NodeFilterMap,
     715                                                      EdgeFilterMap, checked> >
     716    Parent;
     717
    571718  protected:
    572719    SubGraphAdaptor() { }
    573720  public:
     721
    574722    SubGraphAdaptor(_Graph& _graph, NodeFilterMap& _node_filter_map,
    575723                    EdgeFilterMap& _edge_filter_map) {
     
    578726      setEdgeFilterMap(_edge_filter_map);
    579727    }
     728
    580729  };
    581730
     
    636785                           ConstMap<typename Graph::Edge,bool>, checked> {
    637786  public:
     787
    638788    typedef SubGraphAdaptor<Graph, NodeFilterMap,
    639                             ConstMap<typename Graph::Edge,bool> > Parent;
     789                            ConstMap<typename Graph::Edge,bool>, checked >
     790    Parent;
     791
    640792  protected:
    641793    ConstMap<typename Graph::Edge, bool> const_true_map;
     
    646798
    647799  public:
     800
    648801    NodeSubGraphAdaptor(Graph& _graph, NodeFilterMap& _node_filter_map) :
    649802      Parent(), const_true_map(true) {
     
    652805      Parent::setEdgeFilterMap(const_true_map);
    653806    }
     807
    654808  };
    655809
     
    821975
    822976  public:
     977
    823978    EdgeSubGraphAdaptor(Graph& _graph, EdgeFilterMap& _edge_filter_map) :
    824979      Parent(), const_true_map(true) {
     
    827982      Parent::setEdgeFilterMap(_edge_filter_map);
    828983    }
     984
    829985  };
    830986
     
    8491005  public:
    8501006    typedef _Graph Graph;
     1007    typedef UndirGraphAdaptorBase Adaptor;
    8511008    typedef UGraphBaseExtender<GraphAdaptorBase<_Graph> > Parent;
    8521009
     
    8601017    typedef typename Parent::Edge Edge;
    8611018
     1019  private:
    8621020   
    8631021    template <typename _Value>
    864     class EdgeMap {
     1022    class EdgeMapBase {
    8651023    private:
    8661024     
     
    8741032      typedef Edge Key;
    8751033     
    876       EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g) :
    877         forward_map(*(_g.graph)), backward_map(*(_g.graph)) {}
    878 
    879       EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g, const Value& a)
    880         : forward_map(*(_g.graph), a), backward_map(*(_g.graph), a) {}
     1034      EdgeMapBase(const Adaptor& adaptor) :
     1035        forward_map(*adaptor.graph), backward_map(*adaptor.graph) {}
     1036
     1037      EdgeMapBase(const Adaptor& adaptor, const Value& v)
     1038        : forward_map(*adaptor.graph, v), backward_map(*adaptor.graph, v) {}
    8811039     
    8821040      void set(const Edge& e, const Value& a) {
     
    9091067
    9101068    };
     1069
     1070  public:
     1071
     1072    template <typename _Value>
     1073    class EdgeMap
     1074      : public SubMapExtender<Adaptor, EdgeMapBase<_Value> >
     1075    {
     1076    public:
     1077      typedef Adaptor Graph;
     1078      typedef SubMapExtender<Adaptor, EdgeMapBase<_Value> > Parent;
     1079   
     1080      EdgeMap(const Graph& graph)
     1081        : Parent(graph) {}
     1082      EdgeMap(const Graph& graph, const _Value& value)
     1083        : Parent(graph, value) {}
     1084   
     1085      EdgeMap& operator=(const EdgeMap& cmap) {
     1086        return operator=<EdgeMap>(cmap);
     1087      }
     1088   
     1089      template <typename CMap>
     1090      EdgeMap& operator=(const CMap& cmap) {
     1091        Parent::operator=(cmap);
     1092        return *this;
     1093      }
     1094    };
    9111095       
    9121096    template <typename _Value>
    913     class UEdgeMap : public _Graph::template EdgeMap<_Value> {
     1097    class UEdgeMap : public Graph::template EdgeMap<_Value> {
    9141098    public:
    915 
    916       typedef typename _Graph::template EdgeMap<_Value> Parent;
    917 
    918       UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g)
    919         : Parent(*(g.graph)) {}
    920 
    921       UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g, const _Value& a)
    922         : Parent(*(g.graph), a) {}
    923      
     1099     
     1100      typedef typename Graph::template EdgeMap<_Value> Parent;
     1101     
     1102      explicit UEdgeMap(const Adaptor& ga)
     1103        : Parent(*ga.graph) {}
     1104
     1105      UEdgeMap(const Adaptor& ga, const _Value& value)
     1106        : Parent(*ga.graph, value) {}
     1107
     1108      UEdgeMap& operator=(const UEdgeMap& cmap) {
     1109        return operator=<UEdgeMap>(cmap);
     1110      }
     1111
     1112      template <typename CMap>
     1113      UEdgeMap& operator=(const CMap& cmap) {
     1114        Parent::operator=(cmap);
     1115        return *this;
     1116      }
     1117
    9241118    };
    9251119     
     
    9341128
    9351129    typedef _Graph Graph;
     1130    typedef UndirGraphAdaptorBase Adaptor;
    9361131    typedef UGraphBaseExtender<GraphAdaptorBase<_Graph> > Parent;
    9371132
     
    10341229    NotifierProxy edge_notifier_proxy;
    10351230
    1036   public:
    1037    
     1231  private:
    10381232   
    10391233    template <typename _Value>
    1040     class EdgeMap {
     1234    class EdgeMapBase {
    10411235    private:
    10421236     
     
    10501244      typedef Edge Key;
    10511245     
    1052       EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g) :
    1053         forward_map(*(_g.graph)), backward_map(*(_g.graph)) {}
    1054 
    1055       EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g, const Value& a)
    1056         : forward_map(*(_g.graph), a), backward_map(*(_g.graph), a) {}
     1246      EdgeMapBase(const Adaptor& adaptor) :
     1247        forward_map(*adaptor.graph), backward_map(*adaptor.graph) {}
     1248
     1249      EdgeMapBase(const Adaptor& adaptor, const Value& v)
     1250        : forward_map(*adaptor.graph, v), backward_map(*adaptor.graph, v) {}
    10571251     
    10581252      void set(const Edge& e, const Value& a) {
     
    10641258      }
    10651259
    1066       typename MapTraits<MapImpl>::ConstReturnValue
    1067       operator[](const Edge& e) const {
     1260      typename MapTraits<MapImpl>::ConstReturnValue operator[](Edge e) const {
    10681261        if (Parent::direction(e)) {
    10691262          return forward_map[e];
     
    10731266      }
    10741267
    1075       typename MapTraits<MapImpl>::ReturnValue
    1076       operator[](const Edge& e) {
     1268      typename MapTraits<MapImpl>::ReturnValue operator[](Edge e) {
    10771269        if (Parent::direction(e)) {
    10781270          return forward_map[e];
     
    10871279
    10881280    };
     1281
     1282  public:
     1283
     1284    template <typename _Value>
     1285    class EdgeMap
     1286      : public SubMapExtender<Adaptor, EdgeMapBase<_Value> >
     1287    {
     1288    public:
     1289      typedef Adaptor Graph;
     1290      typedef SubMapExtender<Adaptor, EdgeMapBase<_Value> > Parent;
     1291   
     1292      EdgeMap(const Graph& graph)
     1293        : Parent(graph) {}
     1294      EdgeMap(const Graph& graph, const _Value& value)
     1295        : Parent(graph, value) {}
     1296   
     1297      EdgeMap& operator=(const EdgeMap& cmap) {
     1298        return operator=<EdgeMap>(cmap);
     1299      }
     1300   
     1301      template <typename CMap>
     1302      EdgeMap& operator=(const CMap& cmap) {
     1303        Parent::operator=(cmap);
     1304        return *this;
     1305      }
     1306    };
    10891307       
    10901308    template <typename _Value>
    1091     class UEdgeMap : public _Graph::template EdgeMap<_Value> {
     1309    class UEdgeMap : public Graph::template EdgeMap<_Value> {
    10921310    public:
    1093 
    1094       typedef typename _Graph::template EdgeMap<_Value> Parent;
    1095 
    1096       UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g)
    1097         : Parent(*(g.graph)) {}
    1098 
    1099       UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g, const _Value& a)
    1100         : Parent(*(g.graph), a) {}
    1101      
     1311     
     1312      typedef typename Graph::template EdgeMap<_Value> Parent;
     1313     
     1314      explicit UEdgeMap(const Adaptor& ga)
     1315        : Parent(*ga.graph) {}
     1316
     1317      UEdgeMap(const Adaptor& ga, const _Value& value)
     1318        : Parent(*ga.graph, value) {}
     1319
     1320      UEdgeMap& operator=(const UEdgeMap& cmap) {
     1321        return operator=<UEdgeMap>(cmap);
     1322      }
     1323
     1324      template <typename CMap>
     1325      UEdgeMap& operator=(const CMap& cmap) {
     1326        Parent::operator=(cmap);
     1327        return *this;
     1328      }
     1329
    11021330    };
    11031331     
  • lemon/graph_utils.h

    r2029 r2031  
    4949  ///This \c \#define creates convenience typedefs for the following types
    5050  ///of \c Graph: \c Node,  \c NodeIt, \c Edge, \c EdgeIt, \c InEdgeIt,
    51   ///\c OutEdgeIt,  \c BoolNodeMap,  \c IntNodeMap,  \c DoubleNodeMap,
    52   ///\c BoolEdgeMap, \c IntEdgeMap,  \c DoubleEdgeMap. 
     51  ///\c OutEdgeIt
    5352  ///\note If \c G it a template parameter, it should be used in this way.
    5453  ///\code
     
    6564    typedef Graph:: InEdgeIt  InEdgeIt;                 \
    6665    typedef Graph::OutEdgeIt OutEdgeIt;                 
    67 //     typedef Graph::template NodeMap<bool> BoolNodeMap;             
    68 //     typedef Graph::template NodeMap<int> IntNodeMap;       
    69 //     typedef Graph::template NodeMap<double> DoubleNodeMap; 
    70 //     typedef Graph::template EdgeMap<bool> BoolEdgeMap;             
    71 //     typedef Graph::template EdgeMap<int> IntEdgeMap;       
    72 //     typedef Graph::template EdgeMap<double> DoubleEdgeMap;
    73  
     66
    7467  ///Creates convenience typedefs for the undirected graph types and iterators
    7568
     
    7770  ///\ref GRAPH_TYPEDEFS(Graph) and three more, namely it creates
    7871  ///\c UEdge, \c UEdgeIt, \c IncEdgeIt,
    79   ///\c BoolUEdgeMap, \c IntUEdgeMap,  \c DoubleUEdgeMap. 
    8072  ///
    8173  ///\note If \c G it a template parameter, it should be used in this way.
     
    9486//     typedef Graph::template UEdgeMap<int> IntUEdgeMap;
    9587//     typedef Graph::template UEdgeMap<double> DoubleUEdgeMap;
    96  
    97 
     88
     89  ///\brief Creates convenience typedefs for the bipartite undirected graph
     90  ///types and iterators
     91
     92  ///This \c \#define creates the same convenience typedefs as defined by
     93  ///\ref UGRAPH_TYPEDEFS(Graph) and two more, namely it creates
     94  ///\c ANodeIt, \c BNodeIt,
     95  ///
     96  ///\note If \c G it a template parameter, it should be used in this way.
     97  ///\code
     98  ///  BPUGRAPH_TYPEDEFS(typename G)
     99  ///\endcode
     100  ///
     101  ///\warning There are no typedefs for the graph maps because of the lack of
     102  ///template typedefs in C++.
     103#define BPUGRAPH_TYPEDEFS(Graph)            \
     104  UGRAPH_TYPEDEFS(Graph)                    \
     105    typedef Graph::ANodeIt ANodeIt;         \
     106    typedef Graph::BNodeIt BNodeIt;
    98107
    99108  /// \brief Function to count the items in the graph.
     
    431440        if (u != v) {
    432441          if (e == INVALID) {
    433             g.firstInc(e, u, b);
     442            g.firstInc(e, b, u);
    434443          } else {
    435444            b = g.source(e) == u;
     
    441450        } else {
    442451          if (e == INVALID) {
    443             g.firstInc(e, u, b);
     452            g.firstInc(e, b, u);
    444453          } else {
    445454            b = true;
     
    486495  ///\endcode
    487496  template <typename Graph>
    488   inline typename Graph::UEdge findEdge(const Graph &g,
    489                                         typename Graph::Node u,
    490                                         typename Graph::Node v,
    491                                         typename Graph::UEdge prev = INVALID) {
    492     return _graph_utils_bits::FindUEdgeSelector<Graph>::find(g, u, v, prev);
     497  inline typename Graph::UEdge findUEdge(const Graph &g,
     498                                         typename Graph::Node u,
     499                                         typename Graph::Node v,
     500                                         typename Graph::UEdge p = INVALID) {
     501    return _graph_utils_bits::FindUEdgeSelector<Graph>::find(g, u, v, p);
    493502  }
    494503
  • lemon/iterable_maps.h

    r1993 r2031  
    2121
    2222#include <lemon/bits/default_map.h>
     23#include <lemon/bits/map_extender.h>
    2324
    2425#include <vector>
     
    401402  template <typename _Graph, typename _Item>
    402403  class IterableIntMap
    403     : protected DefaultMap<_Graph, _Item, _iterable_maps_bits::
    404                            IterableIntMapNode<_Item> > {
     404    : protected MapExtender<DefaultMap<_Graph, _Item, _iterable_maps_bits::
     405                                       IterableIntMapNode<_Item> > >{
    405406  public:
    406     typedef DefaultMap<_Graph, _Item, _iterable_maps_bits::
    407                        IterableIntMapNode<_Item> >
    408     Parent;
     407    typedef MapExtender<DefaultMap<_Graph, _Item, _iterable_maps_bits::
     408                                   IterableIntMapNode<_Item> > > Parent;
    409409
    410410    /// The key type
     
    690690  template <typename _Graph, typename _Item, typename _Value>
    691691  class IterableValueMap
    692     : protected DefaultMap<_Graph, _Item, _iterable_maps_bits::
    693                            IterableValueMapNode<_Item, _Value> > {
     692    : protected MapExtender<DefaultMap<_Graph, _Item, _iterable_maps_bits::
     693                                       IterableValueMapNode<_Item, _Value> > >{
    694694  public:
    695     typedef DefaultMap<_Graph, _Item, _iterable_maps_bits::
    696                        IterableValueMapNode<_Item, _Value> > Parent;
     695    typedef MapExtender<DefaultMap<_Graph, _Item, _iterable_maps_bits::
     696                                   IterableValueMapNode<_Item, _Value> > >
     697    Parent;
    697698
    698699    /// The key type
     
    703704    typedef _Graph Graph;
    704705
    705   protected:
    706 
    707     typedef typename ItemSetTraits<_Graph, Key>::ItemIt KeyIt;
    708 
    709706  public:
    710707
     
    716713      : Parent(graph, _iterable_maps_bits::
    717714               IterableValueMapNode<_Item, _Value>(value)) {
    718       for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) {
     715      for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
    719716        lace(it);
    720717      }
     
    904901    virtual void build() {
    905902      Parent::build();
    906       for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) {
     903      for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
    907904        lace(it);
    908905      }
  • lemon/list_graph.h

    r1999 r2031  
    6767
    6868      int id;
    69       Node(int pid) { id = pid;}
     69      explicit Node(int pid) { id = pid;}
    7070
    7171    public:
     
    8282
    8383      int id;
    84       Edge(int pid) { id = pid;}
     84      explicit Edge(int pid) { id = pid;}
    8585
    8686    public:
     
    111111    int maxEdgeId() const { return edges.size()-1; }
    112112
    113     Node source(Edge e) const { return edges[e.id].source; }
    114     Node target(Edge e) const { return edges[e.id].target; }
     113    Node source(Edge e) const { return Node(edges[e.id].source); }
     114    Node target(Edge e) const { return Node(edges[e.id].target); }
    115115
    116116
     
    677677      int id;
    678678
    679       Node(int _id) : id(_id) {}
     679      explicit Node(int _id) : id(_id) {}
    680680    public:
    681681      Node() {}
     
    691691      int id;
    692692
    693       Edge(int _id) { id = _id;}
     693      explicit Edge(int _id) { id = _id;}
    694694    public:
    695695      Edge() {}
  • lemon/smart_graph.h

    r1999 r2031  
    576576    }
    577577
     578    typedef True NodeNumTag;
     579    int nodeNum() const { return aNodes.size() + bNodes.size(); }
     580    int aNodeNum() const { return aNodes.size(); }
     581    int bNodeNum() const { return bNodes.size(); }
     582
     583    typedef True EdgeNumTag;
     584    int edgeNum() const { return edges.size(); }
     585
    578586  };
    579587
  • lemon/ugraph_adaptor.h

    r1993 r2031  
    102102    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
    103103    int edgeNum() const { return graph->edgeNum(); }
     104    int uEdgeNum() const { return graph->uEdgeNum(); }
    104105
    105106    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
     
    119120
    120121    void erase(const Node& i) const { graph->erase(i); }
    121     void erase(const Edge& i) const { graph->erase(i); }
     122    void erase(const UEdge& i) const { graph->erase(i); }
    122123 
    123124    void clear() const { graph->clear(); }
    124125   
    125     int id(const Node& v) const { return graph->id(v); }
    126     int id(const UEdge& e) const { return graph->id(e); }
    127 
    128126    bool direction(const Edge& e) const { return graph->direction(e); }
    129127    Edge direct(const UEdge& e, bool d) const { return graph->direct(e, d); }
     128
     129    int id(const Node& v) const { return graph->id(v); }
     130    int id(const Edge& e) const { return graph->id(e); }
     131    int id(const UEdge& e) const { return graph->id(e); }
     132
     133    Node fromNodeId(int id) const {
     134      return graph->fromNodeId(id);
     135    }
     136
     137    Edge fromEdgeId(int id) const {
     138      return graph->fromEdgeId(id);
     139    }
     140
     141    UEdge fromUEdgeId(int id) const {
     142      return graph->fromUEdgeId(id);
     143    }
    130144
    131145    int maxNodeId() const {
     
    174188      template <typename CMap>
    175189      NodeMap& operator=(const CMap& cmap) {
    176         checkConcept<concept::ReadMap<Node, _Value>, CMap>();
    177         const typename Parent::Graph* graph = Parent::getGraph();
    178         Node it;
    179         for (graph->first(it); it != INVALID; graph->next(it)) {
    180           Parent::set(it, cmap[it]);
    181         }
    182         return *this;
    183       }
     190        Parent::operator=(cmap);
     191        return *this;
     192      }
     193
    184194    };
    185195
     
    199209      template <typename CMap>
    200210      EdgeMap& operator=(const CMap& cmap) {
    201         checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
    202         const typename Parent::Graph* graph = Parent::getGraph();
    203         Edge it;
    204         for (graph->first(it); it != INVALID; graph->next(it)) {
    205           Parent::set(it, cmap[it]);
    206         }
     211        Parent::operator=(cmap);
    207212        return *this;
    208213      }
     
    224229      template <typename CMap>
    225230      UEdgeMap& operator=(const CMap& cmap) {
    226         checkConcept<concept::ReadMap<UEdge, _Value>, CMap>();
    227         const typename Parent::Graph* graph = Parent::getGraph();
    228         UEdge it;
    229         for (graph->first(it); it != INVALID; graph->next(it)) {
    230           Parent::set(it, cmap[it]);
    231         }
    232         return *this;
     231        Parent::operator=(cmap);
     232        return *this;
    233233      }
    234234    };
     
    255255  public:
    256256    typedef _UGraph Graph;
     257    typedef SubUGraphAdaptorBase Adaptor;
    257258    typedef UGraphAdaptorBase<_UGraph> Parent;
    258259  protected:
     
    417418      return uedge;
    418419    }
     420
     421    template <typename _Value>
     422    class NodeMap
     423      : public SubMapExtender<Adaptor,
     424                              typename Parent::template NodeMap<_Value> >
     425    {
     426    public:
     427      typedef Adaptor Graph;
     428      typedef SubMapExtender<Adaptor, typename Parent::
     429                             template NodeMap<_Value> > Parent;
     430   
     431      NodeMap(const Graph& graph)
     432        : Parent(graph) {}
     433      NodeMap(const Graph& graph, const _Value& value)
     434        : Parent(graph, value) {}
     435   
     436      NodeMap& operator=(const NodeMap& cmap) {
     437        return operator=<NodeMap>(cmap);
     438      }
     439   
     440      template <typename CMap>
     441      NodeMap& operator=(const CMap& cmap) {
     442        Parent::operator=(cmap);
     443        return *this;
     444      }
     445    };
     446
     447    template <typename _Value>
     448    class EdgeMap
     449      : public SubMapExtender<Adaptor,
     450                              typename Parent::template EdgeMap<_Value> >
     451    {
     452    public:
     453      typedef Adaptor Graph;
     454      typedef SubMapExtender<Adaptor, typename Parent::
     455                             template EdgeMap<_Value> > Parent;
     456   
     457      EdgeMap(const Graph& graph)
     458        : Parent(graph) {}
     459      EdgeMap(const Graph& graph, const _Value& value)
     460        : Parent(graph, value) {}
     461   
     462      EdgeMap& operator=(const EdgeMap& cmap) {
     463        return operator=<EdgeMap>(cmap);
     464      }
     465   
     466      template <typename CMap>
     467      EdgeMap& operator=(const CMap& cmap) {
     468        Parent::operator=(cmap);
     469        return *this;
     470      }
     471    };
     472
     473    template <typename _Value>
     474    class UEdgeMap
     475      : public SubMapExtender<Adaptor,
     476                              typename Parent::template UEdgeMap<_Value> >
     477    {
     478    public:
     479      typedef Adaptor Graph;
     480      typedef SubMapExtender<Adaptor, typename Parent::
     481                             template UEdgeMap<_Value> > Parent;
     482   
     483      UEdgeMap(const Graph& graph)
     484        : Parent(graph) {}
     485      UEdgeMap(const Graph& graph, const _Value& value)
     486        : Parent(graph, value) {}
     487   
     488      UEdgeMap& operator=(const UEdgeMap& cmap) {
     489        return operator=<UEdgeMap>(cmap);
     490      }
     491   
     492      template <typename CMap>
     493      UEdgeMap& operator=(const CMap& cmap) {
     494        Parent::operator=(cmap);
     495        return *this;
     496      }
     497    };
     498
    419499  };
    420500
     
    424504  public:
    425505    typedef _UGraph Graph;
     506    typedef SubUGraphAdaptorBase Adaptor;
    426507    typedef UGraphAdaptorBase<_UGraph> Parent;
    427508  protected:
     
    560641      return uedge;
    561642    }
     643
     644    template <typename _Value>
     645    class NodeMap
     646      : public SubMapExtender<Adaptor,
     647                              typename Parent::template NodeMap<_Value> >
     648    {
     649    public:
     650      typedef Adaptor Graph;
     651      typedef SubMapExtender<Adaptor, typename Parent::
     652                             template NodeMap<_Value> > Parent;
     653   
     654      NodeMap(const Graph& graph)
     655        : Parent(graph) {}
     656      NodeMap(const Graph& graph, const _Value& value)
     657        : Parent(graph, value) {}
     658   
     659      NodeMap& operator=(const NodeMap& cmap) {
     660        return operator=<NodeMap>(cmap);
     661      }
     662   
     663      template <typename CMap>
     664      NodeMap& operator=(const CMap& cmap) {
     665        Parent::operator=(cmap);
     666        return *this;
     667      }
     668    };
     669
     670    template <typename _Value>
     671    class EdgeMap
     672      : public SubMapExtender<Adaptor,
     673                              typename Parent::template EdgeMap<_Value> >
     674    {
     675    public:
     676      typedef Adaptor Graph;
     677      typedef SubMapExtender<Adaptor, typename Parent::
     678                             template EdgeMap<_Value> > Parent;
     679   
     680      EdgeMap(const Graph& graph)
     681        : Parent(graph) {}
     682      EdgeMap(const Graph& graph, const _Value& value)
     683        : Parent(graph, value) {}
     684   
     685      EdgeMap& operator=(const EdgeMap& cmap) {
     686        return operator=<EdgeMap>(cmap);
     687      }
     688   
     689      template <typename CMap>
     690      EdgeMap& operator=(const CMap& cmap) {
     691        Parent::operator=(cmap);
     692        return *this;
     693      }
     694    };
     695
     696    template <typename _Value>
     697    class UEdgeMap
     698      : public SubMapExtender<Adaptor,
     699                              typename Parent::template UEdgeMap<_Value> >
     700    {
     701    public:
     702      typedef Adaptor Graph;
     703      typedef SubMapExtender<Adaptor, typename Parent::
     704                             template UEdgeMap<_Value> > Parent;
     705   
     706      UEdgeMap(const Graph& graph)
     707        : Parent(graph) {}
     708      UEdgeMap(const Graph& graph, const _Value& value)
     709        : Parent(graph, value) {}
     710   
     711      UEdgeMap& operator=(const UEdgeMap& cmap) {
     712        return operator=<UEdgeMap>(cmap);
     713      }
     714   
     715      template <typename CMap>
     716      UEdgeMap& operator=(const CMap& cmap) {
     717        Parent::operator=(cmap);
     718        return *this;
     719      }
     720    };
    562721  };
    563722
     
    679838  }
    680839
    681 
    682840  /// \brief An adaptor for hiding undirected edges from an undirected graph.
    683841  ///
     
    705863
    706864  public:
     865
    707866    EdgeSubUGraphAdaptor(Graph& _graph, UEdgeFilterMap& _uedge_filter_map) :
    708867      Parent(), const_true_map(true) {
     
    711870      Parent::setUEdgeFilterMap(_uedge_filter_map);
    712871    }
     872
    713873  };
    714874
     
    838998    class NodeMap : public _UGraph::template NodeMap<_Value> {
    839999    public:
     1000
    8401001      typedef typename _UGraph::template NodeMap<_Value> Parent;
     1002
    8411003      explicit NodeMap(const DirUGraphAdaptorBase& ga)
    842         : Parent(*ga.graph) { }
     1004        : Parent(*ga.graph) {}
     1005
    8431006      NodeMap(const DirUGraphAdaptorBase& ga, const _Value& value)
    844         : Parent(*ga.graph, value) { }
     1007        : Parent(*ga.graph, value) {}
     1008
     1009      NodeMap& operator=(const NodeMap& cmap) {
     1010        return operator=<NodeMap>(cmap);
     1011      }
     1012
     1013      template <typename CMap>
     1014      NodeMap& operator=(const CMap& cmap) {
     1015        Parent::operator=(cmap);
     1016        return *this;
     1017      }
     1018
    8451019    };
    8461020
     
    8481022    class EdgeMap : public _UGraph::template UEdgeMap<_Value> {
    8491023    public:
     1024
    8501025      typedef typename _UGraph::template UEdgeMap<_Value> Parent;
     1026
    8511027      explicit EdgeMap(const DirUGraphAdaptorBase& ga)
    8521028        : Parent(*ga.graph) { }
     1029
    8531030      EdgeMap(const DirUGraphAdaptorBase& ga, const _Value& value)
    8541031        : Parent(*ga.graph, value) { }
     1032
     1033      EdgeMap& operator=(const EdgeMap& cmap) {
     1034        return operator=<EdgeMap>(cmap);
     1035      }
     1036
     1037      template <typename CMap>
     1038      EdgeMap& operator=(const CMap& cmap) {
     1039        Parent::operator=(cmap);
     1040        return *this;
     1041      }
    8551042    };
    8561043
Note: See TracChangeset for help on using the changeset viewer.