|
Boost Users : |
Subject: Re: [Boost-users] boost graph: Error with compressed_sparse_row graph and strong_components
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-05-09 10:26:52
On Mon, 9 May 2011, aitor wrote:
> Hi,
>
> the following example (taken from csr example in boost docs) fails when
> calling strong_components algorithm. The error message is:
>
> /usr/include/boost-1.46.1/boost/graph/strong_components.hpp:59: error: no matching function for call to 'get(int*&, unsigned int&)'
>
> the program works with boost 1.41.0
>
> any help would be much appreciated :-)
>
>
> #include <boost/graph/compressed_sparse_row_graph.hpp>
> #include <string>
> #include <fstream>
> #include <boost/graph/strong_components.hpp>
>
> using namespace boost;
>
> int main()
> {
> typedef std::pair<int, int> E;
> E the_edges[] = { E(0, 1), E(0, 2), E(0, 3), E(1, 0), E(1, 3), E(1, 5),
> E(2, 0), E(2, 5), E(3, 1), E(3, 4), E(4, 1), E(5, 0),
> E(5, 2) };
>
> typedef compressed_sparse_row_graph<directedS> WebGraph;
> WebGraph g(boost::edges_are_sorted, &the_edges[0], &the_edges[0] + sizeof(the_edges)/sizeof(E), 6);
>
> // strong components
>
> std::vector<int> v(6);
> int i = boost::strong_components(g, &v[0]);
>
> std::cout << i << "\n";
>
> return 0;
> }
Try changing the strong_components call to:
boost::iterator_property_map<
std::vector<int>::iterator,
boost::property_map<WebGraph, boost::vertex_index_t>::type
> pm(v.begin(), get(boost::vertex_index, g));
int i = boost::strong_components(g, pm);
-- Jeremiah Willcock
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net