I have tried to implement the Boost VF2 Subgraph Iso algorithm with my vertex/edge container being a list, but it isn't working.
Here's an example of it working, but with the containers being vectors.
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/vf2_sub_graph_iso.hpp>
using namespace boost;
using namespace std;
int main() {
typedef adjacency_list<setS, vecS, bidirectionalS> graph_type;
// Build graph1
int num_vertices1 = 8; graph_type graph1(num_vertices1);
add_edge(0, 6, graph1); add_edge(0, 7, graph1);
add_edge(1, 5, graph1); add_edge(1, 7, graph1);
add_edge(2, 4, graph1); add_edge(2, 5, graph1); add_edge(2, 6, graph1);
add_edge(3, 4, graph1);
// Build graph2
int num_vertices2 = 9; graph_type graph2(num_vertices2);
add_edge(0, 6, graph2); add_edge(0, 8, graph2);
add_edge(1, 5, graph2); add_edge(1, 7, graph2);
add_edge(2, 4, graph2); add_edge(2, 7, graph2); add_edge(2, 8, graph2);
add_edge(3, 4, graph2); add_edge(3, 5, graph2); add_edge(3, 6, graph2);
// Create callback to print mappings
vf2_print_callback<graph_type, graph_type> callback(graph1, graph2);
// Print out all subgraph isomorphism mappings between graph1 and graph2.
// Vertices and edges are assumed to be always equivalent.
vf2_subgraph_iso(graph1, graph2, callback);
return 0;
}
And here's my attempt at an adaptation to list containers:
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/vf2_sub_graph_iso.hpp>
#include <boost/graph/graph_traits.hpp>
using namespace boost;
using namespace std;
int main() {
typedef adjacency_list<listS, listS, bidirectionalS> graph_type;
typedef boost::graph_traits<graph_type>::vertex_descriptor vertexID;
typedef map<size_t, vertexID> Index_2_Node_Map;
// Build graph1
int num_vertices1 = 8; graph_type graph1(num_vertices1);
Index_2_Node_Map map1;
boost::associative_property_map<Index_2_Node_Map> propmap1(map1);
int counter = 0;
BGL_FORALL_VERTICES(v,graph1,graph_type)
{
boost::put(propmap1, counter++, v);
}
add_edge(map1[0], map1[6], graph1); add_edge(map1[0], map1[7], graph1);
add_edge(map1[1], map1[5], graph1); add_edge(map1[1], map1[7], graph1);
add_edge(map1[2], map1[4], graph1); add_edge(map1[2], map1[5], graph1); add_edge(map1[2], map1[6], graph1);
add_edge(map1[3], map1[4], graph1);
// Build graph2
int num_vertices2 = 9; graph_type graph2(num_vertices2);
Index_2_Node_Map map2;
boost::associative_property_map<Index_2_Node_Map> propmap2(map2);
counter = 0;
BGL_FORALL_VERTICES(v,graph2,graph_type)
{
boost::put(propmap2, counter++, v);
}
add_edge(map2[0], map2[6], graph2); add_edge(map2[0], map2[8], graph2);
add_edge(map2[1], map2[5], graph2); add_edge(map2[1], map2[7], graph2);
add_edge(map2[2], map2[4], graph2); add_edge(map2[2], map2[7], graph2); add_edge(map2[2], map2[8], graph2);
add_edge(map2[3], map2[4], graph2); add_edge(map2[3], map2[5], graph2); add_edge(map2[3], map2[6], graph2);
// Create callback to print mappings
vf2_print_callback<graph_type, graph_type> callback(graph1, graph2);
// Print out all subgraph isomorphism mappings between graph1 and graph2.
// Vertices and edges are assumed to be always equivalent.
vf2_subgraph_iso(graph1, graph2, callback);
return 0;
}
Although the graphs have been constructed just fine, when I run this I get heaps of errors, such as
error: cannot form a reference to 'void'
error: no matching function for call to 'get'