Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50534 - in trunk: boost/graph libs/graph/test
From: asutton_at_[hidden]
Date: 2009-01-10 09:46:37


Author: asutton
Date: 2009-01-10 09:46:36 EST (Sat, 10 Jan 2009)
New Revision: 50534
URL: http://svn.boost.org/trac/boost/changeset/50534

Log:
Patch from Dmitry Bufistov for getting bundled property maps from subgraphs.

Text files modified:
   trunk/boost/graph/subgraph.hpp | 15 +++++++++++++++
   trunk/libs/graph/test/subgraph_bundled.cpp | 20 ++++++++++++++------
   2 files changed, 29 insertions(+), 6 deletions(-)

Modified: trunk/boost/graph/subgraph.hpp
==============================================================================
--- trunk/boost/graph/subgraph.hpp (original)
+++ trunk/boost/graph/subgraph.hpp 2009-01-10 09:46:36 EST (Sat, 10 Jan 2009)
@@ -81,6 +81,8 @@
 
     typedef typename Graph::edge_property_type edge_property_type;
     typedef typename Graph::vertex_property_type vertex_property_type;
+ typedef typename Graph::vertex_bundled vertex_bundled;
+ typedef typename Graph::edge_bundled edge_bundled;
     typedef subgraph_tag graph_tag;
     typedef Graph graph_type;
     typedef typename Graph::graph_property_type graph_property_type;
@@ -837,6 +839,19 @@
     return pmap[k];
   }
 
+#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
+ template<typename TG, typename T, typename Bundle>
+ inline
+ typename property_map<subgraph<TG>, T Bundle::*>::type
+ get(T Bundle::* p, subgraph<TG>& sg)
+ {
+ typedef typename property_map<subgraph<TG>, T Bundle::*>::type
+ result_type;
+ return result_type(&sg, p);
+ }
+
+#endif
+
   template <typename G, typename Property, typename Key, typename Value>
   void
   put(Property, subgraph<G>& g, const Key& k, const Value& val)

Modified: trunk/libs/graph/test/subgraph_bundled.cpp
==============================================================================
--- trunk/libs/graph/test/subgraph_bundled.cpp (original)
+++ trunk/libs/graph/test/subgraph_bundled.cpp 2009-01-10 09:46:36 EST (Sat, 10 Jan 2009)
@@ -37,6 +37,8 @@
 typedef subgraph<Graph> Subgraph;
 typedef graph_traits<Subgraph>::vertex_descriptor Vertex;
 typedef graph_traits<Subgraph>::edge_descriptor Edge;
+typedef graph_traits<Subgraph>::vertex_iterator VertexIter;
+typedef graph_traits<Subgraph>::edge_iterator EdgeIter;
 
 int test_main(int argc, char* argv[])
 {
@@ -99,12 +101,18 @@
     if (num_vertices(g_s) == 0)
       return 0;
 
- // The testing of properties is completely broken (in graph_test) with
- // respect to bundled (or even generic) properties.
- // std::vector<int> weights;
- // for (unsigned i = 0; i < num_vertices(g_s); ++i)
- // weights.push_back(i*2);
- // gt.test_vertex_property_graph(weights, vertex_color_t(), g_s);
+ // Test property maps for vertices.
+ typedef property_map<Subgraph, int node::*>::type ColorMap;
+ ColorMap colors = get(&node::color, g_s);
+ for(std::pair<VertexIter, VertexIter> r = vertices(g_s); r.first != r.second; ++r.first)
+ colors[*r.first] = 0;
+
+ // Test property maps for edges.
+ typedef property_map<Subgraph, int arc::*>::type WeightMap;
+ WeightMap weights = get(&arc::weight, g_s);
+ for(std::pair<EdgeIter, EdgeIter> r = edges(g_s); r.first != r.second; ++r.first) {
+ weights[*r.first] = 12;
+ }
 
     // A regression test: the copy constructor of subgraph did not
     // copy one of the members, so local_edge->global_edge mapping


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk