升压图复制filterd_graph

时间:2019-04-22 14:00:32

标签: c++ boost graph boost-graph

我的实际意图是使用mcgregor_common_subgraphs查找一些归纳的局部子图。但是比较小图需要花费太长时间。因此,我不想比较整个图形,而是想过滤出可比较的顶点和边的子集。然后在它们之间找到子图。

因此,对于这两个图,我都将filtered_graph与顶点和边谓词一起使用。并将经过过滤的图形传递到mcgregor_common_subgraphs。但它抱怨

error: use of deleted function ‘boost::iterators::filter_iterator<bya::util::isomorphism::directed_graph::vertex_filter_predicate, boost::range_detail::integer_iterator<long unsigned int> >& boost::iterators::filter_iterator<bya::util::isomorphism::directed_graph::vertex_filter_predicate, boost::range_detail::integer_iterator<long unsigned int> >::operator=(const boost::iterators::filter_iterator<bya::util::isomorphism::directed_graph::vertex_filter_predicate, boost::range_detail::integer_iterator<long unsigned int> >&)’

因此,我计划使用copy_graph将过滤后的图形复制到新图形中。但是它抱怨说顶点谓词vertex_filter_predicate没有默认的构造函数。

error: no matching function for call to ‘bya::util::isomorphism::directed_graph::vertex_filter_predicate::vertex_filter_predicate()’

但是,我的顶点和边谓词对原始图形采用了const reference。所以我不能添加一个空的默认构造函数。我已经搜索了boost文档,但是没有找到复制filtered_graph的任何示例。解决办法是什么 ?还有copy_graph为什么要求谓词要复制?

struct directed_graph{
    typedef boost::adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS, vertex_data, edge_data> graph_type;
    graph_type _graph;
    // ...
};

我有一个有向图结构,里面有谓词和等价比较器。大和小都是directed_graph的实例。

directed_graph::edge_filter_predicate   edge_filter_small  (small._graph, allowed_vertex_ids), edge_filter_large  (large._graph, allowed_vertex_ids);
directed_graph::vertex_filter_predicate vertex_filter_small(small._graph, allowed_vertex_ids), vertex_filter_large(large._graph, allowed_vertex_ids);

boost::filtered_graph<directed_graph::graph_type, directed_graph::edge_filter_predicate, directed_graph::vertex_filter_predicate> filtered_small_view(small._graph, edge_filter_small, vertex_filter_small);
boost::filtered_graph<directed_graph::graph_type, directed_graph::edge_filter_predicate, directed_graph::vertex_filter_predicate> filtered_large_view(large._graph, edge_filter_large, vertex_filter_large);

directed_graph::graph_type filtered_small;
boost::copy_graph(filtered_small_view, filtered_small);

0 个答案:

没有答案