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