2012-08-17 14 views
5

Yani, bugün bir saat Boost belgelerine geçmiş olmalıdır. Kör olmalıyım.Alma kenar özellikleri :: adjacency_list

nasıl boost :: adjacency_list ile bir kenar için ilgili köşe alabilirim: Ben, umarım, basit bir sorum var?

Ben ben anlamaya çalışıyorum kod aşağıdadır:

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

Herkes bunun nasıl biliyor?

Teşekkür

cevap

8

Sen ("Non-Üye İşlevleri" adlı bölümünde) this page gereken işlevleri bulabilirsiniz. İhtiyacınız olanlar source ve target'dur. Bunun için

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

teşekkürler! – MichaelM