Step toward to a standardised graph interface.
1 #ifndef MARCI_PROPERTY_VECTOR_HH
2 #define MARCI_PROPERTY_VECTOR_HH
8 template <typename iterator>
9 int number_of(iterator _it) {
11 for( ; _it.valid(); ++_it) { ++i; }
15 template <typename graph_type, typename T>
16 class node_property_vector {
17 typedef typename graph_type::node_iterator node_iterator;
18 typedef typename graph_type::each_node_iterator each_node_iterator;
20 std::vector<T> container;
22 node_property_vector(graph_type& _G) : G(_G) {
24 for(each_node_iterator it=G.first_node(); it.valid(); ++it) ++i;
27 node_property_vector(graph_type& _G, T a) : G(_G) {
28 for(each_node_iterator it=G.first_node(); it.valid(); ++it) { container.push_back(a); }
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)]; }
34 template <typename graph_type, typename T>
35 class edge_property_vector {
36 typedef typename graph_type::edge_iterator edge_iterator;
37 typedef typename graph_type::each_edge_iterator each_edge_iterator;
39 std::vector<T> container;
41 edge_property_vector(graph_type& _G) : G(_G) {
43 for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) ++i;
46 edge_property_vector(graph_type& _G, T a) : G(_G) {
47 for(each_edge_iterator it=G.first_edge(); it.valid(); ++it) {
48 container.push_back(a);
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)]; }
57 #endif //MARCI_PROPERTY_VECTOR_HH