6 template <typename GB, typename K>
10 class MappedGraph : public GB {
14 typedef MapBase<GB, typename GB::Edge> EdgeMapBase;
15 typedef MapBase<GB, typename GB::Node> NodeMapBase;
18 typedef std::vector<EdgeMapBase*> EdgeMaps;
19 typedef std::vector<NodeMapBase*> NodeMaps;
24 void add(EdgeMapBase& map_base) {
26 map_base.graph->erase(map_base);
28 edge_maps.push_back(&map_base);
29 map_base.graph_index = map_base.size()-1;
32 void erase(EdgeMapBase& map_base) {
33 if (map_base.graph != this) return;
34 edge_maps.back()->graph_index = map_base.graph_index;
35 edge_maps[map_base.graph_index] = edge_maps.back();
40 void addEdge(typename GB::Edge& edge) {
41 typename EdgeMaps::iterator it;
42 for (it = edge_maps.begin(); it != edge_maps.end(); ++it) {
47 void eraseEdge(typename GB::Edge& edge) {
48 typename EdgeMaps::iterator it;
49 for (it = edge_maps.begin(); it != edge_maps.end(); ++it) {
54 void add(NodeMapBase& map_base) {
56 map_base.graph->erase(map_base);
58 node_maps.push_back(&map_base);
59 map_base.graph_index = node_maps.size()-1;
62 void erase(NodeMapBase& map_base) {
63 if (map_base.graph != this) return;
64 node_maps.back()->graph_index = map_base.graph_index;
65 node_maps[map_base.graph_index] = node_maps.back();
70 void addNode(typename GB::Node& node) {
71 typename NodeMaps::iterator it;
72 for (it = node_maps.begin(); it != node_maps.end(); ++it) {
77 void eraseNode(typename GB::Node& node) {
78 typename NodeMaps::iterator it;
79 for (it = node_maps.begin(); it != node_maps.end(); ++it) {
84 friend class EdgeMapBase;
85 friend class NodeMapBase;