使用Boost :: topological_sort进行拓扑排序

时间:2011-12-23 11:47:58

标签: boost generic-programming topological-sort

我正在尝试使用boost的topological_sort函数。

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

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:错误:不匹配   'operator +'in'((const   boost :: iterator_property_map&lt; __ gnu_cxx :: __ normal_iterator&gt; &gt;中   提高:: adj_list_vertex_property_map,   boost :: detail :: error_property_not_found,const   boost :: detail :: error_property_not_found&amp;,boost :: vertex_index_t&gt;,   提高:: default_color_type,   boost :: default_color_type&amp;&gt; *)this) - &gt; boost :: iterator_property_map&lt; __ gnu_cxx :: __ normal_iterator&gt; &gt;中   提高:: adj_list_vertex_property_map,   boost :: detail :: error_property_not_found,const   boost :: detail :: error_property_not_found&amp;,boost :: vertex_index_t&gt;,   boost :: default_color_type,boost :: default_color_type&amp;&gt; :: iter +   boost :: get [with PropertyMap =   提高:: adj_list_vertex_property_map,   boost :: detail :: error_property_not_found,const   boost :: detail :: error_property_not_found&amp;,boost :: vertex_index_t&gt;,   Reference = const boost :: detail :: error_property_not_found&amp;,K =   void *](((const boost :: put_get_helper,   boost :: detail :: error_property_not_found,const   boost :: detail :: error_property_not_found&amp;,boost :: vertex_index_t&gt;

     
    

&amp;)((const boost :: put_get_helper,     boost :: detail :: error_property_not_found,const     boost :: detail :: error_property_not_found&amp;,boost :: vertex_index_t&gt;     *)(((const boost :: adj_list_vertex_property_map,     boost :: detail :: error_property_not_found,const     提高::详细:: error_property_not_found和放大器;,     升压:: vertex_index_t&GT; *)((常量     boost :: iterator_property_map&lt; __ gnu_cxx :: __ normal_iterator&gt; &gt;中     提高:: adj_list_vertex_property_map,     boost :: detail :: error_property_not_found,const     boost :: detail :: error_property_not_found&amp;,boost :: vertex_index_t&gt;,     boost :: default_color_type,boost :: default_color_type&amp;&gt; )this))+     8u))),((void const&amp;)((void * const *)(&amp; v))))'

  
     

/usr/include/boost/graph/detail/adjacency_list.hpp:2264:错误:否   调用`get_property_value的匹配函数(boost :: no_property&amp ;,,   升压:: vertex_index_t)

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

我对顶点的listS的使用是否违反任何概念要求?

1 个答案:

答案 0 :(得分:0)

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

  

在blah .. iterator ..中找不到'operator +'。

使用VecS时,会得到一个向量 - 其迭代器是随机访问,并且支持operator +

使用ListS时,会得到一个列表 - 其迭代器是双向的,不支持operator +