Boost logo

Boost Users :

Subject: Re: [Boost-users] Graph: create_subgraph not defined
From: Trevor Harmon (Trevor.W.Harmon_at_[hidden])
Date: 2010-06-28 15:23:18


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<adjacency_list>. Theoretically, my code
should still work the same way, right? But I'm getting compiler errors
when calling get(). Pasted below is an example of the problem. The
error is:

subgraph.cpp: In function ‘int main(int, char**)’:
subgraph.cpp:19: error: conversion from
‘boost
::subgraph_global_property_map
<boost::subgraph<boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS, boost::shared_ptr<MyVertex>,
boost::property<boost::edge_index_t, size_t, boost::no_property>,
boost::no_property, boost::listS> >*,
boost::adj_list_edge_property_map<boost::bidirectional_tag, size_t,
size_t&, size_t, boost::property<boost::edge_index_t, size_t,
boost::no_property>, boost::edge_index_t>, boost::edge_index_t>’ to
non-scalar type ‘boost::subgraph_global_property_map<MyGraph*,
boost::adj_list_edge_property_map<boost::bidirectional_tag, size_t,
size_t&, size_t, boost::property<boost::edge_index_t, size_t,
boost::no_property>, boost::edge_index_t>, boost::edge_index_t>’
requested

Any suggestions how to fix this?

Thanks,

Trevor

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/subgraph.hpp>

using namespace boost;

class MyVertex {
public:
     virtual ~MyVertex() {}
};

class MyGraph :
     public subgraph<adjacency_list<vecS, vecS, bidirectionalS,
shared_ptr<MyVertex>, property<edge_index_t, std::size_t> > > {
};

typedef property_map<MyGraph, edge_index_t>::type EdgeIndexMap;

int main(int,char*[]) {
     MyGraph g;
     EdgeIndexMap edgeMap = get(edge_index, g);
     return 0;
}


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