本文整理汇总了C++中boost::edges方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::edges方法的具体用法?C++ boost::edges怎么用?C++ boost::edges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost
的用法示例。
在下文中一共展示了boost::edges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get
void add_middle_vertex_to_edges
(const InputGraph& in_g, OutputGraph& out_g, WeightTag w_tag,
IndexMap i_map, Orig2CopyMap orig_to_copy_map)
{
using boost::vertices;
using boost::edges;
using boost::num_edges;
using boost::source;
using boost::target;
using boost::clear_vertex;
using boost::add_vertex;
using boost::add_edge;
typedef typename boost::graph_traits<OutputGraph>::vertex_descriptor
Vertex;
typedef typename boost::property_map<OutputGraph, boost::edge_all_t>::type
EdgePropertyMap;
typedef typename boost::property_traits<EdgePropertyMap>::value_type
EdgePropertyValue;
typedef typename boost::property_map<OutputGraph, WeightTag>::type
WeightMap;
typedef typename boost::property_traits<WeightMap>::value_type
WeightValue;
typedef boost::tuple<Vertex, Vertex, EdgePropertyValue, WeightValue>
EdgeTuple;
typedef std::vector<EdgeTuple> EdgeTuples;
boost::copy_graph(in_g, out_g,
boost::vertex_index_map(i_map). orig_to_copy(orig_to_copy_map));
WeightMap w_map = get(w_tag, out_g);
EdgePropertyMap e_all_map = get(boost::edge_all, out_g);
EdgeTuples edge_tuples;
edge_tuples.reserve(num_edges(out_g));
typename boost::graph_traits<OutputGraph>::edge_iterator ei, ei_end;
for (boost::tie(ei, ei_end) = edges(out_g); ei != ei_end; ++ei) {
edge_tuples.push_back
(make_tuple(source(*ei, out_g), target(*ei, out_g),
get(e_all_map, *ei), get(w_map, *ei) / 2));
}
typename boost::graph_traits<OutputGraph>::vertex_iterator vi, vi_end;
for (boost::tie(vi, vi_end) = vertices(out_g); vi != vi_end; ++vi) {
clear_vertex(*vi, out_g);
}
// add_vertex must not invalid vertex_descriptor
for (typename EdgeTuples::const_iterator eti = edge_tuples.begin(),
eti_end = edge_tuples.end(); eti != eti_end; ++eti) {
const Vertex new_v = add_vertex(out_g);
put(w_map,
add_edge(get<0>(*eti), new_v, get<2>(*eti), out_g).first,
get<3>(*eti));
put(w_map,
add_edge(new_v, get<1>(*eti), get<2>(*eti), out_g).first,
get<3>(*eti));
}
}