
Hello, I'm boost newbie and have some problems with write_graphviz function. I've already asked this question but perhaps with bad subject so i try again. Sorry if you read this second time. In write_graphviz function documentation I can read that PropertyWriter can be used for print both: interior and exterior properties for each vertex of a graph into the graphviz format file. I can find some example of printing graph properties stored in property maps, for example calling: write_graphviz(std::cout, g, make_label_writer(name)); when the graph have 'name' property map. but how to do that when storing properies as bundled properies? I defined following graph: typedef adjacency_list<vecS, vecS, bidirectionalS, Vect_f, Edge_f> Graph; where: struct Vect_f { int factor; int lowlink; int component; int color; bool in_stack; }; struct Edge_f { int num_visited; int color_k; }; and I want to lay out and print my graph with coloured vertexes (I can always change the type of colour property for more suitable if necessary) but I dont't have any idea to do this. Is it possible at all? Cheers, Michał Nowotka

On Sunday 09 December 2007 07:10, Michał Nowotka wrote:
In write_graphviz function documentation I can read that PropertyWriter can be used for print both: interior and exterior properties for each vertex of a graph into the graphviz format file. I can find some example of printing graph properties stored in property maps, for example calling:
write_graphviz(std::cout, g, make_label_writer(name));
when the graph have 'name' property map.
but how to do that when storing properies as bundled properies?
I did something like this recently (although I was printing colored edges instead of vertices). See the "vertex_labeler" and "edge_colorer" classes defined in this file: http://cvs.comedi.org/cgi-bin/viewcvs.cgi/libpoet/poet/mutex_grapher.hpp?rev... I pass objects of these classes as the third and fourth arguments to write_graphviz. -- Frank

That solved my problem. Thank you very much. BTW - if you used write_graphviz perhabs you could use gvRenderData or gvRender too. I'm trying to display rendered graph image but without storing it in temoprary file. So i found gvRenderData from graphviz library most suitable to do that. But when i call this function it simply seems not to be working. when I type something like that: write_graphviz(my_stringstream, graf->Get_g()); g = agmemread(const_cast<char*>(my_stringstream.str().c_str())); gvLayout(gvc, g, "dot"); gvRenderFilename (gvc, g, "png","out.png"); I get valid png file and everything is OK. But if i do this: write_graphviz(my_stringstream, graf->Get_g()); g = agmemread(const_cast<char*>(my_stringstream.str().c_str())); gvLayout(gvc, g, "dot"); char* data; int result = gvRenderData(gvc, g, "png", &data); // result = 0 so that should be OK std::ofstream my_fstream("picture.png" , std::fstream::binary); while(*data!=EOF) my_fstream.put(*(data++)); stru.close(); than an output file - picture.png is not valid and have smaller size than out.png in first example. I tried to change the following line: while(*data!=EOF) to: while(*data!='\0') but it still is not correct. Maybe you've got some example of using vgRenderData - i would be gratefull. If not - that's not a big deal - you've already helped me so much. Cheers, Michał Nowotka
participants (2)
-
Frank Mori Hess
-
Michał Nowotka