can someone show me an example of how to use the Boost Graph Library isomorphism function with vertex invariants? I’m looking at the example at http://www.boost.org/doc/libs/1_50_0/libs/graph/example/isomorphism.cpp, which uses degree_vertex_invariant(). However, I want to define my own invariant function and an example would really help me to understand how to do this.
Here are some more details:
I am defining a set of discrete attributes on vertices such that I can label each vertex with an integer. So I have a mapping from any vertex(g,v) to its invariant label, which is an unsigned int. These labels are not necessarily unique, i.e. several vertices in the same graph can share the same label. So suppose I define a function:
template <typename Graph>
unsigned discrete_vertex_invariant(const typename boost::graph_traits<Graph>::vertex_descriptor &v, const Graph &g)
I want to call isomorphism like this:
typename property_map<Graph, vertex_index_t>::type
v1_index_map = get(vertex_index, g1),
v2_index_map = get(vertex_index, g2);
vector<typename graph_traits<Graph>::vertex_descriptor> f(num_vertices(g1));
bool is_isomorphic = isomorphism(g1, g2,
isomorphism_map(make_iterator_property_map(f.begin(), v1_index_map, f[0])),
discrete_vertex_invariant, discrete_vertex_invariant
))
… but I get an error:
no matching function for call to ‘isomorphism(
...
<unresolved overloaded function type>, <unresolved overloaded function type>)’
What is the correct way to define discrete_vertex_invariant()?
You can find here the definition of
degree_vertex_invariant. It’s simply a function object with typedefs forresult_typeandargument_typethat is expected to be called with each of the vertices of the graph and that also has a member calledmaxthat return an integer equal to the max value of your invariants plus one.A similar functor using your
discrete_vertex_invariantfunction would look like this:You could then invoke
isomorphismusing its named-parameter version: