COIN-OR::LEMON - Graph Library

Changeset 1990:15fb7a4ea6be in lemon-0.x


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

Some classes assumed that the GraphMaps? should be inherited
from an ObserverBase?. These classes parents replaced with
DefaultMap? which cause that the graph maps should not be
inherited from the ObserverBase?.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • lemon/edge_set.h

    r1979 r1990  
    2121
    2222
     23#include <lemon/bits/default_map.h>
    2324#include <lemon/bits/edge_set_extender.h>
    2425
     
    4647    };
    4748
    48     typedef typename Graph::template NodeMap<NodeT> NodesImplBase;
     49    typedef DefaultMap<Graph, Node, NodeT> NodesImplBase;
    4950
    5051    NodesImplBase* nodes;
     
    197198    Node target(const Edge& edge) const { return edges[edge.id].target;}
    198199
     200    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
     201
     202    NodeNotifier& getNotifier(Node) const {
     203      return graph->getNotifier(Node());
     204    }
     205
    199206    template <typename _Value>
    200207    class NodeMap : public Graph::template NodeMap<_Value> {
     
    405412    };
    406413
    407     typedef typename Graph::template NodeMap<NodeT> NodesImplBase;
     414    typedef DefaultMap<Graph, Node, NodeT> NodesImplBase;
    408415
    409416    NodesImplBase* nodes;
     
    506513    Node target(const Edge& edge) const { return edges[edge.id].target;}
    507514
     515    typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
     516
     517    NodeNotifier& getNotifier(Node) const {
     518      return graph->getNotifier(Node());
     519    }
     520
    508521    template <typename _Value>
    509522    class NodeMap : public Graph::template NodeMap<_Value> {
  • lemon/graph_utils.h

    r1981 r1990  
    2929#include <lemon/maps.h>
    3030#include <lemon/traits.h>
     31
    3132#include <lemon/bits/alteration_notifier.h>
     33#include <lemon/bits/default_map.h>
    3234
    3335///\ingroup gutils
     
    901903  /// \param _Map A ReadWriteMap mapping from the item type to integer.
    902904  template <
    903     typename _Graph, typename _Item, typename _Value, typename _Map
    904     = typename ItemSetTraits<_Graph, _Item>::template Map<_Value>::Parent
     905    typename _Graph, typename _Item, typename _Value,
     906    typename _Map = DefaultMap<_Graph, _Item, _Value>
    905907  >
    906908#else
     
    11061108  /// \param _Map A ReadWriteMap mapping from the item type to integer.
    11071109  template <
    1108     typename _Graph, typename _Item, typename _Map
    1109     = typename ItemSetTraits<_Graph, _Item>::template Map<int>::Parent
     1110    typename _Graph, typename _Item,
     1111    typename _Map = DefaultMap<_Graph, _Item, int>
    11101112  >
    11111113#else
     
    15061508  private:
    15071509
    1508     class AutoNodeMap : public Graph::template NodeMap<int> {
     1510    class AutoNodeMap : public DefaultMap<_Graph, Key, int> {
    15091511    public:
    15101512
    1511       typedef typename Graph::template NodeMap<int> Parent;
    1512 
    1513       typedef typename Parent::Key Key;
    1514       typedef typename Parent::Value Value;
    1515      
     1513      typedef DefaultMap<_Graph, Key, int> Parent;
     1514
    15161515      AutoNodeMap(const Graph& graph) : Parent(graph, 0) {}
    15171516     
     
    16231622  private:
    16241623
    1625     class AutoNodeMap : public Graph::template NodeMap<int> {
     1624    class AutoNodeMap : public DefaultMap<_Graph, Key, int> {
    16261625    public:
    16271626
    1628       typedef typename Graph::template NodeMap<int> Parent;
    1629 
    1630       typedef typename Parent::Key Key;
    1631       typedef typename Parent::Value Value;
    1632      
     1627      typedef DefaultMap<_Graph, Key, int> Parent;
     1628
    16331629      AutoNodeMap(const Graph& graph) : Parent(graph, 0) {}
    16341630     
     
    16641660    }
    16651661   
    1666     /// Gives back the in-degree of a Node.
     1662    /// Gives back the out-degree of a Node.
    16671663    int operator[](const Key& key) const {
    16681664      return deg[key];
  • lemon/iterable_maps.h

    r1956 r1990  
    2020#include <lemon/invalid.h>
    2121
     22#include <lemon/bits/default_map.h>
     23
    2224#include <vector>
    2325#include <map>
     
    4850  /// \param _Item One of the graph's item type, the key of the map.
    4951  template <typename _Graph, typename _Item>
    50   class IterableBoolMap
    51     : protected ItemSetTraits<_Graph, _Item>::template Map<int>::Parent {
     52  class IterableBoolMap : protected DefaultMap<_Graph, _Item, int> {
    5253  private:
    5354    typedef _Graph Graph;
    5455   
    5556    typedef typename ItemSetTraits<Graph, _Item>::ItemIt KeyIt;
    56     typedef typename ItemSetTraits<Graph, _Item>
    57     ::template Map<int>::Parent Parent;
     57    typedef DefaultMap<_Graph, _Item, int> Parent;
    5858   
    5959    std::vector<_Item> array;
     
    400400  /// \param _Item One of the graph's item type, the key of the map.
    401401  template <typename _Graph, typename _Item>
    402   class IterableIntMap : protected ItemSetTraits<_Graph, _Item>
    403   ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> >::Parent {
     402  class IterableIntMap
     403    : protected DefaultMap<_Graph, _Item, _iterable_maps_bits::
     404                           IterableIntMapNode<_Item> > {
    404405  public:
    405     typedef typename ItemSetTraits<_Graph, _Item>
    406     ::template Map<_iterable_maps_bits::IterableIntMapNode<_Item> >
    407     ::Parent Parent;
     406    typedef DefaultMap<_Graph, _Item, _iterable_maps_bits::
     407                       IterableIntMapNode<_Item> >
     408    Parent;
    408409
    409410    /// The key type
     
    688689  /// \param _Value Any comparable value type.
    689690  template <typename _Graph, typename _Item, typename _Value>
    690   class IterableValueMap : protected ItemSetTraits<_Graph, _Item>
    691   ::template Map<_iterable_maps_bits::IterableValueMapNode<_Item, _Value> >
    692   ::Parent {
     691  class IterableValueMap
     692    : protected DefaultMap<_Graph, _Item, _iterable_maps_bits::
     693                           IterableValueMapNode<_Item, _Value> > {
    693694  public:
    694     typedef typename ItemSetTraits<_Graph, _Item>
    695     ::template Map<_iterable_maps_bits::IterableValueMapNode<_Item, _Value> >
    696     ::Parent Parent;
     695    typedef DefaultMap<_Graph, _Item, _iterable_maps_bits::
     696                       IterableValueMapNode<_Item, _Value> > Parent;
    697697
    698698    /// The key type
     
    703703    typedef _Graph Graph;
    704704
     705  protected:
     706
     707    typedef typename ItemSetTraits<_Graph, Key>::ItemIt KeyIt;
     708
     709  public:
     710
    705711    /// \brief Constructor of the Map with a given value.
    706712    ///
     
    708714    explicit IterableValueMap(const Graph& graph,
    709715                              const Value& value = Value())
    710       : Parent(graph, _iterable_maps_bits::IterableValueMapNode<_Item,
    711                _Value>(value)) {
    712       for (typename Parent::ItemIt it(*this); it != INVALID; ++it) {
     716      : Parent(graph, _iterable_maps_bits::
     717               IterableValueMapNode<_Item, _Value>(value)) {
     718      for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) {
    713719        lace(it);
    714720      }
    715721    }
    716722
    717   private:
     723  protected:
    718724   
    719725    void unlace(const Key& key) {
     
    872878  protected:
    873879   
     880    virtual void add(const Key& key) {
     881      Parent::add(key);
     882      unlace(key);
     883    }
     884
     885    virtual void add(const std::vector<Key>& keys) {
     886      Parent::add(keys);
     887      for (int i = 0; i < (int)keys.size(); ++i) {
     888        lace(keys[i]);
     889      }
     890    }
     891
    874892    virtual void erase(const Key& key) {
    875893      unlace(key);
     
    884902    }
    885903
     904    virtual void build() {
     905      Parent::build();
     906      for (KeyIt it(*Parent::getGraph()); it != INVALID; ++it) {
     907        lace(it);
     908      }
     909    }
     910
    886911    virtual void clear() {
    887912      first.clear();
  • lemon/sub_graph.h

    r1979 r1990  
    2121
    2222#include <lemon/graph_adaptor.h>
     23#include <lemon/bits/graph_adaptor_extender.h>
     24#include <lemon/bits/default_map.h>
    2325
    2426namespace lemon {
     
    243245      Edge firstIn, firstOut;
    244246    };
    245     class NodesImpl : public Graph::template NodeMap<NodeT> {
     247    class NodesImpl : public DefaultMap<Graph, Node, NodeT> {
    246248      friend class SubGraphBase;
    247249    public:
    248       typedef typename Graph::template NodeMap<NodeT> Parent;
     250      typedef DefaultMap<Graph, Node, NodeT> Parent;
    249251
    250252      NodesImpl(SubGraph& _adaptor, const Graph& _graph)
     
    306308      Edge prevIn, nextIn;
    307309    };
    308     class EdgesImpl : public Graph::template EdgeMap<EdgeT> {
     310    class EdgesImpl : public DefaultMap<Graph, Edge, EdgeT> {
    309311      friend class SubGraphBase;
    310312    public:
    311       typedef typename Graph::template EdgeMap<EdgeT> Parent;
     313      typedef DefaultMap<Graph, Edge, EdgeT> Parent;
    312314
    313315      EdgesImpl(SubGraph& _adaptor, const Graph& _graph)
     
    561563      Edge firstIn, firstOut;
    562564    };
    563     class NodesImpl : public Graph::template NodeMap<NodeT> {
     565    class NodesImpl : public DefaultMap<Graph, Node, NodeT> {
    564566      friend class EdgeSubGraphBase;
    565567    public:
    566       typedef typename Graph::template NodeMap<NodeT> Parent;
     568      typedef DefaultMap<Graph, Node, NodeT> Parent;
    567569
    568570      NodesImpl(SubGraph& _adaptor, const Graph& _graph)
     
    604606      Edge prevIn, nextIn;
    605607    };
    606     class EdgesImpl : public Graph::template EdgeMap<EdgeT> {
     608    class EdgesImpl : public DefaultMap<Graph, Edge, EdgeT> {
    607609      friend class EdgeSubGraphBase;
    608610    public:
    609       typedef typename Graph::template EdgeMap<EdgeT> Parent;
     611      typedef DefaultMap<Graph, Edge, EdgeT> Parent;
    610612
    611613      EdgesImpl(SubGraph& _adaptor, const Graph& _graph)
  • test/edge_set_test.cc

    r1962 r1990  
    1818using namespace lemon::concept;
    1919
    20 typedef StaticGraph Graph;
     20typedef SmartGraph Graph;
    2121
    2222int main() {
Note: See TracChangeset for help on using the changeset viewer.