src/work/deba/test_graph.h
changeset 571 9632ea8be6ca
parent 378 c3f93631cd24
child 595 e10b5e9419ef
equal deleted inserted replaced
3:160327cb4167 4:65341eb0b543
     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 "vector_map.h"
    10 #include "vector_map_factory.h"
    11 
    11 
    12 namespace hugo {
    12 namespace hugo {
    13 
    13 
    14   template <typename It>
    14   template <typename It>
    15   int count(It it) { 
    15   int count(It it) { 
    36 //    template <typename T> friend class NodeMap;
    36 //    template <typename T> friend class NodeMap;
    37  //   template <typename T> friend class EdgeMap;
    37  //   template <typename T> friend class EdgeMap;
    38  
    38  
    39   private:
    39   private:
    40 
    40 
       
    41  
       
    42 	public:
       
    43 	
    41 		typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
    44 		typedef MapRegistry<ListGraph, Node, NodeIt> NodeMapRegistry;
    42 		NodeMapRegistry node_maps;
    45 		NodeMapRegistry node_maps;
    43 		
    46 		
       
    47 		
    44 		typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
    48 		typedef MapRegistry<ListGraph, Edge, EdgeIt> EdgeMapRegistry;
    45 		EdgeMapRegistry edge_maps;
    49 		EdgeMapRegistry edge_maps;
       
    50 
       
    51 		typedef VectorMapFactory<ListGraph, Edge, EdgeIt> EdgeMapFactory;
       
    52 		typedef VectorMapFactory<ListGraph, Node, NodeIt> NodeMapFactory;
    46  
    53  
    47 	public:
       
    48  
       
    49 
       
    50     template <typename T>
       
    51     class NodeMap : public VectorMap<ListGraph, Node, NodeIt, T> {
       
    52 		public:
       
    53 			NodeMap(ListGraph& g) : VectorMap<ListGraph, Node, NodeIt, T>(g.node_maps) {}
       
    54 		};
       
    55 		
       
    56     template <typename T>
       
    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 
       
    62 
    54 
    63     int node_id;
    55     int node_id;
    64     int edge_id;
    56     int edge_id;
    65     int _node_num;
    57     int _node_num;
    66     int _edge_num;
    58     int _edge_num;
   213 
   205 
   214   public:
   206   public:
   215 
   207 
   216     /* default constructor */
   208     /* default constructor */
   217 
   209 
   218     ListGraph() : node_id(0), edge_id(0), _node_num(0), _edge_num(0), _first_node(0), _last_node(0),
   210     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) { }
       
   220     
   211     
   221     ~ListGraph() { 
   212     ~ListGraph() { 
   222       while (first<NodeIt>().valid()) erase(first<NodeIt>());
   213       while (first<NodeIt>().valid()) erase(first<NodeIt>());
   223     }
   214     }
   224 
   215