fork(1) download
  1.  
  2. #include "boost/graph/graphviz.hpp"
  3.  
  4. struct myVertex_t {
  5. int color;
  6. };
  7.  
  8. typedef boost::adjacency_list<
  9. boost::vecS, // edge container
  10. boost::vecS, // vertex container
  11. boost::undirectedS, // type of graph
  12. myVertex_t, // vertex properties
  13. boost::property< // edge properties
  14. boost::edge_color_t, // ???
  15. boost::default_color_type // enum, holds 5 colors
  16. >
  17. > myGraph_t;
  18.  
  19. int main()
  20. {
  21. myGraph_t g;
  22. boost::add_edge(0, 1, g);
  23.  
  24. myGraph_t::vertex_iterator it = vertices(g).first;
  25. //auto it = vertices(g).first;
  26. g[*it++].color = 42;
  27. g[*it++].color = 43;
  28.  
  29. boost::dynamic_properties dp;
  30. dp.property("color", boost::get( &myVertex_t::color, g ) );
  31. dp.property("node_id", boost::get( boost::vertex_index, g ) );
  32. boost::write_graphviz_dp( std::cout , g, dp);
  33. }
  34.  
Success #stdin #stdout 0s 3528KB
stdin
Standard input is empty
stdout
graph G {
0 [color=42];
1 [color=43];
0--1 ;
}