我正在尝试使用Boost vf2_subgraph_iso()来检测子图同构.
我可以在简单的图形上成功完成此操作,但不能在多图形(允许有多个边缘的图形)上执行此操作.
考虑检测以下G1和G2之间的子图同构:

G1是G2的子图,我想使用以下代码检测:
#include <vector>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/vf2_sub_graph_iso.hpp>
int main()
{
// Define edge property
typedef boost::property<
boost::edge_name_t,
char
> edge_property;
// Define graph type
typedef boost::adjacency_list<
boost::vecS, // OutEdgeListS
boost::vecS, // VertexListS
boost::bidirectionalS, // DirectedS
boost::no_property, // VertexProperties
edge_property, // EdgeProperties
boost::no_property, // GraphProperties
boost::listS // EdgeListS
> MyGraphType;
// Build graph G1
MyGraphType g1;
std::vector<MyGraphType::vertex_descriptor> v1(3);
for (auto itr = v1.begin(); itr != v1.end(); ++itr) {
*itr = boost::add_vertex(g1);
}
boost::add_edge(v1[0], v1[1], …Run Code Online (Sandbox Code Playgroud)