我最终遵循了http://www.boost.org/doc/libs/1_34_0/libs/graph/example/ordered_out_edges.cpp提供的逻辑,即
template <class StoredEdge>
struct weight : public std::binary_function<StoredEdge, StoredEdge, bool>
{
bool operator()(const StoredEdge &lhs, const StoredEdge &rhs) const {
return boost::get(boost::edge_weight, lhs) >
boost::get(boost::edge_weight, rhs);
}
};
struct weightS {};
namespace boost {
template <class ValueType>
struct container_gen<weightS, ValueType> {
typedef std::multiset<ValueType, weight<ValueType> > type;
};
template <>
struct parallel_edge_traits<weightS> {
typedef disallow_parallel_edge_tag type;
};
}
typedef adjacency_list<weightS, vecS, undirectedS, TreeVertexType> Tree;
为了确保根据半径对 out_edges 进行排序,我简单地将边权重定义为源顶点和目标顶点的平均半径。
然而,问题是半径顶点属性是动态的,并且在创建图形时是未知的,因此每当我更新边权重时,边的顺序都不会改变。
有人知道替代方法吗?
谢谢
-约翰