
I using the boost CVS version, obtained last week Tuesday. I'm interested in using read_graphviz in a fairly complex manner. I want to read multiple properties from a *.dot file, including: - 1 graph property - 2 vertex properties - 2 edge properties Can this be done with the read_graphviz? Moreover, I would like these properties to end up outside of the graph. If this is possible, how is it done?

Since no one replied to this message, I'll answer it myself. Yes, to both questions! This is the code that demonstrates: typedef map<Vertex,int,ltDescriptor<Vertex> > Demand; typedef map<Edge,int,ltDescriptor<Edge> > Cost; int main(int argc, char **argv) { try { Graph graph; Demand demand; Cost cost; /* * Populate graph and vertex/edge property maps */ if (argc!=2) { cerr << "usage: ns_test \"dot file name\"" << endl; exit(1); } ifstream in(argv[1]); if (!in) { cerr << "can't open input file \"" << argv[1] << "\"" << endl; exit(1); } associative_property_map<Demand> demandProperty(demand); associative_property_map<Cost> costProperty(cost); dynamic_properties dp; dp.property("node_id",get(vertex_name, graph)); dp.property("demand",demandProperty); dp.property("cost",costProperty); read_graphviz(in,graph,dp); } catch (exception& e){ cerr << "exception: \"" << e.what() << "\"" << endl; } catch (...) { cerr << "Something bad happened!" << endl; } } Note that I put the actual name of vertices into the graph, but placed both vertex and edge properties in external resources. Jeffrey Holle wrote:
I using the boost CVS version, obtained last week Tuesday. I'm interested in using read_graphviz in a fairly complex manner.
I want to read multiple properties from a *.dot file, including: - 1 graph property - 2 vertex properties - 2 edge properties Can this be done with the read_graphviz?
Moreover, I would like these properties to end up outside of the graph. If this is possible, how is it done?

So true. Thought brevity was more important. #include <iostream> #include <fstream> #include <vector> #include <map> #include <exception> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graphviz.hpp> Plus, my graph definition: typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, boost::property<boost::vertex_name_t,std::string> > Graph; Jens Müller wrote:
Jeffrey Holle schrieb:
Since no one replied to this message, I'll answer it myself. Yes, to both questions! This is the code that demonstrates:
There are obviously includes missing in there.
participants (2)
-
Jeffrey Holle
-
Jens Müller