繁体   English   中英

从boost :: adjacency_list获取边缘属性(包括相关顶点)

[英]Getting edge properties (including related vertices) from boost::adjacency_list

所以,我今天必须通过Boost文档一小时。 我必须失明。 我希望,我有一个简单的问题:

如何使用boost :: adjacency_list获取边的相应顶点?

我有以下代码,我想弄清楚:

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph;
typedef boost::graph_traits<Graph>::edge_iterator EdgeIterator;
typedef std::pair<EdgeIterator, EdgeIterator> EdgePair;

EdgePair ep;
for (ep = edges(g); ep.first != ep.second; ++ep.first)
{
    // Get the two vertices that are joined by this edge...
}

有人知道怎么做吗?

谢谢

您可以在此页面中找到所需的功能(在“非成员函数”部分中)。 你需要的是sourcetarget

typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS> Graph;
typedef boost::graph_traits<Graph>::edge_iterator EdgeIterator;
typedef std::pair<EdgeIterator, EdgeIterator> EdgePair;
typedef boost::graph_traits<Graph>::vertex_descriptor VertexDescriptor;

EdgePair ep;
VertexDescriptor u,v;
for (ep = edges(g); ep.first != ep.second; ++ep.first)
{
    // Get the two vertices that are joined by this edge...
    u=source(*ep.first,g);
    v=target(*ep.first,g);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM