用fillcolor节点提升BGL write_graphviz make_label_writer

时间:2015-02-16 23:48:35

标签: c++ boost graphviz boost-graph

我想用自定义颜色填充某个节点的颜色,那么在图表的顶点属性中是否有自定义属性设置或重新实现自定义函子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;
}

似乎在近底阅读本文http://www.informit.com/articles/article.aspx?p=25778&seqNum=5,作者写了一些graph_property设置。但是现在我失去了整齐的文档,准确地告诉了这个设置

0 个答案:

没有答案