COIN-OR::LEMON - Graph Library

Changeset 782:df2e45e09652 in lemon-0.x for src/hugo/full_graph.h


Ignore:
Timestamp:
09/02/04 12:07:30 (20 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1075
Message:

--This line, and those below, will be ignored--

A hugo/sym_map_factory.h
M hugo/list_graph.h
A hugo/array_map_factory.h
A hugo/map_registry.h
M hugo/smart_graph.h
A hugo/map_defines.h
A hugo/extended_pair.h
M hugo/full_graph.h
A hugo/vector_map_factory.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/hugo/full_graph.h

    r774 r782  
    99
    1010#include <vector>
    11 #include <limits.h>
     11#include <climits>
    1212
    1313#include <hugo/invalid.h>
     14
     15#include <hugo/map_registry.h>
     16#include <hugo/array_map_factory.h>
    1417
    1518namespace hugo {
     
    3437    int EdgeNum;
    3538  public:
    36     template <typename T> class EdgeMap;
    37     template <typename T> class NodeMap;
     39
     40    typedef FullGraph Graph;
    3841
    3942    class Node;
    4043    class Edge;
     44
    4145    class NodeIt;
    4246    class EdgeIt;
     
    4448    class InEdgeIt;
    4549   
    46     template <typename T> class NodeMap;
    47     template <typename T> class EdgeMap;
     50    CREATE_MAP_REGISTRIES;
     51    CREATE_MAPS(ArrayMapFactory);
    4852   
    4953  public:
     
    8690    Edge findEdge(Node u,Node v, Edge prev = INVALID)
    8791    {
    88       return prev.n==-1?Edge(*this,u.n,v.n):INVALID;
     92      return prev.n == -1 ? Edge(*this, u.n, v.n) : INVALID;
    8993    }
    9094   
     
    188192    };
    189193
    190     template <typename T> class NodeMap
    191     {
    192       std::vector<T> container;
    193 
    194     public:
    195       typedef T ValueType;
    196       typedef Node KeyType;
    197 
    198       NodeMap(const FullGraph &_G) : container(_G.NodeNum) { }
    199       NodeMap(const FullGraph &_G,const T &t) : container(_G.NodeNum,t) { }
    200       NodeMap(const NodeMap<T> &m) : container(m.container) { }
    201 
    202       template<typename TT> friend class NodeMap;
    203       ///\todo It can copy between different types.
    204       template<typename TT> NodeMap(const NodeMap<TT> &m)
    205         : container(m.container.size())
    206       {
    207         typename std::vector<TT>::const_iterator i;
    208         for(typename std::vector<TT>::const_iterator i=m.container.begin();
    209             i!=m.container.end();
    210             i++)
    211           container.push_back(*i);
    212       }
    213       void set(Node n, T a) { container[n.n]=a; }
    214       //'T& operator[](Node n)' would be wrong here
    215       typename std::vector<T>::reference
    216       operator[](Node n) { return container[n.n]; }
    217       //'const T& operator[](Node n)' would be wrong here
    218       typename std::vector<T>::const_reference
    219       operator[](Node n) const { return container[n.n]; }
    220 
    221       ///\warning There is no safety check at all!
    222       ///Using operator = between maps attached to different graph may
    223       ///cause serious problem.
    224       ///\todo Is this really so?
    225       ///\todo It can copy between different types.
    226       const NodeMap<T>& operator=(const NodeMap<T> &m)
    227       {
    228         container = m.container;
    229         return *this;
    230       }
    231       template<typename TT>
    232       const NodeMap<T>& operator=(const NodeMap<TT> &m)
    233       {
    234         std::copy(m.container.begin(), m.container.end(), container.begin());
    235         return *this;
    236       }
    237      
    238       void update() {}    //Useless for Dynamic Maps
    239       void update(T a) {}  //Useless for Dynamic Maps
    240     };
    241    
    242     template <typename T> class EdgeMap
    243     {
    244       std::vector<T> container;
    245 
    246     public:
    247       typedef T ValueType;
    248       typedef Edge KeyType;
    249 
    250       EdgeMap(const FullGraph &_G) : container(_G.EdgeNum) { }
    251       EdgeMap(const FullGraph &_G,const T &t) : container(_G.EdgeNum,t) { }
    252       EdgeMap(const EdgeMap<T> &m) : container(m.container) { }
    253 
    254       template<typename TT> friend class EdgeMap;
    255       ///\todo It can copy between different types.
    256       ///\todo We could use 'copy'
    257       template<typename TT> EdgeMap(const EdgeMap<TT> &m) :
    258         container(m.container.size())
    259       {
    260         typename std::vector<TT>::const_iterator i;
    261         for(typename std::vector<TT>::const_iterator i=m.container.begin();
    262             i!=m.container.end();
    263             i++)
    264           container.push_back(*i);
    265       }
    266       void set(Edge n, T a) { container[n.n]=a; }
    267       //T get(Edge n) const { return container[n.n]; }
    268       typename std::vector<T>::reference
    269       operator[](Edge n) { return container[n.n]; }
    270       typename std::vector<T>::const_reference
    271       operator[](Edge n) const { return container[n.n]; }
    272 
    273       ///\warning There is no safety check at all!
    274       ///Using operator = between maps attached to different graph may
    275       ///cause serious problem.
    276       ///\todo Is this really so?
    277       ///\todo It can copy between different types.
    278       const EdgeMap<T>& operator=(const EdgeMap<T> &m)
    279       {
    280         container = m.container;
    281         return *this;
    282       }
    283       template<typename TT>
    284       const EdgeMap<T>& operator=(const EdgeMap<TT> &m)
    285       {
    286         std::copy(m.container.begin(), m.container.end(), container.begin());
    287         return *this;
    288       }
    289 
    290       void update() {}
    291       void update(T a) {}
    292     };
    293 
    294194  };
    295195
Note: See TracChangeset for help on using the changeset viewer.