[BGL] how to use write_graphviz_dp with graph bundle properties
Hello. I know how to use write_graphviz_dp with vertices and edges bundle properties but i can't figure out how to print the graph_bundle property of a graph. i have the following code where the line with the error is commented: #include <boost/graph/properties.hpp> #include <boost/graph/graphviz.hpp> #include <boost/graph/adjacency_list.hpp> using namespace boost; using namespace std; struct VertexInfo { int id; }; struct EdgeInfo { int weight; }; struct GraphInfo { int duration; }; typedef adjacency_list<vecS, vecS, undirectedS, VertexInfo, EdgeInfo, GraphInfo> Graph; void printGraph(Graph graph, string file) { ofstream ofs(file.c_str()); dynamic_properties dp; dp.property("node_id", get(vertex_index, graph)); dp.property("label", get(&EdgeInfo::weight, graph)); ///dp.property("label", get(&graph[graph_bundle].duration)); ->error write_graphviz_dp(ofs, graph, dp); } int main() { Graph graph; Graph::vertex_descriptor a = add_vertex(graph); Graph::vertex_descriptor b = add_vertex(graph); Graph::vertex_descriptor c = add_vertex(graph); Graph::vertex_descriptor d = add_vertex(graph); Graph::edge_descriptor e1 = (add_edge(a, b, graph)).first; Graph::edge_descriptor e2 = (add_edge(b, c, graph)).first; Graph::edge_descriptor e3 = (add_edge(c, d, graph)).first; Graph::edge_descriptor e4 = (add_edge(d, a, graph)).first; graph[e1].weight = 1.1; graph[e2].weight = 1.5; graph[e3].weight = 5.2; graph[e4].weight = 1.2; graph[graph_bundle].duration = 10; printGraph(graph, "graph.dot"); }
On Sat, 9 Nov 2013, Pablo Madoery wrote:
Hello. I know how to use write_graphviz_dp with vertices and edges bundle properties but i can't figure out how to print the graph_bundle property of a graph.
(snip)
void printGraph(Graph graph, string file) { ofstream ofs(file.c_str()); dynamic_properties dp; dp.property("node_id", get(vertex_index, graph)); dp.property("label", get(&EdgeInfo::weight, graph)); ///dp.property("label", get(&graph[graph_bundle].duration)); ->error write_graphviz_dp(ofs, graph, dp); }
There does not appear to be a way to write graph properties with write_graphviz_dp (although there is a way to read them). I'm not sure why, so you might want to file a bug report about that so I'll remember to fix it. -- Jeremiah Willcock
On Sat, 9 Nov 2013, Jeremiah Willcock wrote:
On Sat, 9 Nov 2013, Pablo Madoery wrote:
Hello. I know how to use write_graphviz_dp with vertices and edges bundle properties but i can't figure out how to print the graph_bundle property of a graph.
(snip)
void printGraph(Graph graph, string file) { ofstream ofs(file.c_str()); dynamic_properties dp; dp.property("node_id", get(vertex_index, graph)); dp.property("label", get(&EdgeInfo::weight, graph)); ///dp.property("label", get(&graph[graph_bundle].duration)); ->error write_graphviz_dp(ofs, graph, dp); }
I have now fixed this problem in the Boost trunk. To write a graph property, here is the kind of property call you should use: dp.property("label", make_static_property_map<Graph*>(get_property(graph, &GraphInfo::duration))); -- Jeremiah Willcock
It works !!!!!!! Thank you very much !!!!!!!!! 2013/11/9 Jeremiah Willcock <jewillco@crest.iu.edu>
On Sat, 9 Nov 2013, Jeremiah Willcock wrote:
On Sat, 9 Nov 2013, Pablo Madoery wrote:
Hello. I know how to use write_graphviz_dp with vertices and edges
bundle properties but i can't figure out how to print the graph_bundle property of a graph.
(snip)
void printGraph(Graph graph, string file)
{ ofstream ofs(file.c_str()); dynamic_properties dp; dp.property("node_id", get(vertex_index, graph)); dp.property("label", get(&EdgeInfo::weight, graph)); ///dp.property("label", get(&graph[graph_bundle].duration)); ->error write_graphviz_dp(ofs, graph, dp); }
I have now fixed this problem in the Boost trunk. To write a graph property, here is the kind of property call you should use:
dp.property("label", make_static_property_map<Graph*>(get_property(graph, &GraphInfo::duration)));
-- Jeremiah Willcock _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Jeremiah Willcock
-
Pablo Madoery