COIN-OR::LEMON - Graph Library

Changeset 980:0f1044b7a3af in lemon-0.x


Ignore:
Timestamp:
11/11/04 10:31:55 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1368
Message:

maxNodeId() and maxEdgeId() changed to maxId(Node) and maxId(Edge)
getNodeObserverRegistry() and getEdgeObserverRegistry() changed to
getObserverRegistry(Node) and getObserverRegistry(Edge)

IdMappableGraphExtender? erased

Location:
src
Files:
2 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/Makefile.am

    r977 r980  
    11pkginclude_HEADERS =                                                    \
     2        map_defines.h                                                   \
    23        array_map.h                                                     \
    34        bfs.h                                                           \
     
    78        dijkstra.h                                                      \
    89        dimacs.h                                                        \
    9         extended_pair.h                                                 \
    1010        fib_heap.h                                                      \
    1111        full_graph.h                                                    \
     
    1515        kruskal.h                                                       \
    1616        list_graph.h                                                    \
    17         map_iterator.h                                                  \
    1817        alteration_observer_registry.h                                  \
    1918        maps.h                                                          \
     
    2827        xy.h                                                            \
    2928        concept_check.h                                                 \
    30         map_defines.h                                                   \
    31         map_bits.h                                                      \
    3229        utility.h                                                       \
    3330        iterable_graph_extender.h                                       \
    34         idmappable_graph_extender.h                                     \
    3531        extendable_graph_extender.h                                     \
    3632        clearable_graph_extender.h                                      \
  • src/lemon/alteration_observer_registry.h

    r978 r980  
    322322  public:
    323323
    324     EdgeObserverRegistry& getEdgeObserverRegistry() const {
     324    EdgeObserverRegistry& getObserverRegistry(Edge = INVALID) const {
    325325      return edge_observers;
    326326    }
    327327
    328     NodeObserverRegistry& getNodeObserverRegistry() const {
     328    NodeObserverRegistry& getObserverRegistry(Node = INVALID) const {
    329329      return node_observers;
    330330    }
     
    365365    mutable UndirEdgeObserverRegistry undir_edge_observers;
    366366
    367     UndirEdgeObserverRegistry& getUndirEdgeObserverRegistry() const {
     367    UndirEdgeObserverRegistry& getObserverRegistry(UndirEdge = INVALID) const {
    368368      return undir_edge_observers;
    369369    }
  • src/lemon/array_map.h

    r979 r980  
    4545            typename _Item,
    4646            typename _ItemIt,
    47             typename _IdMap,
    4847            typename _Value>
    4948  class ArrayMap : public AlterationObserverRegistry<_Item>::ObserverBase {
     
    6160    /// The iterator to iterate on the keys.
    6261    typedef _ItemIt KeyIt;
    63 
    64     typedef _IdMap IdMap;
    6562
    6663    typedef _Value Value;
     
    9592    /** Graph and Registry initialized map constructor.
    9693     */
    97     ArrayMap(const Graph& _g, Registry& _r) : graph(&_g) {
    98       attach(_r);
     94    ArrayMap(const Graph& _g) : graph(&_g) {
     95      attach(_g.getObserverRegistry(_Item()));
    9996      allocate_memory();
    10097      for (KeyIt it(*graph); it != INVALID; ++it) {
    101         int id = IdMap(*graph)[it];
     98        int id = graph->id(it);;
    10299        allocator.construct(&(values[id]), Value());
    103100      }                                                         
     
    108105    /// It constrates a map and initialize all of the the map.
    109106
    110     ArrayMap(const Graph& _g, Registry& _r, const Value& _v) : graph(&_g) {
    111       attach(_r);
     107    ArrayMap(const Graph& _g, const Value& _v) : graph(&_g) {
     108      attach(_g.getObserverRegistry(_Item()));
    112109      allocate_memory();
    113110      for (KeyIt it(*graph); it != INVALID; ++it) {
    114         int id = IdMap(*graph)[it];
     111        int id = graph->id(it);;
    115112        allocator.construct(&(values[id]), _v);
    116113      }                                                         
     
    127124      values = allocator.allocate(capacity);
    128125      for (KeyIt it(*graph); it != INVALID; ++it) {
    129         int id = IdMap(*graph)[it];
     126        int id = graph->id(it);;
    130127        allocator.construct(&(values[id]), copy.values[id]);
    131128      }
     
    155152
    156153      for (KeyIt it(*graph); it != INVALID; ++it) {
    157         int id = IdMap(*graph)[it];
     154        int id = graph->id(it);;
    158155        allocator.construct(&(values[id]), copy.values[id]);
    159156      }
     
    177174     */
    178175    ReferenceType operator[](const KeyType& key) {
    179       int id = IdMap(*graph)[key];
     176      int id = graph->id(key);
    180177      return values[id];
    181178    }
     
    186183     */
    187184    ConstReferenceType operator[](const KeyType& key) const {
    188       int id = IdMap(*graph)[key];
     185      int id = graph->id(key);
    189186      return values[id];
    190187    }
     
    200197     */
    201198    void add(const KeyType& key) {
    202       int id = IdMap(*graph)[key];
     199      int id = graph->id(key);
    203200      if (id >= capacity) {
    204201        int new_capacity = (capacity == 0 ? 1 : capacity);
     
    208205        Value* new_values = allocator.allocate(new_capacity);
    209206        for (KeyIt it(*graph); it != INVALID; ++it) {
    210           int jd = IdMap(*graph)[it];
     207          int jd = graph->id(it);;
    211208          if (id != jd) {
    212209            allocator.construct(&(new_values[jd]), values[jd]);
     
    224221     */
    225222    void erase(const KeyType& key) {
    226       int id = IdMap(*graph)[key];
     223      int id = graph->id(key);
    227224      allocator.destroy(&(values[id]));
    228225    }
     
    231228      allocate_memory();
    232229      for (KeyIt it(*graph); it != INVALID; ++it) {
    233         int id = IdMap(*graph)[it];
     230        int id = graph->id(it);;
    234231        allocator.construct(&(values[id]), Value());
    235232      }                                                         
     
    239236      if (capacity != 0) {
    240237        for (KeyIt it(*graph); it != INVALID; ++it) {
    241           int id = IdMap(*graph)[it];
     238          int id = graph->id(it);;
    242239          allocator.destroy(&(values[id]));
    243240        }                                                               
     
    303300     
    304301    void allocate_memory() {
    305       int max_id = IdMap(*graph).maxId();
     302      int max_id = graph->maxId(_Item());
    306303      if (max_id == -1) {
    307304        capacity = 0;
     
    344341    typedef typename Parent::Node Node;
    345342    typedef typename Parent::NodeIt NodeIt;
    346     typedef typename Parent::NodeIdMap NodeIdMap;
    347343    typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
    348344
    349345    typedef typename Parent::Edge Edge;
    350346    typedef typename Parent::EdgeIt EdgeIt;
    351     typedef typename Parent::EdgeIdMap EdgeIdMap;
    352347    typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
    353348
     
    355350
    356351    template <typename _Value>
    357     class NodeMap : public ArrayMap<Graph, Node, NodeIt, NodeIdMap, _Value> {
     352    class NodeMap : public ArrayMap<Graph, Node, NodeIt, _Value> {
    358353    public:
    359354      typedef ArrayMappableGraphExtender<_Base> Graph;
     
    361356      typedef typename Graph::Node Node;
    362357      typedef typename Graph::NodeIt NodeIt;
    363       typedef typename Graph::NodeIdMap NodeIdMap;
    364 
    365       typedef ArrayMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent;
     358
     359      typedef ArrayMap<Graph, Node, NodeIt, _Value> Parent;
    366360
    367361      //typedef typename Parent::Graph Graph;
     
    369363
    370364      NodeMap(const Graph& g)
    371         : Parent(g, g.getNodeObserverRegistry()) {}
     365        : Parent(g) {}
    372366      NodeMap(const Graph& g, const Value& v)
    373         : Parent(g, g.getNodeObserverRegistry(), v) {}
     367        : Parent(g, v) {}
    374368
    375369    };
    376370
    377371    template <typename _Value>
    378     class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> {
     372    class EdgeMap : public ArrayMap<Graph, Edge, EdgeIt, _Value> {
    379373    public:
    380374      typedef ArrayMappableGraphExtender<_Base> Graph;
     
    382376      typedef typename Graph::Edge Edge;
    383377      typedef typename Graph::EdgeIt EdgeIt;
    384       typedef typename Graph::EdgeIdMap EdgeIdMap;
    385 
    386       typedef ArrayMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent;
     378
     379      typedef ArrayMap<Graph, Edge, EdgeIt, _Value> Parent;
    387380
    388381      //typedef typename Parent::Graph Graph;
     
    390383
    391384      EdgeMap(const Graph& g)
    392         : Parent(g, g.getEdgeObserverRegistry()) {}
     385        : Parent(g) {}
    393386      EdgeMap(const Graph& g, const Value& v)
    394         : Parent(g, g.getEdgeObserverRegistry(), v) {}
     387        : Parent(g, v) {}
    395388
    396389    };
  • src/lemon/clearable_graph_extender.h

    r946 r980  
    1515    typedef ClearableGraphExtender Graph;
    1616    typedef _Base Parent;
     17    typedef typename Parent::Node Node;
     18    typedef typename Parent::Edge Edge;
    1719
    1820    void clear() {
    19       Parent::getNodeObserverRegistry().clear();
    20       Parent::getEdgeObserverRegistry().clear();
     21      Parent::getObserverRegistry(Node()).clear();
     22      Parent::getObserverRegistry(Edge()).clear();
    2123      Parent::clear();
    2224    }
  • src/lemon/concept/graph_component.h

    r964 r980  
    162162
    163163
     164        /// Assign operator for nodes.
     165
     166        /// The nodes are assignable.
     167        ///
    164168        Node& operator=(const Node&) { return *this;}
    165169
     
    211215        Edge(Invalid) {}
    212216
    213 
     217        /// Assign operator for edges.
     218
     219        /// The edges are assignable.
     220        ///
    214221        Edge& operator=(const Edge&) { return *this;}
    215222
     
    430437      /// Gives back an integer greater or equal to the maximum Node id.
    431438      ///
    432       int maxEdgeId() const { return -1;}
     439      int maxId(Node = INVALID) const { return -1;}
    433440
    434441      /// Gives back an integer greater or equal to the maximum Edge id.
     
    436443      /// Gives back an integer greater or equal to the maximum Edge id.
    437444      ///
    438       int maxNodeId() const { return -1;}
     445      int maxId(Edge = INVALID) const { return -1;}
    439446    };
    440447
     
    448455      void constraints() {
    449456        function_requires< BaseGraphComponentConcept<Graph> >();
    450         int nid = graph.maxEdgeId();
     457        int nid = graph.maxId(typename Graph::Node());
    451458        ignore_unused_variable_warning(nid);
    452         int eid = graph.maxNodeId();
     459        int eid = graph.maxId(typename Graph::Edge());
    453460        ignore_unused_variable_warning(eid);
    454461      }
     
    663670
    664671
    665     class IdMappableGraphComponent : virtual public BaseGraphComponent {
    666 
    667       typedef IdMappableGraphComponent Graph;
    668 
    669     public:
    670 
    671       typedef BaseGraphComponent::Node Node;
    672       typedef BaseGraphComponent::Edge Edge;
    673 
    674       class NodeIdMap : public ReadMap<Node, int> {
    675       public:
    676         NodeIdMap(const Graph&) {}
    677         int maxId() const { return -1;}
    678       };
    679 
    680       class EdgeIdMap : public ReadMap<Edge, int> {
    681       public:
    682         EdgeIdMap(const Graph&) {}
    683         int maxId() const { return -1;}
    684       };
    685 
    686     };
    687    
    688     template <typename Graph>
    689     struct IdMappableGraphComponentConcept {
    690       void constraints() {     
    691         function_requires< BaseGraphComponentConcept<Graph> >();
    692         {
    693           typedef typename Graph::EdgeIdMap EdgeIdMap;
    694           function_requires<ReadMapConcept<EdgeIdMap> >();
    695           EdgeIdMap edge_map(graph);
    696           int n = edge_map.maxId();
    697           ignore_unused_variable_warning(n);
    698         }
    699         {
    700           typedef typename Graph::NodeIdMap NodeIdMap;
    701           function_requires<ReadMapConcept<NodeIdMap> >();
    702           NodeIdMap node_map(graph);
    703           int n = node_map.maxId();
    704           ignore_unused_variable_warning(n);
    705         }
    706       }
    707       Graph& graph;
    708     };
    709 
    710 
    711672    class MappableGraphComponent : virtual public BaseGraphComponent {
    712673    public:
  • src/lemon/default_map.h

    r979 r980  
    4343
    4444
    45   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap, typename _Value>
     45  template <typename _Graph, typename _Item, typename _ItemIt, typename _Value>
    4646  struct DefaultMapSelector {
    47     typedef ArrayMap<_Graph, _Item, _ItemIt, _IdMap, _Value> Map;
     47    typedef ArrayMap<_Graph, _Item, _ItemIt, _Value> Map;
    4848  };
    4949
    5050  // bool
    51   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    52   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, bool> {
    53     typedef VectorMap<_Graph, _Item, _IdMap, bool> Map;
     51  template <typename _Graph, typename _Item, typename _ItemIt>
     52  struct DefaultMapSelector<_Graph, _Item, _ItemIt, bool> {
     53    typedef VectorMap<_Graph, _Item, bool> Map;
    5454  };
    5555
    5656  // char
    57   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    58   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, char> {
    59     typedef VectorMap<_Graph, _Item, _IdMap, char> Map;
    60   };
    61 
    62   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    63   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed char> {
    64     typedef VectorMap<_Graph, _Item, _IdMap, signed char> Map;
    65   };
    66 
    67   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    68   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned char> {
    69     typedef VectorMap<_Graph, _Item, _IdMap, unsigned char> Map;
     57  template <typename _Graph, typename _Item, typename _ItemIt>
     58  struct DefaultMapSelector<_Graph, _Item, _ItemIt, char> {
     59    typedef VectorMap<_Graph, _Item, char> Map;
     60  };
     61
     62  template <typename _Graph, typename _Item, typename _ItemIt>
     63  struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed char> {
     64    typedef VectorMap<_Graph, _Item, signed char> Map;
     65  };
     66
     67  template <typename _Graph, typename _Item, typename _ItemIt>
     68  struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned char> {
     69    typedef VectorMap<_Graph, _Item, unsigned char> Map;
    7070  };
    7171
    7272
    7373  // int
    74   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    75   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed int> {
    76     typedef VectorMap<_Graph, _Item, _IdMap, signed int> Map;
    77   };
    78 
    79   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    80   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned int> {
    81     typedef VectorMap<_Graph, _Item, _IdMap, unsigned int> Map;
     74  template <typename _Graph, typename _Item, typename _ItemIt>
     75  struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed int> {
     76    typedef VectorMap<_Graph, _Item, signed int> Map;
     77  };
     78
     79  template <typename _Graph, typename _Item, typename _ItemIt>
     80  struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned int> {
     81    typedef VectorMap<_Graph, _Item, unsigned int> Map;
    8282  };
    8383
    8484
    8585  // short
    86   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    87   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed short> {
    88     typedef VectorMap<_Graph, _Item, _IdMap, signed short> Map;
    89   };
    90 
    91   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    92   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned short> {
    93     typedef VectorMap<_Graph, _Item, _IdMap, unsigned short> Map;
     86  template <typename _Graph, typename _Item, typename _ItemIt>
     87  struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed short> {
     88    typedef VectorMap<_Graph, _Item, signed short> Map;
     89  };
     90
     91  template <typename _Graph, typename _Item, typename _ItemIt>
     92  struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned short> {
     93    typedef VectorMap<_Graph, _Item, unsigned short> Map;
    9494  };
    9595
    9696
    9797  // long
    98   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    99   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed long> {
    100     typedef VectorMap<_Graph, _Item, _IdMap, signed long> Map;
    101   };
    102 
    103   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    104   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned long> {
    105     typedef VectorMap<_Graph, _Item, _IdMap, unsigned long> Map;
     98  template <typename _Graph, typename _Item, typename _ItemIt>
     99  struct DefaultMapSelector<_Graph, _Item, _ItemIt, signed long> {
     100    typedef VectorMap<_Graph, _Item, signed long> Map;
     101  };
     102
     103  template <typename _Graph, typename _Item, typename _ItemIt>
     104  struct DefaultMapSelector<_Graph, _Item, _ItemIt, unsigned long> {
     105    typedef VectorMap<_Graph, _Item, unsigned long> Map;
    106106  };
    107107
     
    110110
    111111  // float
    112   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    113   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, float> {
    114     typedef VectorMap<_Graph, _Item, _IdMap, float> Map;
     112  template <typename _Graph, typename _Item, typename _ItemIt>
     113  struct DefaultMapSelector<_Graph, _Item, _ItemIt, float> {
     114    typedef VectorMap<_Graph, _Item, float> Map;
    115115  };
    116116
    117117
    118118  // double
    119   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    120   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, double> {
    121     typedef VectorMap<_Graph, _Item, _IdMap, double> Map;
     119  template <typename _Graph, typename _Item, typename _ItemIt>
     120  struct DefaultMapSelector<_Graph, _Item, _ItemIt, double> {
     121    typedef VectorMap<_Graph, _Item, double> Map;
    122122  };
    123123
    124124
    125125  // long double
    126   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
    127   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, long double> {
    128     typedef VectorMap<_Graph, _Item, _IdMap, long double> Map;
     126  template <typename _Graph, typename _Item, typename _ItemIt>
     127  struct DefaultMapSelector<_Graph, _Item, _ItemIt, long double> {
     128    typedef VectorMap<_Graph, _Item, long double> Map;
    129129  };
    130130
    131131
    132132  // pointer
    133   template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap, typename _Ptr>
    134   struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Ptr*> {
    135     typedef VectorMap<_Graph, _Item, _IdMap, _Ptr*> Map;
     133  template <typename _Graph, typename _Item, typename _ItemIt, typename _Ptr>
     134  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _Ptr*> {
     135    typedef VectorMap<_Graph, _Item, _Ptr*> Map;
    136136  };
    137137
     
    141141            typename _Item,
    142142            typename _ItemIt,
    143             typename _IdMap,
    144143            typename _Value>
    145   class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Value>::Map {
     144  class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map {
    146145  public:
    147     typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Value>::Map Parent;
    148     typedef DefaultMap<_Graph, _Item, _ItemIt, _IdMap, bool> Map;
     146    typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _Value>::Map Parent;
     147    typedef DefaultMap<_Graph, _Item, _ItemIt, _Value> Map;
    149148   
    150149    typedef typename Parent::Graph Graph;
    151     typedef typename Parent::Registry Registry;
    152150    typedef typename Parent::ValueType ValueType;
    153151
    154     DefaultMap(const Graph& _g, Registry& _r) : Parent(_g, _r) {}
    155     DefaultMap(const Graph& _g, Registry& _r, const ValueType& _v) : Parent(_g, _r, _v) {}
     152    DefaultMap(const Graph& _g) : Parent(_g) {}
     153    DefaultMap(const Graph& _g, const ValueType& _v) : Parent(_g, _v) {}
    156154  };
    157155
     
    167165    typedef typename Parent::Node Node;
    168166    typedef typename Parent::NodeIt NodeIt;
    169     typedef typename Parent::NodeIdMap NodeIdMap;
    170     typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
    171167
    172168    typedef typename Parent::Edge Edge;
    173169    typedef typename Parent::EdgeIt EdgeIt;
    174     typedef typename Parent::EdgeIdMap EdgeIdMap;
    175     typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
    176170
    177171   
    178 
    179172    template <typename _Value>
    180     class NodeMap : public DefaultMap<Graph, Node, NodeIt, NodeIdMap, _Value> {
     173    class NodeMap : public DefaultMap<Graph, Node, NodeIt, _Value> {
    181174    public:
    182175      typedef DefaultMappableGraphExtender<_Base> Graph;
     
    184177      typedef typename Graph::Node Node;
    185178      typedef typename Graph::NodeIt NodeIt;
    186       typedef typename Graph::NodeIdMap NodeIdMap;
    187 
    188       typedef DefaultMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent;
     179
     180      typedef DefaultMap<Graph, Node, NodeIt, _Value> Parent;
    189181
    190182      //typedef typename Parent::Graph Graph;
    191183      typedef typename Parent::ValueType ValueType;
    192184
    193       NodeMap(const Graph& g)
    194         : Parent(g, g.getNodeObserverRegistry()) {}
    195       NodeMap(const Graph& g, const ValueType& v)
    196         : Parent(g, g.getNodeObserverRegistry(), v) {}
     185      NodeMap(const Graph& _g)
     186        : Parent(_g) {}
     187      NodeMap(const Graph& _g, const ValueType& _v)
     188        : Parent(_g, _v) {}
    197189
    198190    };
    199191
    200192    template <typename _Value>
    201     class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> {
     193    class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, _Value> {
    202194    public:
    203195      typedef DefaultMappableGraphExtender<_Base> Graph;
     
    205197      typedef typename Graph::Edge Edge;
    206198      typedef typename Graph::EdgeIt EdgeIt;
    207       typedef typename Graph::EdgeIdMap EdgeIdMap;
    208 
    209       typedef DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent;
     199
     200      typedef DefaultMap<Graph, Edge, EdgeIt, _Value> Parent;
    210201
    211202      //typedef typename Parent::Graph Graph;
    212203      typedef typename Parent::ValueType ValueType;
    213204
    214       EdgeMap(const Graph& g)
    215         : Parent(g, g.getEdgeObserverRegistry()) {}
    216       EdgeMap(const Graph& g, const ValueType& v)
    217         : Parent(g, g.getEdgeObserverRegistry(), v) {}
     205      EdgeMap(const Graph& _g)
     206        : Parent(_g) {}
     207      EdgeMap(const Graph& _g, const ValueType& _v)
     208        : Parent(_g, _v) {}
    218209
    219210    };
  • src/lemon/erasable_graph_extender.h

    r946 r980  
    3333      }
    3434
    35       Parent::getNodeObserverRegistry().erase(node);
     35      Parent::getObserverRegistry(Node()).erase(node);
    3636      Parent::erase(node);
    3737    }
    3838   
    3939    void erase(const Edge& edge) {
    40       Parent::getEdgeObserverRegistry().erase(edge);
     40      Parent::getObserverRegistry(Edge()).erase(edge);
    4141      Parent::erase(edge);
    4242    }
  • src/lemon/extendable_graph_extender.h

    r946 r980  
    1818    Node addNode() {
    1919      Node node = Parent::addNode();
    20       Parent::getNodeObserverRegistry().add(node);
     20      Parent::getObserverRegistry(Node()).add(node);
    2121      return node;
    2222    }
     
    2424    Edge addEdge(const Node& from, const Node& to) {
    2525      Edge edge = Parent::addEdge(from, to);
    26       Parent::getEdgeObserverRegistry().add(edge);
     26      Parent::getObserverRegistry(Edge()).add(edge);
    2727      return edge;
    2828    }
  • src/lemon/full_graph.h

    r977 r980  
    1919
    2020
    21 #include <lemon/idmappable_graph_extender.h>
    2221#include <lemon/iterable_graph_extender.h>
    2322#include <lemon/alteration_observer_registry.h>
     
    7170    /// Maximum node ID.
    7271    ///\sa id(Node)
    73     int maxNodeId() const { return NodeNum-1; }
     72    int maxId(Node = INVALID) const { return NodeNum-1; }
    7473    /// Maximum edge ID.
    7574   
    7675    /// Maximum edge ID.
    7776    ///\sa id(Edge)
    78     int maxEdgeId() const { return EdgeNum-1; }
     77    int maxId(Edge = INVALID) const { return EdgeNum-1; }
    7978
    8079    Node tail(Edge e) const { return e.id % NodeNum; }
     
    189188  typedef AlterableGraphExtender<FullGraphBase> AlterableFullGraphBase;
    190189  typedef IterableGraphExtender<AlterableFullGraphBase> IterableFullGraphBase;
    191   typedef IdMappableGraphExtender<IterableFullGraphBase> IdMappableFullGraphBase;
    192   typedef DefaultMappableGraphExtender<IdMappableFullGraphBase> MappableFullGraphBase;
     190  typedef DefaultMappableGraphExtender<IterableFullGraphBase> MappableFullGraphBase;
    193191
    194192  ///A full graph class.
  • src/lemon/list_graph.h

    r975 r980  
    2626#include <lemon/extendable_graph_extender.h>
    2727
    28 #include <lemon/idmappable_graph_extender.h>
    29 
    3028#include <lemon/iterable_graph_extender.h>
    3129
     
    106104    /// Maximum node ID.
    107105    ///\sa id(Node)
    108     int maxNodeId() const { return nodes.size()-1; }
     106    int maxId(Node = INVALID) const { return nodes.size()-1; }
    109107
    110108    /// Maximum edge ID.
     
    112110    /// Maximum edge ID.
    113111    ///\sa id(Edge)
    114     int maxEdgeId() const { return edges.size()-1; }
     112    int maxId(Edge = INVALID) const { return edges.size()-1; }
    115113
    116114    Node tail(Edge e) const { return edges[e.id].tail; }
     
    304302  typedef AlterableGraphExtender<ListGraphBase> AlterableListGraphBase;
    305303  typedef IterableGraphExtender<AlterableListGraphBase> IterableListGraphBase;
    306   typedef IdMappableGraphExtender<IterableListGraphBase> IdMappableListGraphBase;
    307   typedef DefaultMappableGraphExtender<IdMappableListGraphBase> MappableListGraphBase;
     304  typedef DefaultMappableGraphExtender<IterableListGraphBase> MappableListGraphBase;
    308305  typedef ExtendableGraphExtender<MappableListGraphBase> ExtendableListGraphBase;
    309306  typedef ClearableGraphExtender<ExtendableListGraphBase> ClearableListGraphBase;
  • src/lemon/smart_graph.h

    r977 r980  
    2828#include <lemon/clearable_graph_extender.h>
    2929#include <lemon/extendable_graph_extender.h>
    30 #include <lemon/idmappable_graph_extender.h>
    3130#include <lemon/iterable_graph_extender.h>
    3231#include <lemon/alteration_observer_registry.h>
     
    9291    /// Maximum node ID.
    9392    ///\sa id(Node)
    94     int maxNodeId() const { return nodes.size()-1; }
     93    int maxId(Node = INVALID) const { return nodes.size()-1; }
    9594    /// Maximum edge ID.
    9695   
    9796    /// Maximum edge ID.
    9897    ///\sa id(Edge)
    99     int maxEdgeId() const { return edges.size()-1; }
     98    int maxId(Edge = INVALID) const { return edges.size()-1; }
    10099
    101100    Node tail(Edge e) const { return edges[e.n].tail; }
     
    222221  typedef AlterableGraphExtender<SmartGraphBase> AlterableSmartGraphBase;
    223222  typedef IterableGraphExtender<AlterableSmartGraphBase> IterableSmartGraphBase;
    224   typedef IdMappableGraphExtender<IterableSmartGraphBase> IdMappableSmartGraphBase;
    225   typedef DefaultMappableGraphExtender<IdMappableSmartGraphBase> MappableSmartGraphBase;
     223  typedef DefaultMappableGraphExtender<IterableSmartGraphBase> MappableSmartGraphBase;
    226224  typedef ExtendableGraphExtender<MappableSmartGraphBase> ExtendableSmartGraphBase;
    227225  typedef ClearableGraphExtender<ExtendableSmartGraphBase> ClearableSmartGraphBase;
     
    240238  ///
    241239  ///\author Alpar Juttner
    242   class SmartGraph :public ClearableSmartGraphBase {
     240  class SmartGraph : public ClearableSmartGraphBase {
    243241  public:
    244242    /// Finds an edge between two nodes.
  • src/lemon/vector_map.h

    r979 r980  
    4747  template <typename _Graph,
    4848            typename _Item,
    49             typename _IdMap,
    5049            typename _Value>
    5150  class VectorMap : public AlterationObserverRegistry<_Item>::ObserverBase {
     
    5756    typedef _Item KeyType;
    5857    /// The id map type of the map.
    59     typedef _IdMap IdMap;
    60     /// The registry type of the map.
    6158    typedef AlterationObserverRegistry<_Item> Registry;
    6259    /// The value type of the map.
     
    9491    /// It adds all the items of the graph to the map.
    9592     
    96     VectorMap(const Graph& _g, Registry& _r) : graph(&_g) {
    97       attach(_r);
     93    VectorMap(const Graph& _g) : graph(&_g) {
     94      attach(_g.getObserverRegistry(_Item()));
    9895      build();
    9996    }
     
    104101    /// It adds all the items of the graph to the map.
    105102     
    106     VectorMap(const Graph& g, Registry& r, const Value& v) : graph(&g) {
    107       attach(r);
    108       container.resize(IdMap(*graph).maxId() + 1, v);
    109     }
    110 
    111     VectorMap(const VectorMap& copy) : graph(copy.getGraph()) {
    112       if (copy.attached()) {
    113         attach(*copy.getRegistry());
    114         container = copy.container;
     103    VectorMap(const Graph& _g, const Value& _v) : graph(&_g) {
     104      attach(_g.getObserverRegistry(_Item()));
     105      container.resize(graph->maxId(_Item()) + 1, _v);
     106    }
     107
     108    VectorMap(const VectorMap& _copy) : graph(_copy.getGraph()) {
     109      if (_copy.attached()) {
     110        attach(*_copy.getRegistry());
     111        container = _copy.container;
    115112      }
    116113    }
     
    155152     
    156153    ReferenceType operator[](const KeyType& key) {
    157       return container[IdMap(*graph)[key]];
     154      return container[graph->id(key)];
    158155    }
    159156               
     
    164161     
    165162    ConstReferenceType operator[](const KeyType& key) const {
    166       return container[IdMap(*graph)[key]];
     163      return container[graph->id(key)];
    167164    }
    168165
     
    183180     
    184181    void add(const KeyType& key) {
    185       int id = IdMap(*graph)[key];
     182      int id = graph->id(key);
    186183      if (id >= (int)container.size()) {
    187184        container.resize(id + 1);
     
    201198
    202199    void build() {
    203       container.resize(IdMap(*graph).maxId() + 1);
     200      container.resize(graph->maxId(_Item()) + 1);
    204201    }
    205202
     
    240237
    241238    template <typename _Value>
    242     class NodeMap : public VectorMap<Graph, Node, NodeIdMap, _Value> {
     239    class NodeMap : public VectorMap<Graph, Node, _Value> {
    243240    public:
    244241      typedef VectorMappableGraphExtender<_Base> Graph;
    245242
    246243      typedef typename Graph::Node Node;
    247       typedef typename Graph::NodeIdMap NodeIdMap;
    248 
    249       typedef VectorMap<Graph, Node, NodeIdMap, _Value> Parent;
     244
     245      typedef VectorMap<Graph, Node, _Value> Parent;
    250246
    251247      //typedef typename Parent::Graph Graph;
     
    253249
    254250      NodeMap(const Graph& g)
    255         : Parent(g, g.getNodeObserverRegistry()) {}
     251        : Parent(g) {}
    256252      NodeMap(const Graph& g, const Value& v)
    257         : Parent(g, g.getNodeObserverRegistry(), v) {}
     253        : Parent(g, v) {}
    258254
    259255    };
    260256
    261257    template <typename _Value>
    262     class EdgeMap : public VectorMap<Graph, Edge, EdgeIdMap, _Value> {
     258    class EdgeMap : public VectorMap<Graph, Edge, _Value> {
    263259    public:
    264260      typedef VectorMappableGraphExtender<_Base> Graph;
    265261
    266262      typedef typename Graph::Edge Edge;
    267       typedef typename Graph::EdgeIdMap EdgeIdMap;
    268 
    269       typedef VectorMap<Graph, Edge, EdgeIdMap, _Value> Parent;
     263
     264      typedef VectorMap<Graph, Edge, _Value> Parent;
    270265
    271266      //typedef typename Parent::Graph Graph;
     
    273268
    274269      EdgeMap(const Graph& g)
    275         : Parent(g, g.getEdgeObserverRegistry()) {}
     270        : Parent(g) {}
    276271      EdgeMap(const Graph& g, const Value& v)
    277         : Parent(g, g.getEdgeObserverRegistry(), v) {}
     272        : Parent(g, v) {}
    278273
    279274    };
  • src/test/graph_test.cc

    r959 r980  
    3434    function_requires<IterableGraphComponentConcept<IterableGraphComponent> >();
    3535
    36     function_requires<IdMappableGraphComponentConcept<IdMappableGraphComponent> >();
    3736    function_requires<MappableGraphComponentConcept<MappableGraphComponent> >();
    3837
Note: See TracChangeset for help on using the changeset viewer.