
Hello, I'm working with boost graph library. I'm creating a graph and i'd like to write its description into a file or to display it on the screen. The properties of Edges and Vertex are bundled, and i'm not able to write them. I have read the doc once and again and i don't get to find a solution. I have looked for examples but i haven't found anything actually useful for me. Could anyone please help me or propose a possible solution? Here is my code: #include <boost/graph/iteration_macros.hpp> #include <string> #include <boost/tuple/tuple.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/visitors.hpp> #include <boost/graph/breadth_first_search.hpp> #include <map> #include <boost/graph/adj_list_serialize.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/multi_array.hpp> #include <cassert> #include <boost/graph/graphviz.hpp> //using namespace boost; struct VertexProperties{ std::string gate_type; int gate_level; int gate_index; int num_input; float prob_err; }; struct edge_properties { std::string name; }; typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, VertexProperties , edge_properties> Graph; typedef boost::graph_traits<Graph>::vertex_descriptor Vertex; typedef boost::graph_traits<Graph>::edge_descriptor Edge; int main() { int i=0; //const char* name = "123"; Graph g; Vertex u1; u1=add_vertex(g); g[u1].gate_type = "Input"; g[u1].gate_level=1; g[u1].gate_index=i; g[u1].num_input=0; g[u1].prob_err=0; i++; Vertex u2; u2=add_vertex(g); g[u2].gate_type = "Input"; g[u2].gate_level=1; g[u2].gate_index=i; g[u2].num_input=0; g[u2].prob_err=0; i++; Vertex u3; u3=add_vertex(g); g[u3].gate_type = "Input"; g[u3].gate_level=1; g[u3].gate_index=i; g[u3].num_input=0; g[u3].prob_err=0; i++; Vertex u4; u4=add_vertex(g); g[u4].gate_type = "XOR"; g[u4].gate_level=2; g[u4].gate_index=i; g[u4].num_input=0; g[u4].prob_err=0.001; i++; Vertex u5; u5=add_vertex(g); g[u5].gate_type = "AND"; g[u5].gate_level=1; g[u5].gate_index=i; g[u5].num_input=0; g[u5].prob_err=0.001; i++; Vertex u6; u6=add_vertex(g); g[u6].gate_type = "XOR"; g[u6].gate_level=1; g[u6].gate_index=i; g[u6].num_input=0; g[u6].prob_err=0.001; i++; Vertex u7; u7=add_vertex(g); g[u7].gate_type = "AND"; g[u7].gate_level=1; g[u7].gate_index=i; g[u7].num_input=0; g[u7].prob_err=0.001; i++; Vertex u8; u8=add_vertex(g); g[u8].gate_type = "OR"; g[u8].gate_level=1; g[u8].gate_index=i; g[u8].num_input=0; g[u8].prob_err=0.001; i++; Edge e1; e1=(add_edge(u1,u4,g)).first; Edge e2; e2=(add_edge(u1,u5,g)).first; Edge e3; e3=(add_edge(u2,u4,g)).first; Edge e4; e4=(add_edge(u2,u5,g)).first; Edge e5; e5=(add_edge(u3,u6,g)).first; Edge e6; e6=(add_edge(u3,u7,g)).first; Edge e7; e7=(add_edge(u4,u6,g)).first; Edge e8; e8=(add_edge(u4,u7,g)).first; Edge e9; e9=(add_edge(u5,u8,g)).first; Edge e10; e10=(add_edge(u7,u8,g)).first; const char* name[] = { "Input 1", "Input 2", "Input 3","XOR","AND","XOR","AND","OR"}; int index[] = {g[u1].gate_index,g[u2].gate_index,g[u3].gate_index,g[u4].gate_index,g[u5].gate_index,g[u6].gate_index,g[u7].gate_index,g[u8].gate_index}; write_graphviz(std::cout, g, boost::make_label_writer(name)); } I am able to write a label, but i can't write all the properties, and that's what i want. Thank you. Josep

Josep TORRAS FLAQUER wrote:
Hello, I'm working with boost graph library. I'm creating a graph and i'd like to write its description into a file or to display it on the screen. The properties of Edges and Vertex are bundled, and i'm not able to write them. I have read the doc once and again and i don't get to find a solution. I have looked for examples but i haven't found anything actually useful for me. Could anyone please help me or propose a possible solution?
Josep, Several properties can be passed to graphviz writer via dynamic_properties map. See attachment. Regards, Dmitry

Thank you very much! Josep Dmitry Bufistov wrote:
Josep TORRAS FLAQUER wrote:
Hello, I'm working with boost graph library. I'm creating a graph and i'd like to write its description into a file or to display it on the screen. The properties of Edges and Vertex are bundled, and i'm not able to write them. I have read the doc once and again and i don't get to find a solution. I have looked for examples but i haven't found anything actually useful for me. Could anyone please help me or propose a possible solution?
Josep,
Several properties can be passed to graphviz writer via dynamic_properties map. See attachment.
Regards, Dmitry ------------------------------------------------------------------------
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Dmitry Bufistov
-
Josep TORRAS FLAQUER