【问题标题】:How to add a vertex in bidirectional graph?如何在双向图中添加顶点?
【发布时间】:2015-07-16 02:55:57
【问题描述】:

我正在使用 boost 算法。但是,它的双向图似乎没有办法添加顶点。如何初始化 MUTABLE 双向图以便随时添加顶点?

【问题讨论】:

  • 你不能用MutableGraph吗?此外,如果您至少显示一些伪代码(或现有代码,如果您有的话),那将是非常棒的。
  • 我明白了。问题暂时关闭。

标签: 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 --> 

【讨论】:

  • 我想我需要试一试。问题暂时关闭。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-20
相关资源
最近更新 更多