Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r82441 - trunk/libs/graph/example
From: jewillco_at_[hidden]
Date: 2013-01-10 17:51:54


Author: jewillco
Date: 2013-01-10 17:51:53 EST (Thu, 10 Jan 2013)
New Revision: 82441
URL: http://svn.boost.org/trac/boost/changeset/82441

Log:
Removed obsolete workarounds and changed to iterator_property_map; refs #7877
Text files modified:
   trunk/libs/graph/example/dijkstra-no-color-map-example.cpp | 25 ++++---------------------
   1 files changed, 4 insertions(+), 21 deletions(-)

Modified: trunk/libs/graph/example/dijkstra-no-color-map-example.cpp
==============================================================================
--- trunk/libs/graph/example/dijkstra-no-color-map-example.cpp (original)
+++ trunk/libs/graph/example/dijkstra-no-color-map-example.cpp 2013-01-10 17:51:53 EST (Thu, 10 Jan 2013)
@@ -16,6 +16,7 @@
 #include <boost/graph/graph_traits.hpp>
 #include <boost/graph/adjacency_list.hpp>
 #include <boost/graph/dijkstra_shortest_paths_no_color_map.hpp>
+#include <boost/property_map/property_map.hpp>
 
 using namespace boost;
 
@@ -36,33 +37,15 @@
   };
   int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 };
   int num_arcs = sizeof(edge_array) / sizeof(Edge);
-#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
- graph_t g(num_nodes);
- property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
- for (std::size_t j = 0; j < num_arcs; ++j) {
- edge_descriptor e; bool inserted;
- boost::tie(e, inserted) = add_edge(edge_array[j].first, edge_array[j].second, g);
- weightmap[e] = weights[j];
- }
-#else
   graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes);
   property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
-#endif
   std::vector<vertex_descriptor> p(num_vertices(g));
   std::vector<int> d(num_vertices(g));
   vertex_descriptor s = vertex(A, g);
 
-#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
- // VC++ has trouble with the named parameters mechanism
- property_map<graph_t, vertex_index_t>::type indexmap = get(vertex_index, g);
- dijkstra_shortest_paths_no_color_map(g, s, &p[0], &d[0], weightmap,
- indexmap, std::less<int>(),
- closed_plus<int>(),
- (std::numeric_limits<int>::max)(), 0,
- default_dijkstra_visitor());
-#else
- dijkstra_shortest_paths_no_color_map(g, s, predecessor_map(&p[0]).distance_map(&d[0]));
-#endif
+ dijkstra_shortest_paths_no_color_map(g, s,
+ predecessor_map(boost::make_iterator_property_map(p.begin(), get(boost::vertex_index, g))).
+ distance_map(boost::make_iterator_property_map(d.begin(), get(boost::vertex_index, g))));
 
   std::cout << "distances and parents:" << std::endl;
   graph_traits < graph_t >::vertex_iterator vi, vend;


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