Re: [Boost-users] Graph: writing graph properties to graphml file

I still have a problem getting graph properties written to a graphml file
(vertex and edge properties get written just fine). Following Jeremiah's
advise form two weeks ago I implemented the code below. The problem appears
to be that the instance of ref_property_map contained in the
dynamic_properties uses the key type Graph*, but the write_graphml function
implemented in boost/graph/graphml.hpp expects it to be of type Graph. This
of course results in a different typeid and the write_graphml function does
not recognize the entry in the dynamic properties as graph properties. I
tried to change the key type of ref_property_map to Graph, which resulted
in a compilation error. Any insight in how to solve that problem would be
greatly appreciated!
Here is my current code:
#include
On Tue, 28 Feb 2012, Juerg Tschirren wrote:
I wrote the code below to construct a directed graph with internal properties (for vertices, edges, and the graph itself) and write everything to a graphml file. The code compiles and works as it is, but my two questions are:
1. What dynamic property do I have to add to write the graph properties out to the graphml file as well? So far I could only figure out how to write vertex and edge properties.
You should be able to add a graph property like in the following code (from libs/graph/test/graphviz_test.cpp):
boost::ref_property_map
gname( get_property(graph,graph_name)); dp.property("name",gname);
2. Does everything else look good? Specifically, is it O.K. to define the properties the way I did in the first typedef line (without using boost::property<>), and is it O.K. to access the properties the way I do it?
It will work, but a better way would be to use boost::property or a class containing your string which you can then access using g[v].mem or g[e].mem.
-- Jeremiah Willcock

On Thu, 15 Mar 2012, Juerg Tschirren wrote:
I still have a problem getting graph properties written to a graphml file (vertex and edge properties get written just fine). Following Jeremiah's advise form two weeks ago I implemented the code below. The problem appears to be that the instance of ref_property_map contained in the dynamic_properties uses the key type Graph*, but the write_graphml function implemented in boost/graph/graphml.hpp expects it to be of type Graph. This of course results in a different typeid and the write_graphml function does not recognize the entry in the dynamic properties as graph properties. I tried to change the key type of ref_property_map to Graph, which resulted in a compilation error. Any insight in how to solve that problem would be greatly appreciated!
I think (looking at the reading code in libs/graph/example/graphviz.cpp) that it should be Graph* in write_graphml; try changing that (on lines 265, 276, and 290 of boost/graph/graphml.hpp in the trunk) and see if it works. -- Jeremiah Willcock
participants (2)
-
Jeremiah Willcock
-
Juerg Tschirren