& params) { std::vector in_degree1_vec(num_vertices(G1)); typedef safe_iterator_property_map::iterator, IndexMap1 #ifdef BOOST_NO_STD_ITERATOR_TRAITS , std::size_t, std::size_t& #endif /* BOOST_NO_STD_ITERATOR_TRAITS */ > InDeg1; InDeg1 in_degree1(in_degree1_vec.begin(), in_degree1_vec.size(), index_map1); compute_in_degree(G1, in_degree1); std::vector in_degree2_vec(num_vertices(G2)); typedef safe_iterator_property_map::iterator, IndexMap2 #ifdef BOOST_NO_STD_ITERATOR_TRAITS , std::size_t, std::size_t& #endif /* BOOST_NO_STD_ITERATOR_TRAITS */ > InDeg2; InDeg2 in_degree2(in_degree2_vec.begin(), in_degree2_vec.size(), index_map2); compute_in_degree(G2, in_degree2); degree_vertex_invariant invariant1(in_degree1, G1); degree_vertex_invariant invariant2(in_degree2, G2); return isomorphism(G1, G2, f, choose_param(get_param(params, vertex_invariant1_t()), invariant1), choose_param(get_param(params, vertex_invariant2_t()), invariant2), choose_param(get_param(params, vertex_max_invariant_t()), (invariant2.max)()), index_map1, index_map2 ); } } // namespace detail // Named parameter interface template bool isomorphism(const Graph1& g1, 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 ); } // All defaults interface template bool isomorphism(const Graph1& g1, const Graph2& g2) { return isomorphism(g1, g2, bgl_named_params(0));// bogus named param } // 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 // concepts modeled, but since we're verifying an O(n^(lg n)) algorithm, // O(n^4) won't hurt us. template inline bool verify_isomorphism(const Graph1& g1, const Graph2& g2, IsoMap iso_map) { #if 0 // problematic for filtered_graph! if (num_vertices(g1) != num_vertices(g2) || num_edges(g1) != num_edges(g2)) return false; #endif for (typename graph_traits::edge_iterator e1 = edges(g1).first; e1 != edges(g1).second; ++e1) { bool found_edge = false; for (typename graph_traits::edge_iterator e2 = edges(g2).first; e2 != edges(g2).second && !found_edge; ++e2) { if (source(*e2, g2) == get(iso_map, source(*e1, g1)) && target(*e2, g2) == get(iso_map, target(*e1, g1))) { found_edge = true; } } if (!found_edge) return false; } return true; } } // namespace boost #ifdef BOOST_ISO_INCLUDED_ITER_MACROS #undef BOOST_ISO_INCLUDED_ITER_MACROS #include #endif #endif // BOOST_GRAPH_ISOMORPHISM_HPP
& 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 ); } // All defaults interface template bool isomorphism(const Graph1& g1, const Graph2& g2) { return isomorphism(g1, g2, bgl_named_params(0));// bogus named param } // 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 // concepts modeled, but since we're verifying an O(n^(lg n)) algorithm, // O(n^4) won't hurt us. template inline bool verify_isomorphism(const Graph1& g1, const Graph2& g2, IsoMap iso_map) { #if 0 // problematic for filtered_graph! if (num_vertices(g1) != num_vertices(g2) || num_edges(g1) != num_edges(g2)) return false; #endif for (typename graph_traits::edge_iterator e1 = edges(g1).first; e1 != edges(g1).second; ++e1) { bool found_edge = false; for (typename graph_traits::edge_iterator e2 = edges(g2).first; e2 != edges(g2).second && !found_edge; ++e2) { if (source(*e2, g2) == get(iso_map, source(*e1, g1)) && target(*e2, g2) == get(iso_map, target(*e1, g1))) { found_edge = true; } } if (!found_edge) return false; } return true; } } // namespace boost #ifdef BOOST_ISO_INCLUDED_ITER_MACROS #undef BOOST_ISO_INCLUDED_ITER_MACROS #include #endif #endif // BOOST_GRAPH_ISOMORPHISM_HPP