boost BGL write_graphviz make_label_writer with fillcolor node

假如想象 提交于 2019-12-24 03:00:49

问题


I want to fill color some node with custom color, so is there custom property setting in vertex attribute from graph or re-implementing custom functor make_edges_writer?

#include <boost/config.hpp>
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp> 
 #include <boost/graph/graphviz.hpp>
 using namespace boost;

  struct Edges {
   int id;
 std::string name;
 };
  struct vert{
 std::string name;
 };
  enum family
 { Jeanie, Debbie, Rick, John, Amanda, Margaret, Benjamin, N };

    typedef adjacency_list <vecS, vecS, directedS, 
                    vert,Edges
                   > Graph; 
 typedef  graph_traits<Graph>::vertex_descriptor VertexDesc;    

int
  main()
{

 const char *name[] = { "Jeanie", "Debbie", "Rick", "John", "Amanda",
"Margaret", "Benjamin"
};

Graph g;
Edges e1,e2,e3;
e1.id=1;
e1.name="Manajer";
e2.id=2;
e2.name="Employee";
e3.id=3;
e3.name="Supervisor";
 VertexDesc vertex;
  for (int vv=0;vv<7;vv++){
vertex = add_vertex(g); 
  } 
add_edge(Jeanie,Debbie,e1,g);
add_edge(Debbie,Jeanie,e2,g); 
add_edge(Rick,Jeanie,e3,g);
add_edge(John,Amanda,e3,g);
 add_edge(Margaret,Benjamin,e3,g);
add_edge(John,Benjamin,e1,g);
add_edge(John,Jeanie,e2,g);
add_edge(John,John,e1,g);
print_graph(g );
std::ofstream fout("label.dot");
   write_graphviz(std::cout,g,make_label_writer(name),make_edges_writer(get(&Edges::id,g),get(&Edges::name,g)));
  write_graphviz(fout,g,make_label_writer(name),make_edges_writer(get(&Edges::id,g),get(&Edges::name,g))  

 return EXIT_SUCCESS;
}

It seems that reading this article http://www.informit.com/articles/article.aspx?p=25778&seqNum=5 at the near bottom, the author write some graph_property setting. But for now I lose neat doc that telling this setting exactly

来源:https://stackoverflow.com/questions/28552357/boost-bgl-write-graphviz-make-label-writer-with-fillcolor-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!