klao@946
|
1 |
// -*- c++ -*-
|
klao@946
|
2 |
|
klao@946
|
3 |
#ifndef LEMON_MAPPABLE_GRAPH_EXTENDER_H
|
klao@946
|
4 |
#define LEMON_MAPPABLE_GRAPH_EXTENDER_H
|
klao@946
|
5 |
|
klao@946
|
6 |
namespace lemon {
|
klao@946
|
7 |
|
klao@946
|
8 |
template <typename Base, template <class,class,class,class,class,class> class DynMap>
|
klao@946
|
9 |
class MappableGraphExtender : public Base {
|
klao@946
|
10 |
public:
|
klao@946
|
11 |
|
klao@946
|
12 |
typedef MappableGraphExtender Graph;
|
klao@946
|
13 |
typedef Base Parent;
|
klao@946
|
14 |
|
klao@946
|
15 |
typedef typename Parent::Node Node;
|
klao@946
|
16 |
typedef typename Parent::NodeIt NodeIt;
|
klao@946
|
17 |
typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
|
klao@946
|
18 |
|
klao@946
|
19 |
typedef typename Parent::Edge Edge;
|
klao@946
|
20 |
typedef typename Parent::EdgeIt EdgeIt;
|
klao@946
|
21 |
typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
|
klao@946
|
22 |
|
klao@946
|
23 |
public:
|
klao@946
|
24 |
|
klao@946
|
25 |
class NodeIdMap {
|
klao@946
|
26 |
private:
|
klao@946
|
27 |
const Graph* graph;
|
klao@946
|
28 |
|
klao@946
|
29 |
public:
|
klao@946
|
30 |
NodeIdMap(const Graph& g) : graph(&g) {}
|
klao@946
|
31 |
|
klao@946
|
32 |
int operator[](const Node& node) { return graph->id(node); }
|
klao@946
|
33 |
|
klao@946
|
34 |
int maxId() const {return graph->maxNodeId(); }
|
klao@946
|
35 |
|
klao@946
|
36 |
};
|
klao@946
|
37 |
|
klao@946
|
38 |
// template <typename Value>
|
klao@946
|
39 |
// friend class DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
|
klao@946
|
40 |
// NodeIdMap, Value>;
|
klao@946
|
41 |
|
klao@946
|
42 |
class EdgeIdMap {
|
klao@946
|
43 |
private:
|
klao@946
|
44 |
const Graph* graph;
|
klao@946
|
45 |
|
klao@946
|
46 |
public:
|
klao@946
|
47 |
EdgeIdMap(const Graph& g) : graph(&g) {}
|
klao@946
|
48 |
|
klao@946
|
49 |
int operator[](const Edge& edge) const { return graph->id(edge); }
|
klao@946
|
50 |
|
klao@946
|
51 |
int maxId() const {return graph->maxEdgeId(); }
|
klao@946
|
52 |
|
klao@946
|
53 |
};
|
klao@946
|
54 |
|
klao@946
|
55 |
// template <typename Value>
|
klao@946
|
56 |
// friend class DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
|
klao@946
|
57 |
// EdgeIdMap, Value>;
|
klao@946
|
58 |
|
klao@946
|
59 |
public:
|
klao@946
|
60 |
|
klao@946
|
61 |
template <typename Value>
|
klao@946
|
62 |
class NodeMap
|
klao@946
|
63 |
: public DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
|
klao@946
|
64 |
NodeIdMap, Value> {
|
klao@946
|
65 |
public:
|
klao@946
|
66 |
typedef DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
|
klao@946
|
67 |
NodeIdMap, Value> Parent;
|
klao@946
|
68 |
|
klao@946
|
69 |
NodeMap(const Graph& g)
|
klao@946
|
70 |
: Parent(g, g.Graph::Parent::getNodeObserverRegistry()) {}
|
klao@946
|
71 |
NodeMap(const Graph& g, const Value& v)
|
klao@946
|
72 |
: Parent(g, g.Graph::Parent::getNodeObserverRegistry(), v) {}
|
klao@946
|
73 |
|
klao@946
|
74 |
};
|
klao@946
|
75 |
|
klao@946
|
76 |
template <typename Value>
|
klao@946
|
77 |
class EdgeMap
|
klao@946
|
78 |
: public DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
|
klao@946
|
79 |
EdgeIdMap, Value> {
|
klao@946
|
80 |
public:
|
klao@946
|
81 |
typedef DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
|
klao@946
|
82 |
EdgeIdMap, Value> Parent;
|
klao@946
|
83 |
|
klao@946
|
84 |
EdgeMap(const Graph& g)
|
klao@946
|
85 |
: Parent(g, g.Graph::Parent::getEdgeObserverRegistry()) {}
|
klao@946
|
86 |
EdgeMap(const Graph& g, const Value& v)
|
klao@946
|
87 |
: Parent(g, g.Graph::Parent::getEdgeObserverRegistry(), v) {}
|
klao@946
|
88 |
|
klao@946
|
89 |
};
|
klao@946
|
90 |
|
klao@946
|
91 |
|
klao@946
|
92 |
};
|
klao@946
|
93 |
|
klao@946
|
94 |
}
|
klao@946
|
95 |
|
klao@946
|
96 |
#endif
|
klao@946
|
97 |
|