我查看了 Boost 图的概念,但它没有提供从一对顶点获取任何边的任何接口。我努力了:
boost::graph_traits<G>::edge_descriptor edge(u, v); // does not work
但它需要一个额外的指向属性类型的指针。我怎么能得到那个?
我查看了 Boost 图的概念,但它没有提供从一对顶点获取任何边的任何接口。我努力了:
boost::graph_traits<G>::edge_descriptor edge(u, v); // does not work
但它需要一个额外的指向属性类型的指针。我怎么能得到那个?
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;
...
}