COIN-OR::LEMON - Graph Library

Changeset 1910:f95eea8c34b0 in lemon-0.x for lemon/bits/default_map.h


Ignore:
Timestamp:
01/26/06 17:24:40 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2485
Message:

Bipartite => Bp
Upper => A
Lower => B

+ some bug fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/default_map.h

    r1909 r1910  
    33 *
    44 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    5  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     5 * (Egervary Research Groin on Combinatorial Optimization, EGRES).
    66 *
    77 * Permission to use, modify and distribute this software is granted
     
    2222#include <lemon/bits/vector_map.h>
    2323
    24 ///\ingroup graphmapfactory
     24///\ingroin graphmapfactory
    2525///\file
    2626///\brief Graph maps that construct and destruct
     
    353353
    354354  template <typename _Base>
    355   class MappableUBipartiteGraphExtender : public _Base {
     355  class MappableBpUGraphExtender : public _Base {
    356356  public:
    357357
    358358    typedef _Base Parent;
    359     typedef MappableUBipartiteGraphExtender Graph;
     359    typedef MappableBpUGraphExtender Graph;
    360360
    361361    typedef typename Parent::Node Node;
    362     typedef typename Parent::UpperNode UpperNode;
    363     typedef typename Parent::LowerNode LowerNode;
     362    typedef typename Parent::ANode ANode;
     363    typedef typename Parent::BNode BNode;
    364364    typedef typename Parent::Edge Edge;
    365365    typedef typename Parent::UEdge UEdge;
    366366   
    367367    template <typename _Value>
    368     class UpperNodeMap
    369       : public IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> > {
    370     public:
    371       typedef MappableUBipartiteGraphExtender Graph;
    372       typedef IterableMapExtender<DefaultMap<Graph, UpperNode, _Value> >
     368    class ANodeMap
     369      : public IterableMapExtender<DefaultMap<Graph, ANode, _Value> > {
     370    public:
     371      typedef MappableBpUGraphExtender Graph;
     372      typedef IterableMapExtender<DefaultMap<Graph, ANode, _Value> >
    373373      Parent;
    374374   
    375       UpperNodeMap(const Graph& _g)
    376         : Parent(_g) {}
    377       UpperNodeMap(const Graph& _g, const _Value& _v)
    378         : Parent(_g, _v) {}
    379    
    380       UpperNodeMap& operator=(const UpperNodeMap& cmap) {
    381         return operator=<UpperNodeMap>(cmap);
     375      ANodeMap(const Graph& _g)
     376        : Parent(_g) {}
     377      ANodeMap(const Graph& _g, const _Value& _v)
     378        : Parent(_g, _v) {}
     379   
     380      ANodeMap& operator=(const ANodeMap& cmap) {
     381        return operator=<ANodeMap>(cmap);
    382382      }
    383383   
     
    387387      /// The given parameter should be conform to the ReadMap
    388388      /// concept and could be indiced by the current item set of
    389       /// the UpperNodeMap. In this case the value for each item
     389      /// the ANodeMap. In this case the value for each item
    390390      /// is assigned by the value of the given ReadMap.
    391391      template <typename CMap>
    392       UpperNodeMap& operator=(const CMap& cmap) {
    393         checkConcept<concept::ReadMap<UpperNode, _Value>, CMap>();
    394         const typename Parent::Graph* graph = Parent::getGraph();
    395         UpperNode it;
    396         for (graph->first(it); it != INVALID; graph->next(it)) {
    397           Parent::set(it, cmap[it]);
    398         }
    399         return *this;
    400       }
    401    
    402     };
    403 
    404     template <typename _Value>
    405     class LowerNodeMap
    406       : public IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> > {
    407     public:
    408       typedef MappableUBipartiteGraphExtender Graph;
    409       typedef IterableMapExtender<DefaultMap<Graph, LowerNode, _Value> >
     392      ANodeMap& operator=(const CMap& cmap) {
     393        checkConcept<concept::ReadMap<ANode, _Value>, CMap>();
     394        const typename Parent::Graph* graph = Parent::getGraph();
     395        ANode it;
     396        for (graph->first(it); it != INVALID; graph->next(it)) {
     397          Parent::set(it, cmap[it]);
     398        }
     399        return *this;
     400      }
     401   
     402    };
     403
     404    template <typename _Value>
     405    class BNodeMap
     406      : public IterableMapExtender<DefaultMap<Graph, BNode, _Value> > {
     407    public:
     408      typedef MappableBpUGraphExtender Graph;
     409      typedef IterableMapExtender<DefaultMap<Graph, BNode, _Value> >
    410410      Parent;
    411411   
    412       LowerNodeMap(const Graph& _g)
    413         : Parent(_g) {}
    414       LowerNodeMap(const Graph& _g, const _Value& _v)
    415         : Parent(_g, _v) {}
    416    
    417       LowerNodeMap& operator=(const LowerNodeMap& cmap) {
    418         return operator=<LowerNodeMap>(cmap);
     412      BNodeMap(const Graph& _g)
     413        : Parent(_g) {}
     414      BNodeMap(const Graph& _g, const _Value& _v)
     415        : Parent(_g, _v) {}
     416   
     417      BNodeMap& operator=(const BNodeMap& cmap) {
     418        return operator=<BNodeMap>(cmap);
    419419      }
    420420   
     
    424424      /// The given parameter should be conform to the ReadMap
    425425      /// concept and could be indiced by the current item set of
    426       /// the LowerNodeMap. In this case the value for each item
     426      /// the BNodeMap. In this case the value for each item
    427427      /// is assigned by the value of the given ReadMap.
    428428      template <typename CMap>
    429       LowerNodeMap& operator=(const CMap& cmap) {
    430         checkConcept<concept::ReadMap<LowerNode, _Value>, CMap>();
    431         const typename Parent::Graph* graph = Parent::getGraph();
    432         LowerNode it;
     429      BNodeMap& operator=(const CMap& cmap) {
     430        checkConcept<concept::ReadMap<BNode, _Value>, CMap>();
     431        const typename Parent::Graph* graph = Parent::getGraph();
     432        BNode it;
    433433        for (graph->first(it); it != INVALID; graph->next(it)) {
    434434          Parent::set(it, cmap[it]);
     
    444444    class NodeMapBase : public Parent::NodeNotifier::ObserverBase {
    445445    public:
    446       typedef MappableUBipartiteGraphExtender Graph;
     446      typedef MappableBpUGraphExtender Graph;
    447447
    448448      typedef Node Key;
     
    450450
    451451      /// The reference type of the map;
    452       typedef typename LowerNodeMap<_Value>::Reference Reference;
     452      typedef typename BNodeMap<_Value>::Reference Reference;
    453453      /// The pointer type of the map;
    454       typedef typename LowerNodeMap<_Value>::Pointer Pointer;
     454      typedef typename BNodeMap<_Value>::Pointer Pointer;
    455455     
    456456      /// The const value type of the map.
    457457      typedef const Value ConstValue;
    458458      /// The const reference type of the map;
    459       typedef typename LowerNodeMap<_Value>::ConstReference ConstReference;
     459      typedef typename BNodeMap<_Value>::ConstReference ConstReference;
    460460      /// The pointer type of the map;
    461       typedef typename LowerNodeMap<_Value>::ConstPointer ConstPointer;
     461      typedef typename BNodeMap<_Value>::ConstPointer ConstPointer;
    462462
    463463      typedef True ReferenceMapTag;
    464464
    465465      NodeMapBase(const Graph& _g)
    466         : graph(&_g), lowerMap(_g), upperMap(_g) {
     466        : graph(&_g), bNodeMap(_g), aNodeMap(_g) {
    467467        Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
    468468      }
    469469      NodeMapBase(const Graph& _g, const _Value& _v)
    470         : graph(&_g), lowerMap(_g, _v),
    471           upperMap(_g, _v) {
     470        : graph(&_g), bNodeMap(_g, _v),
     471          aNodeMap(_g, _v) {
    472472        Parent::NodeNotifier::ObserverBase::attach(_g.getNotifier(Node()));
    473473      }
     
    480480   
    481481      ConstReference operator[](const Key& node) const {
    482         if (Parent::upper(node)) {
    483           return upperMap[node];
     482        if (Parent::aNode(node)) {
     483          return aNodeMap[node];
    484484        } else {
    485           return lowerMap[node];
     485          return bNodeMap[node];
    486486        }
    487487      }
    488488
    489489      Reference operator[](const Key& node) {
    490         if (Parent::upper(node)) {
    491           return upperMap[node];
     490        if (Parent::aNode(node)) {
     491          return aNodeMap[node];
    492492        } else {
    493           return lowerMap[node];
     493          return bNodeMap[node];
    494494        }
    495495      }
    496496
    497497      void set(const Key& node, const Value& value) {
    498         if (Parent::upper(node)) {
    499           upperMap.set(node, value);
     498        if (Parent::aNode(node)) {
     499          aNodeMap.set(node, value);
    500500        } else {
    501           lowerMap.set(node, value);
     501          bNodeMap.set(node, value);
    502502        }
    503503      }
     
    514514    private:
    515515      const Graph* graph;
    516       LowerNodeMap<_Value> lowerMap;
    517       UpperNodeMap<_Value> upperMap;
     516      BNodeMap<_Value> bNodeMap;
     517      ANodeMap<_Value> aNodeMap;
    518518    };
    519519   
     
    524524      : public IterableMapExtender<NodeMapBase<_Value> > {
    525525    public:
    526       typedef MappableUBipartiteGraphExtender Graph;
     526      typedef MappableBpUGraphExtender Graph;
    527527      typedef IterableMapExtender< NodeMapBase<_Value> > Parent;
    528528   
     
    562562      : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
    563563    public:
    564       typedef MappableUBipartiteGraphExtender Graph;
     564      typedef MappableBpUGraphExtender Graph;
    565565      typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
    566566   
     
    590590      : public IterableMapExtender<DefaultMap<Graph, UEdge, _Value> > {
    591591    public:
    592       typedef MappableUBipartiteGraphExtender Graph;
     592      typedef MappableBpUGraphExtender Graph;
    593593      typedef IterableMapExtender<DefaultMap<Graph, UEdge, _Value> >
    594594      Parent;
Note: See TracChangeset for help on using the changeset viewer.