Boost logo

Boost Users :

From: Christiaan Putter (ceputter_at_[hidden])
Date: 2008-07-09 15:36:36


Hi guys,

Thanks for the clarification Dave, after struggling for for 2 days I
wasn't so sure any more. Still not getting it right though.

It seems the basic structure of the BGL interface works on my graph.
I can run a bfs with "visitor(default_bfs_visitor())" , and it
searches through the graph quite well. However when adding my own
visitor...

Taken from the bfs visitor example:

class bfs_name_printer : public default_bfs_visitor {
public:
  bfs_name_printer() { };
  template <typename Vertex, typename Graph>
  void discover_vertex(Vertex u, const Graph &) const
  {
    std::cout << u << ' ';
  }
};

Node* s = _network.getNodes().value(20);

bfs_name_printer vis();
breadth_first_search(_network, s, visitor(vis));

Passing my own visitor causes the whole thing not to compile, with the
error message:

***********************************
***********************************

N:/_tools/boost_1_35_0/boost/graph/named_function_params.hpp: In
instantiation of `boost::bgl_named_params<bfs_name_printer ()(),
boost::graph_visitor_t, boost::no_property>':
N:\_devel\_workspace\GWISeo\src\core\solution.cpp:186: instantiated from here
N:/_tools/boost_1_35_0/boost/graph/named_function_params.hpp:58:
error: field `boost::bgl_named_params<bfs_name_printer ()(),
boost::graph_visitor_t, boost::no_property>::m_value'
invalidly declared function type
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp: In static
member function `static void
boost::detail::bfs_dispatch<boost::detail::error_property_not_found>::apply(Vert
exListGraph&, typename boost::graph_traits<G>::vertex_descriptor,
const boost::bgl_named_params<P, T, R>&,
boost::detail::error_property_not_found) [with VertexListGraph =
Network,
 P = bfs_name_printer ()(), T = boost::graph_visitor_t, R =
boost::no_property]':
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp:255:
instantiated from `void boost::breadth_first_search(const
VertexListGraph&, typename boost::graph_traits<G>::vert
ex_descriptor, const boost::bgl_named_params<P, T, R>&) [with
VertexListGraph = Network, P = bfs_name_printer ()(), T =
boost::graph_visitor_t, R = boost::no_property]'
N:\_devel\_workspace\GWISeo\src\core\solution.cpp:186: instantiated from here
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp:226:
error: function return type cannot be function
N:/_tools/boost_1_35_0/boost/graph/named_function_params.hpp:656:
error: function return type cannot be function
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp:226:
error: function return type cannot be function
N:/_tools/boost_1_35_0/boost/graph/named_function_params.hpp: In
function `typename boost::property_value<boost::bgl_named_params<T1,
Tag1, Base>, Tag2>::type boost::get_param(cons
t boost::bgl_named_params<T1, Tag1, Base>&, Tag2) [with Tag1 =
boost::graph_visitor_t, Tag2 = boost::graph_visitor_t, T1 =
bfs_name_printer ()(), Base = boost::no_property]':
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp:226:
instantiated from `static void
boost::detail::bfs_dispatch<boost::detail::error_property_not_found>::apply(Vertex
ListGraph&, typename boost::graph_traits<G>::vertex_descriptor, const
boost::bgl_named_params<P, T, R>&,
boost::detail::error_property_not_found) [with VertexListGraph =
Network, P
 = bfs_name_printer ()(), T = boost::graph_visitor_t, R = boost::no_property]'
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp:255:
instantiated from `void boost::breadth_first_search(const
VertexListGraph&, typename boost::graph_traits<G>::vert
ex_descriptor, const boost::bgl_named_params<P, T, R>&) [with
VertexListGraph = Network, P = bfs_name_printer ()(), T =
boost::graph_visitor_t, R = boost::no_property]'
N:\_devel\_workspace\GWISeo\src\core\solution.cpp:186: instantiated from here
N:/_tools/boost_1_35_0/boost/graph/named_function_params.hpp:656:
error: function return type cannot be function
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp:226:
instantiated from `static void
boost::detail::bfs_dispatch<boost::detail::error_property_not_found>::apply(Vertex
ListGraph&, typename boost::graph_traits<G>::vertex_descriptor, const
boost::bgl_named_params<P, T, R>&,
boost::detail::error_property_not_found) [with VertexListGraph =
Network, P
 = bfs_name_printer ()(), T = boost::graph_visitor_t, R = boost::no_property]'
N:/_tools/boost_1_35_0/boost/graph/breadth_first_search.hpp:255:
instantiated from `void boost::breadth_first_search(const
VertexListGraph&, typename boost::graph_traits<G>::vert
ex_descriptor, const boost::bgl_named_params<P, T, R>&) [with
VertexListGraph = Network, P = bfs_name_printer ()(), T =
boost::graph_visitor_t, R = boost::no_property]'
N:\_devel\_workspace\GWISeo\src\core\solution.cpp:186: instantiated from here
N:/_tools/boost_1_35_0/boost/graph/named_function_params.hpp:662:
error: invalid conversion from `bfs_name_printer (*)()' to `int'

etc.
etc.

***********************************
***********************************

I'm quite sure their must be something I've left out or done wrong
when writing the BGL interface for my graph. If anybody can point me
in the right direction I'd be very grateful.

And advice on how to implement the bundle concept in my own graph
would be great too.

Have a nice day,
Christiaan

2008/7/9 David Abrahams <dave_at_[hidden]>:
>
> on Wed Jul 09 2008, "Christiaan Putter" <ceputter-AT-googlemail.com> wrote:
>
>> Hi guys and girls,
>>
>> I've got an existing Graph structure, consisting of node and edge
>> classes. The graph structure itself is implicit in the sense that
>> every node contains a list of out edges, and edges know where they
>> start from and go to.
>>
>> I'm using Qt's container classes for simplicity mostly, eg. a node has
>> a QList of successors (QList<Edge*>), and all the nodes and edges get
>> stored in a Network class using QHash<Node*> etc...
>>
>> I've been trying to extend this to work with the BGL, following the
>> LEDA and SGB examples.
>>
>> As far as I know I can simply use the BGL functions on an instance of
>> my own Network, ie. no need to recreate the graph. Is this correct?
>
> Yes, that's what makes BGL a generic library :-)
>
> --
> Dave Abrahams
> BoostPro Computing
> http://www.boostpro.com
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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