在Boost Graph Library(BGL)中,如何以编程方式获取属性类型,例如与 boost::edge_weight_t
相关联的属性?
我搜索并找到了很多关于如何获取 property map 类型的示例,但没有找到属性本身的类型 . 例如,BGL documentation下面的 edge_weight_t
属性 Map 的类型为 property_map<DirectedGraph, edge_weight_t>::type
:
typedef ... DirectedGraph;
DirectedGraph digraph(V);
{
..
property_map<DirectedGraph, edge_weight_t>::type
weight = get(edge_weight, digraph);
}
但是我如何得到边缘重量的类型? ( float
, int
等)
如何使用适当的类型表达式(下面的)声明边权重的变量,以便我可以例如从文件/流中读取这些权重值 .
typedef ... DirectedGraph;
...
??? w;
input_s >> w;
1 回答
正如@llonesmiz在评论中所指出的,对于属性映射类型
可以使用
property_traits
检索属性(权重)值的类型: