小编msk*_*skb的帖子

关于 C++ Boost Graph Creation 和 vertex_index 属性。

我是boost noob。我想知道为什么在以下代码中编译失败。我正在创建一组顶点,并尝试分配我自己的顶点索引和顶点名称。(我正在关注此页面:http : //fireflyblue.blogspot.com/2008/01/boost-graph-library.html。)

我知道vertS顶点列表Boost不需要明确的顶点 id 创建,我也在 Stackoverflow(如何为我的图提供 vertex_index 属性)中看到了这个非常相关的问题,它讨论了如何使用 anassociative_property_map来分配顶点索引。下面虽然 - 获取 vertex_index 映射,并分配键值对 - 似乎是一件相当简单的事情,我想了解它为什么失败。任何帮助是极大的赞赏!

编译错误如下:

error: expression is not assignable vertIndx[v] = i;

//Define graph
typedef boost::property<boost::vertex_name_t, std::string> sv_namePty;
typedef boost::property<boost::vertex_index_t, int, sv_namePty > sv_indx_n_name_pty;
typedef boost::property<boost::edge_weight_t, int> se_weightPty;
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, 
        sv_indx_n_name_pty, se_weightPty> ScafGraph;

//descriptors
typedef boost::graph_traits<ScafGraph>::vertex_descriptor SV;
typedef boost::graph_traits<ScafGraph>::edge_descriptor SE;

//Graph Object
ScafGraph SG;

//property accessors
boost::property_map<ScafGraph, 
     boost::vertex_name_t>::type vertName = boost::get(boost::vertex_name, SG);
boost::property_map<ScafGraph, 
     boost::vertex_index_t>::type …
Run Code Online (Sandbox Code Playgroud)

c++ boost graph boost-graph

5
推荐指数
1
解决办法
4074
查看次数

标签 统计

boost ×1

boost-graph ×1

c++ ×1

graph ×1