0

I'm using boost for an algorithm. However, its bidirectional graph seems to have no way to add a vertex. How could I initialise a MUTABLE bidirectional graph so that I can add vertices at any time?

Aurus Huang
  • 372
  • 1
  • 3
  • 17
  • Can't you use [MutableGraph](http://www.boost.org/doc/libs/1_58_0/libs/graph/doc/MutableGraph.html)? Also it would be great if you show at least some pseudocode (or existing code if you have one) for what you are trying to accomplish. – Nikolay K Jul 16 '15 at 03:12
  • I see that. Problem temporarily closed. – Aurus Huang Jul 18 '15 at 05:45

1 Answers1

1

I don't really see what the problem is: use the 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);
}

Prints

0 --> 1 
1 --> 
sehe
  • 374,641
  • 47
  • 450
  • 633