0
我用升压图的标签,似乎我不明白它非常好。升压图表访问边缘
要访问一个顶点的它似乎是使用GET(vertex_name,graph_),然后用[]在所有访问右侧的标签。 但是我怎样才能访问边缘的标签。
我试图采用相同的方法(和许多其他错误东西),但我 没有成功访问它的标签。
这里是我的代码片段:
typedef property<edge_name_t, int> edge_property;
typedef property<vertex_name_t, int> vertex_property;
typedef adjacency_list<vecS, vecS, undirectedS, vertex_property, edge_property> MyGraph;
MyGraph graph_;
add_vertex(vertex_property(6), graph_);
add_vertex(vertex_property(1), graph_);
add_vertex(vertex_property(1), graph_);
add_edge(0, 1, edge_property(2), graph_);
add_edge(1, 2, edge_property(3), graph_);
add_edge(0, 2, edge_property(1), graph_);
cout << "Graph 1 [graph_]" << endl;
typedef graph_traits<MyGraph>::edge_iterator edge_iter;
pair<edge_iter, edge_iter> ep;
property_map<MyGraph, vertex_name_t>::type labelling_vertex = get(vertex_name, graph_);
property_map<MyGraph, edge_name_t>::type labelling_edge = get(edge_name, graph_);
int position = 0;
for (ep = edges(graph_); ep.first != ep.second; ++ep.first) {
unsigned int source_ = source(*ep.first, graph_);
unsigned int target_ = target(*ep.first, graph_);
cout << source_ << "["<< labelling_vertex[source_] <<"]" << " ~~~~" << labelling_edge[position] << "~~~~ " << target_ <<"[" <<labelling_vertex[target_] <<"]" << endl;
position++;
}