如何在 Boost Graph Library 中获取 属性 的类型

How to get the type of a property in Boost Graph Library

在 Boost Graph Library (BGL) 中,如何以编程方式获取 属性 的类型,例如与 boost::edge_weight_t 关联的类型?

我搜索并找到了很多关于如何获取 属性 map 类型的示例,但不是属性 本身的类型。例如,下面的 BGL documentation 具有 edge_weight_t 的 属性 映射的类型为 property_map<DirectedGraph, edge_weight_t>::type:

typedef ... DirectedGraph;
DirectedGraph digraph(V);
{
  ..
  property_map<DirectedGraph, edge_weight_t>::type
    weight = get(edge_weight, digraph);
}

但是如何获取边的权重类型呢? (floatint 等)

如何使用适当的类型表达式(??? 下面)为边权重声明变量,以便我可以,例如,从 file/stream.

中读入这些权重值
typedef ... DirectedGraph;
...
??? w;
input_s >> w;

正如@llonesmiz 在评论中指出的,对于 属性 地图类型

typedef property_map<Graph, boost::edge_weight_t>::type WeightMap

属性(权重)值的类型可以用 property_traits 检索为:

typedef typename boost::property_traits<WeightMap>::value_type edge_weight_type;