Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost][BGL] Dynamic Property, dynamic_get_failure.
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-04-26 18:15:24

On Tue, 26 Apr 2011, Mathieu - wrote:

> Hi,
> I'm trying to generate random graphs (with random edge weight) and
> write them to a dot file, but
> I get this exception in the write_graphviz_dp() function :
> "what(): dynamic property get cannot retrieve value for property: weight."
> The code looks like this :
> typedef boost::adjacency_list<boost::vecS, boost::vecS,
> boost::directedS, property<edge_index_t, int>,
> property<edge_weight_t, int> > graph;
> boost::minstd_rand gen;
> graph g;
> boost::generate_random_graph(g, 10, 30, gen, false, false);
> boost::randomize_property<boost::edge_weight_t>(g, gen);
> dynamic_properties dp;
>"weight", get(edge_weight, g));
> boost::write_graphviz_dp(std::cout, g, dp, std::string("weight"));
> (don't pay attention to the random generator it's just to keep it simple).
> I've been looking at the examples and at the doc and it doesn't seem
> to me that I'm doing something wrong... but apparently I am.

You are passing "weight" as the node_id parameter to write_graphviz_dp,
but what you have defined as "weight" in dp is an edge property, not a
vertex property. I think removing the last argument to write_graphviz_dp
should fix the problem. Note that your adjacency_list template arguments
also put edge_index_t as a vertex property, not an edge property like you
probably intended.

-- Jeremiah Willcock

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