我有一个adjacency_list图,定义如下:
struct VertexProperties{
std::string name;
...
};
typedef boost::adjacency_list<boost::vecS,
boost::vecS,
boost::directedS,
VertexProperties> GraphType;
typedef GraphType::vertex_descriptor VertexType;
给定图形,顶点和外边缘索引,如何获得相邻顶点?
答案 0 :(得分:0)
解决:
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;