I have a adjacency list of type
boost::adjacency_list<boost::setS, boost::vecS, boost::directedS, GraphData>
Where GraphData is a structure contains name
struct GraphItem
{
std::string Name;
}
I am able to write graph to xml
void WriteGraph() {
boost::dynamic_properties dp;
dp.property("Name", make_transform_value_property_map(&Name,
boost::get(vertex_bundle, graph)));
boost::write_graphml(filename, graph, dp, true);
}
std::string Name(boost::vertex_bundle_type<Graph>::type v) {
std::ostringstream oss;
oss << v.Name;
return oss.str();
}
I get XML as
<graphml>
<key id="key0" for="node" attr.name="Name" attr.type="string" />
<graph id="G" edgedefault="directed" parse.nodeids="canonical"
parse.edgeids="canonical" parse.order="nodesfirst">
<node id="n0">
<data key="key0">A</data>
</node>
<node id="n1">
<data key="key0">D</data>
</node>
<node id="n2">
<data key="key0">B</data>
</node>
<node id="n3">
<data key="key0">C</data>
</node>
<edge id="e0" source="n0" target="n1">
</edge>
<edge id="e1" source="n2" target="n3">
</edge>
</graph>
</graphml>
When I read graph
void ReadGraph() {
boost::dynamic_properties dp;
std::ifstream file(fileName);
boost::read_graphml(file, graph, dp);
}
This is crashing says property Name not found. If I use ignore_other_properties for property,
boost::dynamic_properties dp(ignore_other_properties);
It works but I am not getting any graph item in graph vertices.