Boost logo

Boost Users :

Subject: Re: [Boost-users] BGL: Write graphviz file with invisible edges
From: David Doria (daviddoria_at_[hidden])
Date: 2011-06-21 14:05:37

> 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; = "invis";

 StyleProperty styleNormal;
 styleNormal = "normal";

 boost::add_edge(v0,v1,styleInvisible, g);
 boost::add_edge(v1,v2,styleNormal g);

 boost::dynamic_properties dp;"style", get(&StyleProperty::style, g));

 boost::write_graphviz_dp(std::cout, g, dp, "style");
 return 0;

However, I get an exception "dynamic property get cannot retrieve
value for property: style."

Can you see where I have gone wrong?



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at