Boost logo

Boost Users :

From: Aaron Windsor (aaron.windsor_at_[hidden])
Date: 2008-07-25 08:45:34


On Thu, Jul 24, 2008 at 10:14 PM, Ashwin N <ashwin.n_at_[hidden]> wrote:
> Hi,
>
> I'm trying to get a simple undirected_dfs example to work. The aim is
> simple, to create an undirected graph and print its nodes in DFS
> order.
> Here's my code:
>

<snip>

> MyGraph g;
> boost::add_edge(0, 1, g);
> boost::add_edge(0, 2, g);
> boost::add_edge(1, 3, g);
>
> MyVisitor vis;
> boost::undirected_dfs(g, boost::visitor(vis));

<snip>

> What am I doing wrong? How do I get to print nodes in DFS order? I'm
> on VC++ 2008 Express Edition.

The documentation for undirected_dfs
(http://www.boost.org/doc/libs/1_35_0/libs/graph/doc/undirected_dfs.html)
lists all of the expected parameters for undirected_dfs. You haven't
provided the edge_color_map parameter, which is required. Depending on
what you want to do, you might need to override the defaults on other
parameters as well.

If you just want to print nodes in DFS order, I'd suggest using
depth_first_search
(http://www.boost.org/doc/libs/1_35_0/libs/graph/doc/depth_first_search.html),
which you can call by passing just a graph and a visitor, and works
just fine on undirected graphs.

Regards,
Aaron


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