lemon/bits/graph_extender.h
changeset 784 1a7fe3bef514
parent 685 a27356ceb5bd
child 964 7fdaa05a69a1
     1.1 --- a/lemon/bits/graph_extender.h	Fri Oct 16 10:21:37 2009 +0200
     1.2 +++ b/lemon/bits/graph_extender.h	Thu Nov 05 15:50:01 2009 +0100
     1.3 @@ -2,7 +2,7 @@
     1.4   *
     1.5   * This file is a part of LEMON, a generic C++ optimization library.
     1.6   *
     1.7 - * Copyright (C) 2003-2008
     1.8 + * Copyright (C) 2003-2009
     1.9   * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11   *
    1.12 @@ -29,17 +29,18 @@
    1.13  
    1.14  //\ingroup graphbits
    1.15  //\file
    1.16 -//\brief Extenders for the digraph types
    1.17 +//\brief Extenders for the graph types
    1.18  namespace lemon {
    1.19  
    1.20    // \ingroup graphbits
    1.21    //
    1.22 -  // \brief Extender for the Digraphs
    1.23 +  // \brief Extender for the digraph implementations
    1.24    template <typename Base>
    1.25    class DigraphExtender : public Base {
    1.26 +    typedef Base Parent;
    1.27 +
    1.28    public:
    1.29  
    1.30 -    typedef Base Parent;
    1.31      typedef DigraphExtender Digraph;
    1.32  
    1.33      // Base extensions
    1.34 @@ -55,11 +56,11 @@
    1.35        return Parent::maxArcId();
    1.36      }
    1.37  
    1.38 -    Node fromId(int id, Node) const {
    1.39 +    static Node fromId(int id, Node) {
    1.40        return Parent::nodeFromId(id);
    1.41      }
    1.42  
    1.43 -    Arc fromId(int id, Arc) const {
    1.44 +    static Arc fromId(int id, Arc) {
    1.45        return Parent::arcFromId(id);
    1.46      }
    1.47  
    1.48 @@ -218,10 +219,9 @@
    1.49      template <typename _Value>
    1.50      class NodeMap
    1.51        : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
    1.52 -    public:
    1.53 -      typedef DigraphExtender Digraph;
    1.54        typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
    1.55  
    1.56 +    public:
    1.57        explicit NodeMap(const Digraph& digraph)
    1.58          : Parent(digraph) {}
    1.59        NodeMap(const Digraph& digraph, const _Value& value)
    1.60 @@ -243,10 +243,9 @@
    1.61      template <typename _Value>
    1.62      class ArcMap
    1.63        : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
    1.64 -    public:
    1.65 -      typedef DigraphExtender Digraph;
    1.66        typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
    1.67  
    1.68 +    public:
    1.69        explicit ArcMap(const Digraph& digraph)
    1.70          : Parent(digraph) {}
    1.71        ArcMap(const Digraph& digraph, const _Value& value)
    1.72 @@ -330,9 +329,10 @@
    1.73    // \brief Extender for the Graphs
    1.74    template <typename Base>
    1.75    class GraphExtender : public Base {
    1.76 +    typedef Base Parent;
    1.77 +
    1.78    public:
    1.79  
    1.80 -    typedef Base Parent;
    1.81      typedef GraphExtender Graph;
    1.82  
    1.83      typedef True UndirectedTag;
    1.84 @@ -355,15 +355,15 @@
    1.85        return Parent::maxEdgeId();
    1.86      }
    1.87  
    1.88 -    Node fromId(int id, Node) const {
    1.89 +    static Node fromId(int id, Node) {
    1.90        return Parent::nodeFromId(id);
    1.91      }
    1.92  
    1.93 -    Arc fromId(int id, Arc) const {
    1.94 +    static Arc fromId(int id, Arc) {
    1.95        return Parent::arcFromId(id);
    1.96      }
    1.97  
    1.98 -    Edge fromId(int id, Edge) const {
    1.99 +    static Edge fromId(int id, Edge) {
   1.100        return Parent::edgeFromId(id);
   1.101      }
   1.102  
   1.103 @@ -601,11 +601,10 @@
   1.104      template <typename _Value>
   1.105      class NodeMap
   1.106        : public MapExtender<DefaultMap<Graph, Node, _Value> > {
   1.107 -    public:
   1.108 -      typedef GraphExtender Graph;
   1.109        typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
   1.110  
   1.111 -      NodeMap(const Graph& graph)
   1.112 +    public:
   1.113 +      explicit NodeMap(const Graph& graph)
   1.114          : Parent(graph) {}
   1.115        NodeMap(const Graph& graph, const _Value& value)
   1.116          : Parent(graph, value) {}
   1.117 @@ -626,11 +625,10 @@
   1.118      template <typename _Value>
   1.119      class ArcMap
   1.120        : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
   1.121 -    public:
   1.122 -      typedef GraphExtender Graph;
   1.123        typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
   1.124  
   1.125 -      ArcMap(const Graph& graph)
   1.126 +    public:
   1.127 +      explicit ArcMap(const Graph& graph)
   1.128          : Parent(graph) {}
   1.129        ArcMap(const Graph& graph, const _Value& value)
   1.130          : Parent(graph, value) {}
   1.131 @@ -651,11 +649,10 @@
   1.132      template <typename _Value>
   1.133      class EdgeMap
   1.134        : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
   1.135 -    public:
   1.136 -      typedef GraphExtender Graph;
   1.137        typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
   1.138  
   1.139 -      EdgeMap(const Graph& graph)
   1.140 +    public:
   1.141 +      explicit EdgeMap(const Graph& graph)
   1.142          : Parent(graph) {}
   1.143  
   1.144        EdgeMap(const Graph& graph, const _Value& value)