Can someone explain to a Boost beginner like me what is a property map is in Boost? I came across this when trying to use the BGL for calculating strong connected components. I went through the documentation for the property map and graph module and still don't know what to make of it. Take this code, for example:
- what is the make_iterator_property_map function doing?
- and what is the meaning of this code: get(vertex_index, G)?
#include <boost/config.hpp>
#include <vector>
#include <iostream>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
int main()
{
using namespace boost;
typedef adjacency_list < vecS, vecS, directedS > Graph;
const int N = 6;
Graph G(N);
add_edge(0, 1, G);
add_edge(1, 1, G);
add_edge(1, 3, G);
add_edge(1, 4, G);
add_edge(3, 4, G);
add_edge(3, 0, G);
add_edge(4, 3, G);
add_edge(5, 2, G);
std::vector<int> c(N);
int num = strong_components
(G, make_iterator_property_map(c.begin(), get(vertex_index, G), c[0]));
std::cout << "Total number of components: " << num << std::endl;
std::vector < int >::iterator i;
for (i = c.begin(); i != c.end(); ++i)
std::cout << "Vertex " << i - c.begin()
<< " is in component " << *i << std::endl;
return EXIT_SUCCESS;
}
std::less
as a default order forstd::map
. – Martitaproperty_maps
the users needs a hold of them, how should that work here? – Natishanativestruct Edge { float value; }
. If you need more that one value, provide your ownstruct
. Nothing really different fromstruct RGB { int R; int G; int B; }; std::vector<RGB>
. BGL is so complex that I think you should roll your own in 90% of cases, using BGL only for the hardest 10%. Compare that to STL, which is sufficient for the simplest 90% of cases - the total opposite. – MartitaBOOST_FUSION_ADAPT_STRUCT
) to help you. I had some code that introduces default property maps, iff your struct supports that, but it never went into the main branch. The consensus seems to be to leave BGL as it is rather than break it and go for a rewrite some time (at least one rewrite has already happened, but not up to Boost quality). – Natishanative