Being new to the acceleration graph library, it is often difficult for me to tease which parts of the examples are tied to a specific example and which parts are universal for use.
As an exercise, I try to make a simple graph, assign a color property to the vertices, and print the result in graphviz so that the colors appear as color attributes that get rendered. Any help would be appreciated! Here is what I have so far (more specific use questions in the comments here):
#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 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? }
daj
source share