2011-06-21 41 views
0

您好我有一个像升压图:加速图形递归模板问题

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

的问题是,在边缘类递归模板。我需要存储一个顶点向量。

+0

你确定你有'Graph_t'右边的模板参数吗?第四个和第五个参数是_properties_,而不是顶点和边的类本身......你必须为顶点和边集合提供一个合适的容器,'boost :: adjacency_list :: vertex_descriptor'只是指向那个类型的值容器(或多或少)。 –

+0

你使用什么编译器。我已经编译并在VC++ 2010中运行你的代码没有任何问题 – Eugene

回答

0

我结束了使用小包装类,如:

typedef Graph_t::vertex_descriptor vd_t;       

struct iVertexWrap{             
    iVertexWrap(vd_t v) : v(v) 
    {}                
    vd_t v; 
}; 

边缘课前向前声明它。

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;