【发布时间】:2011-01-25 13:03:15
【问题描述】:
我正在根据以下建议构建一个图形类:Modifying vertex properties in a Boost::Graph
不幸的是,我意识到了一个意想不到的行为。使用我自己的顶点属性时(为简单起见,请忽略边缘属性),似乎没有使用内置属性。 例如,当我有:
typedef adjacency_list<
setS, // disallow parallel edges
listS, // vertex container
undirectedS, // undirected graph
property<vertex_properties_t, VERTEXPROPERTIES>,
property<edge_properties_t, EDGEPROPERTIES>
> GraphContainer;
我可以毫无问题地检索我的自定义属性,但是当我想检索 vertex_index-property 时,我总是为每个顶点获得相同的值,即值为 0。节点是不同的,这由 num_vertices(我的图表)。 然后我认为这可能是由于缺少内置属性,所以我尝试了:
typedef adjacency_list<
setS, // disallow parallel edges
listS, // vertex container
undirectedS, // undirected graph
property<vertex_index_t, unsigned int , property< vertex_properties_t, VERTEXPROPERTIES> >,
property<edge_properties_t, EDGEPROPERTIES>
> GraphContainer;
再次,当想要检索任何顶点的索引时,我得到的值为 0。 这种行为正常吗?使用自定义属性时是否还必须设置内置属性?
【问题讨论】:
标签: c++ boost properties graph