
On Tue, 21 Jun 2011, David Doria wrote:
The strategy for doing that is to create a dynamic_properties object, add an entry to it for the "style" edge property and some property map, and then pass that to write_graphviz_dp. An example of what you want to do is in libs/graph/example/graphviz.cpp; see how the "weight" property is handled. In your case, the value type of the property would be std::string.
-- Jeremiah Willcock
Thanks Jeremiah,
Here is what I tried:
#include <iostream> #include <string>
#include <boost/graph/undirected_graph.hpp> #include <boost/graph/graphviz.hpp>
struct StyleProperty { std::string style; }
typedef boost::undirected_graph<boost::no_property, StyleProperty> Graph;
int main() { Graph g; Graph::vertex_descriptor v0 = g.add_vertex(); Graph::vertex_descriptor v1 = g.add_vertex(); Graph::vertex_descriptor v2 = g.add_vertex();
StyleProperty styleInvisible; styleInvisible.style = "invis";
StyleProperty styleNormal; styleNormal = "normal";
boost::add_edge(v0,v1,styleInvisible, g); boost::add_edge(v1,v2,styleNormal g);
boost::dynamic_properties dp; dp.property("style", get(&StyleProperty::style, g));
boost::write_graphviz_dp(std::cout, g, dp, "style");
The last argument here shouldn't be "style" -- it should be the default "node_id" or something else that can be used to identify vertices in the graph.
return 0; }
However, I get an exception "dynamic property get cannot retrieve value for property: style."
I'm not sure what the issue is for that -- try changing the call to write_graphviz_dp and see if it recurs. -- Jeremiah Willcock