嗨我有一个像:
的提升图struct Vertex;
struct Edge;
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, Vertex, Edge> Graph_t;
struct Vertex {
};
struct Edge {
typedef std::vector<Graph_t::vertex_descriptor> intermediate_vertices_t;
intermediate_vertices_t intermediate_vertices;
};
问题在于Edge类中的递归模板。我需要存储一个顶点向量。
答案 0 :(得分:2)
您可以使用adjacency_list_traits
来解决此问题。此类允许用户访问顶点和边描述符类型,而无需用户提供图的属性类型。
struct Vertex {
};
typedef boost::adjacency_list_traits<boost::vecS, boost::vecS, boost::bidirectionalS>::vertex_descriptor VertexDescriptor;
struct Edge {
typedef std::vector<VertexDescriptor> intermediate_vertices_t;
intermediate_vertices_t intermediate_vertices;
};
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, Vertex, Edge> Graph_t;
答案 1 :(得分:0)
尝试使用adjacency_list
:
http://www.boost.org/doc/libs/1_36_0/libs/graph/doc/adjacency_list.html
答案 2 :(得分:0)
我最终使用了一个小包装类,如:
typedef Graph_t::vertex_descriptor vd_t;
struct iVertexWrap{
iVertexWrap(vd_t v) : v(v)
{}
vd_t v;
};
在Edge类之前声明它。