【问题标题】:How to add a vertex in bidirectional graph?如何在双向图中添加顶点?
【发布时间】:2015-07-16 02:55:57
【问题描述】:
我正在使用 boost 算法。但是,它的双向图似乎没有办法添加顶点。如何初始化 MUTABLE 双向图以便随时添加顶点?
【问题讨论】:
标签:
boost
graph
vertex
bidirectional
【解决方案1】:
我真的不明白问题出在哪里:使用expressions listed in the docs
Live On Coliru
#include <boost/graph/adjacency_list.hpp>
using namespace boost;
using Graph = adjacency_list<vecS, vecS, bidirectionalS>;
#include <boost/graph/graph_utility.hpp> // for display
int main() {
Graph g;
auto a = add_vertex(g);
auto b = add_vertex(g);
add_edge(a,b,g);
print_graph(g);
}
打印
0 --> 1
1 -->