|
Boost Users : |
Subject: Re: [Boost-users] Graph: create_subgraph not defined
From: Trevor Harmon (Trevor.W.Harmon_at_[hidden])
Date: 2010-06-30 17:55:06
On Jun 29, 2010, at 3:13 PM, Trevor Harmon wrote:
> I'm also getting compiler errors when calling add_vertex. Example:
>
> #include <boost/graph/adjacency_list.hpp>
> #include <boost/graph/subgraph.hpp>
>
> using namespace boost;
>
> class MyGraph :
> public subgraph<adjacency_list<vecS, vecS, bidirectionalS,
> std::string, property<edge_index_t, std::size_t> > > {
> };
>
> int main(int,char*[]) {
> MyGraph g;
> std::string v;
> add_vertex(v, g);
> return 0;
> }
I think the problem here is that I'm trying to use
MutablePropertyGraph's specialization of add_vertex, which takes a
property as the first parameter, while subgraph's version of
add_vertex takes a descriptor as the first parameter. Therefore I can
work around the problem by first adding the vertex (without any
properties). I can then attach the property to the vertex in a second
step. Example:
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/subgraph.hpp>
using namespace boost;
class MyGraph :
public subgraph<adjacency_list<vecS, vecS, bidirectionalS,
std::string, property<edge_index_t, std::size_t> > > {
};
int main(int,char*[]) {
MyGraph g;
std::string v;
graph_traits<MyGraph>::vertex_descriptor descriptor = add_vertex(g);
g[descriptor] = v;
return 0;
}
Trevor
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net