本文介绍了提升图:dijkstra_shortest_paths:无法形成对'void'的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  struct顶点
{
octomap :: point3d coord;
OcTreeNode *节点;
};

typedef boost :: adjacency_list< boost :: listS,boost :: vecS,boost :: undirectedS,Vertex>图形;
typedef boost :: graph_traits< Graph> :: vertex_descriptor VertexDesc;
typedef boost :: graph_traits< Graph> :: edge_descriptor EdgeDesc;

struct GraphContainer
{
std :: map< OcTreeNode *,VertexDesc> revmap;
图形图形;
};

我试图用dijkstra来计算最短路径:

  GraphContainer * gc = ...; 
VertexDesc vGoal = ...;
std :: vector< VertexDesc> PR(升压::为num_vertices(G->图));
std :: vector< int> d(升压::为num_vertices(G->图));
dijkstra_shortest_paths(g-> graph,vGoal,
boost :: predecessor_map(
boost :: make_iterator_property_map(
pr.begin(),
boost :: get (boost :: vertex_index,g-> graph)

).distance_map(
boost :: make_iterator_property_map(
d.begin(),
boost) :get(boost :: vertex_index,g-> graph)


);

然而,它无法编译带有难解释的错误:

 从plugin.cpp包含的文件中:14:
从/usr/local/include/boost/graph/adjacency_list.hpp:223包含的文件中:
/usr/local/include/boost/graph/detail/adjacency_list.hpp:2697:27:错误:无法形成对
'void'的引用
typedef value_type&参考;
^
/usr/local/include/boost/graph/detail/adjacency_list.hpp:2730:9:注意:在模板实例化
class'boost :: detail :: adj_list_any_edge_pmap: :bind_< boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: no_property,boost :: edge_weight_t>'here requested
:adj_list_choose_edge_pmap_helper< Tag> :: type :: template bind_< Graph,Property,Tag>
^
/usr/local/include/boost/graph/detail/adjacency_list.hpp:2734:21:注意:在模板的实例化中
class'boost :: detail :: adj_list_choose_edge_pmap< boost :: edge_weight_t,
boost :: adjacency_list< boost :: listS,boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,
boost :: no_property,boost :: listS> ,boost :: no_property>'here here
struct bind_:adj_list_choose_edge_pmap< Tag,Graph,Property> {};
^
/usr/local/include/boost/graph/properties.hpp:193:9:注意:在模板类的实例化中
'boost :: detail :: adj_list_edge_property_selector :: bind_< ; boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: no_property,boost :: edge_weight_t>'here here
:edge_property_selector<
^
/usr/local/include/boost/graph/properties.hpp:213:5:注意:在模板类的实例中
'boost :: detail :: edge_property_map< boost: :adjacency_list< boost :: listS,boost :: vecS,
boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: edge_weight_t>'这里要求
mpl :: if_<
^
/usr/local/include/boost/graph/named_function_params.hpp:261:49:note:在实例化模板
class'boost :: property_map< boost :: adjacency_list< boost :: listS,boost :: vecS,boost :: undirectedS,
Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;, boost :: edge_weight_t,void>'
请求这里
struct const_type_as_type {typedef typename T :: const_type type;};
^
/usr/local/include/boost/mpl/eval_if.hpp:38:22:注意:(在回溯中跳过1个上下文;使用
-ftemplate-backtrace-limit = 0查看全部)
typedef typename f _ :: type type;
^
/usr/local/include/boost/mpl/eval_if.hpp:38:22:注意:在模板类的实例中
'boost :: mpl :: eval_if< mpl_: :bool_< true> ;,
boost :: detail :: const_type_as_type< boost :: property_map< boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: edge_weight_t,void> >,boost :: property_map< boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: edge_weight_t,void> >'在此处请求
/usr/local/include/boost/graph/named_function_params.hpp:270:7:注意:在模板
class'boost :: mpl :: eval_if< boost: :is_same< boost :: param_not_found,boost :: param_not_found> ;,
boost :: mpl :: eval_if< mpl _ :: bool_< true> ;,
boost :: detail :: const_type_as_type< boost :: property_map< ; boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: edge_weight_t,void> >,boost :: property_map< boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: edge_weight_t,void> >,boost :: mpl :: identity< boost :: param_not_found> >'这里请求
boost :: mpl :: eval_if<
^
/usr/local/include/boost/graph/named_function_params.hpp:304:20:注意:在模板实例化
class'boost :: detail :: choose_impl_result< mpl_: :bool_< true>,boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: param_not_found,boost :: edge_weight_t>'here here
typename detail :: choose_impl_result< boost :: mpl :: true_,Graph,Param,PropertyTag> :: type
^
/usr/local/include/boost/graph/dijkstra_shortest_paths.hpp:612:8:注意:在将推导出的
模板参数代入函数模板'choose_const_pmap'[Param =
boost :: param_not_found, Graph = boost :: adjacency_list< boost :: listS,boost :: vecS,
boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS>,PropertyTag =
boost :: edge_weight_t]
choose_const_pmap(get_param(params,edge_weight),g,edge_weight),
^
plugin.cpp:780:5:注意:在函数
的模板专业化'boost :: dijkstra_shortest_paths< boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: iterator_property_map< std :: __ 1 :: __ wrap_iter< int *> ;,
boost :: vec_adj_list_vertex_id_map< Vertex,unsigned long> ;, int,int&>,boost :: vertex_distance_t,
boost :: bgl_named_pa​​rams< boost :: iterator_property_map< std :: __ 1 :: __ wrap_iter< unsigned long *>,
boost :: vec_adj_list_vertex_id_map< Vertex,unsigned long>,unsigned long,unsigned long&> ;,
boost: :vertex_predecessor_t,boost :: no_property> >'在此处请求
dijkstra_shortest_paths(g-> graph,vGoal,
^
从plugin.cpp包含的文件中:14:
从/ usr / local /include/boost/graph/adjacency_list.hpp:223:
/usr/local/include/boost/graph/detail/adjacency_list.hpp:2698:33:错误:无法形成对
'的引用void'
typedef const value_type& const_reference;
^
在plugin.cpp包含的文件中:15:
/usr/local/include/boost/graph/dijkstra_shortest_paths.hpp: 612:8:错误:没有匹配函数调用
到'choose_const_pmap'
choose_const_pmap(get_param(params,edge_weight),g,edge_weight),
^ ~~~~~~~~ ~~~~~~~~
plugin.cpp:780:5:注意:在函数
模板特化的实例化中boost :: dijkstra_shortest_paths< boost :: adjacency_list< boost :: listS,
boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property,boost :: no_property,boost :: listS> ;,
boost :: iterator_property_map< std :: __ 1 :: __ wrap_iter< int *>,
boost :: vec_adj_list_vertex_id_map< Vertex,unsigned long> ;, int,int&>, boost :: vertex_distance_t,
boost :: bgl_named_pa​​rams< boost :: iterator_property_map< std :: __ 1 :: __ wrap_iter< unsigned long *>,
boost :: vec_adj_list_vertex_id_map< Vertex,unsigned long>,unsigned long ,unsigned long&> ;,
boost :: vertex_predecessor_t,boost :: no_property> >'在此处请求
dijkstra_shortest_paths(g-> graph,vGoal,
^
/usr/local/include/boost/graph/named_function_params.hpp:305:3:note:candidate模板被忽略:
替换失败[使用Param = boost :: param_not_found,Graph =
boost :: adjacency_list< boost :: listS,boost :: vecS,boost :: undirectedS,Vertex,boost :: no_property ,
boost :: no_property,boost :: listS> ;, PropertyTag = boost :: edge_weight_t]
choose_const_pmap(const Param& p,const Graph& g,PropertyTag标记)
^

如何解决这个问题?

解决方案
如果你仔细观察或者咨询文档,你会发现Dijkstra需要边权。你没有提供它们。这是一个错误。

事实上,如果你想让迪杰斯特拉没有权重,:

Now to humour you, let's add a constant edge-weight of 1.0:

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

namespace octomap {
    struct point3d { double x,y,z; };
}

struct OcTreeNode {};

struct Vertex {
    octomap::point3d coord;
    OcTreeNode *node;
};

typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, Vertex> Graph;
typedef boost::graph_traits<Graph>::vertex_descriptor VertexDesc;
typedef boost::graph_traits<Graph>::edge_descriptor EdgeDesc;

struct GraphContainer {
    std::map<OcTreeNode*, VertexDesc> revmap;
    Graph graph;
};

int main() {
    GraphContainer gc;
    add_vertex(gc.graph); // make sure we have a valid start vertex
    VertexDesc vGoal = vertex(0, gc.graph);

    std::vector<VertexDesc> pr(num_vertices(gc.graph));
    std::vector<int> d(num_vertices(gc.graph));

    auto idmap = get(boost::vertex_index, gc.graph);

    dijkstra_shortest_paths(gc.graph, vGoal,
            boost::predecessor_map(boost::make_iterator_property_map(pr.begin(), idmap))
            .distance_map(boost::make_iterator_property_map(d.begin(), idmap))
            .weight_map(boost::make_constant_property<EdgeDesc>(1.0))
    );
}

这篇关于提升图:dijkstra_shortest_paths:无法形成对'void'的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 10:41