我将尝试生成一张显示水平图表的.dot文件,使用Boost Graph库。创建图表时,我的代码如下:
但是我遇到了一大堆错误,从这个开始:
struct VertexP {
std::string tag;
};
struct EdgeP {
std::string symbol;
};
struct GraphP{
std::string orientation;
};
typedef boost::adjacency_list<boost::vecS,
boost::vecS, boost::directedS,
VertexP, EdgeP, GraphP> Graph;
GraphP property;
property.orientation = "LR";
Graph graph(property);
// Then fill the graph
我正在使用以下代码来生成.dot文件:
Graph g = creator.AutomatonToGraph(&automaton);
ofstream dot_file("automaton.dot");
dynamic_properties dp;
dp.property("node_id", get(&VertexP::tag, g));
dp.property("label", get(&VertexP::tag, g));
dp.property("label", get(&EdgeP::symbol, g));
write_graphviz_dp(dot_file, g, dp);
这段代码可以完美地将节点和边缘标签写入.dot文件,但我的问题是我想将rankdir=LR
图形属性添加到输出文件中。我尝试过:
Graph g = creator.AutomatonToGraph(&automaton);
ofstream dot_file("automaton.dot");
dynamic_properties dp;
dp.property("node_id", get(&VertexP::tag, g));
dp.property("label", get(&VertexP::tag, g));
dp.property("label", get(&EdgeP::symbol, g));
dp.property("rankdir", get(&GraphP::orientation, g));
write_graphviz_dp(dot_file, g, dp);
但是我遇到了一大堆错误,从这个开始:
/src/lab2.cc:48:55: required from here
/usr/include/boost/graph/detail/adjacency_list.hpp:2585:29: error: forming reference to void
typedef value_type& reference;
^~~~~~~~~
我对使用BGL非常陌生,我哪里做错了吗?