Graph: create_subgraph not defined

Hi,
I've extended an adjacency list into a custom class in order to add
specialized fields and convenience methods. It was working fine until
I tried to call create_subgraph on it. Simplified example:
#include

On Wed, 23 Jun 2010, Trevor Harmon wrote:
Hi,
I've extended an adjacency list into a custom class in order to add specialized fields and convenience methods. It was working fine until I tried to call create_subgraph on it. Simplified example:
#include
#include using namespace boost;
class MyGraph : public adjacency_list
> { }; int main(int,char*[]) { MyGraph g; g.create_subgraph(); return 0; }
This gives a compiler error:
mygraph.cpp:12: error: ‘class MyGraph’ has no member named ‘create_subgraph’
I've no idea why this is giving me an error. Any suggestions? Thanks,
Is there a create_subgraph member mentioned in the documentation? Are you sure that it is not a free (non-member) function rather than a method? -- Jeremiah Willcock

On Jun 24, 2010, at 6:50 AM, Jeremiah Willcock wrote:
Is there a create_subgraph member mentioned in the documentation?
Yes: http://www.boost.org/doc/libs/1_31_0/libs/graph/doc/subgraph.html It is also used in the subgraph.cpp example.
Are you sure that it is not a free (non-member) function rather than a method?
Yes, it is used as a member function in the documentation and example code: typedef subgraph< adjacency_list > > Graph; Graph G0(6); ..... Graph& G1 = G0.create_subgraph(); Trevor

On Thu, 24 Jun 2010, Trevor Harmon wrote:
On Jun 24, 2010, at 6:50 AM, Jeremiah Willcock wrote:
Is there a create_subgraph member mentioned in the documentation?
Yes:
http://www.boost.org/doc/libs/1_31_0/libs/graph/doc/subgraph.html
It is also used in the subgraph.cpp example.
Are you sure that it is not a free (non-member) function rather than a method?
Yes, it is used as a member function in the documentation and example code:
typedef subgraph< adjacency_list > > Graph; Graph G0(6); ..... Graph& G1 = G0.create_subgraph();
Note that G0 is of type subgraph<...>, not adjacency_list<...> like you were using. Could that be the issue? -- Jeremiah Willcock

On Jun 24, 2010, at 10:12 AM, Jeremiah Willcock wrote:
Note that G0 is of type subgraph<...>, not adjacency_list<...> like you were using. Could that be the issue?
Yes, that's definitely something I was doing wrong. After rereading
the docs, I see now that subgraphs must be of a special subgraph class
type, but I don't understand why. Conceptually speaking, I see no
reason for this class to exist. For example, when implementing a
generic tree structure, there's no need to have separate "Node" and
"Subnode" classes; all nodes can be of type "Node". The top-level node
is distinguished simply by the fact that it has no parents. For the
same reason, the top-level graph in a hierarchy of graphs can have the
same type as any of its children (and vice versa). The way Boost
implements this concept seems overly complicated.
Design issues aside, I'm now trying to modify my graph code to use
subgraphs. To start off, I thought I would try changing my
adjacency_list to subgraph

On Jun 28, 2010, at 12:23 PM, Trevor Harmon wrote:
#include
#include using namespace boost;
class MyVertex { public: virtual ~MyVertex() {} };
class MyGraph : public subgraph
> > { }; typedef property_map
::type EdgeIndexMap; int main(int,char*[]) { MyGraph g; EdgeIndexMap edgeMap = get(edge_index, g); return 0; }
Hmm... If I change the EdgeIndexMap typedef so that MyGraph is simply
replaced by its superclass, then the code compiles. That is, I change
this:
typedef property_map

On Jun 28, 2010, at 12:23 PM, Trevor Harmon wrote:
Design issues aside, I'm now trying to modify my graph code to use subgraphs. To start off, I thought I would try changing my adjacency_list to subgraph
. Theoretically, my code should still work the same way, right? But I'm getting compiler errors when calling get().
I'm also getting compiler errors when calling add_vertex. Example:
#include

On Jun 29, 2010, at 3:13 PM, Trevor Harmon wrote:
I'm also getting compiler errors when calling add_vertex. Example:
#include
#include using namespace boost;
class MyGraph : public subgraph
> > { }; 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
participants (2)
-
Jeremiah Willcock
-
Trevor Harmon