marci@9: #ifndef MARCI_PROPERTY_VECTOR_HH marci@9: #define MARCI_PROPERTY_VECTOR_HH marci@9: marci@9: #include marci@9: marci@9: #include marci@9: marci@9: namespace marci { marci@9: marci@9: template marci@9: int number_of(iterator _it) { marci@9: int i=0; marci@9: for( ; _it.is_valid(); ++_it) { ++i; } marci@9: return i; marci@9: } marci@9: marci@9: template marci@9: class node_property_vector { marci@9: typedef typename graph_traits::node_iterator node_iterator; marci@9: typedef typename graph_traits::each_node_iterator each_node_iterator; marci@9: graph_type& G; marci@9: std::vector container; marci@9: public: marci@9: node_property_vector(graph_type& _G) : G(_G) { marci@9: int i=0; marci@9: for(each_node_iterator it=G.first_node(); it.is_valid(); ++it) ++i; marci@9: container.resize(i); marci@9: } marci@9: node_property_vector(graph_type& _G, T a) : G(_G) { marci@9: for(each_node_iterator it=G.first_node(); it.is_valid(); ++it) { container.push_back(a); } marci@9: } marci@9: void put(node_iterator nit, const T& a) { container[G.id(nit)]=a; } marci@9: T get(node_iterator nit) { return container[G.id(nit)]; } marci@9: }; marci@9: marci@9: template marci@9: class edge_property_vector { marci@9: typedef typename graph_traits::edge_iterator edge_iterator; marci@9: typedef typename graph_traits::each_edge_iterator each_edge_iterator; marci@9: graph_type& G; marci@9: std::vector container; marci@9: public: marci@9: edge_property_vector(graph_type& _G) : G(_G) { marci@9: int i=0; marci@9: for(each_edge_iterator it=G.first_edge(); it.is_valid(); ++it) ++i; marci@9: container.resize(i); marci@9: } marci@9: edge_property_vector(graph_type& _G, T a) : G(_G) { marci@9: for(each_edge_iterator it=G.first_edge(); it.is_valid(); ++it) { marci@9: container.push_back(a); marci@9: } marci@9: } marci@9: void put(edge_iterator eit, const T& a) { container[G.id(eit)]=a; } marci@9: T get(edge_iterator eit) { return container[G.id(eit)]; } marci@9: }; marci@9: marci@9: } // namespace marci marci@9: marci@9: #endif //MARCI_PROPERTY_VECTOR_HH