隐式图的 BGL 内部属性
我正在尝试在隐式图上使用 Boost BGL 的 A* 搜索。我已经实现了自己的图形类型,它模拟了 Graph 和 IncidenceGraph 的概念。根据 A* 的文档,我应该将 astar_search_no_init 函数与隐式图一起使用。
为了让整个事情顺利进行,我尝试实现所有所需概念的虚拟版本。这包括图、访问者、启发式和顶点类型。我的主要函数如下所示
int main()
{
graph g;
// The vertex type is a simple wrapper for int.
vertex start(1);
vertex goal(10);
boost::astar_search_no_init(g, start, heuristic(),
boost::visitor(visitor(goal)));
}
在不指定任何命名参数的情况下,实现应该使用一些默认值。显然这些默认值需要我的图表的一些支持。该图如下所示:
struct graph
{
typedef void adjacency_iterator;
typedef void in_edge_iterator;
typedef void vertex_iterator;
typedef void edge_iterator;
typedef void vertices_size_type;
typedef void edge_iterator;
typedef void edges_size_type;
typedef vertex vertex_descriptor;
typedef double edge_descriptor;
typedef boost::directed_tag directed_category;
typedef boost::disallow_parallel_edge_tag edge_parallel_category;
typedef boost::incidence_graph_tag traversal_category;
typedef std::vector<double>::iterator out_edge_iterator;
typedef int degree_size_type;
};
编译时,第一个也是最有趣的错误是:
error C2039: 'edge_property_type' : is not a member of 'graph'
根据我的理解,我需要为我的图添加属性。我相信这些属性应该是内部属性。我的问题是:如何为我自己的隐式图形类型添加内部属性?
I'm trying to use the A* search from Boost BGL on an implicit graph. I have implemented my own graph type which models the concept of Graph and IncidenceGraph. According to the documentation of A*, I should be using the astar_search_no_init function with implicit graphs.
Just to get the whole thing working, I have tried to implement dummy versions of all of the needed concepts. This includes the graph, the visitor, the heuristic and the vertex type. My main function looks like this
int main()
{
graph g;
// The vertex type is a simple wrapper for int.
vertex start(1);
vertex goal(10);
boost::astar_search_no_init(g, start, heuristic(),
boost::visitor(visitor(goal)));
}
Without specifying any of the named parameters, the implementation should be using some default values. Apparently these default values require some support from my graph. The graph looks like this:
struct graph
{
typedef void adjacency_iterator;
typedef void in_edge_iterator;
typedef void vertex_iterator;
typedef void edge_iterator;
typedef void vertices_size_type;
typedef void edge_iterator;
typedef void edges_size_type;
typedef vertex vertex_descriptor;
typedef double edge_descriptor;
typedef boost::directed_tag directed_category;
typedef boost::disallow_parallel_edge_tag edge_parallel_category;
typedef boost::incidence_graph_tag traversal_category;
typedef std::vector<double>::iterator out_edge_iterator;
typedef int degree_size_type;
};
When compiling, the first and the most interesting error is this:
error C2039: 'edge_property_type' : is not a member of 'graph'
From what I understand, I need to add properties for my graph. I believe these properties should be interior properties. My question is: how do I add interior properties for my own implicit graph type?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论