Boostグラフライブラリに慣れていないので、例のどの部分が特定の例に関連付けられているか、どの部分が使用法に普遍的であるかを理解するのは難しいことがよくあります。
演習として、単純なグラフを作成し、頂点にcolorプロパティを割り当て、その結果をgraphvizに出力して、色がレンダリングされる色属性として表示されるようにします。どんな助けでもいただければ幸いです!これが私がこれまでに持っているものです(より具体的な使用法の質問はここのコメントにあります):
#include "fstream"
#include "boost/graph/graphviz.hpp"
#include "boost/graph/adjacency_list.hpp"
struct vertex_info {
int color;
};
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, vertex_info> Graph;
typedef std::pair<int, int> Edge;
int main(void) {
Graph g;
add_edge(0, 1, g);
add_edge(1, 2, g);
// replace this with some traversing and assigning of colors to the 3 vertices ...
// should I use bundled properties for this?
// it's unclear how I would get write_graphviz to recognize a bundled property as the color attribute
g[0].color = 1;
std::ofstream outf("min.gv");
write_graphviz(outf, g); // how can I make write_graphviz output the vertex colors?
}