|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85655 - in trunk/libs/graph: example test
From: jewillco_at_[hidden]
Date: 2013-09-12 11:14:36
Author: jewillco
Date: 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013)
New Revision: 85655
URL: http://svn.boost.org/trac/boost/changeset/85655
Log:
Removed uses of pointers as property maps from tests and examples
Text files modified:
trunk/libs/graph/example/astar-cities.cpp | 3 ++-
trunk/libs/graph/example/bfs-example.cpp | 10 +++++++---
trunk/libs/graph/example/bfs-example2.cpp | 18 +++++++++++++++---
trunk/libs/graph/example/canonical_ordering.cpp | 8 ++++++--
trunk/libs/graph/example/dfs-example.cpp | 15 +++++++++------
trunk/libs/graph/example/implicit_graph.cpp | 10 ++++++++--
trunk/libs/graph/test/astar_search_test.cpp | 7 ++++++-
trunk/libs/graph/test/bellman-test.cpp | 10 ++++++----
trunk/libs/graph/test/bfs.cpp | 28 +++++++++++++++++++++++-----
trunk/libs/graph/test/boykov_kolmogorov_max_flow_test.cpp | 3 ++-
trunk/libs/graph/test/dfs.cpp | 25 ++++++++++++++++++++-----
trunk/libs/graph/test/dijkstra_heap_performance.cpp | 10 +++++++---
trunk/libs/graph/test/make_connected_test.cpp | 16 ++++++++++++----
trunk/libs/graph/test/successive_shortest_path_nonnegative_weights_test.cpp | 10 ++++++----
trunk/libs/graph/test/transitive_closure_test.cpp | 10 +++++-----
trunk/libs/graph/test/undirected_dfs.cpp | 25 ++++++++++++++++++++-----
16 files changed, 154 insertions(+), 54 deletions(-)
Modified: trunk/libs/graph/example/astar-cities.cpp
==============================================================================
--- trunk/libs/graph/example/astar-cities.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/example/astar-cities.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -195,7 +195,8 @@
(g, start,
distance_heuristic<mygraph_t, cost, location*>
(locations, goal),
- predecessor_map(&p[0]).distance_map(&d[0]).
+ predecessor_map(make_iterator_property_map(p.begin(), get(vertex_index, g))).
+ distance_map(make_iterator_property_map(d.begin(), get(vertex_index, g))).
visitor(astar_goal_visitor<vertex>(goal)));
Modified: trunk/libs/graph/example/bfs-example.cpp
==============================================================================
--- trunk/libs/graph/example/bfs-example.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/example/bfs-example.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -55,13 +55,17 @@
// Typedefs
typedef graph_traits < graph_t >::vertices_size_type Size;
- typedef Size* Iiter;
// a vector to hold the discover time property for each vertex
std::vector < Size > dtime(num_vertices(g));
+ typedef
+ iterator_property_map<std::vector<Size>::iterator,
+ property_map<graph_t, vertex_index_t>::const_type>
+ dtime_pm_type;
+ dtime_pm_type dtime_pm(dtime.begin(), get(vertex_index, g));
Size time = 0;
- bfs_time_visitor < Size * >vis(&dtime[0], time);
+ bfs_time_visitor < dtime_pm_type >vis(dtime_pm, time);
breadth_first_search(g, vertex(s, g), visitor(vis));
// Use std::sort to order the vertices by their discover time
@@ -69,7 +73,7 @@
integer_range < int >range(0, N);
std::copy(range.begin(), range.end(), discover_order.begin());
std::sort(discover_order.begin(), discover_order.end(),
- indirect_cmp < Iiter, std::less < Size > >(&dtime[0]));
+ indirect_cmp < dtime_pm_type, std::less < Size > >(dtime_pm));
std::cout << "order of discovery: ";
for (int i = 0; i < N; ++i)
Modified: trunk/libs/graph/example/bfs-example2.cpp
==============================================================================
--- trunk/libs/graph/example/bfs-example2.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/example/bfs-example2.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -9,6 +9,7 @@
#include <boost/graph/breadth_first_search.hpp>
#include <boost/pending/indirect_cmp.hpp>
#include <boost/range/irange.hpp>
+#include <boost/property_map/property_map.hpp>
#include <iostream>
@@ -30,6 +31,7 @@
struct VertexProps {
boost::default_color_type color;
std::size_t discover_time;
+ unsigned int index;
};
int
@@ -64,7 +66,6 @@
// Typedefs
typedef graph_traits<graph_t>::vertices_size_type Size;
- typedef Size* Iiter;
Size time = 0;
typedef property_map<graph_t, std::size_t VertexProps::*>::type dtime_map_t;
@@ -75,17 +76,28 @@
// a vector to hold the discover time property for each vertex
std::vector < Size > dtime(num_vertices(g));
+ typedef
+ iterator_property_map<std::vector<Size>::iterator,
+ property_map<graph_t, unsigned int VertexProps::*>::type>
+ dtime_pm_type;
graph_traits<graph_t>::vertex_iterator vi, vi_end;
std::size_t c = 0;
- for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c)
+ for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) {
dtime[c] = dtime_map[*vi];
+ put(&VertexProps::index, g, *vi, c);
+ }
+ dtime_pm_type dtime_pm(dtime.begin(), get(&VertexProps::index, g));
// Use std::sort to order the vertices by their discover time
std::vector<graph_traits<graph_t>::vertices_size_type > discover_order(N);
integer_range < int >range(0, N);
std::copy(range.begin(), range.end(), discover_order.begin());
std::sort(discover_order.begin(), discover_order.end(),
- indirect_cmp < Iiter, std::less < Size > >(&dtime[0]));
+ make_indirect_cmp(
+ std::less<Size>(),
+ make_iterator_property_map(
+ dtime.begin(),
+ typed_identity_property_map<std::size_t>())));
std::cout << "order of discovery: ";
for (int i = 0; i < N; ++i)
Modified: trunk/libs/graph/example/canonical_ordering.cpp
==============================================================================
--- trunk/libs/graph/example/canonical_ordering.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/example/canonical_ordering.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -64,7 +64,8 @@
std::vector<vec_t> embedding(num_vertices(g));
if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g,
boyer_myrvold_params::embedding =
- &embedding[0]
+ make_iterator_property_map(
+ embedding.begin(), get(vertex_index, g))
)
)
std::cout << "Input graph is planar" << std::endl;
@@ -75,7 +76,10 @@
ordering_storage_t;
ordering_storage_t ordering;
- planar_canonical_ordering(g, &embedding[0], std::back_inserter(ordering));
+ planar_canonical_ordering(g,
+ make_iterator_property_map(
+ embedding.begin(), get(vertex_index, g)),
+ std::back_inserter(ordering));
ordering_storage_t::iterator oi, oi_end;
oi_end = ordering.end();
Modified: trunk/libs/graph/example/dfs-example.cpp
==============================================================================
--- trunk/libs/graph/example/dfs-example.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/example/dfs-example.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -58,14 +58,17 @@
graph_t g(edge_array, edge_array + sizeof(edge_array) / sizeof(E), N);
#endif
- // Typedefs
- typedef size_type* Iiter;
-
// discover time and finish time properties
std::vector < size_type > dtime(num_vertices(g));
std::vector < size_type > ftime(num_vertices(g));
+ typedef
+ iterator_property_map<std::vector<size_type>::iterator,
+ property_map<graph_t, vertex_index_t>::const_type>
+ time_pm_type;
+ time_pm_type dtime_pm(dtime.begin(), get(vertex_index, g));
+ time_pm_type ftime_pm(ftime.begin(), get(vertex_index, g));
size_type t = 0;
- dfs_time_visitor < size_type * >vis(&dtime[0], &ftime[0], t);
+ dfs_time_visitor < time_pm_type >vis(dtime_pm, ftime_pm, t);
depth_first_search(g, visitor(vis));
@@ -74,7 +77,7 @@
integer_range < size_type > r(0, N);
std::copy(r.begin(), r.end(), discover_order.begin());
std::sort(discover_order.begin(), discover_order.end(),
- indirect_cmp < Iiter, std::less < size_type > >(&dtime[0]));
+ indirect_cmp < time_pm_type, std::less < size_type > >(dtime_pm));
std::cout << "order of discovery: ";
int i;
for (i = 0; i < N; ++i)
@@ -83,7 +86,7 @@
std::vector < size_type > finish_order(N);
std::copy(r.begin(), r.end(), finish_order.begin());
std::sort(finish_order.begin(), finish_order.end(),
- indirect_cmp < Iiter, std::less < size_type > >(&ftime[0]));
+ indirect_cmp < time_pm_type, std::less < size_type > >(ftime_pm));
std::cout << std::endl << "order of finish: ";
for (i = 0; i < N; ++i)
std::cout << name[finish_order[i]] << " ";
Modified: trunk/libs/graph/example/implicit_graph.cpp
==============================================================================
--- trunk/libs/graph/example/implicit_graph.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/example/implicit_graph.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -527,10 +527,16 @@
vertex_descriptor source = 0;
std::vector<vertex_descriptor> pred(num_vertices(g));
std::vector<edge_weight_map_value_type> dist(num_vertices(g));
+ iterator_property_map<std::vector<vertex_descriptor>::iterator,
+ property_map<ring_graph, vertex_index_t>::const_type>
+ pred_pm(pred.begin(), get(vertex_index, g));
+ iterator_property_map<std::vector<edge_weight_map_value_type>::iterator,
+ property_map<ring_graph, vertex_index_t>::const_type>
+ dist_pm(dist.begin(), get(vertex_index, g));
dijkstra_shortest_paths(g, source,
- predecessor_map(&pred[0]).
- distance_map(&dist[0]) );
+ predecessor_map(pred_pm).
+ distance_map(dist_pm) );
std::cout << "Dijkstra search from vertex " << source << std::endl;
for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
Modified: trunk/libs/graph/test/astar_search_test.cpp
==============================================================================
--- trunk/libs/graph/test/astar_search_test.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/astar_search_test.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -184,13 +184,18 @@
vector<mygraph_t::vertex_descriptor> p(num_vertices(g));
vector<cost> d(num_vertices(g));
+
+ boost::property_map<mygraph_t, boost::vertex_index_t>::const_type
+ idx = get(boost::vertex_index, g);
+
try {
// call astar named parameter interface
astar_search
(g, start,
distance_heuristic<mygraph_t, cost, location*>
(locations, goal),
- predecessor_map(&p[0]).distance_map(&d[0]).
+ predecessor_map(make_iterator_property_map(p.begin(), idx)).
+ distance_map(make_iterator_property_map(d.begin(), idx)).
visitor(astar_goal_visitor<vertex>(goal)).distance_inf(my_float((std::numeric_limits<float>::max)())));
Modified: trunk/libs/graph/test/bellman-test.cpp
==============================================================================
--- trunk/libs/graph/test/bellman-test.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/bellman-test.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -56,8 +56,8 @@
bool const r = bellman_ford_shortest_paths
(g, int (numVertex),
weight_pmap,
- &parent[0],
- &distance[0],
+ boost::make_iterator_property_map(parent.begin(), get(boost::vertex_index, g)),
+ boost::make_iterator_property_map(distance.begin(), get(boost::vertex_index, g)),
closed_plus<int>(),
std::less<int>(),
default_bellman_visitor());
@@ -81,8 +81,10 @@
std::vector<int> distance2(numVertex, 17);
bool const r2 = bellman_ford_shortest_paths
(g,
- weight_map(weight_pmap).distance_map(&distance2[0]).
- predecessor_map(&parent2[0]).root_vertex(s));
+ weight_map(weight_pmap).
+ distance_map(boost::make_iterator_property_map(distance2.begin(), get(boost::vertex_index, g))).
+ predecessor_map(boost::make_iterator_property_map(parent2.begin(), get(boost::vertex_index, g))).
+ root_vertex(s));
if (r2) {
for(int i = 0; i < numVertex; ++i) {
std::cout << name[i] << ": ";
Modified: trunk/libs/graph/test/bfs.cpp
==============================================================================
--- trunk/libs/graph/test/bfs.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/bfs.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -140,20 +140,38 @@
parent[*ui] = *ui;
std::vector<boost::default_color_type> color(i);
+ // Get vertex index map
+ typedef typename boost::property_map<Graph, boost::vertex_index_t>::const_type idx_type;
+ idx_type idx = get(boost::vertex_index, g);
+
+ // Make property maps from vectors
+ typedef
+ boost::iterator_property_map<std::vector<int>::iterator, idx_type>
+ distance_pm_type;
+ distance_pm_type distance_pm(distance.begin(), idx);
+ typedef
+ boost::iterator_property_map<typename std::vector<vertex_descriptor>::iterator, idx_type>
+ parent_pm_type;
+ parent_pm_type parent_pm(parent.begin(), idx);
+ typedef
+ boost::iterator_property_map<std::vector<boost::default_color_type>::iterator, idx_type>
+ color_pm_type;
+ color_pm_type color_pm(color.begin(), idx);
+
// Create the testing visitor.
- bfs_testing_visitor<int*,vertex_descriptor*,Graph,
- boost::default_color_type*>
- vis(start, &distance[0], &parent[0], &color[0]);
+ bfs_testing_visitor<distance_pm_type, parent_pm_type, Graph,
+ color_pm_type>
+ vis(start, distance_pm, parent_pm, color_pm);
boost::breadth_first_search(g, start,
visitor(vis).
- color_map(&color[0]));
+ color_map(color_pm));
// All white vertices should be unreachable from the source.
for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui)
if (color[*ui] == Color::white()) {
std::vector<boost::default_color_type> color2(i, Color::white());
- BOOST_CHECK(!boost::is_reachable(start, *ui, g, &color2[0]));
+ BOOST_CHECK(!boost::is_reachable(start, *ui, g, color_pm_type(color2.begin(), idx)));
}
// The shortest path to a child should be one longer than
Modified: trunk/libs/graph/test/boykov_kolmogorov_max_flow_test.cpp
==============================================================================
--- trunk/libs/graph/test/boykov_kolmogorov_max_flow_test.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/boykov_kolmogorov_max_flow_test.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -218,7 +218,8 @@
get(edge_capacity,g),
get(edge_residual_capacity,g),
get(edge_reverse,g),
- &(color_vec[0]),
+ boost::make_iterator_property_map(
+ color_vec.begin(), get(vertex_index, g)),
get(vertex_index,g),
src, sink);
Modified: trunk/libs/graph/test/dfs.cpp
==============================================================================
--- trunk/libs/graph/test/dfs.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/dfs.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -122,9 +122,24 @@
std::vector<int> discover_time(num_vertices(g)),
finish_time(num_vertices(g));
- dfs_test_visitor<ColorMap, vertex_descriptor*,
- int*, int*> vis(color, &parent[0],
- &discover_time[0], &finish_time[0]);
+ // Get vertex index map
+ typedef typename boost::property_map<Graph, boost::vertex_index_t>::const_type idx_type;
+ idx_type idx = get(boost::vertex_index, g);
+
+ typedef
+ boost::iterator_property_map<typename std::vector<vertex_descriptor>::iterator, idx_type>
+ parent_pm_type;
+ parent_pm_type parent_pm(parent.begin(), idx);
+ typedef
+ boost::iterator_property_map<std::vector<int>::iterator, idx_type>
+ time_pm_type;
+ time_pm_type discover_time_pm(discover_time.begin(), idx);
+ time_pm_type finish_time_pm(finish_time.begin(), idx);
+
+ dfs_test_visitor<ColorMap, parent_pm_type,
+ time_pm_type, time_pm_type>
+ vis(color, parent_pm,
+ discover_time_pm, finish_time_pm);
boost::depth_first_search(g, visitor(vis).color_map(color));
@@ -142,10 +157,10 @@
|| finish_time[v] < discover_time[u]
|| (discover_time[v] < discover_time[u]
&& finish_time[u] < finish_time[v]
- && boost::is_descendant(u, v, &parent[0]))
+ && boost::is_descendant(u, v, parent_pm))
|| (discover_time[u] < discover_time[v]
&& finish_time[v] < finish_time[u]
- && boost::is_descendant(v, u, &parent[0]))
+ && boost::is_descendant(v, u, parent_pm))
);
}
}
Modified: trunk/libs/graph/test/dijkstra_heap_performance.cpp
==============================================================================
--- trunk/libs/graph/test/dijkstra_heap_performance.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/dijkstra_heap_performance.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -117,7 +117,9 @@
dijkstra_relaxed_heap = false;
#endif
dijkstra_shortest_paths(g, vertex(0, g),
- distance_map(&binary_heap_distances[0]));
+ distance_map(
+ boost::make_iterator_property_map(
+ binary_heap_distances.begin(), get(boost::vertex_index, g))));
double binary_heap_time = t.elapsed();
std::cout << binary_heap_time << " seconds.\n";
@@ -135,7 +137,9 @@
dijkstra_relaxed_heap = true;
#endif
dijkstra_shortest_paths(g, vertex(0, g),
- distance_map(&relaxed_heap_distances[0]));
+ distance_map(
+ boost::make_iterator_property_map(
+ relaxed_heap_distances.begin(), get(boost::vertex_index, g))));
double relaxed_heap_time = t.elapsed();
std::cout << relaxed_heap_time << " seconds.\n"
<< "Speedup = " << (binary_heap_time / relaxed_heap_time) << ".\n";
@@ -159,7 +163,7 @@
dijkstra_shortest_paths_no_color_map
(g, vertex(0, g),
boost::dummy_property_map(),
- boost::make_iterator_property_map(&no_color_map_distances[0],
+ boost::make_iterator_property_map(no_color_map_distances.begin(),
get(boost::vertex_index, g),
0.),
get(boost::edge_weight, g),
Modified: trunk/libs/graph/test/make_connected_test.cpp
==============================================================================
--- trunk/libs/graph/test/make_connected_test.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/make_connected_test.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -114,10 +114,14 @@
make_disconnected_cycles(gVV, num_cycles, cycle_size);
reset_edge_index(gVV);
std::vector<int> gVV_components(num_vertices(gVV));
- BOOST_CHECK(connected_components(gVV, &gVV_components[0]) ==
+ boost::iterator_property_map<
+ std::vector<int>::iterator,
+ typename boost::property_map<VVgraph_t, boost::vertex_index_t>::const_type
+ > gVV_components_pm(gVV_components.begin(), get(boost::vertex_index, gVV));
+ BOOST_CHECK(connected_components(gVV, gVV_components_pm) ==
static_cast<int>(num_cycles));
make_connected(gVV);
- BOOST_CHECK(connected_components(gVV, &gVV_components[0]) == 1);
+ BOOST_CHECK(connected_components(gVV, gVV_components_pm) == 1);
BOOST_CHECK(num_edges(gVV) == num_cycles * cycle_size + num_cycles - 1);
LVgraph_t gLV;
@@ -126,10 +130,14 @@
make_disconnected_cycles(gLV, num_cycles, cycle_size);
reset_edge_index(gLV);
std::vector<int> gLV_components(num_vertices(gLV));
- BOOST_CHECK(connected_components(gLV, &gLV_components[0]) ==
+ boost::iterator_property_map<
+ std::vector<int>::iterator,
+ typename boost::property_map<VVgraph_t, boost::vertex_index_t>::const_type
+ > gLV_components_pm(gLV_components.begin(), get(boost::vertex_index, gLV));
+ BOOST_CHECK(connected_components(gLV, gLV_components_pm) ==
static_cast<int>(num_cycles));
make_connected(gLV);
- BOOST_CHECK(connected_components(gLV, &gLV_components[0]) == 1);
+ BOOST_CHECK(connected_components(gLV, gLV_components_pm) == 1);
BOOST_CHECK(num_edges(gLV) == num_cycles * cycle_size + num_cycles - 1);
VLgraph_t gVL;
Modified: trunk/libs/graph/test/successive_shortest_path_nonnegative_weights_test.cpp
==============================================================================
--- trunk/libs/graph/test/successive_shortest_path_nonnegative_weights_test.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/successive_shortest_path_nonnegative_weights_test.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -50,12 +50,14 @@
typedef boost::graph_traits<Graph>::edge_descriptor edge_descriptor;
std::vector<edge_descriptor> pred(N);
+ boost::property_map<Graph, boost::vertex_index_t>::const_type
+ idx = get(boost::vertex_index, g);
boost::successive_shortest_path_nonnegative_weights(g, s, t,
- boost::distance_map(&dist[0]).
- predecessor_map(&pred[0]).
- distance_map2(&dist_prev[0]).
- vertex_index_map(boost::identity_property_map()));
+ boost::distance_map(boost::make_iterator_property_map(dist.begin(), idx)).
+ predecessor_map(boost::make_iterator_property_map(pred.begin(), idx)).
+ distance_map2(boost::make_iterator_property_map(dist_prev.begin(), idx)).
+ vertex_index_map(idx));
int cost = boost::find_flow_cost(g);
BOOST_CHECK_EQUAL(cost, 29);
Modified: trunk/libs/graph/test/transitive_closure_test.cpp
==============================================================================
--- trunk/libs/graph/test/transitive_closure_test.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/transitive_closure_test.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -74,7 +74,7 @@
typename graph_traits<Graph>::adjacency_iterator k, k_end;
for (boost::tie(k, k_end) = adjacent_vertices(*i, g); k != k_end; ++k) {
std::vector<default_color_type> color_map_vec(num_vertices(g));
- if (is_reachable(*k, *i, g, &color_map_vec[0])) {
+ if (is_reachable(*k, *i, g, boost::make_iterator_property_map(color_map_vec.begin(), get(boost::vertex_index, g)))) {
can_reach = true;
break;
}
@@ -93,7 +93,7 @@
}
} else {
std::vector<default_color_type> color_map_vec(num_vertices(g));
- if (is_reachable(*i, *j, g, &color_map_vec[0])) {
+ if (is_reachable(*i, *j, g, boost::make_iterator_property_map(color_map_vec.begin(), get(boost::vertex_index, g)))) {
if (num_tc != 1)
return false;
} else {
@@ -117,16 +117,16 @@
{
progress_timer t;
cout << "transitive_closure" << endl;
- transitive_closure(g1, g1_tc, vertex_index_map(identity_property_map()));
+ transitive_closure(g1, g1_tc, vertex_index_map(get(boost::vertex_index, g1)));
}
if(check_transitive_closure(g1, g1_tc))
return true;
else {
cout << "Original graph was ";
- print_graph(g1, identity_property_map());
+ print_graph(g1, get(boost::vertex_index, g1));
cout << "Result is ";
- print_graph(g1_tc, identity_property_map());
+ print_graph(g1_tc, get(boost::vertex_index, g1_tc));
return false;
}
}
Modified: trunk/libs/graph/test/undirected_dfs.cpp
==============================================================================
--- trunk/libs/graph/test/undirected_dfs.cpp Thu Sep 12 10:01:50 2013 (r85654)
+++ trunk/libs/graph/test/undirected_dfs.cpp 2013-09-12 11:14:36 EDT (Thu, 12 Sep 2013) (r85655)
@@ -130,9 +130,24 @@
std::vector<int> discover_time(num_vertices(g)),
finish_time(num_vertices(g));
- dfs_test_visitor<ColorMap, vertex_descriptor*,
- int*, int*> vis(color, &parent[0],
- &discover_time[0], &finish_time[0]);
+ // Get vertex index map
+ typedef typename boost::property_map<Graph, boost::vertex_index_t>::const_type idx_type;
+ idx_type idx = get(boost::vertex_index, g);
+
+ typedef
+ boost::iterator_property_map<typename std::vector<vertex_descriptor>::iterator, idx_type>
+ parent_pm_type;
+ parent_pm_type parent_pm(parent.begin(), idx);
+ typedef
+ boost::iterator_property_map<std::vector<int>::iterator, idx_type>
+ time_pm_type;
+ time_pm_type discover_time_pm(discover_time.begin(), idx);
+ time_pm_type finish_time_pm(finish_time.begin(), idx);
+
+ dfs_test_visitor<ColorMap, parent_pm_type,
+ time_pm_type, time_pm_type>
+ vis(color, parent_pm,
+ discover_time_pm, finish_time_pm);
boost::undirected_dfs(g, visitor(vis).color_map(color)
.edge_color_map(e_color));
@@ -155,10 +170,10 @@
|| finish_time[v] < discover_time[u]
|| (discover_time[v] < discover_time[u]
&& finish_time[u] < finish_time[v]
- && boost::is_descendant(u, v, &parent[0]))
+ && boost::is_descendant(u, v, parent_pm))
|| (discover_time[u] < discover_time[v]
&& finish_time[v] < finish_time[u]
- && boost::is_descendant(v, u, &parent[0]))
+ && boost::is_descendant(v, u, parent_pm))
);
}
}
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