// graph-tool -- a general graph modification and manipulation thingy // // Copyright (C) 2007 Tiago de Paula Peixoto // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 3 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #include #include "graph.hh" #include "graph_filtering.hh" #include using namespace graph_tool; using namespace boost; using namespace boost::lambda; struct check_iso { template void operator()(Graph1* g1, Graph2* g2, IsoMap map, VertexIndexMap index1, VertexIndexMap index2, bool& result) const { result = isomorphism(*g1, *g2,isomorphism_map(map). vertex_index1_map(index1). vertex_index2_map(index2)); } }; struct directed_graph_view_pointers: mpl::transform >::type {}; struct undirected_graph_view_pointers: mpl::transform >::type {}; typedef property_map_types::apply >::type vertex_props_t; bool check_isomorphism(GraphInterface& gi1, GraphInterface& gi2, boost::any iso_map) { bool result; if (gi1.GetDirected() != gi2.GetDirected()) return false; if (gi1.GetDirected()) { run_action() (gi1, bind(check_iso(), _1, _2, _3, gi1.GetVertexIndex(), gi2.GetVertexIndex(), var(result)), directed_graph_view_pointers(), vertex_props_t()) (gi2.GetGraphView(), iso_map); } else { run_action() (gi1, bind(check_iso(), _1, _2, _3, gi1.GetVertexIndex(), gi2.GetVertexIndex(), var(result)), undirected_graph_view_pointers(), vertex_props_t()) (gi2.GetGraphView(), iso_map); } return result; }