2012-08-17 33 views
5

तो, मुझे आज एक घंटे के लिए बूस्ट दस्तावेज़ों के माध्यम से जाना होगा। मुझे अंधे होना चाहिए। मेरे पास है, मुझे उम्मीद है, एक साधारण सवाल:बढ़ावा से किनारे गुण (संबंधित शीर्षकों सहित) प्राप्त करना :: adjacency_list

बूस्ट :: 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 में की जरूरत है (अनुभाग "गैर-सदस्य कार्य" कहा जाता है में) मिल सकता है। जिनकी आपको आवश्यकता है source और target हैं।

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