【问题标题】:Get specific edge with boost::graph使用 boost::graph 获取特定优势
【发布时间】:2011-06-11 17:12:27
【问题描述】:

我正在使用boost::graph,我有两个vertex_descriptors。在不遍历所有边缘的情况下,获得它们之间边缘的最快方法是什么?

【问题讨论】:

    标签: c++ boost boost-graph


    【解决方案1】:

    好的,我发现了。 boost::edge(u,v,g) 返回pair<edge_descriptor, bool> 其中bool 是边缘是否存在。所以就我而言,我知道它确实如此,所以我使用以下表达式:

    boost::edge(u,v,g).first
    

    【讨论】:

    • 其实应该是boost::edge(u,v,g).second,如果你想要bool的值...
    • @tnull 因为我知道边缘存在并且我正在寻找边缘本身,first 是我需要的属性。
    【解决方案2】:

    boost/graph/lookup_edge.hpp中还有一个函数boost::lookup_edge();该函数分派到edge()out_edges(),并根据您使用的特定图形类型进行搜索。

    【讨论】:

      猜你喜欢
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多