2012-08-17 4 views
5

今日、私は1時間ブーストのドキュメントを読んできたに違いありません。私は盲目でなければならない。boost :: adjacency_listからエッジプロパティ(関連する頂点を含む)を取得する

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... 
} 

はこれを行う方法を誰もが知っていますか?

おかげ

答えて

8

あなたは(「非メンバ関数」と呼ばれるセクションで)this pageに必要な機能を見つけることができます。必要なものは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); 
} 
+0

ありがとうございます! – MichaelM

関連する問題