[9] | 1 | #ifndef MARCI_PROPERTY_VECTOR_HH |
---|

| 2 | #define MARCI_PROPERTY_VECTOR_HH |
---|

| 3 | |
---|

| 4 | #include <vector> |
---|

| 5 | |
---|

| 6 | namespace marci { |
---|

| 7 | |
---|

| 8 | template <typename iterator> |
---|

| 9 | int number_of(iterator _it) { |
---|

| 10 | int i=0; |
---|

[19] | 11 | for( ; _it.valid(); ++_it) { ++i; } |
---|

[9] | 12 | return i; |
---|

| 13 | } |
---|

| 14 | |
---|

| 15 | template <typename graph_type, typename T> |
---|

| 16 | class node_property_vector { |
---|

[19] | 17 | typedef typename list_graph::node_iterator node_iterator; |
---|

| 18 | typedef typename list_graph::each_node_iterator each_node_iterator; |
---|

[9] | 19 | graph_type& G; |
---|

| 20 | std::vector<T> container; |
---|

| 21 | public: |
---|

| 22 | node_property_vector(graph_type& _G) : G(_G) { |
---|

| 23 | int i=0; |
---|

[19] | 24 | for(each_node_iterator it=G.first_node(); it.valid(); ++it) ++i; |
---|

[9] | 25 | container.resize(i); |
---|

| 26 | } |
---|

| 27 | node_property_vector(graph_type& _G, T a) : G(_G) { |
---|

[19] | 28 | for(each_node_iterator it=G.first_node(); it.valid(); ++it) { container.push_back(a); } |
---|

[9] | 29 | } |
---|

| 30 | void put(node_iterator nit, const T& a) { container[G.id(nit)]=a; } |
---|

| 31 | T get(node_iterator nit) { return container[G.id(nit)]; } |
---|

| 32 | }; |
---|

| 33 | |
---|

| 34 | template <typename graph_type, typename T> |
---|

| 35 | class edge_property_vector { |
---|

[19] | 36 | typedef typename graph_type::edge_iterator edge_iterator; |
---|

| 37 | typedef typename graph_type::each_edge_iterator each_edge_iterator; |
---|

[9] | 38 | graph_type& G; |
---|

| 39 | std::vector<T> container; |
---|

| 40 | public: |
---|

| 41 | edge_property_vector(graph_type& _G) : G(_G) { |
---|

| 42 | int i=0; |
---|

[19] | 43 | for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) ++i; |
---|

[9] | 44 | container.resize(i); |
---|

| 45 | } |
---|

| 46 | edge_property_vector(graph_type& _G, T a) : G(_G) { |
---|

[19] | 47 | for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) { |
---|

[9] | 48 | container.push_back(a); |
---|

| 49 | } |
---|

| 50 | } |
---|

| 51 | void put(edge_iterator eit, const T& a) { container[G.id(eit)]=a; } |
---|

| 52 | T get(edge_iterator eit) { return container[G.id(eit)]; } |
---|

| 53 | }; |
---|

| 54 | |
---|

| 55 | } // namespace marci |
---|

| 56 | |
---|

| 57 | #endif //MARCI_PROPERTY_VECTOR_HH |
---|