Мой вопрос основан на:Как распечатать график с одним отображаемым свойством
Я использую связанные свойства:
typedef struct vert{
std::string name;
};
typedef struct edge{
int capacity;
int weight;
};
typedef adjacency_list Graph;
Graph g;
vector ele;
У меня есть следующий вызов в цикле, который должен создавать ребра:
edge prop;
prop.weight = 5;
prop.capacity = 4;
add_edge(ele.first,ele.second, prop, g);
Именно этот сегмент печатает график в точечный формат.
ofstream dot("graph.dot");
write_graphviz(dot, g,
boost::make_label_writer(boost::get(&vert::name, g)),
boost::make_label_writer(boost::get(&edge::weight, g)),
boost::make_label_writer(boost::get(&edge::capacity, g)));
Ошибка:
/usr/include/boost/graph/graphviz.hpp: In function ‘void boost::write_graphviz(std::ostream&, const Graph&, VertexPropertiesWriter, EdgePropertiesWriter, GraphPropertiesWriter, VertexID) [with Graph = boost::adjacency_list, VertexPropertiesWriter = boost::label_writer, long unsigned int, vert, std::basic_string, std::allocator > > >, EdgePropertiesWriter = boost::label_writer, boost::detail::edge_desc_impl, edge, int> >, GraphPropertiesWriter = boost::label_writer, boost::detail::edge_desc_impl, edge, int> >, VertexID = boost::vec_adj_list_vertex_id_map, long unsigned int>]’:
/usr/include/boost/graph/graphviz.hpp:260: instantiated from ‘void boost::write_graphviz(std::ostream&, const Graph&, VertexPropertiesWriter, EdgePropertiesWriter, GraphPropertiesWriter) [with Graph = Graph, VertexPropertiesWriter = boost::label_writer, long unsigned int, vert, std::basic_string, std::allocator > > >, EdgePropertiesWriter = boost::label_writer, boost::detail::edge_desc_impl, edge, int> >, GraphPropertiesWriter = boost::label_writer, boost::detail::edge_desc_impl, edge, int> >]’
file_format.cc:194: instantiated from here
/usr/include/boost/graph/graphviz.hpp:236: error: no match for call to ‘(boost::label_writer, boost::detail::edge_desc_impl, edge, int> >) (std::basic_ostream >&)’
Мне это странно, потому что это работает:
write_graphviz(dot, g,
boost::make_label_writer(boost::get(&vert_info::name, g)));
и выводит следующее:
graph G {
0[label="0"];
1[label="1"];
2[label="2"];
3[label="3"];
4[label="4"];
5[label="5"];
6[label="6"];
7[label="7"];
8[label="8"];
9[label=""]; // this is another problem that I will have to fix but beside the point
0--9 ;
0--5 ;
0--2 ;
0--1 ;
...
...
}
Моя цель состоит в том, чтобы каждый узел был помечен, а каждое ребро помечено его емкостью и весом.