Boost:将dijkstra_最短路径()应用于过滤的_图

Boost:将dijkstra_最短路径()应用于过滤的_图,boost,graph,Boost,Graph,我有一个带有捆绑属性的图 //property struct Edge { int distance; }; //graph typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, Node, Edge> graph_t; //predicate template <typename Graph> struct Filter { const Graph

我有一个带有捆绑属性的图

//property
struct Edge
{
    int distance;
};

//graph
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, Node, Edge> graph_t;

//predicate
template <typename Graph>
struct Filter
{
    const Graph gr;
    Filter(const Graph &g): gr(g) {}
    bool operator() (const Edge &e) const {
        if(gr[e].distance < 5) return 0;
        return 1;
    }
};

Filter <graph_t> filter(g);
boost::filtered_graph <graph_t, Filter <graph_t> > fg(g, filter);
//属性
结构边
{
整数距离;
};
//图表
typedef boost::邻接列表图;
//谓词
模板
结构过滤器
{
常量图gr;
过滤器(常量图&g):gr(g){}
布尔运算符()(常数边和e)常数{
if(gr[e].距离<5)返回0;
返回1;
}
};
过滤器(g);
boost::filtered_图fg(g,filter);
我想把dijkstra_最短路径算法应用于过滤图

std::vector<int> d(num_vertices(fg));
std::vector<v> p(boost::num_vertices(fg));
boost::dijkstra_shortest_paths(fg, nodes[0], boost::weight_map(get(&Edge::distance, fg))
        .distance_map(boost::make_iterator_property_map(d.begin(), get(boost::vertex_index, fg)))
        .predecessor_map(boost::make_iterator_property_map(p.begin(), get(boost::vertex_index, fg))));
std::向量d(顶点数(fg));
std::vector p(boost::num_顶点(fg));
boost::dijkstra_最短路径(fg,节点[0],boost::权重_映射(get(&Edge::distance,fg))
.distance_map(boost::make_iterator_property_map(d.begin(),get(boost::vertex_index,fg)))
.preference_map(boost::make_iterator_property_map(p.begin(),get(boost::vertex_index,fg)));
我在编译时遇到的错误有:

/Users/artem/Documents/boost\u 1\u 55\u 0/boost/concept\u check.hpp:142:错误:类型为'boost::filter\u iterator>,boost::keep\u all,boost::filter\u graph,filter>,boost::keep\u all>,boost::detail::out\u edge\u iter,void*>,edge>*>,unsigned long,boost::detail::edge\u desc\u impl,无法分配long>>,因为其复制分配运算符已被隐式删除 a=b;//需要赋值运算符 ^

什么是不正确的?无法真正理解如何解决此问题。

如本文所述,您的
运算符()应接受边描述符,而不是边

例如,您可以尝试以下方法:

bool operator() (const boost::graph_traits<graph_t>::edge_descriptor& e) const 
{
    ... get the variable edge of type Edge from the edge_descriptor e in some way ...

    if(gr[edge].distance < 5) return 0;
    return 1;
}
bool操作符()
{
…以某种方式从edge_描述符e获取edge类型的变量edge。。。
if(gr[edge].距离<5)返回0;
返回1;
}
所有这些都使得使用
boost::graph
非常烦人。我希望开发人员能够提高可用性,目前可用性非常差

也可以查看一下