簡體   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