src/work/deba/test_graph.h
changeset 522 a0ed1fa1b800
parent 377 33fe0ee01dc5
child 571 9632ea8be6ca
equal deleted inserted replaced
2:ad2c6cfd5763 3:160327cb4167
     5 #include <iostream>
     5 #include <iostream>
     6 #include <vector>
     6 #include <vector>
     7 
     7 
     8 #include "invalid.h"
     8 #include "invalid.h"
     9 
     9 
    10 #include "edge_map_registry.h"
       
    11 #include "node_map_registry.h"
       
    12 #include "edge_map_base.h"
       
    13 #include "node_map_base.h"
       
    14 #include "vector_map.h"
    10 #include "vector_map.h"
    15 
    11 
    16 namespace hugo {
    12 namespace hugo {
    17 
    13 
    18   template <typename It>
    14   template <typename It>
    40 //    template <typename T> friend class NodeMap;
    36 //    template <typename T> friend class NodeMap;
    41  //   template <typename T> friend class EdgeMap;
    37  //   template <typename T> friend class EdgeMap;
    42  
    38  
    43   private:
    39   private:
    44 
    40 
    45 		NodeMapRegistry<ListGraph, Node> node_maps(*this);
    41 		typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
    46 		EdgeMapRegistry<ListGraph, Edge> edge_maps(*this);
    42 		NodeMapRegistry node_maps;
       
    43 		
       
    44 		typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
       
    45 		EdgeMapRegistry edge_maps;
    47  
    46  
    48 	public:
    47 	public:
    49  
    48  
    50 
    49 
    51     template <typename T>
    50     template <typename T>
    52     class NodeMap : public VectorMap<ListGraph, Node, T, NodeMapBase> {
    51     class NodeMap : public VectorMap<ListGraph, Node, NodeIt, T> {
    53 		public:
    52 		public:
    54 			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, T, NodeMapBase>(g) {}
    53 			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, NodeIt, T>(g.node_maps) {}
    55 		};
    54 		};
    56 		
    55 		
    57 		EdgeMapRegistry<ListGraph, Edge> edge_maps;
       
    58 
       
    59     template <typename T>
    56     template <typename T>
    60     class EdgeMap : public VectorMap<ListGraph, Edge, T, EdgeMapBase> {};
    57     class EdgeMap : public VectorMap<ListGraph, Edge, EdgeIt, T> {
       
    58 		public:
       
    59 			EdgeMap(ListGraph& g) : VectorMap<ListGraph, Edge, EdgeIt, T>(g.edge_maps) {}
       
    60 		};
    61 
    61 
    62 
    62 
    63     int node_id;
    63     int node_id;
    64     int edge_id;
    64     int edge_id;
    65     int _node_num;
    65     int _node_num;
   213 
   213 
   214   public:
   214   public:
   215 
   215 
   216     /* default constructor */
   216     /* default constructor */
   217 
   217 
   218     ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0) { }
   218     ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0),
       
   219 			edge_maps(*this), node_maps(*this) { }
   219     
   220     
   220     ~ListGraph() { 
   221     ~ListGraph() { 
   221       while (first<NodeIt>().valid()) erase(first<NodeIt>());
   222       while (first<NodeIt>().valid()) erase(first<NodeIt>());
   222     }
   223     }
   223 
   224