升压格拉夫read_graphml&动态顶点属性(Boost Graph read_graphml

2019-10-17 20:23发布

我已经使用升压图形库,并以图表从graphml像这样写着:

<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"  
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
   http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
    <graph id="G" edgedefault="directed">
        <node id="A"/>
        <node id="B"/>
        <edge id="0" source="A" target="B">
    </graph>
</graphml>

我有以下的C ++函数:

using namespace boost;
typedef adjacency_list<vecS, vecS, directedS> BoostGraphType;
typedef dynamic_properties BoostDynamicProperties;

BoostGraphType& g = ...;
BoostDynamicProperties& dp = ...;
read_graphml(is, g, dp);

// get the property map for vertex indices
typedef property_map<BoostGraphType, vertex_index_t>::type IndexMap;
IndexMap index_map = get(vertex_index, g);

typedef graph_traits<BoostGraphType>::vertex_iterator vertex_iter;
for (auto vp = vertices(g); vp.first != vp.second; ++vp.first)
{
    size_t index = index_map[*vp.first];
    // How do I get the id of the node?
}

我怎样才能提取每个节点的ID,RESP。 升压的vertex_index和“ID” -graphml标签联系起来?

另外,我怎么能识别或映射在我的升压图结构的顶点在我的GraphML文件中的顶点?

文章来源: Boost Graph read_graphml & dynamic vertex properties