我正在尝试在隐式图上使用来自 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;
};
编译时,第一个也是最有趣的错误是:
错误 C2039:“edge_property_type”:不是“graph”的成员
据我了解,我需要为我的图表添加属性。我相信这些属性应该是内部属性。我的问题是:如何为我自己的隐式图形类型添加内部属性?