我正在努力尝试使用boost手动着色图形的顶点。我编写了下面的代码,但我无法弄清楚为什么生成的文件没有任何颜色。
int main(int,char*[]) {
typedef property<edge_name_t, string> EdgeProperties;
typedef property<vertex_name_t, string, property<vertex_color_t, default_color_type>> VertexProperties;
typedef adjacency_list<vecS, vecS, directedS, VertexProperties, EdgeProperties> Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex;
typedef graph_traits<Graph>::edge_descriptor Edge;
Graph g;
property_map<Graph, vertex_name_t>::type vertex_label = get(vertex_name, g);
property_map<Graph, vertex_color_t>::type color_map = get(vertex_color, g);
property_map<Graph, edge_name_t>::type edge_label = get(edge_name, g);
Vertex v1 = add_vertex(g);
vertex_label[v1] = "v1";
put(color_map, v1, boost::red_color);
std::ofstream outf("example.gv");
write_graphviz(outf, g,
make_label_writer(vertex_label),
make_label_writer(edge_label)
);
return 0;
}