Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2007-08-11 11:43:18


Author: asutton
Date: 2007-08-11 11:43:17 EDT (Sat, 11 Aug 2007)
New Revision: 38596
URL: http://svn.boost.org/trac/boost/changeset/38596

Log:
Adding test for constant property map

Added:
   sandbox/SOC/2007/graphs/libs/graph/test/constant_property_map.cpp (contents, props changed)

Added: sandbox/SOC/2007/graphs/libs/graph/test/constant_property_map.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/graphs/libs/graph/test/constant_property_map.cpp 2007-08-11 11:43:17 EDT (Sat, 11 Aug 2007)
@@ -0,0 +1,58 @@
+// (C) Copyright Andrew Sutton 2007
+//
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0 (See accompanying file
+// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+#include <iostream>
+#include <vector>
+
+#include <boost/graph/undirected_graph.hpp>
+#include <boost/graph/directed_graph.hpp>
+#include <boost/graph/exterior_property.hpp>
+#include <boost/graph/constant_property_map.hpp>
+#include <boost/graph/floyd_warshall_shortest.hpp>
+#include <boost/graph/closeness_centrality.hpp>
+#include "io.hpp"
+
+using namespace std;
+using namespace boost;
+
+// useful types
+// number of vertices in the graph
+static const unsigned N = 5;
+
+template <typename Graph>
+void build_graph(Graph& g)
+{
+ for(size_t i = 0; i < N; ++i) {
+ add_vertex(g);
+ }
+};
+
+
+template <typename Graph>
+void test()
+{
+ typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
+ typedef typename graph_traits<Graph>::vertex_iterator VertexIterator;
+
+ typedef constant_property_map<Vertex, int> Map;
+
+ Graph g;
+ build_graph(g);
+
+ Map m(1);
+
+ VertexIterator i, end;
+ for(tie(i, end) = vertices(g); i != end; ++i) {
+ BOOST_ASSERT(m[*i] == 1);
+ }
+}
+
+int
+main(int argc, char *argv[])
+{
+ typedef undirected_graph<> Graph;
+ test<Graph>();
+}


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