How to make Boost :: graph vertices_equivalent () work correctly?

I created two graphs and named the algorithm:

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)));

The return is null for the input (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" }

I would expect property_map with vertex_equivalent (make_property_map_equivalent ()) to map 2 known vertices from the 1st graph to the second graph and the algorithm will search only among other vertices.

Without the vertices_equivalent () solution of the return algorithm!

What am I doing wrong? Please help me!

+4
source share

Source: https://habr.com/ru/post/1524058/


All Articles