我试图使用BGL计算图形之间的最短路径 . 我打电话的功能是

boost::johnson_all_pairs_shortest_paths(g,distances);

其中g是自定义图表类型

typedef property<label_t, int> LabelProperty;
typedef  property<edge_weight_t,int> EdgeWeightProperty;

//graph definition
typedef adjacency_list<listS, 
                       listS, 
                       directedS,
                        property<vertex_index_t,int, 
                       LabelProperty >,
                        EdgeWeightProperty
                       > Graph;

我正在将距离作为 Map 的 Map 来实现

typedef map<int,map<int,int> > DistMat;
DistMat distances;

所以我可以访问distaces作为distance [i] [j]并且可以使用大图 .

当我编译(使用gcc 4.6.3)时,我收到以下错误:

/usr/include/boost/graph/graph_concepts.hpp:518:31:错误:将'const std :: map>'作为'this'参数传递给'std :: map <_Key,_Tp,_Compare,_Alloc> :: mapped_type&std :: map <_Key,_Tp,_Compare,_Alloc> :: operator [](const key_type&)[with _Key = int,_Tp = std :: map,_Compare = std :: less,_Alloc = std :: allocator> >,std :: map <_Key,_Tp,_Compare,_Alloc> :: mapped_type = std :: map,std :: map <_Key,_Tp,_Compare,_Alloc> :: key_type = int]'丢弃限定符[-fpermissive]

实际上,如果我使用[-fpermissive]选项,代码将编译并运行 . 但是,我想安排代码,以便编译而不选择此选项 . 我相信解决方案是here,但我在这么多模板中迷失了 .

任何提示?非常感谢你提前