我正在尝试使用用户定义的顶点和边类型可视化图形。我的顶点类型是phase_t的向量,而我的边缘类型则标记有以下规则中定义的某些规则。
#include <boost/graph/adj_list_serialize.hpp>
#include <boost/graph/graphviz.hpp>
#include <boost/property_map/function_property_map.hpp>
#include <vector>
using namespace boost;
using namespace std;
class phase_t {
public :
unsigned int bench_id;
unsigned int alloc;
phase_t();
phase_t(unsigned int bench_id,unsigned int alloc);
};
phase_t::phase_t(unsigned int bench_id,unsigned int alloc) : bench_id{bench_id}, alloc{alloc} {}
phase_t::phase_t() : bench_id{0}, alloc{0} {}
enum RulesEdgeType {RULE1,RULE2,RULE3,RULE4};
typedef vector<phase_t> alloc2_t;
typedef adjacency_list<setS,setS,directedS,alloc2_t,RulesEdgeType> Graph;
int main() {
Graph g;
// Then fill the graph
add_edge(
add_vertex(alloc2_t{phase_t(0,1),phase_t(0,2),phase_t(0,4)}, g),
add_vertex(alloc2_t{phase_t(0,3),phase_t(0,6),phase_t(0,7)}, g),
RULE1, g
);
write_graphviz(std::cout, g);
}
但是,write_graphviz()调用最终会出现一长串错误,这些错误总结如下。
tmp3.cpp:40:32: required from here
/usr/include/boost/graph/detail/adjacency_list.hpp:2543:29: error: forming reference to void
typedef value_type& reference;
^
/usr/include/boost/graph/detail/adjacency_list.hpp:2544:35: error: forming reference to void
typedef const value_type& const_reference;
^
/usr/include/boost/graph/detail/adjacency_list.hpp:2547:47: error: forming reference to void
<Graph, value_type, reference, Tag> type;
^
/usr/include/boost/graph/detail/adjacency_list.hpp:2549:53: error: forming reference to void
<Graph, value_type, const_reference, Tag> const_type;
第40行对应于write_graphviz()调用。 我是新来的提升者,任何帮助都将不胜感激。预先感谢。