Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53286 - in trunk: boost/graph libs/graph/test
From: asutton_at_[hidden]
Date: 2009-05-26 16:06:09


Author: asutton
Date: 2009-05-26 16:06:07 EDT (Tue, 26 May 2009)
New Revision: 53286
URL: http://svn.boost.org/trac/boost/changeset/53286

Log:
Modifications to subgraph, graph testing framework.

Text files modified:
   trunk/boost/graph/subgraph.hpp | 17 ++++++++++++-----
   trunk/libs/graph/test/subgraph.cpp | 24 +++++++++++++++++++++++-
   trunk/libs/graph/test/test_construction.hpp | 25 +++++++++++++++++++++++++
   trunk/libs/graph/test/test_graph.hpp | 7 ++++++-
   trunk/libs/graph/test/test_graphs.cpp | 7 -------
   5 files changed, 66 insertions(+), 14 deletions(-)

Modified: trunk/boost/graph/subgraph.hpp
==============================================================================
--- trunk/boost/graph/subgraph.hpp (original)
+++ trunk/boost/graph/subgraph.hpp 2009-05-26 16:06:07 EDT (Tue, 26 May 2009)
@@ -41,10 +41,9 @@
   // assumed that the edge vertices are assigned automatically, they are
   // explicitly assigned here.
   //
- // NOTE [asutton]: The requirement of internal indexing causes this to fail
- // for many, many graphs (i.e., those of non-vecS storage, and using bundled
- // properties). To work around this - in part - you can do the following:
-
+ // NOTE: The requirement of internal indexing causes this to fail for many,
+ // many graphs (i.e., those of non-vecS storage, and using bundled
+ // properties).
   template <typename Graph>
   class subgraph {
     typedef graph_traits<Graph> Traits;
@@ -683,6 +682,15 @@
   }
 
   template <typename G>
+ typename subgraph<G>::vertex_descriptor
+ add_vertex(typename subgraph<G>::vertex_property_type const& vp,
+ subgraph<G>& g)
+ {
+ // UNDER CONSTRUCTION
+ assert(false);
+ }
+
+ template <typename G>
   void remove_vertex(typename subgraph<G>::vertex_descriptor u,
                      subgraph<G>& g)
   {
@@ -690,7 +698,6 @@
     assert(false);
   }
 
-
   //===========================================================================
   // Functions required by the PropertyGraph concept
 

Modified: trunk/libs/graph/test/subgraph.cpp
==============================================================================
--- trunk/libs/graph/test/subgraph.cpp (original)
+++ trunk/libs/graph/test/subgraph.cpp 2009-05-26 16:06:07 EDT (Tue, 26 May 2009)
@@ -12,9 +12,10 @@
 #include <boost/graph/random.hpp>
 #include <boost/graph/graph_test.hpp>
 #include <boost/graph/iteration_macros.hpp>
-
 #include <boost/random/mersenne_twister.hpp>
 
+#include "test_graph.hpp"
+
 // UNDER CONSTRUCTION
 
 int test_main(int argc, char* argv[])
@@ -110,6 +111,27 @@
         }
     }
 
+ // Bootstrap the test_graph framework.
+ // TODO: Subgraph is fundamentally broken for property types.
+ // TODO: Under construction.
+ {
+ using namespace boost;
+ typedef property<edge_index_t, size_t, EdgeBundle> EdgeProp;
+ typedef adjacency_list<vecS, vecS, directedS, VertexBundle, EdgeProp> BaseGraph;
+ typedef subgraph<BaseGraph> Graph;
+ typedef graph_traits<Graph>::vertex_descriptor Vertex;
+ Graph g;
+ Vertex v = add_vertex(g);
+
+ typedef property_map<Graph, int VertexBundle::*>::type BundleMap;
+ BundleMap map = get(&VertexBundle::value, g);
+ get(map, v);
+// put(map, v, 5);
+// BOOST_ASSERT(get(map, v) == 5);
+
+// test_graph(g);
+ return 0;
+ }
   }
   return 0;
 }

Modified: trunk/libs/graph/test/test_construction.hpp
==============================================================================
--- trunk/libs/graph/test/test_construction.hpp (original)
+++ trunk/libs/graph/test/test_construction.hpp 2009-05-26 16:06:07 EDT (Tue, 26 May 2009)
@@ -51,6 +51,31 @@
 }
 //@}
 
+/** @name Build Mutable
+ * For mutable property graphs, try to add a vertex with a property. This test
+ * actually builds a new graph - or at least tries to. We're not testing for
+ * labeled graphs since that's actually done in build_graph above.
+ */
+//@{
+template <typename Graph, typename Add, typename Label>
+void build_property_graph(Graph const& g, Add, Label)
+{ }
+
+template <typename Graph>
+void build_property_graph(Graph const& g, boost::mpl::true_, boost::mpl::false_) {
+ using namespace boost;
+ BOOST_CONCEPT_ASSERT((VertexMutablePropertyGraphConcept<Graph>));
+ typedef typename vertex_property<Graph>::type VertexProp;
+
+ std::cout << "...build mutable\n";
+
+ // Start with clean graph. Nothing really to assert. Just make sure it
+ // copmpiles.
+ Graph h;
+ add_vertex(VertexProp(), h);
+}
+//@}
+
 
 /** @name Connect Graph
  * Given a constructed graph, connect the edges to create a the standard

Modified: trunk/libs/graph/test/test_graph.hpp
==============================================================================
--- trunk/libs/graph/test/test_graph.hpp (original)
+++ trunk/libs/graph/test/test_graph.hpp 2009-05-26 16:06:07 EDT (Tue, 26 May 2009)
@@ -15,12 +15,15 @@
  * differentiate testable features of graph instances.
  */
 
+#include "typestr.hpp"
+
 #include <utility>
 #include <vector>
 #include <boost/assert.hpp>
+#include <boost/graph/graph_concepts.hpp>
 #include <boost/graph/graph_traits.hpp>
 #include <boost/graph/graph_mutability_traits.hpp>
-#include <boost/graph/graph_concepts.hpp>
+#include <boost/graph/labeled_graph.hpp>
 
 #define BOOST_META_ASSERT(x) BOOST_ASSERT(x::value)
 
@@ -101,6 +104,7 @@
 
     // Test constrution and vertex list.
     build_graph(g, can_add_vertex, is_labeled);
+ build_property_graph(g, can_add_vertex, is_labeled);
     test_vertex_list_graph(g);
 
     // Collect the vertices for an easy method of "naming" them.
@@ -114,6 +118,7 @@
 
     // Test connection and edge list
     connect_graph(g, verts, is_labeled);
+// connect_property_graph(g, verts, is_labeld);
     test_edge_list_graph(g);
 
     // Test properties

Modified: trunk/libs/graph/test/test_graphs.cpp
==============================================================================
--- trunk/libs/graph/test/test_graphs.cpp (original)
+++ trunk/libs/graph/test/test_graphs.cpp 2009-05-26 16:06:07 EDT (Tue, 26 May 2009)
@@ -151,12 +151,5 @@
         Graph g;
         test_graph(g);
     }
- {
- typedef property<edge_index_t, size_t, EdgeBundle> EdgeProp;
- typedef adjacency_list<vecS, vecS, directedS, VertexBundle, EdgeProp> BaseGraph;
- typedef subgraph<BaseGraph> Graph;
- Graph g;
- test_graph(g);
- }
 }
 


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