【发布时间】:2017-12-20 11:03:17
【问题描述】:
我有一个用以下内容实例化的图表:
typedef boost::property<boost::edge_weight_t, uint32_t> EdgeWeightProperty;
typedef boost::property<boost::vertex_index_t, uint32_t> VertexProperty;
typedef boost::adjacency_list<boost::vecS, boost::setS,
boost::undirectedS, VertexProperty,
EdgeWeightProperty, boost::setS> Graph;
我需要更新此图表,例如添加或删除边缘。由于我使用集合来存储顶点,所以我不能使用它们的索引,但我可以保留一张地图:
unordered_map<uint32_t, Vertex_Descriptor>
这会将我的索引映射到顶点描述符,因此我以后可以直接在 BGL 中访问,这种方法有效,但会增加此映射开销。
在 BGL 中获取/放置顶点时,我能否以某种方式指定自定义索引或要比较的内容?还是在地图中保留顶点描述符是最好的方法?
coliru 上的完整示例
【问题讨论】:
标签: c++ boost boost-graph