How do I specify boost::isomorphism_map
when using adjacency_list<vecS, vecS, undirectedS>
?
What I'm trying to complete is marked ?????????
:
typedef adjacency_list<vecS, vecS, undirectedS> graph_t;
graph_t g1(n), g2(n);
add_edge(0, 1, g1); add_edge(1, 2, g1);
add_edge(9, 10, g2); add_edge(10, 11, g2);
std::vector<graph_traits<graph_t>::vertex_descriptor> f(n);
bool ret = isomorphism
(g1, g2, isomorphism_map
(make_iterator_property_map(f.begin(), ?????????, f[0])));
To make an iterator property-map, you need two arguments:
make_iterator_property_map( RAIter iter, ID id )
Drop your third argument.
The first you have: f.begin()
is the random access iterator to the first element.
ID
needs to be the vertex index map. In your case you can query it from the graph (because vecS
results in a implicit vertex index):
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/isomorphism.hpp>
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> graph_t;
int main() {
int n = 12;
graph_t g1(n), g2(n);
add_edge(0, 1, g1);
add_edge(1, 2, g1);
add_edge(9, 10, g2);
add_edge(10, 11, g2);
std::vector<graph_t::vertex_descriptor> f(n);
bool ret = isomorphism(
g1, g2,
isomorphism_map(boost::make_iterator_property_map(f.begin(), boost::get(boost::vertex_index, g1)))
);
}
Consider making a safe iterator map:
boost::make_safe_iterator_property_map(f.begin(), n, boost::get(boost::vertex_index, g1))
If you're not interested in safety (?!??) you can do a lot shorter:
bool ret = isomorphism(g1, g2, boost::isomorphism_map(f.data()));
This uses the vertex_index
automatically.