From eeaee30dd31a154b7f5103239ffe18cfb81c338b Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 3 Apr 2012 05:50:40 +0000 Subject: [PATCH] Converted to Boost.Parameter [SVN r77739] --- include/boost/graph/isomorphism.hpp | 80 ++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/include/boost/graph/isomorphism.hpp b/include/boost/graph/isomorphism.hpp index a3e036d7..c4950ccb 100644 --- a/include/boost/graph/isomorphism.hpp +++ b/include/boost/graph/isomorphism.hpp @@ -467,9 +467,64 @@ fi_adj_loop_k:++fi_adj.first; index_map1, index_map2 ); } + + template + struct make_degree_invariant { + const G& g; + const Index& index; + make_degree_invariant(const G& g, const Index& index): g(g), index(index) {} + typedef typename boost::graph_traits::degree_size_type degree_size_type; + typedef shared_array_property_map prop_map_type; + typedef degree_vertex_invariant result_type; + result_type operator()() const { + prop_map_type pm = make_shared_array_property_map(num_vertices(g), degree_size_type(), index); + compute_in_degree(g, pm); + return result_type(pm, g); + } + }; } // namespace detail + namespace graph { + namespace detail { + template + struct isomorphism_impl { + typedef bool result_type; + bool operator()(const Graph1& g1, const Graph2& g2, const ArgPack& arg_pack) const { + using namespace boost::graph::keywords; + typedef typename boost::detail::override_const_property_result::type index1_map_type; + typedef typename boost::detail::override_const_property_result::type index2_map_type; + index1_map_type index1_map = boost::detail::override_const_property(arg_pack, _vertex_index1_map, g1, boost::vertex_index); + index2_map_type index2_map = boost::detail::override_const_property(arg_pack, _vertex_index2_map, g2, boost::vertex_index); + typedef typename graph_traits::vertex_descriptor vertex2_t; + typename std::vector::size_type n = (typename std::vector::size_type)num_vertices(g1); + std::vector f(n); + typename boost::parameter::lazy_binding< + ArgPack, + tag::vertex_invariant1, + boost::detail::make_degree_invariant >::type + invariant1 = + arg_pack[_vertex_invariant1 || boost::detail::make_degree_invariant(g1, index1_map)]; + typename boost::parameter::lazy_binding< + ArgPack, + tag::vertex_invariant2, + boost::detail::make_degree_invariant >::type + invariant2 = + arg_pack[_vertex_invariant2 || boost::detail::make_degree_invariant(g2, index2_map)]; + return boost::isomorphism + (g1, g2, + choose_param(arg_pack[_isomorphism_map | boost::param_not_found()], + make_shared_array_property_map(num_vertices(g1), vertex2_t(), index1_map)), + invariant1, + invariant2, + arg_pack[_vertex_max_invariant | (invariant2.max)()], + index1_map, + index2_map); + } + }; + } + BOOST_GRAPH_MAKE_FORWARDING_FUNCTION(isomorphism, 2, 6) + } // Named parameter interface template @@ -477,30 +532,19 @@ fi_adj_loop_k:++fi_adj.first; const Graph2& g2, const bgl_named_params& params) { - typedef typename graph_traits::vertex_descriptor vertex2_t; - typename std::vector::size_type n = num_vertices(g1); - std::vector f(n); - return detail::isomorphism_impl - (g1, g2, - choose_param(get_param(params, vertex_isomorphism_t()), - make_safe_iterator_property_map(f.begin(), f.size(), - choose_const_pmap(get_param(params, vertex_index1), - g1, vertex_index), vertex2_t())), - choose_const_pmap(get_param(params, vertex_index1), g1, vertex_index), - choose_const_pmap(get_param(params, vertex_index2), g2, vertex_index), - params - ); + typedef bgl_named_params params_type; + BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params) + return boost::graph::isomorphism_with_named_params(g1, g2, arg_pack); } - // All defaults interface template - bool isomorphism(const Graph1& g1, const Graph2& g2) + bool isomorphism(const Graph1& g1, + const Graph2& g2) { - return isomorphism(g1, g2, - bgl_named_params(0));// bogus named param + BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(no_named_parameters, no_named_parameters()) + return boost::graph::isomorphism_with_named_params(g1, g2, arg_pack); } - // Verify that the given mapping iso_map from the vertices of g1 to the // vertices of g2 describes an isomorphism. // Note: this could be made much faster by specializing based on the graph