我创建了两个图并调用算法:
typedef boost::adjacency_list<boost::setS, boost::vecS,
boost::bidirectionalS, boost::property<boost::vertex_name_t, std::string>
> graph_type;
//Create two graphs and put into them some vertex with property:
graph_type g1, g2;
boost::add_vertex(label ,g1); //the same with g2
//Create property_map:
typedef property_map<graph_type, vertex_name_t>::type NameMap;
NameMap name1 = boost::get(vertex_name_t(), g1);
NameMap name2 = boost::get(vertex_name_t(), g2);
//Create callback copied from algoritm http://www.boost.org/doc/libs/1_55_0b1/libs/graph/doc/mcgregor_common_subgraphs.html
print_callback<graph_type, graph_type> callback(g1, g2);
//And call algorithm:
mcgregor_common_subgraphs_unique(g1, g2, true, callback,
vertices_equivalent(make_property_map_equivalent(name1, name2)));
输入数据(graph1)的返回值为空:
node: "0" label: ""
node: "1" label: "PlayerMoveStop::Create"
node: "2" label: ""
node: "3" label: ""
node: "4" label: "PlayerMoveStartBackward::Create"
node: "5" label: ""
node: "6" label: ""
node: "7" label: ""
edge: { sourcename: "0" targetname: "6" }
edge: { sourcename: "0" targetname: "7" }
edge: { sourcename: "1" targetname: "5" }
edge: { sourcename: "1" targetname: "7" }
edge: { sourcename: "2" targetname: "4" }
edge: { sourcename: "2" targetname: "5" }
edge: { sourcename: "2" targetname: "6" }
edge: { sourcename: "3" targetname: "4" }
graph2:
node: "0" label: "PlayerMoveStop::Create"
node: "1" label: "PlayerMoveStop::Create"
node: "2" label: "MoveFallLand_Destruct"
node: "3" label: "PlayerMoveStop::Destroy"
node: "4" label: "PlayerMoveStartBackward::Destroy"
node: "5" label: "PlayerMoveStartBackward::Create"
node: "6" label: "PlayerMoveHeartbeat::Destroy"
node: "7" label: "PlayerMoveFallLand::CliPut"
node: "8" label: "PlayerMoveStartForward::CliPut"
edge: { sourcename: "0" targetname: "6" }
edge: { sourcename: "0" targetname: "8" }
edge: { sourcename: "1" targetname: "5" }
edge: { sourcename: "1" targetname: "7" }
edge: { sourcename: "2" targetname: "4" }
edge: { sourcename: "2" targetname: "7" }
edge: { sourcename: "2" targetname: "8" }
edge: { sourcename: "3" targetname: "4" }
edge: { sourcename: "3" targetname: "5" }
edge: { sourcename: "3" targetname: "6" }
我希望带有vertex_equivalent(make_property_map_equivalent())的property_map将2个已知顶点从第1个图形映射到第2个图形,算法将只搜索其他顶点。
没有vertices_equivalent()算法返回解决方案!
我做错了什么? 请帮帮我!