1 #ifndef MARCI_PROPERTY_VECTOR_HH
2 #define MARCI_PROPERTY_VECTOR_HH
6 #include <marci_graph_traits.hh>
10 template <typename iterator>
11 int number_of(iterator _it) {
13 for( ; _it.is_valid(); ++_it) { ++i; }
17 template <typename graph_type, typename T>
18 class node_property_vector {
19 typedef typename graph_traits<graph_type>::node_iterator node_iterator;
20 typedef typename graph_traits<graph_type>::each_node_iterator each_node_iterator;
22 std::vector<T> container;
24 node_property_vector(graph_type& _G) : G(_G) {
26 for(each_node_iterator it=G.first_node(); it.is_valid(); ++it) ++i;
29 node_property_vector(graph_type& _G, T a) : G(_G) {
30 for(each_node_iterator it=G.first_node(); it.is_valid(); ++it) { container.push_back(a); }
32 void put(node_iterator nit, const T& a) { container[G.id(nit)]=a; }
33 T get(node_iterator nit) { return container[G.id(nit)]; }
36 template <typename graph_type, typename T>
37 class edge_property_vector {
38 typedef typename graph_traits<graph_type>::edge_iterator edge_iterator;
39 typedef typename graph_traits<graph_type>::each_edge_iterator each_edge_iterator;
41 std::vector<T> container;
43 edge_property_vector(graph_type& _G) : G(_G) {
45 for(each_edge_iterator it=G.first_edge(); it.is_valid(); ++it) ++i;
48 edge_property_vector(graph_type& _G, T a) : G(_G) {
49 for(each_edge_iterator it=G.first_edge(); it.is_valid(); ++it) {
50 container.push_back(a);
53 void put(edge_iterator eit, const T& a) { container[G.id(eit)]=a; }
54 T get(edge_iterator eit) { return container[G.id(eit)]; }
59 #endif //MARCI_PROPERTY_VECTOR_HH