I have an adjacency_list graph defined as follows:
struct VertexProperties{
std::string name;
...
};
typedef boost::adjacency_list<boost::vecS,
boost::vecS,
boost::directedS,
VertexProperties> GraphType;
typedef GraphType::vertex_descriptor VertexType;
Given a graph, vertex, and out edge index, how can I get the adjacent vertex?
Solved:
typedef boost::graph_traits<GraphType>::out_edge_iterator out_edge_iterator; typedef std::pair<out_edge_iterator, out_edge_iterator> out_edge_iterator_range; out_edge_iterator_range range = boost::out_edges(current_vertex, graph); if (out_index > range.second - range.first){ // out_index is invalid } out_edge_iterator iter = range.first + row; VertexType out_vertex = iter->m_target;