src/lemon/idmappable_graph_extender.h
author alpar
Tue, 09 Nov 2004 17:48:52 +0000
changeset 973 6a6f3ac07b20
permissions -rw-r--r--
- Add makeSnapshot()/rollBack() functionality
- Remove an unnecessary #include
klao@946
     1
// -*- c++ -*-
klao@946
     2
klao@946
     3
#ifndef LEMON_IDMAPPABLE_GRAPH_EXTENDER_H
klao@946
     4
#define LEMON_IDMAPPABLE_GRAPH_EXTENDER_H
klao@946
     5
klao@946
     6
klao@946
     7
namespace lemon {
klao@946
     8
klao@946
     9
  template <typename Base> 
klao@946
    10
  class IdMappableGraphExtender : public Base {
klao@946
    11
  public:
klao@946
    12
klao@946
    13
    typedef IdMappableGraphExtender Graph;
klao@946
    14
    typedef Base Parent;
klao@946
    15
 
klao@946
    16
    typedef typename Parent::Node Node;
klao@946
    17
    typedef typename Parent::Edge Edge;
klao@946
    18
klao@946
    19
klao@946
    20
  public:
klao@946
    21
klao@946
    22
    class NodeIdMap {
klao@946
    23
    private:
klao@946
    24
      const Graph* graph;
klao@946
    25
klao@946
    26
    public:
klao@946
    27
      NodeIdMap(const Graph& g) : graph(&g) {}
klao@946
    28
klao@946
    29
      int operator[](const Node& node) const { return graph->id(node); }
klao@946
    30
klao@946
    31
      int maxId() const {return graph->maxNodeId(); }
klao@946
    32
klao@946
    33
    };
klao@946
    34
klao@946
    35
    class EdgeIdMap {
klao@946
    36
    private:
klao@946
    37
      const Graph* graph;
klao@946
    38
klao@946
    39
    public:
klao@946
    40
      EdgeIdMap(const Graph& g) : graph(&g) {}
klao@946
    41
klao@946
    42
      int operator[](const Edge& edge) const { return graph->id(edge); }
klao@946
    43
klao@946
    44
      int maxId() const {return graph->maxEdgeId(); }
klao@946
    45
klao@946
    46
    };
klao@946
    47
klao@946
    48
  };
klao@946
    49
klao@946
    50
}
klao@946
    51
klao@946
    52
#endif