【发布时间】:2013-07-18 21:37:13
【问题描述】:
我查看了 Boost 图的概念,但它没有提供从顶点对中获取任何边的任何接口。 我试过了:
boost::graph_traits<G>::edge_descriptor edge(u, v); // does not work
但它需要一个额外的指向属性类型的指针。我怎样才能得到它?
【问题讨论】:
标签: c++ boost-graph
我查看了 Boost 图的概念,但它没有提供从顶点对中获取任何边的任何接口。 我试过了:
boost::graph_traits<G>::edge_descriptor edge(u, v); // does not work
但它需要一个额外的指向属性类型的指针。我怎样才能得到它?
【问题讨论】:
标签: c++ boost-graph
boost::edge() 的第三个参数是你的图表。
还请注意,该函数不直接返回边描述符,而是包含边描述符和布尔值的对,具体取决于边的存在
类似这样的:
G myGraph; // construct the graph
.... // populate it
.... // select a pair of vertices u, v
// get the edge between the vertices, if it exists
typedef boost::graph_traits<G>::edge_descriptor edge_t;
edge_t found_edge;
std::pair < edge_t, bool > p = boost::edge( u, v, myGraph );
if( ! p.second) {
// edge does not exist
...
} else {
found_edge = p.first;
...
}
【讨论】: