COIN-OR::LEMON - Graph Library

Changeset 1267:a93f94dbe3d3 in lemon-0.x for src/lemon/graph_utils.h


Ignore:
Timestamp:
03/26/05 00:31:57 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1694
Message:

First version of iterable maps.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/graph_utils.h

    r1192 r1267  
    2222#include <lemon/invalid.h>
    2323#include <lemon/utility.h>
    24 #include <lemon/map_utils.h>
    2524
    2625///\ingroup gutils
     
    3534namespace lemon {
    3635
    37 /// \addtogroup gutils
    38 /// @{
     36  /// \addtogroup gutils
     37  /// @{
    3938
    4039  /// \brief Function to count the items in the graph.
     
    161160  template <typename Graph>
    162161  typename Graph::Edge findEdge(const Graph &g,
    163                 typename Graph::Node u, typename Graph::Node v,
    164                 typename Graph::Edge prev = INVALID)
     162                                typename Graph::Node u, typename Graph::Node v,
     163                                typename Graph::Edge prev = INVALID)
    165164  {
    166165    typename Graph::OutEdgeIt e(g,prev);
     
    226225  }
    227226 
    228    template <
     227  template <
    229228    typename _DestinationGraph,
    230229    typename _SourceGraph,
     
    232231    =typename _SourceGraph::template NodeMap<typename _DestinationGraph::Node>,
    233232    typename _EdgeBijection
    234     =typename _SourceGraph::template EdgeMap<typename _DestinationGraph::Edge>
    235    >
    236    class GraphCopy {
    237    public:
    238 
    239      typedef _DestinationGraph DestinationGraph;
    240      typedef _SourceGraph SourceGraph;
    241 
    242      typedef _NodeBijection NodeBijection;
    243      typedef _EdgeBijection EdgeBijection;
    244 
    245    protected:         
    246 
    247      NodeBijection node_bijection;
    248      EdgeBijection edge_bijection;     
    249 
    250    public:
     233    = typename _SourceGraph::template EdgeMap<typename _DestinationGraph::Edge>
     234  >
     235  class GraphCopy {
     236  public:
     237   
     238    typedef _DestinationGraph DestinationGraph;
     239    typedef _SourceGraph SourceGraph;
     240
     241    typedef _NodeBijection NodeBijection;
     242    typedef _EdgeBijection EdgeBijection;
     243   
     244  protected:         
     245   
     246    NodeBijection node_bijection;
     247    EdgeBijection edge_bijection;     
     248
     249  public:
    251250     
    252      GraphCopy(DestinationGraph& _d, const SourceGraph& _s) {
    253        copyGraph(_d, _s, node_bijection, edge_bijection);
    254      }
    255 
    256      const NodeBijection& getNodeBijection() const {
    257        return node_bijection;
    258      }
    259 
    260      const EdgeBijection& getEdgeBijection() const {
    261        return edge_bijection;
    262      }
     251    GraphCopy(DestinationGraph& _d, const SourceGraph& _s) {
     252      copyGraph(_d, _s, node_bijection, edge_bijection);
     253    }
     254   
     255    const NodeBijection& getNodeBijection() const {
     256      return node_bijection;
     257    }
     258
     259    const EdgeBijection& getEdgeBijection() const {
     260      return edge_bijection;
     261    }
    263262     
    264    };
     263  };
     264
     265
     266  template <typename _Graph, typename _Item>
     267  class ItemSetTraits {
     268  };
    265269 
    266270  template <typename _Graph>
    267   class GraphNodeSet {
     271  class ItemSetTraits<_Graph, typename _Graph::Node> {
    268272  public:
    269273   
     
    284288    };
    285289
    286     typedef IdMap<Graph, Item> IdMap;
    287    
    288   private:
    289     Graph* graph;
    290290  };
    291291
    292292  template <typename _Graph>
    293   class GraphEdgeSet {
     293  class ItemSetTraits<_Graph, typename _Graph::Edge> {
    294294  public:
    295295   
     
    310310    };
    311311
    312     typedef IdMap<Graph, Item> IdMap;
    313    
    314   private:
    315     Graph* graph;
    316   };
    317 
     312  };
     313
     314  template <typename _Graph>
     315  class ItemSetTraits<_Graph, typename _Graph::UndirEdge> {
     316  public:
     317   
     318    typedef _Graph Graph;
     319
     320    typedef typename Graph::UndirEdge Item;
     321    typedef typename Graph::UndirEdgeIt ItemIt;
     322
     323    template <typename _Value>
     324    class Map : public Graph::template UndirEdgeMap<_Value> {
     325    public:
     326      typedef typename Graph::template UndirEdgeMap<_Value> Parent;
     327      typedef typename Parent::Value Value;
     328
     329      Map(const Graph& _graph) : Parent(_graph) {}
     330      Map(const Graph& _graph, const Value& _value)
     331        : Parent(_graph, _value) {}
     332    };
     333
     334  };
    318335
    319336  /// @}
Note: See TracChangeset for help on using the changeset viewer.