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?
Asked
Active
Viewed 65 times
0
-
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 Answers
1
I don't really see what the problem is: use the expressions listed in the docs
#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