Fwd: [Graph] Problem with dynamic_properties

Hi everybody, I'm new to BGL and very frustrated beacause I can't make a proper use of dynamic_properties. I'm just trying to read a graphviz dot file with read_graphviz and I found a sample which make use of dynamic_properties in order to make a proper call to read_grahviz. Here is the slightly modified sample: typedef boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS > Graph; typedef boost::graph_traits<Graph>::vertex_descriptor Vertex; typedef boost::graph_traits<Graph>::vertex_iterator Iterator; int main(int argc, char **argv) { Graph g; std::ifstream input(argv[1]); boost::dynamic_properties dp; dp.property("node_id", boost::get(boost::vertex_name, g)); dp.property("weight", boost::get(boost::edge_weight, g)); boost::read_graphviz(input, g, dp, "id"); return 0; } When I try to compile it, g++ returns lots of cryptic template related error messages but I suspect the most relevant part is : no match for 'operator<<' in 'out << boost::get...' I must be doing something wrong, but I can't get it; expect you'll point me out my mistake so that I could re-focus on the algorithms instead of these annoying technical details.

Hi, I can't see the problem straight away, but I had similar problems. Here are the examples from the book, fixed to use dp's. You will have to install a recent boost version from the trunk, and then change the location in my makefile, then it should work. Hope that helps, Adam. -- Dr Adam Spargo High Performance Assembly Group email: aws@sanger.ac.uk Wellcome Trust Sanger Institute Tel: +44 (0)1223 834244 x7728 Hinxton, Cambridge CB10 1SA Fax: +44 (0)1223 494919 On Wed, 13 Oct 2010, fokenrute wrote:
Hi everybody, I'm new to BGL and very frustrated beacause I can't make a proper use of dynamic_properties.I'm just trying to read a graphviz dot file with read_graphviz and I found a sample which make use of dynamic_properties in order to make a proper call to read_grahviz. Here is the slightly modified sample:
typedef boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS > Graph; typedef boost::graph_traits<Graph>::vertex_descriptor Vertex; typedef boost::graph_traits<Graph>::vertex_iterator Iterator;
int main(int argc, char **argv) { Graph g; std::ifstream input(argv[1]); boost::dynamic_properties dp; dp.property("node_id", boost::get(boost::vertex_name, g)); dp.property("weight", boost::get(boost::edge_weight, g)); boost::read_graphviz(input, g, dp, "id"); return 0; }
When I try to compile it, g++ returns lots of cryptic template related error messages but I suspect the most relevant part is : no match for 'operator<<' in 'out << boost::get...' I must be doing something wrong, but I can't get it; expect you'll point me out my mistake so that I could re-focus on the algorithms instead of these annoying technical details.
-- The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.

On Wed, 13 Oct 2010, fokenrute wrote:
Hi everybody, I'm new to BGL and very frustrated beacause I can't make a proper use of dynamic_properties.I'm just trying to read a graphviz dot file with read_graphviz and I found a sample which make use of dynamic_properties in order to make a proper call to read_grahviz. Here is the slightly modified sample:
typedef boost::adjacency_list < boost::listS, boost::vecS, boost::undirectedS > Graph; typedef boost::graph_traits<Graph>::vertex_descriptor Vertex; typedef boost::graph_traits<Graph>::vertex_iterator Iterator;
int main(int argc, char **argv) { Graph g; std::ifstream input(argv[1]); boost::dynamic_properties dp; dp.property("node_id", boost::get(boost::vertex_name, g)); dp.property("weight", boost::get(boost::edge_weight, g)); boost::read_graphviz(input, g, dp, "id"); return 0; }
When I try to compile it, g++ returns lots of cryptic template related error messages but I suspect the most relevant part is : no match for 'operator<<' in 'out << boost::get...' I must be doing something wrong, but I can't get it; expect you'll point me out my mistake so that I could re-focus on the algorithms instead of these annoying technical details.
You are trying to read data into the properties vertex_name and edge_weight, but your graph does not have those properties (and thus does not have any way to store the read-in data). If you modify the definition of Graph to add vertex_name and edge_weight properties, the code will probably work; see the adjacency_list documentation for how to add properties to a graph. You can also use external properties, but just modifying your graph type definition is probably easier here. -- Jeremiah Willcock
participants (3)
-
Adam Spargo
-
fokenrute
-
Jeremiah Willcock