src/lemon/idmappable_graph_extender.h
changeset 953 d9c115e2eeaf
equal deleted inserted replaced
-1:000000000000 0:210bcd8fc184
       
     1 // -*- c++ -*-
       
     2 
       
     3 #ifndef LEMON_IDMAPPABLE_GRAPH_EXTENDER_H
       
     4 #define LEMON_IDMAPPABLE_GRAPH_EXTENDER_H
       
     5 
       
     6 
       
     7 namespace lemon {
       
     8 
       
     9   template <typename Base> 
       
    10   class IdMappableGraphExtender : public Base {
       
    11   public:
       
    12 
       
    13     typedef IdMappableGraphExtender Graph;
       
    14     typedef Base Parent;
       
    15  
       
    16     typedef typename Parent::Node Node;
       
    17     typedef typename Parent::Edge Edge;
       
    18 
       
    19 
       
    20   public:
       
    21 
       
    22     class NodeIdMap {
       
    23     private:
       
    24       const Graph* graph;
       
    25 
       
    26     public:
       
    27       NodeIdMap(const Graph& g) : graph(&g) {}
       
    28 
       
    29       int operator[](const Node& node) const { return graph->id(node); }
       
    30 
       
    31       int maxId() const {return graph->maxNodeId(); }
       
    32 
       
    33     };
       
    34 
       
    35     class EdgeIdMap {
       
    36     private:
       
    37       const Graph* graph;
       
    38 
       
    39     public:
       
    40       EdgeIdMap(const Graph& g) : graph(&g) {}
       
    41 
       
    42       int operator[](const Edge& edge) const { return graph->id(edge); }
       
    43 
       
    44       int maxId() const {return graph->maxEdgeId(); }
       
    45 
       
    46     };
       
    47 
       
    48   };
       
    49 
       
    50 }
       
    51 
       
    52 #endif