Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-10-10 00:18:23


sashan wrote:
> I'm trying to use a vistitor class on a graph I have defined. The
> visitor class is very simple and inherits from default_dfs_visitor:

There's a little trouble with your message. When you say that a program does
not compile, please always include the program --- complete one, not just
important pieces. That way, anybody can copy-paste it into an editor and
immediately try it.

> class OpenGLVisitor :
> public boost::default_dfs_visitor
> {
> public:
> OpenGLVisitor(void);
> virtual ~OpenGLVisitor(void);
> };
>
> My graph type is:
> typedef adjacency_list < vecS, listS, directedS > graph_t;
>
> The code to perform a dfs on the graph is as follows:
> graph_t g;
> depth_first_search(g, visitor(OGLVisitor));

You did not declare OGLVisitor anywere. It's easy to guess, but anyway.

> However I get the compiler error (see attachment).
>
> If I change the typedef to
> typedef adjacency_list < vecS, vecS, directedS > graph_t;
>
> then there is no error. This seems odd since it should also work when
> the vertices of the graph use the std::list as their container class.

The problem is that depth_first_seach need a color map. When you do not pass
any, it tries to get vertex_index property and build color map using that.
When vertices are stored in list, the vertex_index property is not created
automatically for you, and you need to do declare this property, as well as
manually assign indices. The attached example does it and compiles, though it
does not link because implementation of OpenGLVisitor is missing.

For the record, I don't think this is nice behaviour, but nobody implemented
anything better.

- Volodya




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk