I am trying to access the graph label for a dot(graphviz) formatted input file using the Boost Graph Library. Below is the typedef for the graph type:
struct DotVertex {
std::string label;
};
struct DotEdge {
std::string label;
};
struct DotGraph {
std::string label;
};
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS,
DotVertex, DotEdge, DotGraph> graph_t;
And this is how I assign the dynamic properties:
graph_t graphviz;
boost::dynamic_properties dp(boost::ignore_other_properties);
dp.property("label", boost::get(&DotGraph::label, graphviz));
dp.property("label", boost::get(&DotVertex::label, graphviz));
dp.property("label", boost::get(&DotEdge::label, graphviz));
std::ifstream ifs("sample.dot");
bool status = boost::read_graphviz(ifs, graphviz, dp);
The compiler complains about the assignment for the DotGraph::label with the error message:
read_graph.cc:25:30: error: no matching function for call to 'get' dp.property("label", boost::get(&DotGraph::label, graphviz));
Can someone point out what is the convenient way to read the graph label in this case? Thanks!
Managed to map the graph property using as found in step 3 of read_graphviz() in Boost::Graph, pass to constructor:
boost::ref_property_map<graph_t *, std::string> dg_label(get_property(graphviz, &DotGraph::label));
dp.property("label", dg_label);
And then can access the label by:
std::cout<<get_property(graphviz, &DotGraph::label)<<std::endl;