【问题标题】:Topological Sort using Boost::topological_sort使用 Boost::topological_sort 进行拓扑排序
【发布时间】:2011-12-23 11:47:58
【问题描述】:

我正在尝试使用 boost 的 topological_sort 功能。

我使用带有 setS 和 listS 的 boost::adjacency_list 作为边和顶点的底层存储。

typedef boost::adjacency_list<boost::setS, boost::listS, boost::bidirectionalS > SizerGraph;  
    SizerGraph sizerGraph;  
    typedef boost::graph_traits<SizerGraph>::vertex_descriptor Vertex;  
    boost::topological_sort(sizerGraph, std::ostream_iterator<Vertex>(std::cout, "\n"));

编译会导致错误。 (g++ 3.4.6)

/usr/include/boost/property_map.hpp:349:错误:不匹配 '运算符+' in '((const boost::iterator_property_map<:__normal_iterator>>, boost::adj_list_vertex_property_map, boost::detail::error_property_not_found, 常量 boost::detail::error_property_not_found&, boost::vertex_index_t>, boost::default_color_type, boost::default_color_type&>*)this)->boost::iterator_property_map<:__normal_iterator>>, boost::adj_list_vertex_property_map, boost::detail::error_property_not_found, 常量 boost::detail::error_property_not_found&, boost::vertex_index_t>, boost::default_color_type, boost::default_color_type&>::iter + boost::get [与 PropertyMap = boost::adj_list_vertex_property_map, boost::detail::error_property_not_found, 常量 boost::detail::error_property_not_found&, boost::vertex_index_t>, 参考 = const boost::detail::error_property_not_found&, K = void*](((const boost::put_get_helper, boost::detail::error_property_not_found, 常量 boost::detail::error_property_not_found&, boost::vertex_index_t>

&)((const boost::put_get_helper, boost::detail::error_property_not_found, 常量 boost::detail::error_property_not_found&,boost::vertex_index_t> *)(((const boost::adj_list_vertex_property_map, boost::detail::error_property_not_found, 常量 boost::detail::error_property_not_found&, boost::vertex_index_t>*)((const boost::iterator_property_map<:__normal_iterator>>, boost::adj_list_vertex_property_map, boost::detail::error_property_not_found, 常量 boost::detail::error_property_not_found&, boost::vertex_index_t>, boost::default_color_type, boost::default_color_type&>)this)) + 8u))), ((void const&)((void* const*)(&v))))'

/usr/include/boost/graph/detail/adjacency_list.hpp:2264:错误:否 调用 `get_property_value(boost::no_property&, boost::vertex_index_t)

但是,使用 vecS 作为顶点的底层存储机制会导致干净的编译。

我将 listS 用于顶点是否违反了任何概念要求?

【问题讨论】:

  • 您好,在我发现 this 的 boost 讨论组上进行谷歌搜索。需要尝试一下。

标签: boost generic-programming topological-sort


【解决方案1】:

这只是猜测,但错误信息开始:​​

blah .. iterator .. 中的 'operator+' 没有匹配项 ..

当你使用 VecS 时,你会得到一个向量——它的迭代器是随机访问的,并且支持 operator+

当你使用 ListS 时,你会得到一个列表——它的迭代器是双向的,并且不支持 operator+

【讨论】:

  • 你是对的。但是,文档说该图应该是 VertexListGraph 概念boost topo-sort 的模型。似乎这个概念不需要顶点的随机访问要求。如果我错了,请纠正我!
猜你喜欢
  • 2014-10-03
  • 2010-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-28
  • 1970-01-01
相关资源
最近更新 更多